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

Side by Side Diff: content/browser/renderer_host/render_widget_host_view_android.cc

Issue 1732323002: Remove layer for readback (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fixed a bug Created 4 years, 10 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 #include <utility> 8 #include <utility>
9 9
10 #include "base/android/build_info.h" 10 #include "base/android/build_info.h"
(...skipping 873 matching lines...) Expand 10 before | Expand all | Expand 10 after
884 gfx::ConvertRectToPixel(device_scale_factor, src_subrect); 884 gfx::ConvertRectToPixel(device_scale_factor, src_subrect);
885 885
886 if (!using_browser_compositor_) { 886 if (!using_browser_compositor_) {
887 SynchronousCopyContents(src_subrect_in_pixel, dst_size_in_pixel, callback, 887 SynchronousCopyContents(src_subrect_in_pixel, dst_size_in_pixel, callback,
888 preferred_color_type); 888 preferred_color_type);
889 UMA_HISTOGRAM_TIMES("Compositing.CopyFromSurfaceTimeSynchronous", 889 UMA_HISTOGRAM_TIMES("Compositing.CopyFromSurfaceTimeSynchronous",
890 base::TimeTicks::Now() - start_time); 890 base::TimeTicks::Now() - start_time);
891 return; 891 return;
892 } 892 }
893 893
894 scoped_ptr<cc::CopyOutputRequest> request;
895 scoped_refptr<cc::Layer> readback_layer;
896 if (!content_view_core_ || !(content_view_core_->GetWindowAndroid())) { 894 if (!content_view_core_ || !(content_view_core_->GetWindowAndroid())) {
897 callback.Run(SkBitmap(), READBACK_FAILED); 895 callback.Run(SkBitmap(), READBACK_FAILED);
898 return; 896 return;
899 } 897 }
900 ui::WindowAndroidCompositor* compositor = 898 ui::WindowAndroidCompositor* compositor =
901 content_view_core_->GetWindowAndroid()->GetCompositor(); 899 content_view_core_->GetWindowAndroid()->GetCompositor();
902 DCHECK(compositor); 900 DCHECK(compositor);
903 DCHECK(!surface_id_.is_null()); 901 DCHECK(!surface_id_.is_null());
904 scoped_refptr<cc::Layer> layer = CreateDelegatedLayer(); 902 scoped_ptr<cc::CopyOutputRequest> request =
905 DCHECK(layer); 903 cc::CopyOutputRequest::CreateRequest(
906 layer->SetHideLayerAndSubtree(true); 904 base::Bind(&PrepareTextureCopyOutputResult,
907 compositor->AttachLayerForReadback(layer); 905 dst_size_in_pixel, preferred_color_type, start_time,
908 906 callback));
909 readback_layer = layer;
910 request = cc::CopyOutputRequest::CreateRequest(
911 base::Bind(&RenderWidgetHostViewAndroid::
912 PrepareTextureCopyOutputResultForDelegatedReadback,
913 dst_size_in_pixel, preferred_color_type, start_time,
914 readback_layer, callback));
915 if (!src_subrect_in_pixel.IsEmpty()) 907 if (!src_subrect_in_pixel.IsEmpty())
916 request->set_area(src_subrect_in_pixel); 908 request->set_area(src_subrect_in_pixel);
917 readback_layer->RequestCopyOfOutput(std::move(request)); 909 layer_->RequestCopyOfOutput(std::move(request));
918 } 910 }
919 911
920 void RenderWidgetHostViewAndroid::CopyFromCompositingSurfaceToVideoFrame( 912 void RenderWidgetHostViewAndroid::CopyFromCompositingSurfaceToVideoFrame(
921 const gfx::Rect& src_subrect, 913 const gfx::Rect& src_subrect,
922 const scoped_refptr<media::VideoFrame>& target, 914 const scoped_refptr<media::VideoFrame>& target,
923 const base::Callback<void(const gfx::Rect&, bool)>& callback) { 915 const base::Callback<void(const gfx::Rect&, bool)>& callback) {
924 NOTIMPLEMENTED(); 916 NOTIMPLEMENTED();
925 callback.Run(gfx::Rect(), false); 917 callback.Run(gfx::Rect(), false);
926 } 918 }
927 919
(...skipping 995 matching lines...) Expand 10 before | Expand all | Expand 10 after
1923 ShowInternal(); 1915 ShowInternal();
1924 } 1916 }
1925 1917
1926 void RenderWidgetHostViewAndroid::OnLostResources() { 1918 void RenderWidgetHostViewAndroid::OnLostResources() {
1927 ReleaseLocksOnSurface(); 1919 ReleaseLocksOnSurface();
1928 if (layer_.get()) 1920 if (layer_.get())
1929 DestroyDelegatedContent(); 1921 DestroyDelegatedContent();
1930 DCHECK(ack_callbacks_.empty()); 1922 DCHECK(ack_callbacks_.empty());
1931 } 1923 }
1932 1924
1933 // static
1934 void RenderWidgetHostViewAndroid::
1935 PrepareTextureCopyOutputResultForDelegatedReadback(
1936 const gfx::Size& dst_size_in_pixel,
1937 SkColorType color_type,
1938 const base::TimeTicks& start_time,
1939 scoped_refptr<cc::Layer> readback_layer,
1940 const ReadbackRequestCallback& callback,
1941 scoped_ptr<cc::CopyOutputResult> result) {
1942 readback_layer->RemoveFromParent();
1943 PrepareTextureCopyOutputResult(dst_size_in_pixel, color_type, start_time,
1944 callback, std::move(result));
1945 }
1946
1947 // TODO(wjmaclean): There is significant overlap between 1925 // TODO(wjmaclean): There is significant overlap between
1948 // PrepareTextureCopyOutputResult and CopyFromCompositingSurfaceFinished in 1926 // PrepareTextureCopyOutputResult and CopyFromCompositingSurfaceFinished in
1949 // this file, and the versions in surface_utils.cc. They should 1927 // this file, and the versions in surface_utils.cc. They should
1950 // be merged. See https://crbug.com/582955 1928 // be merged. See https://crbug.com/582955
1951 1929
1952 // static 1930 // static
1953 void RenderWidgetHostViewAndroid::PrepareTextureCopyOutputResult( 1931 void RenderWidgetHostViewAndroid::PrepareTextureCopyOutputResult(
1954 const gfx::Size& dst_size_in_pixel, 1932 const gfx::Size& dst_size_in_pixel,
1955 SkColorType color_type, 1933 SkColorType color_type,
1956 const base::TimeTicks& start_time, 1934 const base::TimeTicks& start_time,
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
2046 results->orientationAngle = display.RotationAsDegree(); 2024 results->orientationAngle = display.RotationAsDegree();
2047 results->orientationType = 2025 results->orientationType =
2048 RenderWidgetHostViewBase::GetOrientationTypeForMobile(display); 2026 RenderWidgetHostViewBase::GetOrientationTypeForMobile(display);
2049 gfx::DeviceDisplayInfo info; 2027 gfx::DeviceDisplayInfo info;
2050 results->depth = info.GetBitsPerPixel(); 2028 results->depth = info.GetBitsPerPixel();
2051 results->depthPerComponent = info.GetBitsPerComponent(); 2029 results->depthPerComponent = info.GetBitsPerComponent();
2052 results->isMonochrome = (results->depthPerComponent == 0); 2030 results->isMonochrome = (results->depthPerComponent == 0);
2053 } 2031 }
2054 2032
2055 } // namespace content 2033 } // 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