Index: ui/snapshot/snapshot.h |
diff --git a/ui/snapshot/snapshot.h b/ui/snapshot/snapshot.h |
index 4b2733c1536b846fa85d51cd25dc3a6b2ce703a7..90b88b258b9725d48ab850b6eedd0a8dea0fdbc3 100644 |
--- a/ui/snapshot/snapshot.h |
+++ b/ui/snapshot/snapshot.h |
@@ -5,6 +5,7 @@ |
#ifndef UI_SNAPSHOT_SNAPSHOT_H_ |
#define UI_SNAPSHOT_SNAPSHOT_H_ |
+#include <stdint.h> |
#include <vector> |
#include "base/callback_forward.h" |
@@ -25,6 +26,14 @@ class Size; |
namespace ui { |
+enum class SnapshotEncoding { PNG, JPEG }; |
+constexpr SnapshotEncoding kSnapshotEncodingDefault = SnapshotEncoding::PNG; |
+ |
+using SnapshotQuality = uint8_t; |
+constexpr SnapshotQuality kSnapshotQualityMin = 0; |
+constexpr SnapshotQuality kSnapshotQualityDefault = 80; |
+constexpr SnapshotQuality kSnapshotQualityMax = 100; |
+ |
// Grabs a snapshot of the window/view. No security checks are done. This is |
// intended to be used for debugging purposes where no BrowserProcess instance |
// is available (ie. tests). This function is synchronous, so it should NOT be |
@@ -33,14 +42,17 @@ namespace ui { |
// synchronous function first and if it returns false call the async one. |
SNAPSHOT_EXPORT bool GrabWindowSnapshot( |
gfx::NativeWindow window, |
- std::vector<unsigned char>* png_representation, |
- const gfx::Rect& snapshot_bounds); |
+ std::vector<unsigned char>* encoded_data, |
+ const gfx::Rect& snapshot_bounds, |
+ SnapshotEncoding encoding = kSnapshotEncodingDefault, |
+ SnapshotQuality quality = kSnapshotQualityDefault); |
SNAPSHOT_EXPORT bool GrabViewSnapshot( |
gfx::NativeView view, |
- std::vector<unsigned char>* png_representation, |
- const gfx::Rect& snapshot_bounds); |
- |
+ std::vector<unsigned char>* encoded_data, |
+ const gfx::Rect& snapshot_bounds, |
+ SnapshotEncoding encoding = kSnapshotEncodingDefault, |
+ SnapshotQuality quality = kSnapshotQualityDefault); |
// These functions take a snapshot of |source_rect|, specified in layer space |
// coordinates (DIP for desktop, physical pixels for Android), and scale the |
@@ -54,18 +66,22 @@ SNAPSHOT_EXPORT void GrabWindowSnapshotAndScaleAsync( |
scoped_refptr<base::TaskRunner> background_task_runner, |
const GrabWindowSnapshotAsyncCallback& callback); |
-typedef base::Callback<void(scoped_refptr<base::RefCountedBytes> png_data)> |
- GrabWindowSnapshotAsyncPNGCallback; |
+typedef base::Callback<void(scoped_refptr<base::RefCountedBytes> encoded_data)> |
+ GrabWindowSnapshotAsyncEncodedCallback; |
SNAPSHOT_EXPORT void GrabWindowSnapshotAsync( |
gfx::NativeWindow window, |
const gfx::Rect& source_rect, |
scoped_refptr<base::TaskRunner> background_task_runner, |
- const GrabWindowSnapshotAsyncPNGCallback& callback); |
+ const GrabWindowSnapshotAsyncEncodedCallback& callback, |
+ SnapshotEncoding encoding = kSnapshotEncodingDefault, |
+ SnapshotQuality quality = kSnapshotQualityDefault); |
SNAPSHOT_EXPORT void GrabViewSnapshotAsync( |
gfx::NativeView view, |
const gfx::Rect& source_rect, |
scoped_refptr<base::TaskRunner> background_task_runner, |
- const GrabWindowSnapshotAsyncPNGCallback& callback); |
+ const GrabWindowSnapshotAsyncEncodedCallback& callback, |
+ SnapshotEncoding encoding = kSnapshotEncodingDefault, |
+ SnapshotQuality quality = kSnapshotQualityDefault); |
} // namespace ui |