Chromium Code Reviews| Index: src/codec/SkWebpCodec.cpp |
| diff --git a/src/codec/SkWebpCodec.cpp b/src/codec/SkWebpCodec.cpp |
| index a795fdd6d551637467cdf95fae5b4cffb07691d8..a60b3ab8a83451afbe52b01514f695ef910c7ff4 100644 |
| --- a/src/codec/SkWebpCodec.cpp |
| +++ b/src/codec/SkWebpCodec.cpp |
| @@ -31,7 +31,7 @@ bool SkWebpCodec::IsWebp(const void* buf, size_t bytesRead) { |
| // Parse headers of RIFF container, and check for valid Webp (VP8) content. |
| // NOTE: This calls peek instead of read, since onGetPixels will need these |
| // bytes again. |
| -static bool webp_parse_header(SkStream* stream, SkImageInfo* info) { |
| +static bool webp_parse_header(SkStream* stream, SkEncodedInfo* info) { |
| unsigned char buffer[WEBP_VP8_HEADER_SIZE]; |
| SkASSERT(WEBP_VP8_HEADER_SIZE <= SkCodec::MinBufferedBytesNeeded()); |
| @@ -62,20 +62,18 @@ static bool webp_parse_header(SkStream* stream, SkImageInfo* info) { |
| } |
| if (info) { |
| - // FIXME: Is N32 the right type? |
| - // Is unpremul the right type? Clients of SkCodec may assume it's the |
| - // best type, when Skia currently cannot draw unpremul (and raster is faster |
| - // with premul). |
| - *info = SkImageInfo::Make(features.width, features.height, kN32_SkColorType, |
| - SkToBool(features.has_alpha) ? kUnpremul_SkAlphaType |
| - : kOpaque_SkAlphaType); |
| + SkEncodedInfo::Color color = SkToBool(features.has_alpha) ? SkEncodedInfo::kYUVA_Color : |
| + SkEncodedInfo::kYUV_Color; |
| + SkEncodedInfo::Alpha alpha = SkToBool(features.has_alpha) ? SkEncodedInfo::kUnpremul_Alpha : |
|
scroggo
2016/03/23 14:48:50
How does alpha work for a YUV image? Is "unpremul"
msarett
2016/03/24 16:20:44
Thanks for questioning this. I dug a little deepe
|
| + SkEncodedInfo::kOpaque_Alpha; |
| + *info = SkEncodedInfo::Make(features.width, features.height, color, alpha, 8); |
|
scroggo
2016/03/23 14:48:50
Similarly, is 8 bits per component meaningful here
msarett
2016/03/24 16:20:44
Acknowledged.
|
| } |
| return true; |
| } |
| SkCodec* SkWebpCodec::NewFromStream(SkStream* stream) { |
| SkAutoTDelete<SkStream> streamDeleter(stream); |
| - SkImageInfo info; |
| + SkEncodedInfo info; |
| if (webp_parse_header(stream, &info)) { |
| return new SkWebpCodec(info, streamDeleter.release()); |
| } |
| @@ -251,5 +249,5 @@ SkCodec::Result SkWebpCodec::onGetPixels(const SkImageInfo& dstInfo, void* dst, |
| } |
| } |
| -SkWebpCodec::SkWebpCodec(const SkImageInfo& info, SkStream* stream) |
| +SkWebpCodec::SkWebpCodec(const SkEncodedInfo& info, SkStream* stream) |
| : INHERITED(info, stream) {} |