Index: tools/sk_tool_utils.h |
diff --git a/tools/sk_tool_utils.h b/tools/sk_tool_utils.h |
index dab42e31fdc8cecb335887198039124e923e06ae..67fd869a878d196d0cef66a84cb77462b2c6dcda 100644 |
--- a/tools/sk_tool_utils.h |
+++ b/tools/sk_tool_utils.h |
@@ -113,6 +113,18 @@ |
SkBitmap create_string_bitmap(int w, int h, SkColor c, int x, int y, |
int textSize, const char* str); |
+ |
+ // 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) override { return true; } |
+ SkData* onEncodePixels(const SkImageInfo& info, const void* pixels, |
+ size_t rowBytes) override { |
+ return SkImageEncoder::EncodeData(info, pixels, rowBytes, |
+ SkImageEncoder::kPNG_Type, 100); |
+ } |
+ }; |
// A helper for inserting a drawtext call into a SkTextBlobBuilder |
void add_to_text_blob(SkTextBlobBuilder* builder, const char* text, const SkPaint& origPaint, |