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

Unified Diff: android_webview/browser/browser_view_renderer.cc

Issue 2347563003: Added FrameFuture class (Closed)
Patch Set: Code review 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 ba3defa6fa867c16a79348e24e3f270ea2f22f0a..28841cda09e6511df15d44e15afb2c28095faffc 100644
--- a/android_webview/browser/browser_view_renderer.cc
+++ b/android_webview/browser/browser_view_renderer.cc
@@ -232,43 +232,42 @@ 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);
+ frame_future = compositor_->DemandDrawHwAsync(
+ size_, viewport_rect_for_tile_priority, transform_for_tile_priority);
return current_compositor_frame_consumer_->HasFrameOnUI();
+ } 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) {
+ if (!(frame_future && frame_future->getFrame() &&
+ frame_future->getFrame()->frame)) {
boliu 2016/09/20 00:27:56 can't call getFrame here because we will want to h
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;
-
+ 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.compositor_frame_sink_id, std::move(frame.frame), compositor_id_,
- viewport_rect_for_tile_priority.IsEmpty(), transform_for_tile_priority,
- offscreen_pre_raster_, external_draw_constraints_.is_layer);
ReturnUnusedResource(
current_compositor_frame_consumer_->PassUncommittedFrameOnUI());
- current_compositor_frame_consumer_->SetFrameOnUI(std::move(child_frame));
+
+ current_compositor_frame_consumer_->SetFrameOnUI(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));
}
gfx::Rect BrowserViewRenderer::ComputeViewportRectForTilePriority() {
@@ -313,17 +312,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_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->compositor_frame_sink_id,
- resources);
+ compositor->ReturnResources(
+ child_frame->frame_future->getFrame()->compositor_frame_sink_id,
+ resources);
}
void BrowserViewRenderer::ReturnResourceFromParent(

Powered by Google App Engine
This is Rietveld 408576698