Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(145)

Unified Diff: tools/sk_tool_utils.h

Issue 1511183002: Revert of default SkPixelSerializer (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 5 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « tests/PictureTest.cpp ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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,
« no previous file with comments | « tests/PictureTest.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698