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

Unified Diff: android_webview/browser/browser_view_renderer.cc

Issue 2347563003: Added FrameFuture class (Closed)
Patch Set: 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 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 154f9728d61748ce33f751e9c4b080afc0cddb78..76e4ac78277a8cb1264b1f49dc662a6a9dd0fd87 100644
--- a/android_webview/browser/browser_view_renderer.cc
+++ b/android_webview/browser/browser_view_renderer.cc
@@ -232,42 +232,51 @@ bool BrowserViewRenderer::OnDrawHardware() {
gfx::Rect viewport_rect_for_tile_priority =
ComputeViewportRectForTilePriority();
+ scoped_refptr<content::SynchronousCompositor::FrameFuture> frame_future;
+
if (async_on_draw_hardware_) {
- compositor_->DemandDrawHwAsync(size_, viewport_rect_for_tile_priority,
- transform_for_tile_priority);
- return current_compositor_frame_consumer_->HasFrameOnUI();
+ frame_future = compositor_->DemandDrawHwAsync(
+ size_, viewport_rect_for_tile_priority, transform_for_tile_priority);
+ // return current_compositor_frame_consumer_->HasFrameOnUI();
boliu 2016/09/16 16:26:11 why is this commented out?
ojars 2016/09/19 22:02:36 Changed back.
ojars 2016/09/19 22:02:36 Done.
+ } else {
+ frame_future = 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) {
- TRACE_EVENT_INSTANT0("android_webview", "NoNewFrame",
- TRACE_EVENT_SCOPE_THREAD);
- return current_compositor_frame_consumer_->HasFrameOnUI();
- }
+ // if (!frame.frame) {
boliu 2016/09/16 16:26:11 why is this commented out?
ojars 2016/09/19 22:02:36 Changed back.
ojars 2016/09/19 22:02:36 Done.
+ // TRACE_EVENT_INSTANT0("android_webview", "NoNewFrame",
+ // TRACE_EVENT_SCOPE_THREAD);
+ // return current_compositor_frame_consumer_->HasFrameOnUI();
+ // }
- OnDrawHardwareProcessFrame(std::move(frame));
+ OnDrawHardwareProcessFrame(std::move(frame_future));
return true;
}
-void BrowserViewRenderer::OnDrawHardwareProcessFrame(
- content::SynchronousCompositor::Frame frame) {
- TRACE_EVENT0("android_webview",
- "BrowserViewRenderer::OnDrawHardwareProcessFrame");
- if (!frame.frame)
- return;
-
+std::unique_ptr<ChildFrame> BrowserViewRenderer::CreateChildFrame(
boliu 2016/09/16 16:26:11 there is only one caller for this method, just inl
ojars 2016/09/19 22:02:36 Done.
+ 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();
- std::unique_ptr<ChildFrame> child_frame = base::MakeUnique<ChildFrame>(
- frame.output_surface_id, std::move(frame.frame), compositor_id_,
+ gfx::Rect viewport_rect_for_tile_priority;
+
+ if (!offscreen_pre_raster_ && !external_draw_constraints_.is_layer) {
+ viewport_rect_for_tile_priority = last_on_draw_global_visible_rect_;
+ }
+
+ return base::MakeUnique<ChildFrame>(
+ std::move(frame_future), compositor_id_,
viewport_rect_for_tile_priority.IsEmpty(), transform_for_tile_priority,
offscreen_pre_raster_, external_draw_constraints_.is_layer);
+}
+
+void BrowserViewRenderer::OnDrawHardwareProcessFrame(
+ scoped_refptr<content::SynchronousCompositor::FrameFuture> frame_future) {
+ std::unique_ptr<ChildFrame> child_frame =
+ CreateChildFrame(std::move(frame_future));
ReturnUnusedResource(
current_compositor_frame_consumer_->PassUncommittedFrameOnUI());
+
current_compositor_frame_consumer_->SetFrameOnUI(std::move(child_frame));
}
@@ -313,16 +322,20 @@ void BrowserViewRenderer::RemoveCompositorFrameConsumer(
void BrowserViewRenderer::ReturnUnusedResource(
std::unique_ptr<ChildFrame> child_frame) {
- if (!child_frame.get() || !child_frame->frame.get())
+ // if (!child_frame.get() || !child_frame->frame.get())
boliu 2016/09/16 16:26:11 remove?
ojars 2016/09/19 22:02:36 Done.
+ if (!child_frame.get() || !child_frame->frame_future->hasFrame())
return;
cc::ReturnedResourceArray resources;
cc::TransferableResource::ReturnResources(
- child_frame->frame->delegated_frame_data->resource_list, &resources);
+ child_frame->frame_future->getFrame()
+ ->frame->delegated_frame_data->resource_list,
+ &resources);
content::SynchronousCompositor* compositor =
FindCompositor(child_frame->compositor_id);
if (compositor && !resources.empty())
- compositor->ReturnResources(child_frame->output_surface_id, resources);
+ compositor->ReturnResources(
+ child_frame->frame_future->getFrame()->output_surface_id, resources);
}
void BrowserViewRenderer::ReturnResourceFromParent(

Powered by Google App Engine
This is Rietveld 408576698