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

Side by Side 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 unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "content/browser/renderer_host/render_widget_host_view_android.h" 5 #include "content/browser/renderer_host/render_widget_host_view_android.h"
6 6
7 #include <android/bitmap.h> 7 #include <android/bitmap.h>
8 8
9 #include <utility> 9 #include <utility>
10 10
(...skipping 876 matching lines...) Expand 10 before | Expand all | Expand 10 after
887 preferred_color_type); 887 preferred_color_type);
888 UMA_HISTOGRAM_TIMES("Compositing.CopyFromSurfaceTimeSynchronous", 888 UMA_HISTOGRAM_TIMES("Compositing.CopyFromSurfaceTimeSynchronous",
889 base::TimeTicks::Now() - start_time); 889 base::TimeTicks::Now() - start_time);
890 return; 890 return;
891 } 891 }
892 892
893 ui::WindowAndroidCompositor* compositor = 893 ui::WindowAndroidCompositor* compositor =
894 content_view_core_->GetWindowAndroid()->GetCompositor(); 894 content_view_core_->GetWindowAndroid()->GetCompositor();
895 DCHECK(compositor); 895 DCHECK(compositor);
896 DCHECK(!surface_id_.is_null()); 896 DCHECK(!surface_id_.is_null());
897 scoped_refptr<cc::Layer> layer =
898 CreateSurfaceLayer(surface_id_, texture_size_in_layer_);
899 layer->SetHideLayerAndSubtree(true);
900 compositor->AttachLayerForReadback(layer);
901
897 std::unique_ptr<cc::CopyOutputRequest> request = 902 std::unique_ptr<cc::CopyOutputRequest> request =
898 cc::CopyOutputRequest::CreateRequest(base::Bind( 903 cc::CopyOutputRequest::CreateRequest(
899 &PrepareTextureCopyOutputResult, weak_ptr_factory_.GetWeakPtr(), 904 base::Bind(&PrepareTextureCopyOutputResult,
900 dst_size_in_pixel, preferred_color_type, start_time, callback)); 905 weak_ptr_factory_.GetWeakPtr(), layer, dst_size_in_pixel,
906 preferred_color_type, start_time, callback));
907
901 if (!src_subrect_in_pixel.IsEmpty()) 908 if (!src_subrect_in_pixel.IsEmpty())
902 request->set_area(src_subrect_in_pixel); 909 request->set_area(src_subrect_in_pixel);
903 // Make sure the current frame doesn't get deleted until we fulfill the 910 // Make sure the current frame doesn't get deleted until we fulfill the
904 // request. 911 // request.
905 LockCompositingSurface(); 912 LockCompositingSurface();
906 surface_factory_->RequestCopyOfSurface(surface_id_, std::move(request)); 913 surface_factory_->RequestCopyOfSurface(surface_id_, std::move(request));
907 } 914 }
908 915
909 void RenderWidgetHostViewAndroid::CopyFromCompositingSurfaceToVideoFrame( 916 void RenderWidgetHostViewAndroid::CopyFromCompositingSurfaceToVideoFrame(
910 const gfx::Rect& src_subrect, 917 const gfx::Rect& src_subrect,
(...skipping 957 matching lines...) Expand 10 before | Expand all | Expand 10 after
1868 } 1875 }
1869 1876
1870 // TODO(wjmaclean): There is significant overlap between 1877 // TODO(wjmaclean): There is significant overlap between
1871 // PrepareTextureCopyOutputResult and CopyFromCompositingSurfaceFinished in 1878 // PrepareTextureCopyOutputResult and CopyFromCompositingSurfaceFinished in
1872 // this file, and the versions in surface_utils.cc. They should 1879 // this file, and the versions in surface_utils.cc. They should
1873 // be merged. See https://crbug.com/582955 1880 // be merged. See https://crbug.com/582955
1874 1881
1875 // static 1882 // static
1876 void RenderWidgetHostViewAndroid::PrepareTextureCopyOutputResult( 1883 void RenderWidgetHostViewAndroid::PrepareTextureCopyOutputResult(
1877 base::WeakPtr<RenderWidgetHostViewAndroid> rwhva, 1884 base::WeakPtr<RenderWidgetHostViewAndroid> rwhva,
1885 scoped_refptr<cc::Layer> readback_layer,
1878 const gfx::Size& dst_size_in_pixel, 1886 const gfx::Size& dst_size_in_pixel,
1879 SkColorType color_type, 1887 SkColorType color_type,
1880 const base::TimeTicks& start_time, 1888 const base::TimeTicks& start_time,
1881 const ReadbackRequestCallback& callback, 1889 const ReadbackRequestCallback& callback,
1882 std::unique_ptr<cc::CopyOutputResult> result) { 1890 std::unique_ptr<cc::CopyOutputResult> result) {
1883 base::ScopedClosureRunner scoped_callback_runner( 1891 base::ScopedClosureRunner scoped_callback_runner(
1884 base::Bind(callback, SkBitmap(), READBACK_FAILED)); 1892 base::Bind(callback, SkBitmap(), READBACK_FAILED));
1885 TRACE_EVENT0("cc", 1893 TRACE_EVENT0("cc",
1886 "RenderWidgetHostViewAndroid::PrepareTextureCopyOutputResult"); 1894 "RenderWidgetHostViewAndroid::PrepareTextureCopyOutputResult");
1895 readback_layer->RemoveFromParent();
1887 if (rwhva) 1896 if (rwhva)
1888 rwhva->UnlockCompositingSurface(); 1897 rwhva->UnlockCompositingSurface();
1889 if (!result->HasTexture() || result->IsEmpty() || result->size().IsEmpty()) 1898 if (!result->HasTexture() || result->IsEmpty() || result->size().IsEmpty())
1890 return; 1899 return;
1891 cc::TextureMailbox texture_mailbox; 1900 cc::TextureMailbox texture_mailbox;
1892 std::unique_ptr<cc::SingleReleaseCallback> release_callback; 1901 std::unique_ptr<cc::SingleReleaseCallback> release_callback;
1893 result->TakeTexture(&texture_mailbox, &release_callback); 1902 result->TakeTexture(&texture_mailbox, &release_callback);
1894 DCHECK(texture_mailbox.IsTexture()); 1903 DCHECK(texture_mailbox.IsTexture());
1895 if (!texture_mailbox.IsTexture()) 1904 if (!texture_mailbox.IsTexture())
1896 return; 1905 return;
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
1993 case ui::MotionEvent::ACTION_UP: 2002 case ui::MotionEvent::ACTION_UP:
1994 case ui::MotionEvent::ACTION_POINTER_UP: 2003 case ui::MotionEvent::ACTION_POINTER_UP:
1995 UMA_HISTOGRAM_CUSTOM_COUNTS("Event.Latency.OS.TOUCH_RELEASED", 2004 UMA_HISTOGRAM_CUSTOM_COUNTS("Event.Latency.OS.TOUCH_RELEASED",
1996 delta.InMicroseconds(), 1, 1000000, 50); 2005 delta.InMicroseconds(), 1, 1000000, 50);
1997 default: 2006 default:
1998 return; 2007 return;
1999 } 2008 }
2000 } 2009 }
2001 2010
2002 } // namespace content 2011 } // namespace content
OLDNEW
« 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