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

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: Fix jpeg 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..db13aaea2973f62445477f8fefdf42bef948d761 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 an output format. For now, as a workaround,
+// we guess what output format the client wants.
+static SkImageInfo fix_info(const SkCodec& codec) {
+ 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.
+ SkColorProfileType profileType = (codec.getColorSpace()) ? kSRGB_SkColorProfileType :
+ 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