Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(81)

Unified Diff: src/codec/SkCodecImageGenerator.cpp

Issue 1820413002: Workaround to set the sRGB flag on SkImageGenerator (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 4 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | src/codec/SkCodecPriv.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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))
{}
« no previous file with comments | « no previous file | src/codec/SkCodecPriv.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698