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

Unified Diff: android_webview/browser/browser_view_renderer.cc

Issue 2418383002: sync compositor: Signal async frame on IO thread (Closed)
Patch Set: bad_message, and minor cleanups Created 4 years, 2 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 side-by-side diff with in-line comments
Download patch
Index: android_webview/browser/browser_view_renderer.cc
diff --git a/android_webview/browser/browser_view_renderer.cc b/android_webview/browser/browser_view_renderer.cc
index 1f0d849e1e5b60719b9b133bb0cca61acf518678..14165922ae0a3986a5dca49b4687047a66086a2c 100644
--- a/android_webview/browser/browser_view_renderer.cc
+++ b/android_webview/browser/browser_view_renderer.cc
@@ -109,7 +109,8 @@ BrowserViewRenderer::BrowserViewRenderer(
max_page_scale_factor_(0.f),
on_new_picture_enable_(false),
clear_view_(false),
- offscreen_pre_raster_(false) {}
+ offscreen_pre_raster_(false),
+ first_sync_frame_(false) {}
BrowserViewRenderer::~BrowserViewRenderer() {
DCHECK(compositor_map_.empty());
@@ -232,20 +233,24 @@ bool BrowserViewRenderer::OnDrawHardware() {
gfx::Rect viewport_rect_for_tile_priority =
ComputeViewportRectForTilePriority();
- if (async_on_draw_hardware_) {
- compositor_->DemandDrawHwAsync(size_, viewport_rect_for_tile_priority,
- transform_for_tile_priority);
- return current_compositor_frame_consumer_->HasFrameOnUI();
+ scoped_refptr<content::SynchronousCompositor::FrameFuture> future; // Async.
+ content::SynchronousCompositor::Frame frame; // Sync.
+ bool async = async_on_draw_hardware_ && first_sync_frame_;
dcheng 2016/10/21 06:42:56 This might be worth a comment: it's not clear to m
boliu 2016/10/21 15:15:32 renamed this to "allow_async_draw_" and added a co
+ if (async) {
+ future = compositor_->DemandDrawHwAsync(
+ size_, viewport_rect_for_tile_priority, transform_for_tile_priority);
+ } else {
+ frame = compositor_->DemandDrawHw(size_, viewport_rect_for_tile_priority,
+ transform_for_tile_priority);
}
- content::SynchronousCompositor::Frame frame = compositor_->DemandDrawHw(
- size_, viewport_rect_for_tile_priority, transform_for_tile_priority);
- if (!frame.frame) {
+ if (!frame.frame && !future) {
dcheng 2016/10/21 06:42:56 Maybe a comment that documents what this means wou
boliu 2016/10/21 15:15:32 yeah should generally be clear to compositor folks
TRACE_EVENT_INSTANT0("android_webview", "NoNewFrame",
TRACE_EVENT_SCOPE_THREAD);
return current_compositor_frame_consumer_->HasFrameOnUI();
}
+ first_sync_frame_ = true;
std::unique_ptr<ChildFrame> child_frame = base::MakeUnique<ChildFrame>(
frame.compositor_frame_sink_id, std::move(frame.frame), compositor_id_,
viewport_rect_for_tile_priority.IsEmpty(), transform_for_tile_priority,
@@ -254,29 +259,10 @@ bool BrowserViewRenderer::OnDrawHardware() {
ReturnUnusedResource(
current_compositor_frame_consumer_->PassUncommittedFrameOnUI());
current_compositor_frame_consumer_->SetFrameOnUI(std::move(child_frame),
- nullptr);
-
+ future);
dcheng 2016/10/21 06:42:56 Nit: std::move(future)
boliu 2016/10/21 15:15:32 Done.
return true;
}
-void BrowserViewRenderer::OnDrawHardwareProcessFrameFuture(
- const scoped_refptr<content::SynchronousCompositor::FrameFuture>&
- frame_future) {
- gfx::Transform transform_for_tile_priority =
- external_draw_constraints_.transform;
- gfx::Rect viewport_rect_for_tile_priority =
- ComputeViewportRectForTilePriority();
-
- ReturnUnusedResource(
- current_compositor_frame_consumer_->PassUncommittedFrameOnUI());
- current_compositor_frame_consumer_->SetFrameOnUI(
- base::MakeUnique<ChildFrame>(
- 0, nullptr, compositor_id_, viewport_rect_for_tile_priority.IsEmpty(),
- transform_for_tile_priority, offscreen_pre_raster_,
- external_draw_constraints_.is_layer),
- frame_future);
-}
-
gfx::Rect BrowserViewRenderer::ComputeViewportRectForTilePriority() {
// If the WebView is on a layer, WebView does not know what transform is
// applied onto the layer so global visible rect does not make sense here.

Powered by Google App Engine
This is Rietveld 408576698