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 std::vector<unsigned char>* png_representation, |
26 const gfx::Rect& snapshot_bounds) { | 26 const gfx::Rect& snapshot_bounds, |
27 return GrabWindowSnapshot( | 27 SnapshotEncoding encoding, |
28 view->GetWindowAndroid(), png_representation, snapshot_bounds); | 28 SnapshotQuality quality) { |
| 29 return GrabWindowSnapshot(view->GetWindowAndroid(), png_representation, |
| 30 snapshot_bounds, encoding, quality); |
29 } | 31 } |
30 | 32 |
31 bool GrabWindowSnapshot(gfx::NativeWindow window, | 33 bool GrabWindowSnapshot(gfx::NativeWindow window, |
32 std::vector<unsigned char>* png_representation, | 34 std::vector<unsigned char>* png_representation, |
33 const gfx::Rect& snapshot_bounds) { | 35 const gfx::Rect& snapshot_bounds, |
| 36 SnapshotEncoding encoding, |
| 37 SnapshotQuality quality) { |
34 // Not supported in Android. Callers should fall back to the async version. | 38 // Not supported in Android. Callers should fall back to the async version. |
35 return false; | 39 return false; |
36 } | 40 } |
37 | 41 |
38 static void MakeAsyncCopyRequest( | 42 static void MakeAsyncCopyRequest( |
39 gfx::NativeWindow window, | 43 gfx::NativeWindow window, |
40 const gfx::Rect& source_rect, | 44 const gfx::Rect& source_rect, |
41 const cc::CopyOutputRequest::CopyOutputRequestCallback& callback) { | 45 const cc::CopyOutputRequest::CopyOutputRequestCallback& callback) { |
42 std::unique_ptr<cc::CopyOutputRequest> request = | 46 std::unique_ptr<cc::CopyOutputRequest> request = |
43 cc::CopyOutputRequest::CreateBitmapRequest(callback); | 47 cc::CopyOutputRequest::CreateBitmapRequest(callback); |
(...skipping 28 matching lines...) Expand all Loading... |
72 base::Bind(&SnapshotAsync::ScaleCopyOutputResult, | 76 base::Bind(&SnapshotAsync::ScaleCopyOutputResult, |
73 callback, | 77 callback, |
74 target_size, | 78 target_size, |
75 background_task_runner)); | 79 background_task_runner)); |
76 } | 80 } |
77 | 81 |
78 void GrabWindowSnapshotAsync( | 82 void GrabWindowSnapshotAsync( |
79 gfx::NativeWindow window, | 83 gfx::NativeWindow window, |
80 const gfx::Rect& source_rect, | 84 const gfx::Rect& source_rect, |
81 scoped_refptr<base::TaskRunner> background_task_runner, | 85 scoped_refptr<base::TaskRunner> background_task_runner, |
82 const GrabWindowSnapshotAsyncPNGCallback& callback) { | 86 const GrabWindowSnapshotAsyncEncodedCallback& callback, |
83 MakeAsyncCopyRequest(window, | 87 SnapshotEncoding encoding, |
84 source_rect, | 88 SnapshotQuality quality) { |
85 base::Bind(&SnapshotAsync::EncodeCopyOutputResult, | 89 MakeAsyncCopyRequest( |
86 callback, | 90 window, source_rect, |
87 background_task_runner)); | 91 base::Bind(&SnapshotAsync::EncodeCopyOutputResult, callback, |
| 92 background_task_runner, encoding, quality)); |
88 } | 93 } |
89 | 94 |
90 void GrabViewSnapshotAsync( | 95 void GrabViewSnapshotAsync( |
91 gfx::NativeView view, | 96 gfx::NativeView view, |
92 const gfx::Rect& source_rect, | 97 const gfx::Rect& source_rect, |
93 scoped_refptr<base::TaskRunner> background_task_runner, | 98 scoped_refptr<base::TaskRunner> background_task_runner, |
94 const GrabWindowSnapshotAsyncPNGCallback& callback) { | 99 const GrabWindowSnapshotAsyncEncodedCallback& callback, |
95 GrabWindowSnapshotAsync( | 100 SnapshotEncoding encoding, |
96 view->GetWindowAndroid(), source_rect, background_task_runner, callback); | 101 SnapshotQuality quality) { |
| 102 GrabWindowSnapshotAsync(view->GetWindowAndroid(), source_rect, |
| 103 background_task_runner, callback, encoding, quality); |
97 } | 104 } |
98 | 105 |
99 } // namespace ui | 106 } // namespace ui |
OLD | NEW |