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 <memory> | 7 #include <memory> |
| 8 #include <utility> | 8 #include <utility> |
| 9 | 9 |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| 11 #include "cc/output/copy_output_request.h" | 11 #include "cc/output/copy_output_request.h" |
| 12 #include "third_party/skia/include/core/SkBitmap.h" | 12 #include "third_party/skia/include/core/SkBitmap.h" |
| 13 #include "ui/android/display_android_manager.h" | |
| 13 #include "ui/android/view_android.h" | 14 #include "ui/android/view_android.h" |
| 14 #include "ui/android/window_android.h" | 15 #include "ui/android/window_android.h" |
| 15 #include "ui/android/window_android_compositor.h" | 16 #include "ui/android/window_android_compositor.h" |
| 16 #include "ui/display/display.h" | 17 #include "ui/display/display.h" |
| 17 #include "ui/display/screen.h" | 18 #include "ui/display/screen.h" |
| 18 #include "ui/gfx/geometry/point_conversions.h" | 19 #include "ui/gfx/geometry/point_conversions.h" |
| 19 #include "ui/gfx/geometry/rect_conversions.h" | 20 #include "ui/gfx/geometry/rect_conversions.h" |
| 20 #include "ui/snapshot/snapshot_async.h" | 21 #include "ui/snapshot/snapshot_async.h" |
| 21 | 22 |
| 22 namespace ui { | 23 namespace ui { |
| (...skipping 12 matching lines...) Expand all Loading... | |
| 35 return false; | 36 return false; |
| 36 } | 37 } |
| 37 | 38 |
| 38 static void MakeAsyncCopyRequest( | 39 static void MakeAsyncCopyRequest( |
| 39 gfx::NativeWindow window, | 40 gfx::NativeWindow window, |
| 40 const gfx::Rect& source_rect, | 41 const gfx::Rect& source_rect, |
| 41 const cc::CopyOutputRequest::CopyOutputRequestCallback& callback) { | 42 const cc::CopyOutputRequest::CopyOutputRequestCallback& callback) { |
| 42 std::unique_ptr<cc::CopyOutputRequest> request = | 43 std::unique_ptr<cc::CopyOutputRequest> request = |
| 43 cc::CopyOutputRequest::CreateBitmapRequest(callback); | 44 cc::CopyOutputRequest::CreateBitmapRequest(callback); |
| 44 | 45 |
| 46 DisplayAndroidManager* display_manager = | |
| 47 static_cast<DisplayAndroidManager*>(display::Screen::GetScreen()); | |
|
boliu
2017/01/04 18:58:06
cast should happen in DisplayAndroidManager, maybe
Jinsuk Kim
2017/01/05 11:03:13
Done.
| |
| 45 const display::Display& display = | 48 const display::Display& display = |
| 46 display::Screen::GetScreen()->GetDisplayNearestWindow(window); | 49 display_manager->GetDisplayNearestWindowAndroid(window); |
| 47 float device_scale_factor = display.device_scale_factor(); | 50 float device_scale_factor = display.device_scale_factor(); |
| 48 gfx::Rect source_rect_in_pixel = | 51 gfx::Rect source_rect_in_pixel = |
| 49 gfx::ScaleToEnclosingRect(source_rect, device_scale_factor); | 52 gfx::ScaleToEnclosingRect(source_rect, device_scale_factor); |
| 50 | 53 |
| 51 // Account for the toolbar offset. | 54 // Account for the toolbar offset. |
| 52 gfx::Vector2dF offset_in_pixel = | 55 gfx::Vector2dF offset_in_pixel = |
| 53 gfx::ScaleVector2d(window->content_offset(), device_scale_factor); | 56 gfx::ScaleVector2d(window->content_offset(), device_scale_factor); |
| 54 gfx::Rect adjusted_source_rect( | 57 gfx::Rect adjusted_source_rect( |
| 55 gfx::ToRoundedPoint( | 58 gfx::ToRoundedPoint( |
| 56 gfx::PointF(source_rect_in_pixel.x() + offset_in_pixel.x(), | 59 gfx::PointF(source_rect_in_pixel.x() + offset_in_pixel.x(), |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 90 void GrabViewSnapshotAsync( | 93 void GrabViewSnapshotAsync( |
| 91 gfx::NativeView view, | 94 gfx::NativeView view, |
| 92 const gfx::Rect& source_rect, | 95 const gfx::Rect& source_rect, |
| 93 scoped_refptr<base::TaskRunner> background_task_runner, | 96 scoped_refptr<base::TaskRunner> background_task_runner, |
| 94 const GrabWindowSnapshotAsyncPNGCallback& callback) { | 97 const GrabWindowSnapshotAsyncPNGCallback& callback) { |
| 95 GrabWindowSnapshotAsync( | 98 GrabWindowSnapshotAsync( |
| 96 view->GetWindowAndroid(), source_rect, background_task_runner, callback); | 99 view->GetWindowAndroid(), source_rect, background_task_runner, callback); |
| 97 } | 100 } |
| 98 | 101 |
| 99 } // namespace ui | 102 } // namespace ui |
| OLD | NEW |