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

Unified Diff: content/browser/renderer_host/render_widget_host_view_android.cc

Issue 331453004: android: Fix inconsistent sizes in GetScaledContentBitmap (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: last change i hope Created 6 years, 6 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « content/browser/renderer_host/render_widget_host_view_android.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 {
« no previous file with comments | « content/browser/renderer_host/render_widget_host_view_android.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698