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/view_android.h" | 13 #include "ui/android/view_android.h" |
14 #include "ui/android/window_android.h" | 14 #include "ui/android/window_android.h" |
15 #include "ui/android/window_android_compositor.h" | 15 #include "ui/android/window_android_compositor.h" |
16 #include "ui/display/display.h" | 16 #include "ui/display/display.h" |
17 #include "ui/display/screen.h" | 17 #include "ui/display/screen.h" |
18 #include "ui/gfx/geometry/point_conversions.h" | 18 #include "ui/gfx/geometry/point_conversions.h" |
19 #include "ui/gfx/geometry/rect_conversions.h" | 19 #include "ui/gfx/geometry/rect_conversions.h" |
20 #include "ui/snapshot/snapshot_async.h" | 20 #include "ui/snapshot/snapshot_async.h" |
21 | 21 |
22 namespace ui { | 22 namespace ui { |
23 | 23 |
24 bool GrabViewSnapshot(gfx::NativeView view, | 24 bool GrabViewSnapshot(gfx::NativeView view, |
25 std::vector<unsigned char>* png_representation, | 25 gfx::Image* image, |
26 const gfx::Rect& snapshot_bounds) { | 26 const gfx::Rect& snapshot_bounds) { |
27 return GrabWindowSnapshot( | 27 return GrabWindowSnapshot(view->GetWindowAndroid(), image, snapshot_bounds); |
28 view->GetWindowAndroid(), png_representation, snapshot_bounds); | |
29 } | 28 } |
30 | 29 |
31 bool GrabWindowSnapshot(gfx::NativeWindow window, | 30 bool GrabWindowSnapshot(gfx::NativeWindow window, |
32 std::vector<unsigned char>* png_representation, | 31 gfx::Image* image, |
33 const gfx::Rect& snapshot_bounds) { | 32 const gfx::Rect& snapshot_bounds) { |
34 // Not supported in Android. Callers should fall back to the async version. | 33 // Not supported in Android. Callers should fall back to the async version. |
35 return false; | 34 return false; |
36 } | 35 } |
37 | 36 |
38 static void MakeAsyncCopyRequest( | 37 static void MakeAsyncCopyRequest( |
39 gfx::NativeWindow window, | 38 gfx::NativeWindow window, |
40 const gfx::Rect& source_rect, | 39 const gfx::Rect& source_rect, |
41 const cc::CopyOutputRequest::CopyOutputRequestCallback& callback) { | 40 const cc::CopyOutputRequest::CopyOutputRequestCallback& callback) { |
42 std::unique_ptr<cc::CopyOutputRequest> request = | 41 std::unique_ptr<cc::CopyOutputRequest> request = |
(...skipping 25 matching lines...) Expand all Loading... |
68 scoped_refptr<base::TaskRunner> background_task_runner, | 67 scoped_refptr<base::TaskRunner> background_task_runner, |
69 const GrabWindowSnapshotAsyncCallback& callback) { | 68 const GrabWindowSnapshotAsyncCallback& callback) { |
70 MakeAsyncCopyRequest(window, | 69 MakeAsyncCopyRequest(window, |
71 source_rect, | 70 source_rect, |
72 base::Bind(&SnapshotAsync::ScaleCopyOutputResult, | 71 base::Bind(&SnapshotAsync::ScaleCopyOutputResult, |
73 callback, | 72 callback, |
74 target_size, | 73 target_size, |
75 background_task_runner)); | 74 background_task_runner)); |
76 } | 75 } |
77 | 76 |
78 void GrabWindowSnapshotAsync( | 77 void GrabWindowSnapshotAsync(gfx::NativeWindow window, |
79 gfx::NativeWindow window, | 78 const gfx::Rect& source_rect, |
80 const gfx::Rect& source_rect, | 79 const GrabWindowSnapshotAsyncCallback& callback) { |
81 scoped_refptr<base::TaskRunner> background_task_runner, | 80 MakeAsyncCopyRequest( |
82 const GrabWindowSnapshotAsyncPNGCallback& callback) { | 81 window, source_rect, |
83 MakeAsyncCopyRequest(window, | 82 base::Bind(&SnapshotAsync::RunCallbackWithCopyOutputResult, callback)); |
84 source_rect, | |
85 base::Bind(&SnapshotAsync::EncodeCopyOutputResult, | |
86 callback, | |
87 background_task_runner)); | |
88 } | 83 } |
89 | 84 |
90 void GrabViewSnapshotAsync( | 85 void GrabViewSnapshotAsync(gfx::NativeView view, |
91 gfx::NativeView view, | 86 const gfx::Rect& source_rect, |
92 const gfx::Rect& source_rect, | 87 const GrabWindowSnapshotAsyncCallback& callback) { |
93 scoped_refptr<base::TaskRunner> background_task_runner, | 88 GrabWindowSnapshotAsync(view->GetWindowAndroid(), source_rect, callback); |
94 const GrabWindowSnapshotAsyncPNGCallback& callback) { | |
95 GrabWindowSnapshotAsync( | |
96 view->GetWindowAndroid(), source_rect, background_task_runner, callback); | |
97 } | 89 } |
98 | 90 |
99 } // namespace ui | 91 } // namespace ui |
OLD | NEW |