child_frame.cc 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. // Copyright 2015 The Chromium Authors. All rights reserved.
  2. // Use of this source code is governed by a BSD-style license that can be
  3. // found in the LICENSE file.
  4. #include "android_webview/browser/gfx/child_frame.h"
  5. #include <utility>
  6. #include "base/trace_event/trace_event.h"
  7. #include "components/viz/common/frame_sinks/copy_output_request.h"
  8. #include "components/viz/common/quads/compositor_frame.h"
  9. namespace android_webview {
  10. ChildFrame::ChildFrame(
  11. scoped_refptr<content::SynchronousCompositor::FrameFuture> frame_future,
  12. const viz::FrameSinkId& frame_sink_id,
  13. const gfx::Size& viewport_size_for_tile_priority,
  14. const gfx::Transform& transform_for_tile_priority,
  15. bool offscreen_pre_raster,
  16. float device_scale_factor,
  17. CopyOutputRequestQueue copy_requests,
  18. bool did_invalidate,
  19. const viz::BeginFrameArgs& begin_frame_args)
  20. : frame_future(std::move(frame_future)),
  21. frame_sink_id(frame_sink_id),
  22. viewport_size_for_tile_priority(viewport_size_for_tile_priority),
  23. transform_for_tile_priority(transform_for_tile_priority),
  24. offscreen_pre_raster(offscreen_pre_raster),
  25. device_scale_factor(device_scale_factor),
  26. copy_requests(std::move(copy_requests)),
  27. did_invalidate(did_invalidate),
  28. begin_frame_args(begin_frame_args) {}
  29. ChildFrame::~ChildFrame() {
  30. }
  31. void ChildFrame::WaitOnFutureIfNeeded() {
  32. if (!frame_future)
  33. return;
  34. TRACE_EVENT0("android_webview", "GetFrame");
  35. DCHECK(!frame);
  36. auto frame_ptr = frame_future->GetFrame();
  37. if (frame_ptr) {
  38. layer_tree_frame_sink_id = frame_ptr->layer_tree_frame_sink_id;
  39. frame = std::move(frame_ptr->frame);
  40. local_surface_id = frame_ptr->local_surface_id;
  41. hit_test_region_list = std::move(frame_ptr->hit_test_region_list);
  42. }
  43. frame_future = nullptr;
  44. }
  45. viz::SurfaceId ChildFrame::GetSurfaceId() const {
  46. DCHECK(!frame_future);
  47. return viz::SurfaceId(frame_sink_id, local_surface_id);
  48. }
  49. } // namespace android_webview