aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorGravatar msarett <msarett@google.com>2016-03-23 06:50:59 -0700
committerGravatar Commit bot <commit-bot@chromium.org>2016-03-23 06:50:59 -0700
commit3ec5db42cc145fb11e352eca6474f91d7a4957e3 (patch)
tree34cdbc141fee49af0ed9a3a7add4837ac7306200
parentb4a7dc99b1a01cdd5c0cd5913b630436ca696210 (diff)
Workaround to set the sRGB flag on SkImageGenerator
-rw-r--r--src/codec/SkCodecImageGenerator.cpp20
-rw-r--r--src/codec/SkCodecPriv.h10
-rw-r--r--src/codec/SkJpegCodec.cpp7
3 files changed, 17 insertions, 20 deletions
diff --git a/src/codec/SkCodecImageGenerator.cpp b/src/codec/SkCodecImageGenerator.cpp
index e579da92f6..db13aaea29 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))
{}
diff --git a/src/codec/SkCodecPriv.h b/src/codec/SkCodecPriv.h
index 2b22922b0c..8dde60fcd3 100644
--- a/src/codec/SkCodecPriv.h
+++ b/src/codec/SkCodecPriv.h
@@ -117,13 +117,9 @@ inline bool valid_alpha(SkAlphaType dstAlpha, SkAlphaType srcAlpha) {
*/
inline bool conversion_possible(const SkImageInfo& dst, const SkImageInfo& src) {
// FIXME: skbug.com/4895
- // Currently, we treat both kLinear and ksRGB encoded images as if they are kLinear.
- // This makes sense while we do not have proper support for ksRGB. This is also
- // the reason why we always allow the client to request kLinear.
- if (dst.profileType() != src.profileType() &&
- kLinear_SkColorProfileType != dst.profileType()) {
- return false;
- }
+ // Currently, we ignore the SkColorProfileType on the SkImageInfo. We
+ // will treat the encoded data as linear regardless of what the client
+ // requests.
// Ensure the alpha type is valid
if (!valid_alpha(dst.alphaType(), src.alphaType())) {
diff --git a/src/codec/SkJpegCodec.cpp b/src/codec/SkJpegCodec.cpp
index e920de1956..2005d1d694 100644
--- a/src/codec/SkJpegCodec.cpp
+++ b/src/codec/SkJpegCodec.cpp
@@ -331,13 +331,6 @@ bool SkJpegCodec::onRewind() {
* Sets the output color space
*/
bool SkJpegCodec::setOutputColorSpace(const SkImageInfo& dst) {
- const SkImageInfo& src = this->getInfo();
-
- // Ensure that the profile type is unchanged
- if (dst.profileType() != src.profileType()) {
- return false;
- }
-
if (kUnknown_SkAlphaType == dst.alphaType()) {
return false;
}