Index: tools/sk_tool_utils.h |
diff --git a/tools/sk_tool_utils.h b/tools/sk_tool_utils.h |
index 48c71e7e74315fa521110f80ba51bb2f956192ff..8754de69af126fe8c2c72b785c12240a9ac27648 100644 |
--- a/tools/sk_tool_utils.h |
+++ b/tools/sk_tool_utils.h |
@@ -9,7 +9,9 @@ |
#define sk_tool_utils_DEFINED |
#include "SkColor.h" |
+#include "SkImageEncoder.h" |
#include "SkImageInfo.h" |
+#include "SkPixelSerializer.h" |
#include "SkTypeface.h" |
class SkBitmap; |
@@ -55,6 +57,18 @@ namespace sk_tool_utils { |
sk_tool_utils::draw_checkerboard(canvas, 0xFF999999, 0xFF666666, 8); |
} |
+ // Encodes to PNG, unless there is already encoded data, in which case that gets |
+ // used. |
+ class PngPixelSerializer : public SkPixelSerializer { |
+ public: |
+ bool onUseEncodedData(const void*, size_t) SK_OVERRIDE { return true; } |
+ SkData* onEncodePixels(const SkImageInfo& info, const void* pixels, |
+ size_t rowBytes) SK_OVERRIDE { |
+ return SkImageEncoder::EncodeData(info, pixels, rowBytes, |
+ SkImageEncoder::kPNG_Type, 100); |
+ } |
+ }; |
+ |
} // namespace sk_tool_utils |
#endif // sk_tool_utils_DEFINED |