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

Side by Side Diff: ui/snapshot/snapshot_android.cc

Issue 1409833004: Add DeviceDisplayInfo getter in WindowAndroid. Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix failing bot, revert RWHVA changes, add NOTIMPLEMENTED to some functions in screen_android Created 4 years, 9 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 unified diff | Download patch
« no previous file with comments | « ui/gfx/screen_android.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "ui/snapshot/snapshot.h" 5 #include "ui/snapshot/snapshot.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "cc/output/copy_output_request.h" 10 #include "cc/output/copy_output_request.h"
11 #include "third_party/skia/include/core/SkBitmap.h" 11 #include "third_party/skia/include/core/SkBitmap.h"
12 #include "ui/android/view_android.h" 12 #include "ui/android/view_android.h"
13 #include "ui/android/window_android.h" 13 #include "ui/android/window_android.h"
14 #include "ui/android/window_android_compositor.h" 14 #include "ui/android/window_android_compositor.h"
15 #include "ui/gfx/android/device_display_info.h"
15 #include "ui/gfx/display.h" 16 #include "ui/gfx/display.h"
16 #include "ui/gfx/geometry/point_conversions.h" 17 #include "ui/gfx/geometry/point_conversions.h"
17 #include "ui/gfx/geometry/rect_conversions.h" 18 #include "ui/gfx/geometry/rect_conversions.h"
18 #include "ui/gfx/screen.h" 19 #include "ui/gfx/screen.h"
19 #include "ui/snapshot/snapshot_async.h" 20 #include "ui/snapshot/snapshot_async.h"
20 21
21 namespace ui { 22 namespace ui {
22 23
23 bool GrabViewSnapshot(gfx::NativeView view, 24 bool GrabViewSnapshot(gfx::NativeView view,
24 std::vector<unsigned char>* png_representation, 25 std::vector<unsigned char>* png_representation,
25 const gfx::Rect& snapshot_bounds) { 26 const gfx::Rect& snapshot_bounds) {
26 return GrabWindowSnapshot( 27 return GrabWindowSnapshot(
27 view->GetWindowAndroid(), png_representation, snapshot_bounds); 28 view->GetWindowAndroid(), png_representation, snapshot_bounds);
28 } 29 }
29 30
30 bool GrabWindowSnapshot(gfx::NativeWindow window, 31 bool GrabWindowSnapshot(gfx::NativeWindow window,
31 std::vector<unsigned char>* png_representation, 32 std::vector<unsigned char>* png_representation,
32 const gfx::Rect& snapshot_bounds) { 33 const gfx::Rect& snapshot_bounds) {
33 // Not supported in Android. Callers should fall back to the async version. 34 // Not supported in Android. Callers should fall back to the async version.
34 return false; 35 return false;
35 } 36 }
36 37
37 static void MakeAsyncCopyRequest( 38 static void MakeAsyncCopyRequest(
38 gfx::NativeWindow window, 39 gfx::NativeWindow window,
39 const gfx::Rect& source_rect, 40 const gfx::Rect& source_rect,
40 const cc::CopyOutputRequest::CopyOutputRequestCallback& callback) { 41 const cc::CopyOutputRequest::CopyOutputRequestCallback& callback) {
41 scoped_ptr<cc::CopyOutputRequest> request = 42 scoped_ptr<cc::CopyOutputRequest> request =
42 cc::CopyOutputRequest::CreateBitmapRequest(callback); 43 cc::CopyOutputRequest::CreateBitmapRequest(callback);
43 44
44 const gfx::Display& display = gfx::Screen::GetScreen()->GetPrimaryDisplay(); 45 float device_scale_factor =
45 float device_scale_factor = display.device_scale_factor(); 46 gfx::Display::HasForceDeviceScaleFactor()
47 ? gfx::Display::GetForcedDeviceScaleFactor()
48 : window->GetDeviceDisplayInfo().GetDIPScale();
49
46 gfx::Rect source_rect_in_pixel = 50 gfx::Rect source_rect_in_pixel =
47 gfx::ScaleToEnclosingRect(source_rect, device_scale_factor); 51 gfx::ScaleToEnclosingRect(source_rect, device_scale_factor);
48 52
49 // Account for the toolbar offset. 53 // Account for the toolbar offset.
50 gfx::Vector2dF offset = window->content_offset(); 54 gfx::Vector2dF offset = window->content_offset();
51 gfx::Rect adjusted_source_rect(gfx::ToRoundedPoint( 55 gfx::Rect adjusted_source_rect(gfx::ToRoundedPoint(
52 gfx::PointF(source_rect_in_pixel.x() + offset.x(), 56 gfx::PointF(source_rect_in_pixel.x() + offset.x(),
53 source_rect_in_pixel.y() + offset.y())), 57 source_rect_in_pixel.y() + offset.y())),
54 source_rect_in_pixel.size()); 58 source_rect_in_pixel.size());
55 59
(...skipping 30 matching lines...) Expand all
86 void GrabViewSnapshotAsync( 90 void GrabViewSnapshotAsync(
87 gfx::NativeView view, 91 gfx::NativeView view,
88 const gfx::Rect& source_rect, 92 const gfx::Rect& source_rect,
89 scoped_refptr<base::TaskRunner> background_task_runner, 93 scoped_refptr<base::TaskRunner> background_task_runner,
90 const GrabWindowSnapshotAsyncPNGCallback& callback) { 94 const GrabWindowSnapshotAsyncPNGCallback& callback) {
91 GrabWindowSnapshotAsync( 95 GrabWindowSnapshotAsync(
92 view->GetWindowAndroid(), source_rect, background_task_runner, callback); 96 view->GetWindowAndroid(), source_rect, background_task_runner, callback);
93 } 97 }
94 98
95 } // namespace ui 99 } // namespace ui
OLDNEW
« no previous file with comments | « ui/gfx/screen_android.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698