diff options
author | reed <reed@google.com> | 2015-12-08 10:59:13 -0800 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2015-12-08 10:59:13 -0800 |
commit | 290f00cd752b51f517b88c40bc89016fcaf5e477 (patch) | |
tree | 38bc2a14fef381d315339bdf498eaada59b55162 /tools | |
parent | 1cf6f9b6b51bcf09d93142ba40d6c331c21f50a6 (diff) |
Revert of default SkPixelSerializer (patchset #1 id:1 of https://codereview.chromium.org/1507123002/ )
Reason for revert:
Breaking DEPS roll (linker error)
Original issue's description:
> default SkPixelSerializer
>
> Add SkImageEncoder::EncodeData(const SkPixmap&, ...) function.
>
> Add SkImageEncoder::CreatePixelSerializer() to return a
> PixelSerializer that calls into SkImageEncoder::EncodeData.
>
> SkImage::encode() make use of SkImageEncoder::CreatePixelSerializer.
>
> Committed: https://skia.googlesource.com/skia/+/b0bd1516bff3f5afcbfd615e805867531657811b
TBR=scroggo@google.com,halcanary@google.com
NOPRESUBMIT=true
NOTREECHECKS=true
NOTRY=true
Review URL: https://codereview.chromium.org/1505203003
Diffstat (limited to 'tools')
-rw-r--r-- | tools/sk_tool_utils.h | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/tools/sk_tool_utils.h b/tools/sk_tool_utils.h index dab42e31fd..67fd869a87 100644 --- a/tools/sk_tool_utils.h +++ b/tools/sk_tool_utils.h @@ -114,6 +114,18 @@ namespace sk_tool_utils { 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, SkScalar x, SkScalar y); |