diff options
author | Matt Sarett <msarett@google.com> | 2017-03-28 14:34:20 -0400 |
---|---|---|
committer | Skia Commit-Bot <skia-commit-bot@chromium.org> | 2017-03-28 19:39:42 +0000 |
commit | 3725f0a7dd2916c10bc6d0059821e19a5b4452c3 (patch) | |
tree | 23ba20c8e98abc8aa7cb41080c4a189199359e20 /src/codec/SkWebpCodec.cpp | |
parent | 56ea77ac5f782d0165b2992b9575b4e3b9b15715 (diff) |
Add codec and color xform support for 565
Bug: skia:
Change-Id: I23184acc4e17d38861d27ab81172048a24c400d2
Reviewed-on: https://skia-review.googlesource.com/10288
Reviewed-by: Mike Klein <mtklein@chromium.org>
Commit-Queue: Matt Sarett <msarett@google.com>
Diffstat (limited to 'src/codec/SkWebpCodec.cpp')
-rw-r--r-- | src/codec/SkWebpCodec.cpp | 16 |
1 files changed, 9 insertions, 7 deletions
diff --git a/src/codec/SkWebpCodec.cpp b/src/codec/SkWebpCodec.cpp index ae8668bd06..0e85dada44 100644 --- a/src/codec/SkWebpCodec.cpp +++ b/src/codec/SkWebpCodec.cpp @@ -301,15 +301,17 @@ SkCodec::Result SkWebpCodec::onGetPixels(const SkImageInfo& dstInfo, void* dst, config.output.is_external_memory = 1; // We will decode the entire image and then perform the color transform. libwebp - // does not provide a row-by-row API. This is a shame particularly in the F16 case, - // where we need to allocate an extra image-sized buffer. + // does not provide a row-by-row API. This is a shame particularly when we do not want + // 8888, since we will need to create another image sized buffer. SkAutoTMalloc<uint32_t> pixels; - bool isF16 = kRGBA_F16_SkColorType == dstInfo.colorType(); - void* webpDst = isF16 ? pixels.reset(dstInfo.width() * dstInfo.height()) : dst; - size_t webpRowBytes = isF16 ? dstInfo.width() * sizeof(uint32_t) : rowBytes; - size_t totalBytes = isF16 ? webpRowBytes * dstInfo.height() : dstInfo.getSafeSize(webpRowBytes); + bool is8888 = (kRGBA_8888_SkColorType == dstInfo.colorType()) || + (kBGRA_8888_SkColorType == dstInfo.colorType()); + void* webpDst = is8888 ? dst : pixels.reset(dstInfo.width() * dstInfo.height()); + size_t webpRowBytes = is8888 ? rowBytes : dstInfo.width() * sizeof(uint32_t); + size_t totalBytes = is8888 ? dstInfo.getSafeSize(webpRowBytes) + : webpRowBytes * dstInfo.height(); size_t dstBpp = SkColorTypeBytesPerPixel(dstInfo.colorType()); - size_t webpBpp = isF16 ? sizeof(uint32_t) : dstBpp; + size_t webpBpp = sizeof(uint32_t); size_t offset = dstX * webpBpp + dstY * webpRowBytes; config.output.u.RGBA.rgba = SkTAddOffset<uint8_t>(webpDst, offset); |