| 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" | 10 #include "base/callback_forward.h" |
| (...skipping 10 matching lines...) Expand all Loading... |
| 21 class Rect; | 21 class Rect; |
| 22 class Image; | 22 class Image; |
| 23 class Size; | 23 class Size; |
| 24 } | 24 } |
| 25 | 25 |
| 26 namespace ui { | 26 namespace ui { |
| 27 | 27 |
| 28 // Grabs a snapshot of the window/view. No security checks are done. This is | 28 // Grabs a snapshot of the window/view. No security checks are done. This is |
| 29 // intended to be used for debugging purposes where no BrowserProcess instance | 29 // intended to be used for debugging purposes where no BrowserProcess instance |
| 30 // is available (ie. tests). This function is synchronous, so it should NOT be | 30 // is available (ie. tests). This function is synchronous, so it should NOT be |
| 31 // used in a result of user action. Use asynchronous GrabWindowSnapshotAsync() | 31 // used in a result of user action. Support for async vs synchronous |
| 32 // instead on supported platforms. | 32 // GrabWindowSnapshot differs by platform. To be most general, use the |
| 33 // synchronous function first and if it returns false call the async one. |
| 33 SNAPSHOT_EXPORT bool GrabWindowSnapshot( | 34 SNAPSHOT_EXPORT bool GrabWindowSnapshot( |
| 34 gfx::NativeWindow window, | 35 gfx::NativeWindow window, |
| 35 std::vector<unsigned char>* png_representation, | 36 std::vector<unsigned char>* png_representation, |
| 36 const gfx::Rect& snapshot_bounds); | 37 const gfx::Rect& snapshot_bounds); |
| 37 | 38 |
| 38 SNAPSHOT_EXPORT bool GrabViewSnapshot( | 39 SNAPSHOT_EXPORT bool GrabViewSnapshot( |
| 39 gfx::NativeView view, | 40 gfx::NativeView view, |
| 40 std::vector<unsigned char>* png_representation, | 41 std::vector<unsigned char>* png_representation, |
| 41 const gfx::Rect& snapshot_bounds); | 42 const gfx::Rect& snapshot_bounds); |
| 42 | 43 |
| 43 typedef base::Callback<void(const gfx::Image& snapshot)> | 44 typedef base::Callback<void(const gfx::Image& snapshot)> |
| 44 GrabWindowSnapshotAsyncCallback; | 45 GrabWindowSnapshotAsyncCallback; |
| 45 // GrabWindowSnapshotAndScaleAsync() copies snapshot of |source_rect| from | 46 // GrabWindowSnapshotAndScaleAsync() copies snapshot of |source_rect| from |
| 46 // window and scales it to |target_size| asynchronously. | 47 // window and scales it to |target_size| asynchronously. |
| 47 SNAPSHOT_EXPORT void GrabWindowSnapshotAndScaleAsync( | 48 SNAPSHOT_EXPORT void GrabWindowSnapshotAndScaleAsync( |
| 48 gfx::NativeWindow window, | 49 gfx::NativeWindow window, |
| 49 const gfx::Rect& source_rect, | 50 const gfx::Rect& source_rect, |
| 50 const gfx::Size& target_size, | 51 const gfx::Size& target_size, |
| 51 scoped_refptr<base::TaskRunner> background_task_runner, | 52 scoped_refptr<base::TaskRunner> background_task_runner, |
| 52 const GrabWindowSnapshotAsyncCallback& callback); | 53 const GrabWindowSnapshotAsyncCallback& callback); |
| 53 | 54 |
| 54 typedef base::Callback<void(scoped_refptr<base::RefCountedBytes> png_data)> | 55 typedef base::Callback<void(scoped_refptr<base::RefCountedBytes> png_data)> |
| 55 GrabWindowSnapshotAsyncPNGCallback; | 56 GrabWindowSnapshotAsyncPNGCallback; |
| 56 SNAPSHOT_EXPORT void GrabWindowSnapshotAsync( | 57 SNAPSHOT_EXPORT void GrabWindowSnapshotAsync( |
| 57 gfx::NativeWindow window, | 58 gfx::NativeWindow window, |
| 58 const gfx::Rect& source_rect, | 59 const gfx::Rect& source_rect, |
| 59 scoped_refptr<base::TaskRunner> background_task_runner, | 60 scoped_refptr<base::TaskRunner> background_task_runner, |
| 60 const GrabWindowSnapshotAsyncPNGCallback& callback); | 61 const GrabWindowSnapshotAsyncPNGCallback& callback); |
| 62 SNAPSHOT_EXPORT void GrabViewSnapshotAsync( |
| 63 gfx::NativeView view, |
| 64 const gfx::Rect& source_rect, |
| 65 scoped_refptr<base::TaskRunner> background_task_runner, |
| 66 const GrabWindowSnapshotAsyncPNGCallback& callback); |
| 61 | 67 |
| 62 } // namespace ui | 68 } // namespace ui |
| 63 | 69 |
| 64 #endif // UI_SNAPSHOT_SNAPSHOT_H_ | 70 #endif // UI_SNAPSHOT_SNAPSHOT_H_ |
| OLD | NEW |