Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(227)

Side by Side Diff: android_webview/browser/browser_view_renderer.cc

Issue 2347563003: Added FrameFuture class (Closed)
Patch Set: Finished, working Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 222 matching lines...) Expand 10 before | Expand all | Expand 10 after
233 ComputeViewportRectForTilePriority(); 233 ComputeViewportRectForTilePriority();
234 234
235 if (async_on_draw_hardware_) { 235 if (async_on_draw_hardware_) {
236 compositor_->DemandDrawHwAsync(size_, viewport_rect_for_tile_priority, 236 compositor_->DemandDrawHwAsync(size_, viewport_rect_for_tile_priority,
237 transform_for_tile_priority); 237 transform_for_tile_priority);
238 return current_compositor_frame_consumer_->HasFrameOnUI(); 238 return current_compositor_frame_consumer_->HasFrameOnUI();
239 } 239 }
240 240
241 content::SynchronousCompositor::Frame frame = compositor_->DemandDrawHw( 241 content::SynchronousCompositor::Frame frame = compositor_->DemandDrawHw(
242 size_, viewport_rect_for_tile_priority, transform_for_tile_priority); 242 size_, viewport_rect_for_tile_priority, transform_for_tile_priority);
243
boliu 2016/09/22 23:05:31 nit: remove new blank line
ojars 2016/09/28 00:17:58 Done.
243 if (!frame.frame) { 244 if (!frame.frame) {
244 TRACE_EVENT_INSTANT0("android_webview", "NoNewFrame", 245 TRACE_EVENT_INSTANT0("android_webview", "NoNewFrame",
245 TRACE_EVENT_SCOPE_THREAD); 246 TRACE_EVENT_SCOPE_THREAD);
246 return current_compositor_frame_consumer_->HasFrameOnUI(); 247 return current_compositor_frame_consumer_->HasFrameOnUI();
247 } 248 }
248 249
249 OnDrawHardwareProcessFrame(std::move(frame));
250 return true;
251 }
252
253 void BrowserViewRenderer::OnDrawHardwareProcessFrame(
254 content::SynchronousCompositor::Frame frame) {
255 TRACE_EVENT0("android_webview",
256 "BrowserViewRenderer::OnDrawHardwareProcessFrame");
257 if (!frame.frame)
258 return;
259
260 gfx::Transform transform_for_tile_priority =
261 external_draw_constraints_.transform;
262 gfx::Rect viewport_rect_for_tile_priority =
263 ComputeViewportRectForTilePriority();
264 std::unique_ptr<ChildFrame> child_frame = base::MakeUnique<ChildFrame>( 250 std::unique_ptr<ChildFrame> child_frame = base::MakeUnique<ChildFrame>(
265 frame.compositor_frame_sink_id, std::move(frame.frame), compositor_id_, 251 frame.compositor_frame_sink_id, std::move(frame.frame), compositor_id_,
266 viewport_rect_for_tile_priority.IsEmpty(), transform_for_tile_priority, 252 viewport_rect_for_tile_priority.IsEmpty(), transform_for_tile_priority,
267 offscreen_pre_raster_, external_draw_constraints_.is_layer); 253 offscreen_pre_raster_, external_draw_constraints_.is_layer);
268 254
269 ReturnUnusedResource( 255 ReturnUnusedResource(
270 current_compositor_frame_consumer_->PassUncommittedFrameOnUI()); 256 current_compositor_frame_consumer_->PassUncommittedFrameOnUI());
271 current_compositor_frame_consumer_->SetFrameOnUI(std::move(child_frame)); 257 current_compositor_frame_consumer_->SetFrameOnUI(std::move(child_frame));
258
259 return true;
260 }
261
262 void BrowserViewRenderer::OnDrawHardwareProcessFrameFuture(
263 const scoped_refptr<content::SynchronousCompositor::FrameFuture>&
264 frame_future) {
265 gfx::Transform transform_for_tile_priority =
266 external_draw_constraints_.transform;
267 gfx::Rect viewport_rect_for_tile_priority =
268 ComputeViewportRectForTilePriority();
269
270 ReturnUnusedResource(
271 current_compositor_frame_consumer_->PassUncommittedFrameOnUI());
272
273 current_compositor_frame_consumer_->SetFrameFutureOnUI(
274 std::move(frame_future));
boliu 2016/09/22 23:05:31 don't need move here I think
ojars 2016/09/28 00:17:58 Done.
275 current_compositor_frame_consumer_->SetFrameOnUI(base::MakeUnique<ChildFrame>(
276 0, nullptr, compositor_id_, viewport_rect_for_tile_priority.IsEmpty(),
277 transform_for_tile_priority, offscreen_pre_raster_,
278 external_draw_constraints_.is_layer));
272 } 279 }
273 280
274 gfx::Rect BrowserViewRenderer::ComputeViewportRectForTilePriority() { 281 gfx::Rect BrowserViewRenderer::ComputeViewportRectForTilePriority() {
275 // If the WebView is on a layer, WebView does not know what transform is 282 // If the WebView is on a layer, WebView does not know what transform is
276 // applied onto the layer so global visible rect does not make sense here. 283 // applied onto the layer so global visible rect does not make sense here.
277 // In this case, just use the surface rect for tiling. 284 // In this case, just use the surface rect for tiling.
278 // Leave viewport_rect_for_tile_priority empty if offscreen_pre_raster_ is on. 285 // Leave viewport_rect_for_tile_priority empty if offscreen_pre_raster_ is on.
279 gfx::Rect viewport_rect_for_tile_priority; 286 gfx::Rect viewport_rect_for_tile_priority;
280 287
281 if (!offscreen_pre_raster_ && !external_draw_constraints_.is_layer) { 288 if (!offscreen_pre_raster_ && !external_draw_constraints_.is_layer) {
(...skipping 485 matching lines...) Expand 10 before | Expand all | Expand 10 after
767 base::StringAppendF(&str, 774 base::StringAppendF(&str,
768 "overscroll_rounding_error_: %s ", 775 "overscroll_rounding_error_: %s ",
769 overscroll_rounding_error_.ToString().c_str()); 776 overscroll_rounding_error_.ToString().c_str());
770 base::StringAppendF( 777 base::StringAppendF(
771 &str, "on_new_picture_enable: %d ", on_new_picture_enable_); 778 &str, "on_new_picture_enable: %d ", on_new_picture_enable_);
772 base::StringAppendF(&str, "clear_view: %d ", clear_view_); 779 base::StringAppendF(&str, "clear_view: %d ", clear_view_);
773 return str; 780 return str;
774 } 781 }
775 782
776 } // namespace android_webview 783 } // namespace android_webview
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698