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 #ifndef UI_SNAPSHOT_SNAPSHOT_H_ | 5 #ifndef UI_SNAPSHOT_SNAPSHOT_H_ |
6 #define UI_SNAPSHOT_SNAPSHOT_H_ | 6 #define UI_SNAPSHOT_SNAPSHOT_H_ |
7 | 7 |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
| 10 #include "base/callback_forward.h" |
| 11 #include "base/memory/ref_counted.h" |
10 #include "ui/gfx/native_widget_types.h" | 12 #include "ui/gfx/native_widget_types.h" |
11 #include "ui/snapshot/snapshot_export.h" | 13 #include "ui/snapshot/snapshot_export.h" |
12 | 14 |
| 15 namespace base { |
| 16 class TaskRunner; |
| 17 } |
| 18 |
13 namespace gfx { | 19 namespace gfx { |
14 class Rect; | 20 class Rect; |
| 21 class Image; |
| 22 class Size; |
15 } | 23 } |
16 | 24 |
17 namespace ui { | 25 namespace ui { |
18 | 26 |
19 // Grabs a snapshot of the window/view. No security checks are done. | 27 // Grabs a snapshot of the window/view. No security checks are done. This is |
20 // This is intended to be used for debugging purposes where no BrowserProcess | 28 // intended to be used for debugging purposes where no BrowserProcess instance |
21 // instance is available (ie. tests). DO NOT use in a result of user action. | 29 // is available (ie. tests). This function is synchronous, so it should NOT be |
| 30 // used in a result of user action. Use asynchronous GrapWindowSnapshotAsync() |
| 31 // instead. |
22 SNAPSHOT_EXPORT bool GrabWindowSnapshot( | 32 SNAPSHOT_EXPORT bool GrabWindowSnapshot( |
23 gfx::NativeWindow window, | 33 gfx::NativeWindow window, |
24 std::vector<unsigned char>* png_representation, | 34 std::vector<unsigned char>* png_representation, |
25 const gfx::Rect& snapshot_bounds); | 35 const gfx::Rect& snapshot_bounds); |
26 | 36 |
27 SNAPSHOT_EXPORT bool GrabViewSnapshot( | 37 SNAPSHOT_EXPORT bool GrabViewSnapshot( |
28 gfx::NativeView view, | 38 gfx::NativeView view, |
29 std::vector<unsigned char>* png_representation, | 39 std::vector<unsigned char>* png_representation, |
30 const gfx::Rect& snapshot_bounds); | 40 const gfx::Rect& snapshot_bounds); |
31 | 41 |
| 42 // GrapWindowSnapshotAsync() copies snapshot of |source_rect| from window and |
| 43 // scales it to |target_size| asynchronously. |
| 44 typedef base::Callback<void(const gfx::Image& snapshot)> |
| 45 GrapWindowSnapshotAsyncCallback; |
| 46 SNAPSHOT_EXPORT void GrapWindowSnapshotAsync( |
| 47 gfx::NativeWindow window, |
| 48 const gfx::Rect& source_rect, |
| 49 const gfx::Size& target_size, |
| 50 scoped_refptr<base::TaskRunner> background_task_runner, |
| 51 const GrapWindowSnapshotAsyncCallback& callback); |
| 52 |
32 } // namespace ui | 53 } // namespace ui |
33 | 54 |
34 #endif // UI_SNAPSHOT_SNAPSHOT_H_ | 55 #endif // UI_SNAPSHOT_SNAPSHOT_H_ |
OLD | NEW |