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

Unified Diff: content/browser/renderer_host/render_widget_host_view_android.cc

Issue 2243663002: Android: Attach hidden layer for CopyFromCompositingSurface() (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 4 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: content/browser/renderer_host/render_widget_host_view_android.cc
diff --git a/content/browser/renderer_host/render_widget_host_view_android.cc b/content/browser/renderer_host/render_widget_host_view_android.cc
index f29806a0d39156454381aaea89f7707545793c88..2a626c8772c430470e9fc8279bd69058aa07ca40 100644
--- a/content/browser/renderer_host/render_widget_host_view_android.cc
+++ b/content/browser/renderer_host/render_widget_host_view_android.cc
@@ -894,10 +894,17 @@ void RenderWidgetHostViewAndroid::CopyFromCompositingSurface(
content_view_core_->GetWindowAndroid()->GetCompositor();
DCHECK(compositor);
DCHECK(!surface_id_.is_null());
+ scoped_refptr<cc::Layer> layer =
+ CreateSurfaceLayer(surface_id_, texture_size_in_layer_);
+ layer->SetHideLayerAndSubtree(true);
+ compositor->AttachLayerForReadback(layer);
+
std::unique_ptr<cc::CopyOutputRequest> request =
- cc::CopyOutputRequest::CreateRequest(base::Bind(
- &PrepareTextureCopyOutputResult, weak_ptr_factory_.GetWeakPtr(),
- dst_size_in_pixel, preferred_color_type, start_time, callback));
+ cc::CopyOutputRequest::CreateRequest(
+ base::Bind(&PrepareTextureCopyOutputResult,
+ weak_ptr_factory_.GetWeakPtr(), layer, dst_size_in_pixel,
+ preferred_color_type, start_time, callback));
+
if (!src_subrect_in_pixel.IsEmpty())
request->set_area(src_subrect_in_pixel);
// Make sure the current frame doesn't get deleted until we fulfill the
@@ -1875,6 +1882,7 @@ void RenderWidgetHostViewAndroid::OnLostResources() {
// static
void RenderWidgetHostViewAndroid::PrepareTextureCopyOutputResult(
base::WeakPtr<RenderWidgetHostViewAndroid> rwhva,
+ scoped_refptr<cc::Layer> readback_layer,
const gfx::Size& dst_size_in_pixel,
SkColorType color_type,
const base::TimeTicks& start_time,
@@ -1884,6 +1892,7 @@ void RenderWidgetHostViewAndroid::PrepareTextureCopyOutputResult(
base::Bind(callback, SkBitmap(), READBACK_FAILED));
TRACE_EVENT0("cc",
"RenderWidgetHostViewAndroid::PrepareTextureCopyOutputResult");
+ readback_layer->RemoveFromParent();
if (rwhva)
rwhva->UnlockCompositingSurface();
if (!result->HasTexture() || result->IsEmpty() || result->size().IsEmpty())
« no previous file with comments | « content/browser/renderer_host/render_widget_host_view_android.h ('k') | ui/android/window_android_compositor.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698