aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/codec/SkJpegCodec.cpp
diff options
context:
space:
mode:
authorGravatar Matt Sarett <msarett@google.com>2017-01-12 18:36:38 -0500
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2017-01-13 14:39:25 +0000
commit523116d9fee8b79af09563b55b19cbd267353300 (patch)
tree36c13950b852908519463d557192f516e3ef93ba /src/codec/SkJpegCodec.cpp
parent76467a11a0aa4ba15f0f2e3ee078ba9b6ecbaa91 (diff)
Unify ICC support for gray jpegs and gray pngs
(1) Parse ICC gray profiles into RGB SkColorSpace objects. This is easy - "gray transfer fn + white point" is subset of "RGB transfer fns + matrix". This makes it easier/possible for the drawing code to reason about color spaces attached to kGray buffers. (2) Allow gray images to be tagged with gray ICCs OR rgb ICCs. ICC gray forces to designer to use "D50 gray". It is not uncommon to see gray images with RGB profiles - and this actually allows the designer to choose more kinds of gray (ex: sRGB gray). (3) Make SkJpegCodec support gray images with RGB ICCs. (4) Make SkPngCodec support gray images with Gray ICCs. (5) Delete gray from SkColorSpace_A2B - we no longer create these objects for gray profiles. BUG=skia: Change-Id: Id5eca803798330c54a19c4657def2e5976d1941e Reviewed-on: https://skia-review.googlesource.com/6922 Reviewed-by: Brian Osman <brianosman@google.com> Commit-Queue: Matt Sarett <msarett@google.com>
Diffstat (limited to 'src/codec/SkJpegCodec.cpp')
-rw-r--r--src/codec/SkJpegCodec.cpp11
1 files changed, 5 insertions, 6 deletions
diff --git a/src/codec/SkJpegCodec.cpp b/src/codec/SkJpegCodec.cpp
index 8c2f5dc4e3..8295236258 100644
--- a/src/codec/SkJpegCodec.cpp
+++ b/src/codec/SkJpegCodec.cpp
@@ -231,21 +231,20 @@ bool SkJpegCodec::ReadHeader(SkStream* stream, SkCodec** codecOut,
sk_sp<SkColorSpace> colorSpace = nullptr;
bool unsupportedICC = false;
if (iccData) {
- SkColorSpace_Base::InputColorFormat inputColorFormat =
- SkColorSpace_Base::InputColorFormat::kRGB;
+ SkColorSpace_Base::ICCTypeFlag iccType = SkColorSpace_Base::kRGB_ICCTypeFlag;
switch (decoderMgr->dinfo()->jpeg_color_space) {
case JCS_CMYK:
case JCS_YCCK:
- inputColorFormat = SkColorSpace_Base::InputColorFormat::kCMYK;
+ iccType = SkColorSpace_Base::kCMYK_ICCTypeFlag;
break;
case JCS_GRAYSCALE:
- inputColorFormat = SkColorSpace_Base::InputColorFormat::kGray;
+ // Note the "or equals". We will accept gray or rgb profiles for gray images.
+ iccType |= SkColorSpace_Base::kGray_ICCTypeFlag;
break;
default:
break;
}
- colorSpace = SkColorSpace_Base::MakeICC(iccData->data(), iccData->size(),
- inputColorFormat);
+ colorSpace = SkColorSpace_Base::MakeICC(iccData->data(), iccData->size(), iccType);
if (!colorSpace) {
SkCodecPrintf("Could not create SkColorSpace from ICC data.\n");
unsupportedICC = true;