Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 883 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 894 scoped_ptr<cc::CopyOutputRequest> request; | 894 scoped_ptr<cc::CopyOutputRequest> request; |
| 895 scoped_refptr<cc::Layer> readback_layer; | 895 scoped_refptr<cc::Layer> readback_layer; |
| 896 if (!content_view_core_ || !(content_view_core_->GetWindowAndroid())) { | 896 if (!content_view_core_ || !(content_view_core_->GetWindowAndroid())) { |
| 897 callback.Run(SkBitmap(), READBACK_FAILED); | 897 callback.Run(SkBitmap(), READBACK_FAILED); |
| 898 return; | 898 return; |
| 899 } | 899 } |
| 900 ui::WindowAndroidCompositor* compositor = | 900 ui::WindowAndroidCompositor* compositor = |
| 901 content_view_core_->GetWindowAndroid()->GetCompositor(); | 901 content_view_core_->GetWindowAndroid()->GetCompositor(); |
| 902 DCHECK(compositor); | 902 DCHECK(compositor); |
| 903 DCHECK(!surface_id_.is_null()); | 903 DCHECK(!surface_id_.is_null()); |
| 904 scoped_refptr<cc::Layer> layer = CreateDelegatedLayer(); | |
| 905 DCHECK(layer); | |
| 906 layer->SetHideLayerAndSubtree(true); | |
| 907 compositor->AttachLayerForReadback(layer); | |
| 908 | |
| 909 readback_layer = layer; | |
| 910 request = cc::CopyOutputRequest::CreateRequest( | 904 request = cc::CopyOutputRequest::CreateRequest( |
| 911 base::Bind(&RenderWidgetHostViewAndroid:: | 905 base::Bind(&RenderWidgetHostViewAndroid:: |
| 912 PrepareTextureCopyOutputResultForDelegatedReadback, | 906 PrepareTextureCopyOutputResult, |
| 913 dst_size_in_pixel, preferred_color_type, start_time, | 907 dst_size_in_pixel, preferred_color_type, start_time, |
| 914 readback_layer, callback)); | 908 callback)); |
| 915 if (!src_subrect_in_pixel.IsEmpty()) | 909 if (!src_subrect_in_pixel.IsEmpty()) |
| 916 request->set_area(src_subrect_in_pixel); | 910 request->set_area(src_subrect_in_pixel); |
| 917 readback_layer->RequestCopyOfOutput(std::move(request)); | 911 compositor->RequestCopyOfOutputOnRootLayer(std::move(request)); |
|
no sievers
2016/02/25 23:26:11
You want to use |layer_| here or you'll get the wh
Jinsuk Kim
2016/02/26 00:53:30
Thanks for helping out. Fixed.
| |
| 918 } | 912 } |
| 919 | 913 |
| 920 void RenderWidgetHostViewAndroid::CopyFromCompositingSurfaceToVideoFrame( | 914 void RenderWidgetHostViewAndroid::CopyFromCompositingSurfaceToVideoFrame( |
| 921 const gfx::Rect& src_subrect, | 915 const gfx::Rect& src_subrect, |
| 922 const scoped_refptr<media::VideoFrame>& target, | 916 const scoped_refptr<media::VideoFrame>& target, |
| 923 const base::Callback<void(const gfx::Rect&, bool)>& callback) { | 917 const base::Callback<void(const gfx::Rect&, bool)>& callback) { |
| 924 NOTIMPLEMENTED(); | 918 NOTIMPLEMENTED(); |
| 925 callback.Run(gfx::Rect(), false); | 919 callback.Run(gfx::Rect(), false); |
| 926 } | 920 } |
| 927 | 921 |
| (...skipping 995 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1923 ShowInternal(); | 1917 ShowInternal(); |
| 1924 } | 1918 } |
| 1925 | 1919 |
| 1926 void RenderWidgetHostViewAndroid::OnLostResources() { | 1920 void RenderWidgetHostViewAndroid::OnLostResources() { |
| 1927 ReleaseLocksOnSurface(); | 1921 ReleaseLocksOnSurface(); |
| 1928 if (layer_.get()) | 1922 if (layer_.get()) |
| 1929 DestroyDelegatedContent(); | 1923 DestroyDelegatedContent(); |
| 1930 DCHECK(ack_callbacks_.empty()); | 1924 DCHECK(ack_callbacks_.empty()); |
| 1931 } | 1925 } |
| 1932 | 1926 |
| 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 | 1927 // TODO(wjmaclean): There is significant overlap between |
| 1948 // PrepareTextureCopyOutputResult and CopyFromCompositingSurfaceFinished in | 1928 // PrepareTextureCopyOutputResult and CopyFromCompositingSurfaceFinished in |
| 1949 // this file, and the versions in surface_utils.cc. They should | 1929 // this file, and the versions in surface_utils.cc. They should |
| 1950 // be merged. See https://crbug.com/582955 | 1930 // be merged. See https://crbug.com/582955 |
| 1951 | 1931 |
| 1952 // static | 1932 // static |
| 1953 void RenderWidgetHostViewAndroid::PrepareTextureCopyOutputResult( | 1933 void RenderWidgetHostViewAndroid::PrepareTextureCopyOutputResult( |
| 1954 const gfx::Size& dst_size_in_pixel, | 1934 const gfx::Size& dst_size_in_pixel, |
| 1955 SkColorType color_type, | 1935 SkColorType color_type, |
| 1956 const base::TimeTicks& start_time, | 1936 const base::TimeTicks& start_time, |
| (...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2046 results->orientationAngle = display.RotationAsDegree(); | 2026 results->orientationAngle = display.RotationAsDegree(); |
| 2047 results->orientationType = | 2027 results->orientationType = |
| 2048 RenderWidgetHostViewBase::GetOrientationTypeForMobile(display); | 2028 RenderWidgetHostViewBase::GetOrientationTypeForMobile(display); |
| 2049 gfx::DeviceDisplayInfo info; | 2029 gfx::DeviceDisplayInfo info; |
| 2050 results->depth = info.GetBitsPerPixel(); | 2030 results->depth = info.GetBitsPerPixel(); |
| 2051 results->depthPerComponent = info.GetBitsPerComponent(); | 2031 results->depthPerComponent = info.GetBitsPerComponent(); |
| 2052 results->isMonochrome = (results->depthPerComponent == 0); | 2032 results->isMonochrome = (results->depthPerComponent == 0); |
| 2053 } | 2033 } |
| 2054 | 2034 |
| 2055 } // namespace content | 2035 } // namespace content |
| OLD | NEW |