Chromium Code Reviews| Index: content/browser/renderer_host/render_widget_host_view_android.cc |
| diff --git a/content/browser/renderer_host/render_widget_host_view_android.cc b/content/browser/renderer_host/render_widget_host_view_android.cc |
| index 644343df3754e8b8d962c298eb860135033e7536..a134b308b7be53b0c7be2e4676baad95a4f1ecb4 100644 |
| --- a/content/browser/renderer_host/render_widget_host_view_android.cc |
| +++ b/content/browser/renderer_host/render_widget_host_view_android.cc |
| @@ -66,6 +66,7 @@ |
| #include "ui/gfx/android/device_display_info.h" |
| #include "ui/gfx/android/java_bitmap.h" |
| #include "ui/gfx/display.h" |
| +#include "ui/gfx/point_conversions.h" |
| #include "ui/gfx/screen.h" |
| #include "ui/gfx/size_conversions.h" |
| @@ -299,19 +300,32 @@ void RenderWidgetHostViewAndroid::GetScaledContentBitmap( |
| return; |
| } |
| - gfx::Size bounds = layer_->bounds(); |
| - if (src_subrect.IsEmpty()) |
| - src_subrect = gfx::Rect(bounds); |
| - DCHECK_LE(src_subrect.width() + src_subrect.x(), bounds.width()); |
| - DCHECK_LE(src_subrect.height() + src_subrect.y(), bounds.height()); |
| const gfx::Display& display = |
| gfx::Screen::GetNativeScreen()->GetPrimaryDisplay(); |
| float device_scale_factor = display.device_scale_factor(); |
| DCHECK_GT(device_scale_factor, 0); |
| - gfx::Size dst_size( |
| - gfx::ToCeiledSize(gfx::ScaleSize(bounds, scale / device_scale_factor))); |
| + |
| + gfx::Size bounds = layer_->bounds(); |
| + |
| + gfx::Size dst_size_in_dip(gfx::ToCeiledSize(gfx::ScaleSize(bounds, scale))); |
| + |
| + gfx::RectF src_subrect_in_dip_f(gfx::ScaleRect( |
| + ConvertRectToDIP(device_scale_factor, src_subrect), scale)); |
|
no sievers
2014/06/11 21:39:11
Why does the src_subrect get scaled by |scale|?
powei
2014/06/11 21:46:12
I think |src_subrect| assumes its space to be pre-
|
| + |
| + gfx::Rect src_subrect_in_dip( |
| + gfx::ToFlooredPoint(src_subrect_in_dip_f.origin()), |
| + gfx::ToCeiledSize(src_subrect_in_dip_f.size())); |
| + |
| + if (src_subrect_in_dip.IsEmpty()) |
| + src_subrect_in_dip = gfx::Rect(dst_size_in_dip); |
|
no sievers
2014/06/11 21:39:11
When does this happen?
powei
2014/06/11 21:46:11
It's a somewhat hacky convention that when |src_su
|
| + |
| + DCHECK_LE(src_subrect_in_dip.width() + src_subrect_in_dip.x(), |
| + bounds.width()); |
| + DCHECK_LE(src_subrect_in_dip.height() + src_subrect_in_dip.y(), |
| + bounds.height()); |
| + |
| CopyFromCompositingSurface( |
| - src_subrect, dst_size, result_callback, bitmap_config); |
| + src_subrect_in_dip, dst_size_in_dip, result_callback, bitmap_config); |
| } |
| bool RenderWidgetHostViewAndroid::HasValidFrame() const { |