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 411 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
422 const ReadbackRequestCallback& result_callback) { | 422 const ReadbackRequestCallback& result_callback) { |
423 if (!host_ || host_->is_hidden() || !IsSurfaceAvailableForCopy()) { | 423 if (!host_ || host_->is_hidden() || !IsSurfaceAvailableForCopy()) { |
424 result_callback.Run(SkBitmap(), READBACK_SURFACE_UNAVAILABLE); | 424 result_callback.Run(SkBitmap(), READBACK_SURFACE_UNAVAILABLE); |
425 return; | 425 return; |
426 } | 426 } |
427 gfx::Size bounds = layer_->bounds(); | 427 gfx::Size bounds = layer_->bounds(); |
428 if (src_subrect.IsEmpty()) | 428 if (src_subrect.IsEmpty()) |
429 src_subrect = gfx::Rect(bounds); | 429 src_subrect = gfx::Rect(bounds); |
430 DCHECK_LE(src_subrect.width() + src_subrect.x(), bounds.width()); | 430 DCHECK_LE(src_subrect.width() + src_subrect.x(), bounds.width()); |
431 DCHECK_LE(src_subrect.height() + src_subrect.y(), bounds.height()); | 431 DCHECK_LE(src_subrect.height() + src_subrect.y(), bounds.height()); |
432 const gfx::Display& display = | 432 const gfx::Display& display = gfx::Screen::GetScreen()->GetPrimaryDisplay(); |
433 gfx::Screen::GetNativeScreen()->GetPrimaryDisplay(); | |
434 float device_scale_factor = display.device_scale_factor(); | 433 float device_scale_factor = display.device_scale_factor(); |
435 DCHECK_GT(device_scale_factor, 0); | 434 DCHECK_GT(device_scale_factor, 0); |
436 gfx::Size dst_size( | 435 gfx::Size dst_size( |
437 gfx::ScaleToCeiledSize(src_subrect.size(), scale / device_scale_factor)); | 436 gfx::ScaleToCeiledSize(src_subrect.size(), scale / device_scale_factor)); |
438 src_subrect = gfx::ConvertRectToDIP(device_scale_factor, src_subrect); | 437 src_subrect = gfx::ConvertRectToDIP(device_scale_factor, src_subrect); |
439 | 438 |
440 CopyFromCompositingSurface(src_subrect, dst_size, result_callback, | 439 CopyFromCompositingSurface(src_subrect, dst_size, result_callback, |
441 preferred_color_type); | 440 preferred_color_type); |
442 } | 441 } |
443 | 442 |
(...skipping 434 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
878 TRACE_EVENT0("cc", "RenderWidgetHostViewAndroid::CopyFromCompositingSurface"); | 877 TRACE_EVENT0("cc", "RenderWidgetHostViewAndroid::CopyFromCompositingSurface"); |
879 if (!host_ || host_->is_hidden()) { | 878 if (!host_ || host_->is_hidden()) { |
880 callback.Run(SkBitmap(), READBACK_SURFACE_UNAVAILABLE); | 879 callback.Run(SkBitmap(), READBACK_SURFACE_UNAVAILABLE); |
881 return; | 880 return; |
882 } | 881 } |
883 base::TimeTicks start_time = base::TimeTicks::Now(); | 882 base::TimeTicks start_time = base::TimeTicks::Now(); |
884 if (!IsSurfaceAvailableForCopy()) { | 883 if (!IsSurfaceAvailableForCopy()) { |
885 callback.Run(SkBitmap(), READBACK_SURFACE_UNAVAILABLE); | 884 callback.Run(SkBitmap(), READBACK_SURFACE_UNAVAILABLE); |
886 return; | 885 return; |
887 } | 886 } |
888 const gfx::Display& display = | 887 const gfx::Display& display = gfx::Screen::GetScreen()->GetPrimaryDisplay(); |
889 gfx::Screen::GetNativeScreen()->GetPrimaryDisplay(); | |
890 float device_scale_factor = display.device_scale_factor(); | 888 float device_scale_factor = display.device_scale_factor(); |
891 gfx::Size dst_size_in_pixel = | 889 gfx::Size dst_size_in_pixel = |
892 gfx::ConvertRectToPixel(device_scale_factor, gfx::Rect(dst_size)).size(); | 890 gfx::ConvertRectToPixel(device_scale_factor, gfx::Rect(dst_size)).size(); |
893 gfx::Rect src_subrect_in_pixel = | 891 gfx::Rect src_subrect_in_pixel = |
894 gfx::ConvertRectToPixel(device_scale_factor, src_subrect); | 892 gfx::ConvertRectToPixel(device_scale_factor, src_subrect); |
895 | 893 |
896 if (!using_browser_compositor_) { | 894 if (!using_browser_compositor_) { |
897 SynchronousCopyContents(src_subrect_in_pixel, dst_size_in_pixel, callback, | 895 SynchronousCopyContents(src_subrect_in_pixel, dst_size_in_pixel, callback, |
898 preferred_color_type); | 896 preferred_color_type); |
899 UMA_HISTOGRAM_TIMES("Compositing.CopyFromSurfaceTimeSynchronous", | 897 UMA_HISTOGRAM_TIMES("Compositing.CopyFromSurfaceTimeSynchronous", |
(...skipping 1150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2050 // context menu depending on the targetted content. | 2048 // context menu depending on the targetted content. |
2051 blink::WebGestureEvent long_press = WebGestureEventBuilder::Build( | 2049 blink::WebGestureEvent long_press = WebGestureEventBuilder::Build( |
2052 blink::WebInputEvent::GestureLongPress, | 2050 blink::WebInputEvent::GestureLongPress, |
2053 (time - base::TimeTicks()).InSecondsF(), x, y); | 2051 (time - base::TimeTicks()).InSecondsF(), x, y); |
2054 SendGestureEvent(long_press); | 2052 SendGestureEvent(long_press); |
2055 } | 2053 } |
2056 | 2054 |
2057 // static | 2055 // static |
2058 void RenderWidgetHostViewBase::GetDefaultScreenInfo( | 2056 void RenderWidgetHostViewBase::GetDefaultScreenInfo( |
2059 blink::WebScreenInfo* results) { | 2057 blink::WebScreenInfo* results) { |
2060 const gfx::Display& display = | 2058 const gfx::Display& display = gfx::Screen::GetScreen()->GetPrimaryDisplay(); |
2061 gfx::Screen::GetNativeScreen()->GetPrimaryDisplay(); | |
2062 results->rect = display.bounds(); | 2059 results->rect = display.bounds(); |
2063 // TODO(husky): Remove any system controls from availableRect. | 2060 // TODO(husky): Remove any system controls from availableRect. |
2064 results->availableRect = display.work_area(); | 2061 results->availableRect = display.work_area(); |
2065 results->deviceScaleFactor = display.device_scale_factor(); | 2062 results->deviceScaleFactor = display.device_scale_factor(); |
2066 results->orientationAngle = display.RotationAsDegree(); | 2063 results->orientationAngle = display.RotationAsDegree(); |
2067 results->orientationType = | 2064 results->orientationType = |
2068 RenderWidgetHostViewBase::GetOrientationTypeForMobile(display); | 2065 RenderWidgetHostViewBase::GetOrientationTypeForMobile(display); |
2069 gfx::DeviceDisplayInfo info; | 2066 gfx::DeviceDisplayInfo info; |
2070 results->depth = info.GetBitsPerPixel(); | 2067 results->depth = info.GetBitsPerPixel(); |
2071 results->depthPerComponent = info.GetBitsPerComponent(); | 2068 results->depthPerComponent = info.GetBitsPerComponent(); |
2072 results->isMonochrome = (results->depthPerComponent == 0); | 2069 results->isMonochrome = (results->depthPerComponent == 0); |
2073 } | 2070 } |
2074 | 2071 |
2075 } // namespace content | 2072 } // namespace content |
OLD | NEW |