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 <utility> |
| 8 |
7 #include "base/bind.h" | 9 #include "base/bind.h" |
8 #include "cc/output/copy_output_request.h" | 10 #include "cc/output/copy_output_request.h" |
9 #include "third_party/skia/include/core/SkBitmap.h" | 11 #include "third_party/skia/include/core/SkBitmap.h" |
10 #include "ui/android/view_android.h" | 12 #include "ui/android/view_android.h" |
11 #include "ui/android/window_android.h" | 13 #include "ui/android/window_android.h" |
12 #include "ui/android/window_android_compositor.h" | 14 #include "ui/android/window_android_compositor.h" |
13 #include "ui/gfx/display.h" | 15 #include "ui/gfx/display.h" |
14 #include "ui/gfx/geometry/point_conversions.h" | 16 #include "ui/gfx/geometry/point_conversions.h" |
15 #include "ui/gfx/geometry/rect_conversions.h" | 17 #include "ui/gfx/geometry/rect_conversions.h" |
16 #include "ui/gfx/screen.h" | 18 #include "ui/gfx/screen.h" |
(...skipping 29 matching lines...) Expand all Loading... |
46 gfx::ScaleToEnclosingRect(source_rect, device_scale_factor); | 48 gfx::ScaleToEnclosingRect(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 |
55 request->set_area(adjusted_source_rect); | 57 request->set_area(adjusted_source_rect); |
56 window->GetCompositor()->RequestCopyOfOutputOnRootLayer(request.Pass()); | 58 window->GetCompositor()->RequestCopyOfOutputOnRootLayer(std::move(request)); |
57 } | 59 } |
58 | 60 |
59 void GrabWindowSnapshotAndScaleAsync( | 61 void GrabWindowSnapshotAndScaleAsync( |
60 gfx::NativeWindow window, | 62 gfx::NativeWindow window, |
61 const gfx::Rect& source_rect, | 63 const gfx::Rect& source_rect, |
62 const gfx::Size& target_size, | 64 const gfx::Size& target_size, |
63 scoped_refptr<base::TaskRunner> background_task_runner, | 65 scoped_refptr<base::TaskRunner> background_task_runner, |
64 const GrabWindowSnapshotAsyncCallback& callback) { | 66 const GrabWindowSnapshotAsyncCallback& callback) { |
65 MakeAsyncCopyRequest(window, | 67 MakeAsyncCopyRequest(window, |
66 source_rect, | 68 source_rect, |
(...skipping 18 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 |