diff options
author | powei@chromium.org <powei@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-06-17 09:47:56 +0000 |
---|---|---|
committer | powei@chromium.org <powei@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-06-17 09:47:56 +0000 |
commit | cec12326f1e77dcd82d292a7e0c2bbc7a6e95118 (patch) | |
tree | 3e3124db6e207abb21285e624603a92d8892ecae | |
parent | ffe904b8e0e12777658fd4c4a5f5e6d251f715c7 (diff) | |
download | chromium_src-cec12326f1e77dcd82d292a7e0c2bbc7a6e95118.zip chromium_src-cec12326f1e77dcd82d292a7e0c2bbc7a6e95118.tar.gz chromium_src-cec12326f1e77dcd82d292a7e0c2bbc7a6e95118.tar.bz2 |
android: Fix set_area size for snapshot_android
For Chrome for Android, the size of the layers correspond to their physical
pixel size. We should scale the copy request subrect by the device scale
factor.
The reason why content/test/gpu/page_sets/pixel_tests.py never failed is
because the test only takes a 300x300 sub-region of the output bitmap; so
as long as the request subrect is greater than that region, the test will
pass through. After this change, ui::GrabViewSnapshot will return a bitmap
of the content in phyiscal pixel size. Should not affect pixel_tests.py.
BUG=384551
Review URL: https://codereview.chromium.org/333413002
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@277690 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | ui/snapshot/snapshot_android.cc | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/ui/snapshot/snapshot_android.cc b/ui/snapshot/snapshot_android.cc index 49e276c..9713cff 100644 --- a/ui/snapshot/snapshot_android.cc +++ b/ui/snapshot/snapshot_android.cc @@ -10,6 +10,9 @@ #include "ui/base/android/view_android.h" #include "ui/base/android/window_android.h" #include "ui/base/android/window_android_compositor.h" +#include "ui/gfx/display.h" +#include "ui/gfx/geometry/rect_conversions.h" +#include "ui/gfx/screen.h" #include "ui/snapshot/snapshot_async.h" namespace ui { @@ -34,7 +37,14 @@ static void MakeAsyncCopyRequest( const cc::CopyOutputRequest::CopyOutputRequestCallback& callback) { scoped_ptr<cc::CopyOutputRequest> request = cc::CopyOutputRequest::CreateBitmapRequest(callback); - request->set_area(source_rect); + + const gfx::Display& display = + gfx::Screen::GetNativeScreen()->GetPrimaryDisplay(); + float device_scale_factor = display.device_scale_factor(); + gfx::Rect source_rect_in_pixel = + gfx::ToEnclosingRect(gfx::ScaleRect(source_rect, device_scale_factor)); + + request->set_area(source_rect_in_pixel); window->GetCompositor()->RequestCopyOfOutputOnRootLayer(request.Pass()); } |