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

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: make set_area consistent 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/compositor/delegated_frame_host.cc ('k') | ui/snapshot/snapshot_aura.cc » ('j') | 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..bf04ccf05c6e0228644ca526a5f54a8e30c24466 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,17 +300,16 @@ 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 dst_size;
+ if (src_subrect.IsEmpty()) {
+ dst_size =
+ gfx::ToCeiledSize(ConvertSizeToPixel(scale, layer_->bounds()));
+ src_subrect = gfx::Rect(layer_->bounds());
+ } else {
+ dst_size =
+ gfx::ToCeiledSize(ConvertSizeToPixel(scale, src_subrect.size()));
+ }
+
CopyFromCompositingSurface(
src_subrect, dst_size, result_callback, bitmap_config);
}
@@ -667,10 +667,10 @@ void RenderWidgetHostViewAndroid::CopyFromCompositingSurface(
float device_scale_factor = display.device_scale_factor();
gfx::Size dst_size_in_pixel =
ConvertRectToPixel(device_scale_factor, gfx::Rect(dst_size)).size();
- gfx::Rect src_subrect_in_pixel =
- ConvertRectToPixel(device_scale_factor, src_subrect);
if (using_synchronous_compositor_) {
+ gfx::Rect src_subrect_in_pixel =
+ ConvertRectToPixel(device_scale_factor, src_subrect);
SynchronousCopyContents(src_subrect_in_pixel, dst_size_in_pixel, callback,
bitmap_config);
UMA_HISTOGRAM_TIMES("Compositing.CopyFromSurfaceTimeSynchronous",
@@ -679,7 +679,6 @@ void RenderWidgetHostViewAndroid::CopyFromCompositingSurface(
}
scoped_ptr<cc::CopyOutputRequest> request;
- scoped_refptr<cc::Layer> readback_layer;
DCHECK(content_view_core_);
DCHECK(content_view_core_->GetWindowAndroid());
ui::WindowAndroidCompositor* compositor =
@@ -697,17 +696,16 @@ void RenderWidgetHostViewAndroid::CopyFromCompositingSurface(
delegated_layer->SetTransform(layer_scale);
compositor->AttachLayerForReadback(delegated_layer);
- readback_layer = delegated_layer;
request = cc::CopyOutputRequest::CreateRequest(
base::Bind(&RenderWidgetHostViewAndroid::
PrepareTextureCopyOutputResultForDelegatedReadback,
dst_size_in_pixel,
bitmap_config,
start_time,
- readback_layer,
+ delegated_layer,
callback));
- request->set_area(src_subrect_in_pixel);
- readback_layer->RequestCopyOfOutput(request.Pass());
+ request->set_area(src_subrect);
+ delegated_layer->RequestCopyOfOutput(request.Pass());
}
void RenderWidgetHostViewAndroid::CopyFromCompositingSurfaceToVideoFrame(
« no previous file with comments | « content/browser/compositor/delegated_frame_host.cc ('k') | ui/snapshot/snapshot_aura.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698