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

Unified Diff: ui/snapshot/snapshot_android.cc

Issue 2219823002: Move content offset to ViewAndroid (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: updated comments Created 3 years, 11 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 | « ui/android/window_android.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/snapshot/snapshot_android.cc
diff --git a/ui/snapshot/snapshot_android.cc b/ui/snapshot/snapshot_android.cc
index 557a325db03b1682b79613561520a3070ea4bfb0..f687aa21daf359ba68c44ed1e1943d416f872b36 100644
--- a/ui/snapshot/snapshot_android.cc
+++ b/ui/snapshot/snapshot_android.cc
@@ -21,6 +21,8 @@
namespace ui {
+// Sync versions are not supported in Android. Callers should fall back
+// to the async version.
bool GrabViewSnapshot(gfx::NativeView view,
std::vector<unsigned char>* png_representation,
const gfx::Rect& snapshot_bounds) {
@@ -31,7 +33,6 @@ bool GrabViewSnapshot(gfx::NativeView view,
bool GrabWindowSnapshot(gfx::NativeWindow window,
std::vector<unsigned char>* png_representation,
const gfx::Rect& snapshot_bounds) {
- // Not supported in Android. Callers should fall back to the async version.
return false;
}
@@ -44,20 +45,8 @@ static void MakeAsyncCopyRequest(
const display::Display& display =
display::Screen::GetScreen()->GetDisplayNearestWindow(window);
- float device_scale_factor = display.device_scale_factor();
- gfx::Rect source_rect_in_pixel =
- gfx::ScaleToEnclosingRect(source_rect, device_scale_factor);
-
- // Account for the toolbar offset.
- gfx::Vector2dF offset_in_pixel =
- gfx::ScaleVector2d(window->content_offset(), device_scale_factor);
- gfx::Rect adjusted_source_rect(
- gfx::ToRoundedPoint(
- gfx::PointF(source_rect_in_pixel.x() + offset_in_pixel.x(),
- source_rect_in_pixel.y() + offset_in_pixel.y())),
- source_rect_in_pixel.size());
-
- request->set_area(adjusted_source_rect);
+ float scale = display.device_scale_factor();
+ request->set_area(gfx::ScaleToEnclosingRect(source_rect, scale));
window->GetCompositor()->RequestCopyOfOutputOnRootLayer(std::move(request));
}
@@ -92,8 +81,11 @@ void GrabViewSnapshotAsync(
const gfx::Rect& source_rect,
scoped_refptr<base::TaskRunner> background_task_runner,
const GrabWindowSnapshotAsyncPNGCallback& callback) {
- GrabWindowSnapshotAsync(
- view->GetWindowAndroid(), source_rect, background_task_runner, callback);
+ MakeAsyncCopyRequest(view->GetWindowAndroid(),
+ source_rect,
+ base::Bind(&SnapshotAsync::EncodeCopyOutputResult,
+ callback,
+ background_task_runner));
}
} // namespace ui
« no previous file with comments | « ui/android/window_android.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698