Chromium Code Reviews| OLD | NEW |
|---|---|
| 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" |
| (...skipping 21 matching lines...) Expand all Loading... | |
| 32 return false; | 32 return false; |
| 33 } | 33 } |
| 34 | 34 |
| 35 static void MakeAsyncCopyRequest( | 35 static void MakeAsyncCopyRequest( |
| 36 gfx::NativeWindow window, | 36 gfx::NativeWindow window, |
| 37 const gfx::Rect& source_rect, | 37 const gfx::Rect& source_rect, |
| 38 const cc::CopyOutputRequest::CopyOutputRequestCallback& callback) { | 38 const cc::CopyOutputRequest::CopyOutputRequestCallback& callback) { |
| 39 scoped_ptr<cc::CopyOutputRequest> request = | 39 scoped_ptr<cc::CopyOutputRequest> request = |
| 40 cc::CopyOutputRequest::CreateBitmapRequest(callback); | 40 cc::CopyOutputRequest::CreateBitmapRequest(callback); |
| 41 | 41 |
| 42 const gfx::Display& display = | 42 float device_scale_factor = |
| 43 gfx::Screen::GetNativeScreen()->GetPrimaryDisplay(); | 43 gfx::Display::HasForceDeviceScaleFactor() |
| 44 float device_scale_factor = display.device_scale_factor(); | 44 ? gfx::Display::GetForcedDeviceScaleFactor() |
|
jdduke (slow)
2015/07/15 16:03:07
Why not use GetDisplayNearestWindow which should d
gsennton
2015/07/15 19:26:21
GetDisplayNearestWindow takes a NativeView (contra
| |
| 45 : window->GetDeviceDisplayInfo().GetDIPScale(); | |
| 46 | |
| 45 gfx::Rect source_rect_in_pixel = | 47 gfx::Rect source_rect_in_pixel = |
| 46 gfx::ToEnclosingRect(gfx::ScaleRect(source_rect, device_scale_factor)); | 48 gfx::ToEnclosingRect(gfx::ScaleRect(source_rect, device_scale_factor)); |
| 47 | 49 |
| 48 // Account for the toolbar offset. | 50 // Account for the toolbar offset. |
| 49 gfx::Vector2dF offset = window->content_offset(); | 51 gfx::Vector2dF offset = window->content_offset(); |
| 50 gfx::Rect adjusted_source_rect(gfx::ToRoundedPoint( | 52 gfx::Rect adjusted_source_rect(gfx::ToRoundedPoint( |
| 51 gfx::PointF(source_rect_in_pixel.x() + offset.x(), | 53 gfx::PointF(source_rect_in_pixel.x() + offset.x(), |
| 52 source_rect_in_pixel.y() + offset.y())), | 54 source_rect_in_pixel.y() + offset.y())), |
| 53 source_rect_in_pixel.size()); | 55 source_rect_in_pixel.size()); |
| 54 | 56 |
| (...skipping 30 matching lines...) Expand all Loading... | |
| 85 void GrabViewSnapshotAsync( | 87 void GrabViewSnapshotAsync( |
| 86 gfx::NativeView view, | 88 gfx::NativeView view, |
| 87 const gfx::Rect& source_rect, | 89 const gfx::Rect& source_rect, |
| 88 scoped_refptr<base::TaskRunner> background_task_runner, | 90 scoped_refptr<base::TaskRunner> background_task_runner, |
| 89 const GrabWindowSnapshotAsyncPNGCallback& callback) { | 91 const GrabWindowSnapshotAsyncPNGCallback& callback) { |
| 90 GrabWindowSnapshotAsync( | 92 GrabWindowSnapshotAsync( |
| 91 view->GetWindowAndroid(), source_rect, background_task_runner, callback); | 93 view->GetWindowAndroid(), source_rect, background_task_runner, callback); |
| 92 } | 94 } |
| 93 | 95 |
| 94 } // namespace ui | 96 } // namespace ui |
| OLD | NEW |