OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "android_webview/browser/browser_view_renderer.h" | 5 #include "android_webview/browser/browser_view_renderer.h" |
6 | 6 |
7 #include <utility> | 7 #include <utility> |
8 | 8 |
9 #include "android_webview/browser/browser_view_renderer_client.h" | 9 #include "android_webview/browser/browser_view_renderer_client.h" |
10 #include "android_webview/browser/child_frame.h" | 10 #include "android_webview/browser/child_frame.h" |
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
102 view_visible_(false), | 102 view_visible_(false), |
103 window_visible_(false), | 103 window_visible_(false), |
104 attached_to_window_(false), | 104 attached_to_window_(false), |
105 hardware_enabled_(false), | 105 hardware_enabled_(false), |
106 dip_scale_(0.f), | 106 dip_scale_(0.f), |
107 page_scale_factor_(1.f), | 107 page_scale_factor_(1.f), |
108 min_page_scale_factor_(0.f), | 108 min_page_scale_factor_(0.f), |
109 max_page_scale_factor_(0.f), | 109 max_page_scale_factor_(0.f), |
110 on_new_picture_enable_(false), | 110 on_new_picture_enable_(false), |
111 clear_view_(false), | 111 clear_view_(false), |
112 offscreen_pre_raster_(false) {} | 112 offscreen_pre_raster_(false), |
| 113 first_sync_frame_(false) {} |
113 | 114 |
114 BrowserViewRenderer::~BrowserViewRenderer() { | 115 BrowserViewRenderer::~BrowserViewRenderer() { |
115 DCHECK(compositor_map_.empty()); | 116 DCHECK(compositor_map_.empty()); |
116 SetCurrentCompositorFrameConsumer(nullptr); | 117 SetCurrentCompositorFrameConsumer(nullptr); |
117 while (compositor_frame_consumers_.size()) { | 118 while (compositor_frame_consumers_.size()) { |
118 RemoveCompositorFrameConsumer(*compositor_frame_consumers_.begin()); | 119 RemoveCompositorFrameConsumer(*compositor_frame_consumers_.begin()); |
119 } | 120 } |
120 } | 121 } |
121 | 122 |
122 void BrowserViewRenderer::SetCurrentCompositorFrameConsumer( | 123 void BrowserViewRenderer::SetCurrentCompositorFrameConsumer( |
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
225 | 226 |
226 ReturnResourceFromParent(current_compositor_frame_consumer_); | 227 ReturnResourceFromParent(current_compositor_frame_consumer_); |
227 UpdateMemoryPolicy(); | 228 UpdateMemoryPolicy(); |
228 | 229 |
229 gfx::Transform transform_for_tile_priority = | 230 gfx::Transform transform_for_tile_priority = |
230 external_draw_constraints_.transform; | 231 external_draw_constraints_.transform; |
231 | 232 |
232 gfx::Rect viewport_rect_for_tile_priority = | 233 gfx::Rect viewport_rect_for_tile_priority = |
233 ComputeViewportRectForTilePriority(); | 234 ComputeViewportRectForTilePriority(); |
234 | 235 |
235 if (async_on_draw_hardware_) { | 236 if (async_on_draw_hardware_ && first_sync_frame_) { |
236 compositor_->DemandDrawHwAsync(size_, viewport_rect_for_tile_priority, | 237 OnDrawHardwareProcessFrameFuture(compositor_->DemandDrawHwAsync( |
237 transform_for_tile_priority); | 238 size_, viewport_rect_for_tile_priority, transform_for_tile_priority)); |
238 return current_compositor_frame_consumer_->HasFrameOnUI(); | 239 return current_compositor_frame_consumer_->HasFrameOnUI(); |
239 } | 240 } |
240 | 241 |
| 242 first_sync_frame_ = true; |
| 243 |
241 content::SynchronousCompositor::Frame frame = compositor_->DemandDrawHw( | 244 content::SynchronousCompositor::Frame frame = compositor_->DemandDrawHw( |
242 size_, viewport_rect_for_tile_priority, transform_for_tile_priority); | 245 size_, viewport_rect_for_tile_priority, transform_for_tile_priority); |
| 246 |
243 if (!frame.frame) { | 247 if (!frame.frame) { |
244 TRACE_EVENT_INSTANT0("android_webview", "NoNewFrame", | 248 TRACE_EVENT_INSTANT0("android_webview", "NoNewFrame", |
245 TRACE_EVENT_SCOPE_THREAD); | 249 TRACE_EVENT_SCOPE_THREAD); |
246 return current_compositor_frame_consumer_->HasFrameOnUI(); | 250 return current_compositor_frame_consumer_->HasFrameOnUI(); |
247 } | 251 } |
248 | 252 |
249 std::unique_ptr<ChildFrame> child_frame = base::MakeUnique<ChildFrame>( | 253 std::unique_ptr<ChildFrame> child_frame = base::MakeUnique<ChildFrame>( |
250 frame.compositor_frame_sink_id, std::move(frame.frame), compositor_id_, | 254 frame.compositor_frame_sink_id, std::move(frame.frame), compositor_id_, |
251 viewport_rect_for_tile_priority.IsEmpty(), transform_for_tile_priority, | 255 viewport_rect_for_tile_priority.IsEmpty(), transform_for_tile_priority, |
252 offscreen_pre_raster_, external_draw_constraints_.is_layer); | 256 offscreen_pre_raster_, external_draw_constraints_.is_layer); |
253 | 257 |
254 ReturnUnusedResource( | 258 ReturnUnusedResource( |
255 current_compositor_frame_consumer_->PassUncommittedFrameOnUI()); | 259 current_compositor_frame_consumer_->PassUncommittedFrameOnUI()); |
256 current_compositor_frame_consumer_->SetFrameOnUI(std::move(child_frame), | 260 current_compositor_frame_consumer_->SetFrameOnUI(std::move(child_frame), |
257 nullptr); | 261 nullptr); |
258 | |
259 return true; | 262 return true; |
260 } | 263 } |
261 | 264 |
262 void BrowserViewRenderer::OnDrawHardwareProcessFrameFuture( | 265 void BrowserViewRenderer::OnDrawHardwareProcessFrameFuture( |
263 const scoped_refptr<content::SynchronousCompositor::FrameFuture>& | 266 const scoped_refptr<content::SynchronousCompositor::FrameFuture>& |
264 frame_future) { | 267 frame_future) { |
265 gfx::Transform transform_for_tile_priority = | 268 gfx::Transform transform_for_tile_priority = |
266 external_draw_constraints_.transform; | 269 external_draw_constraints_.transform; |
267 gfx::Rect viewport_rect_for_tile_priority = | 270 gfx::Rect viewport_rect_for_tile_priority = |
268 ComputeViewportRectForTilePriority(); | 271 ComputeViewportRectForTilePriority(); |
(...skipping 504 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
773 base::StringAppendF(&str, | 776 base::StringAppendF(&str, |
774 "overscroll_rounding_error_: %s ", | 777 "overscroll_rounding_error_: %s ", |
775 overscroll_rounding_error_.ToString().c_str()); | 778 overscroll_rounding_error_.ToString().c_str()); |
776 base::StringAppendF( | 779 base::StringAppendF( |
777 &str, "on_new_picture_enable: %d ", on_new_picture_enable_); | 780 &str, "on_new_picture_enable: %d ", on_new_picture_enable_); |
778 base::StringAppendF(&str, "clear_view: %d ", clear_view_); | 781 base::StringAppendF(&str, "clear_view: %d ", clear_view_); |
779 return str; | 782 return str; |
780 } | 783 } |
781 | 784 |
782 } // namespace android_webview | 785 } // namespace android_webview |
OLD | NEW |