boliu | b887d327 | 2015-03-19 00:29:26 | [diff] [blame] | 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 | |
| 5 | #include "android_webview/browser/child_frame.h" |
| 6 | |
boliu | 7b1edda | 2016-11-07 17:38:11 | [diff] [blame] | 7 | #include <utility> |
| 8 | |
| 9 | #include "base/trace_event/trace_event.h" |
boliu | b887d327 | 2015-03-19 00:29:26 | [diff] [blame] | 10 | #include "cc/output/compositor_frame.h" |
| 11 | |
| 12 | namespace android_webview { |
| 13 | |
boliu | 7b1edda | 2016-11-07 17:38:11 | [diff] [blame] | 14 | ChildFrame::ChildFrame( |
| 15 | scoped_refptr<content::SynchronousCompositor::FrameFuture> frame_future, |
danakj | c7afae5 | 2017-06-20 21:12:41 | [diff] [blame^] | 16 | uint32_t layer_tree_frame_sink_id, |
boliu | 7b1edda | 2016-11-07 17:38:11 | [diff] [blame] | 17 | std::unique_ptr<cc::CompositorFrame> frame, |
| 18 | const CompositorID& compositor_id, |
| 19 | bool viewport_rect_for_tile_priority_empty, |
| 20 | const gfx::Transform& transform_for_tile_priority, |
| 21 | bool offscreen_pre_raster, |
| 22 | bool is_layer) |
| 23 | : frame_future(std::move(frame_future)), |
danakj | c7afae5 | 2017-06-20 21:12:41 | [diff] [blame^] | 24 | layer_tree_frame_sink_id(layer_tree_frame_sink_id), |
boliu | f4e57485 | 2016-03-22 19:33:17 | [diff] [blame] | 25 | frame(std::move(frame)), |
hush | 45918a8 | 2015-12-17 03:50:59 | [diff] [blame] | 26 | compositor_id(compositor_id), |
boliu | 7441045ad | 2015-06-29 21:08:12 | [diff] [blame] | 27 | viewport_rect_for_tile_priority_empty( |
| 28 | viewport_rect_for_tile_priority_empty), |
boliu | b887d327 | 2015-03-19 00:29:26 | [diff] [blame] | 29 | transform_for_tile_priority(transform_for_tile_priority), |
| 30 | offscreen_pre_raster(offscreen_pre_raster), |
boliu | 7441045ad | 2015-06-29 21:08:12 | [diff] [blame] | 31 | is_layer(is_layer) {} |
boliu | b887d327 | 2015-03-19 00:29:26 | [diff] [blame] | 32 | |
| 33 | ChildFrame::~ChildFrame() { |
| 34 | } |
| 35 | |
boliu | 7b1edda | 2016-11-07 17:38:11 | [diff] [blame] | 36 | void ChildFrame::WaitOnFutureIfNeeded() { |
| 37 | if (!frame_future) |
| 38 | return; |
| 39 | |
| 40 | TRACE_EVENT0("android_webview", "GetFrame"); |
| 41 | DCHECK(!frame); |
| 42 | auto frame_ptr = frame_future->GetFrame(); |
| 43 | if (frame_ptr) { |
danakj | c7afae5 | 2017-06-20 21:12:41 | [diff] [blame^] | 44 | layer_tree_frame_sink_id = frame_ptr->layer_tree_frame_sink_id; |
boliu | 7b1edda | 2016-11-07 17:38:11 | [diff] [blame] | 45 | frame = std::move(frame_ptr->frame); |
| 46 | } |
| 47 | frame_future = nullptr; |
| 48 | } |
| 49 | |
fanjinsong | db647e04 | 2017-06-09 20:26:45 | [diff] [blame] | 50 | } // namespace android_webview |