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 | 8 |
9 #include "base/android/build_info.h" | 9 #include "base/android/build_info.h" |
10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
(...skipping 419 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
430 void RenderWidgetHostViewAndroid::SetBounds(const gfx::Rect& rect) { | 430 void RenderWidgetHostViewAndroid::SetBounds(const gfx::Rect& rect) { |
431 SetSize(rect.size()); | 431 SetSize(rect.size()); |
432 } | 432 } |
433 | 433 |
434 void RenderWidgetHostViewAndroid::GetScaledContentBitmap( | 434 void RenderWidgetHostViewAndroid::GetScaledContentBitmap( |
435 float scale, | 435 float scale, |
436 SkColorType color_type, | 436 SkColorType color_type, |
437 gfx::Rect src_subrect, | 437 gfx::Rect src_subrect, |
438 ReadbackRequestCallback& result_callback) { | 438 ReadbackRequestCallback& result_callback) { |
439 if (!host_ || host_->is_hidden() || !IsSurfaceAvailableForCopy()) { | 439 if (!host_ || host_->is_hidden() || !IsSurfaceAvailableForCopy()) { |
440 result_callback.Run(SkBitmap(), READBACK_NOT_SUPPORTED); | 440 result_callback.Run(SkBitmap(), READBACK_SURFACE_UNAVAILABLE); |
441 return; | 441 return; |
442 } | 442 } |
443 gfx::Size bounds = layer_->bounds(); | 443 gfx::Size bounds = layer_->bounds(); |
444 if (src_subrect.IsEmpty()) | 444 if (src_subrect.IsEmpty()) |
445 src_subrect = gfx::Rect(bounds); | 445 src_subrect = gfx::Rect(bounds); |
446 DCHECK_LE(src_subrect.width() + src_subrect.x(), bounds.width()); | 446 DCHECK_LE(src_subrect.width() + src_subrect.x(), bounds.width()); |
447 DCHECK_LE(src_subrect.height() + src_subrect.y(), bounds.height()); | 447 DCHECK_LE(src_subrect.height() + src_subrect.y(), bounds.height()); |
448 const gfx::Display& display = | 448 const gfx::Display& display = |
449 gfx::Screen::GetNativeScreen()->GetPrimaryDisplay(); | 449 gfx::Screen::GetNativeScreen()->GetPrimaryDisplay(); |
450 float device_scale_factor = display.device_scale_factor(); | 450 float device_scale_factor = display.device_scale_factor(); |
(...skipping 467 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
918 const gfx::Size& dst_size, | 918 const gfx::Size& dst_size, |
919 ReadbackRequestCallback& callback, | 919 ReadbackRequestCallback& callback, |
920 const SkColorType color_type) { | 920 const SkColorType color_type) { |
921 TRACE_EVENT0("cc", "RenderWidgetHostViewAndroid::CopyFromCompositingSurface"); | 921 TRACE_EVENT0("cc", "RenderWidgetHostViewAndroid::CopyFromCompositingSurface"); |
922 if (!host_ || host_->is_hidden()) { | 922 if (!host_ || host_->is_hidden()) { |
923 callback.Run(SkBitmap(), READBACK_SURFACE_UNAVAILABLE); | 923 callback.Run(SkBitmap(), READBACK_SURFACE_UNAVAILABLE); |
924 return; | 924 return; |
925 } | 925 } |
926 base::TimeTicks start_time = base::TimeTicks::Now(); | 926 base::TimeTicks start_time = base::TimeTicks::Now(); |
927 if (using_browser_compositor_ && !IsSurfaceAvailableForCopy()) { | 927 if (using_browser_compositor_ && !IsSurfaceAvailableForCopy()) { |
928 callback.Run(SkBitmap(), READBACK_NOT_SUPPORTED); | 928 callback.Run(SkBitmap(), READBACK_SURFACE_UNAVAILABLE); |
929 return; | 929 return; |
930 } | 930 } |
931 const gfx::Display& display = | 931 const gfx::Display& display = |
932 gfx::Screen::GetNativeScreen()->GetPrimaryDisplay(); | 932 gfx::Screen::GetNativeScreen()->GetPrimaryDisplay(); |
933 float device_scale_factor = display.device_scale_factor(); | 933 float device_scale_factor = display.device_scale_factor(); |
934 gfx::Size dst_size_in_pixel = | 934 gfx::Size dst_size_in_pixel = |
935 gfx::ConvertRectToPixel(device_scale_factor, gfx::Rect(dst_size)).size(); | 935 gfx::ConvertRectToPixel(device_scale_factor, gfx::Rect(dst_size)).size(); |
936 gfx::Rect src_subrect_in_pixel = | 936 gfx::Rect src_subrect_in_pixel = |
937 gfx::ConvertRectToPixel(device_scale_factor, src_subrect); | 937 gfx::ConvertRectToPixel(device_scale_factor, src_subrect); |
938 | 938 |
(...skipping 949 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1888 GLHelper* gl_helper = GetPostReadbackGLHelper(); | 1888 GLHelper* gl_helper = GetPostReadbackGLHelper(); |
1889 if (!gl_helper) | 1889 if (!gl_helper) |
1890 return; | 1890 return; |
1891 if (!gl_helper->IsReadbackConfigSupported(color_type)) | 1891 if (!gl_helper->IsReadbackConfigSupported(color_type)) |
1892 color_type = kRGBA_8888_SkColorType; | 1892 color_type = kRGBA_8888_SkColorType; |
1893 scoped_ptr<SkBitmap> bitmap(new SkBitmap); | 1893 scoped_ptr<SkBitmap> bitmap(new SkBitmap); |
1894 if (!bitmap->tryAllocPixels(SkImageInfo::Make(output_size_in_pixel.width(), | 1894 if (!bitmap->tryAllocPixels(SkImageInfo::Make(output_size_in_pixel.width(), |
1895 output_size_in_pixel.height(), | 1895 output_size_in_pixel.height(), |
1896 color_type, | 1896 color_type, |
1897 kOpaque_SkAlphaType))) { | 1897 kOpaque_SkAlphaType))) { |
| 1898 scoped_callback_runner.Reset( |
| 1899 base::Bind(callback, SkBitmap(), READBACK_BITMAP_ALLOCATION_FAILURE)); |
1898 return; | 1900 return; |
1899 } | 1901 } |
1900 | 1902 |
1901 | 1903 |
1902 scoped_ptr<SkAutoLockPixels> bitmap_pixels_lock( | 1904 scoped_ptr<SkAutoLockPixels> bitmap_pixels_lock( |
1903 new SkAutoLockPixels(*bitmap)); | 1905 new SkAutoLockPixels(*bitmap)); |
1904 uint8* pixels = static_cast<uint8*>(bitmap->getPixels()); | 1906 uint8* pixels = static_cast<uint8*>(bitmap->getPixels()); |
1905 | 1907 |
1906 cc::TextureMailbox texture_mailbox; | 1908 cc::TextureMailbox texture_mailbox; |
1907 scoped_ptr<cc::SingleReleaseCallback> release_callback; | 1909 scoped_ptr<cc::SingleReleaseCallback> release_callback; |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1968 results->orientationAngle = display.RotationAsDegree(); | 1970 results->orientationAngle = display.RotationAsDegree(); |
1969 results->orientationType = | 1971 results->orientationType = |
1970 RenderWidgetHostViewBase::GetOrientationTypeForMobile(display); | 1972 RenderWidgetHostViewBase::GetOrientationTypeForMobile(display); |
1971 gfx::DeviceDisplayInfo info; | 1973 gfx::DeviceDisplayInfo info; |
1972 results->depth = info.GetBitsPerPixel(); | 1974 results->depth = info.GetBitsPerPixel(); |
1973 results->depthPerComponent = info.GetBitsPerComponent(); | 1975 results->depthPerComponent = info.GetBitsPerComponent(); |
1974 results->isMonochrome = (results->depthPerComponent == 0); | 1976 results->isMonochrome = (results->depthPerComponent == 0); |
1975 } | 1977 } |
1976 | 1978 |
1977 } // namespace content | 1979 } // namespace content |
OLD | NEW |