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

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: Pass display area instead of NativeWindow to GLHelperHolder. Created 5 years, 1 month 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
« ui/gfx/screen_android.cc ('K') | « 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 "base/bind.h" 7 #include "base/bind.h"
8 #include "cc/output/copy_output_request.h" 8 #include "cc/output/copy_output_request.h"
9 #include "third_party/skia/include/core/SkBitmap.h" 9 #include "third_party/skia/include/core/SkBitmap.h"
10 #include "ui/android/view_android.h" 10 #include "ui/android/view_android.h"
11 #include "ui/android/window_android.h" 11 #include "ui/android/window_android.h"
12 #include "ui/android/window_android_compositor.h" 12 #include "ui/android/window_android_compositor.h"
13 #include "ui/gfx/android/device_display_info.h"
13 #include "ui/gfx/display.h" 14 #include "ui/gfx/display.h"
14 #include "ui/gfx/geometry/point_conversions.h" 15 #include "ui/gfx/geometry/point_conversions.h"
15 #include "ui/gfx/geometry/rect_conversions.h" 16 #include "ui/gfx/geometry/rect_conversions.h"
16 #include "ui/gfx/screen.h" 17 #include "ui/gfx/screen.h"
17 #include "ui/snapshot/snapshot_async.h" 18 #include "ui/snapshot/snapshot_async.h"
18 19
19 namespace ui { 20 namespace ui {
20 21
21 bool GrabViewSnapshot(gfx::NativeView view, 22 bool GrabViewSnapshot(gfx::NativeView view,
22 std::vector<unsigned char>* png_representation, 23 std::vector<unsigned char>* png_representation,
23 const gfx::Rect& snapshot_bounds) { 24 const gfx::Rect& snapshot_bounds) {
24 return GrabWindowSnapshot( 25 return GrabWindowSnapshot(
25 view->GetWindowAndroid(), png_representation, snapshot_bounds); 26 view->GetWindowAndroid(), png_representation, snapshot_bounds);
26 } 27 }
27 28
28 bool GrabWindowSnapshot(gfx::NativeWindow window, 29 bool GrabWindowSnapshot(gfx::NativeWindow window,
29 std::vector<unsigned char>* png_representation, 30 std::vector<unsigned char>* png_representation,
30 const gfx::Rect& snapshot_bounds) { 31 const gfx::Rect& snapshot_bounds) {
31 // Not supported in Android. Callers should fall back to the async version. 32 // Not supported in Android. Callers should fall back to the async version.
32 return false; 33 return false;
33 } 34 }
34 35
35 static void MakeAsyncCopyRequest( 36 static void MakeAsyncCopyRequest(
36 gfx::NativeWindow window, 37 gfx::NativeWindow window,
37 const gfx::Rect& source_rect, 38 const gfx::Rect& source_rect,
38 const cc::CopyOutputRequest::CopyOutputRequestCallback& callback) { 39 const cc::CopyOutputRequest::CopyOutputRequestCallback& callback) {
39 scoped_ptr<cc::CopyOutputRequest> request = 40 scoped_ptr<cc::CopyOutputRequest> request =
40 cc::CopyOutputRequest::CreateBitmapRequest(callback); 41 cc::CopyOutputRequest::CreateBitmapRequest(callback);
41 42
42 const gfx::Display& display = 43 float device_scale_factor =
43 gfx::Screen::GetNativeScreen()->GetPrimaryDisplay(); 44 gfx::Display::HasForceDeviceScaleFactor()
44 float device_scale_factor = display.device_scale_factor(); 45 ? gfx::Display::GetForcedDeviceScaleFactor()
46 : window->GetDeviceDisplayInfo().GetDIPScale();
47
45 gfx::Rect source_rect_in_pixel = 48 gfx::Rect source_rect_in_pixel =
46 gfx::ScaleToEnclosingRect(source_rect, device_scale_factor); 49 gfx::ScaleToEnclosingRect(source_rect, device_scale_factor);
47 50
48 // Account for the toolbar offset. 51 // Account for the toolbar offset.
49 gfx::Vector2dF offset = window->content_offset(); 52 gfx::Vector2dF offset = window->content_offset();
50 gfx::Rect adjusted_source_rect(gfx::ToRoundedPoint( 53 gfx::Rect adjusted_source_rect(gfx::ToRoundedPoint(
51 gfx::PointF(source_rect_in_pixel.x() + offset.x(), 54 gfx::PointF(source_rect_in_pixel.x() + offset.x(),
52 source_rect_in_pixel.y() + offset.y())), 55 source_rect_in_pixel.y() + offset.y())),
53 source_rect_in_pixel.size()); 56 source_rect_in_pixel.size());
54 57
(...skipping 30 matching lines...) Expand all
85 void GrabViewSnapshotAsync( 88 void GrabViewSnapshotAsync(
86 gfx::NativeView view, 89 gfx::NativeView view,
87 const gfx::Rect& source_rect, 90 const gfx::Rect& source_rect,
88 scoped_refptr<base::TaskRunner> background_task_runner, 91 scoped_refptr<base::TaskRunner> background_task_runner,
89 const GrabWindowSnapshotAsyncPNGCallback& callback) { 92 const GrabWindowSnapshotAsyncPNGCallback& callback) {
90 GrabWindowSnapshotAsync( 93 GrabWindowSnapshotAsync(
91 view->GetWindowAndroid(), source_rect, background_task_runner, callback); 94 view->GetWindowAndroid(), source_rect, background_task_runner, callback);
92 } 95 }
93 96
94 } // namespace ui 97 } // namespace ui
OLDNEW
« ui/gfx/screen_android.cc ('K') | « ui/gfx/screen_android.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698