Chromium Code Reviews| Index: src/codec/SkCodecImageGenerator.cpp |
| diff --git a/src/codec/SkCodecImageGenerator.cpp b/src/codec/SkCodecImageGenerator.cpp |
| index e579da92f6f435c8a34ba21aae5fdfb02f2cbe23..f6d97d24a1d01873c042887e677b467f1522f652 100644 |
| --- a/src/codec/SkCodecImageGenerator.cpp |
| +++ b/src/codec/SkCodecImageGenerator.cpp |
| @@ -16,16 +16,24 @@ SkImageGenerator* SkCodecImageGenerator::NewFromEncodedCodec(SkData* data) { |
| return new SkCodecImageGenerator(codec, data); |
| } |
| -static SkImageInfo make_premul(const SkImageInfo& info) { |
| - if (kUnpremul_SkAlphaType == info.alphaType()) { |
| - return info.makeAlphaType(kPremul_SkAlphaType); |
| - } |
| +// FIXME: We should expose information about the encoded format on the |
| +// SkImageGenerator, so the client can interpret the encoded |
| +// format and request the an output format. For now, as a |
|
scroggo
2016/03/23 13:02:26
the an -> an?
msarett
2016/03/23 13:23:28
Done.
|
| +// workaround, we guess what output format the client wants. |
| +static SkImageInfo fix_info(SkCodec* codec) { |
|
scroggo
2016/03/23 13:02:26
I think this should be a const ref. You do not mod
msarett
2016/03/23 13:23:28
Done.
|
| + const SkImageInfo& info = codec->getInfo(); |
| + SkAlphaType alphaType = (kUnpremul_SkAlphaType == info.alphaType()) ? kPremul_SkAlphaType : |
| + info.alphaType(); |
| + |
| + // Crudely guess that the presence of a color space means sRGB. |
|
scroggo
2016/03/23 13:02:26
I was going to suggest a FIXME here, but when SkIm
msarett
2016/03/23 13:23:28
Acknowledged. sgtm, I was counting on the FIXME a
scroggo
2016/03/23 13:26:38
Haha, touche.
|
| + SkColorProfileType profileType = (codec->getColorSpace()) ? kSRGB_SkColorProfileType : |
|
msarett
2016/03/22 20:12:22
Insert whatever hack here is most useful in the sh
|
| + kLinear_SkColorProfileType; |
| - return info; |
| + return SkImageInfo::Make(info.width(), info.height(), info.colorType(), alphaType, profileType); |
| } |
| SkCodecImageGenerator::SkCodecImageGenerator(SkCodec* codec, SkData* data) |
| - : INHERITED(make_premul(codec->getInfo())) |
| + : INHERITED(fix_info(codec)) |
| , fCodec(codec) |
| , fData(SkRef(data)) |
| {} |