aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/codec/SkWebpCodec.cpp
diff options
context:
space:
mode:
authorGravatar Matt Sarett <msarett@google.com>2017-03-28 17:49:23 -0400
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2017-03-28 22:22:31 +0000
commit58c7b9235b9d3bc7b319d6d895c476e2b13b803b (patch)
tree2692952a8cefde0dbaa651e9a9adc231a5aa9b97 /src/codec/SkWebpCodec.cpp
parent2677a9a1359a2a95a2adb0d1cbcf7d28185ddc11 (diff)
Fix msan errors in webp decoder
Bug: skia: Change-Id: I919a24fc61137c4a30160c97ad69fa4a2eadd031 Reviewed-on: https://skia-review.googlesource.com/10325 Reviewed-by: Matt Sarett <msarett@google.com> Commit-Queue: Matt Sarett <msarett@google.com>
Diffstat (limited to 'src/codec/SkWebpCodec.cpp')
-rw-r--r--src/codec/SkWebpCodec.cpp14
1 files changed, 7 insertions, 7 deletions
diff --git a/src/codec/SkWebpCodec.cpp b/src/codec/SkWebpCodec.cpp
index 0e85dada44..ab0b91b112 100644
--- a/src/codec/SkWebpCodec.cpp
+++ b/src/codec/SkWebpCodec.cpp
@@ -304,14 +304,14 @@ SkCodec::Result SkWebpCodec::onGetPixels(const SkImageInfo& dstInfo, void* dst,
// 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 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();
+ bool needsCopy = this->colorXform() && kRGBA_8888_SkColorType != dstInfo.colorType() &&
+ kBGRA_8888_SkColorType != dstInfo.colorType();
+ void* webpDst = needsCopy ? pixels.reset(dstInfo.width() * dstInfo.height()) : dst;
+ size_t webpRowBytes = needsCopy ? dstInfo.width() * sizeof(uint32_t) : rowBytes;
+ size_t totalBytes = needsCopy ? webpRowBytes * dstInfo.height()
+ : dstInfo.getSafeSize(webpRowBytes);
size_t dstBpp = SkColorTypeBytesPerPixel(dstInfo.colorType());
- size_t webpBpp = sizeof(uint32_t);
+ size_t webpBpp = needsCopy ? sizeof(uint32_t) : dstBpp;
size_t offset = dstX * webpBpp + dstY * webpRowBytes;
config.output.u.RGBA.rgba = SkTAddOffset<uint8_t>(webpDst, offset);