aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/codec
diff options
context:
space:
mode:
authorGravatar raftias <raftias@google.com>2016-12-01 13:44:07 -0500
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2016-12-01 19:42:32 +0000
commit5476128f0a88217414f05e6a7ee518cdb411d026 (patch)
tree6b65531042d9af58a82ba8305a928edec17e0f29 /src/codec
parentb6d4e139b522821933d356ef7d2472816d25340a (diff)
Added CMYK support for ICC profiles.
Changed ICC parsing/SkGammas/SkColorLookUpTable to handle non-3-channel inputs. Parsed CMYK A2B ICC profiles. Integrated this with SkJpegCodec (the only file that supports CMYK) and SkColorSpaceXform_A2B to allow parsing and color xforming of ICC CMYK images. CQ_INCLUDE_TRYBOTS=skia.primary:Test-Ubuntu-GCC-GCE-CPU-AVX2-x86_64-Release-SKNX_NO_SIMD Change-Id: I11e3d17180244281be3eb43fd608609925a7f71e Reviewed-on: https://skia-review.googlesource.com/5444 Reviewed-by: Matt Sarett <msarett@google.com> Commit-Queue: Matt Sarett <msarett@google.com>
Diffstat (limited to 'src/codec')
-rw-r--r--src/codec/SkJpegCodec.cpp19
1 files changed, 14 insertions, 5 deletions
diff --git a/src/codec/SkJpegCodec.cpp b/src/codec/SkJpegCodec.cpp
index 69b80273df..7a264d5d99 100644
--- a/src/codec/SkJpegCodec.cpp
+++ b/src/codec/SkJpegCodec.cpp
@@ -11,6 +11,7 @@
#include "SkJpegDecoderMgr.h"
#include "SkCodecPriv.h"
#include "SkColorPriv.h"
+#include "SkColorSpace_Base.h"
#include "SkStream.h"
#include "SkTemplates.h"
#include "SkTypes.h"
@@ -229,7 +230,18 @@ bool SkJpegCodec::ReadHeader(SkStream* stream, SkCodec** codecOut,
sk_sp<SkData> iccData = get_icc_profile(decoderMgr->dinfo());
sk_sp<SkColorSpace> colorSpace = nullptr;
if (iccData) {
- colorSpace = SkColorSpace::MakeICC(iccData->data(), iccData->size());
+ SkColorSpace_Base::InputColorFormat inputColorFormat =
+ SkColorSpace_Base::InputColorFormat::kRGB;
+ switch (decoderMgr->dinfo()->jpeg_color_space) {
+ case JCS_CMYK:
+ case JCS_YCCK:
+ inputColorFormat = SkColorSpace_Base::InputColorFormat::kCMYK;
+ break;
+ default:
+ break;
+ }
+ colorSpace = SkColorSpace_Base::MakeICC(iccData->data(), iccData->size(),
+ inputColorFormat);
if (!colorSpace) {
SkCodecPrintf("Could not create SkColorSpace from ICC data.\n");
}
@@ -368,9 +380,6 @@ bool SkJpegCodec::setOutputColorSpace(const SkImageInfo& dstInfo) {
// we must do it ourselves.
J_COLOR_SPACE encodedColorType = fDecoderMgr->dinfo()->jpeg_color_space;
bool isCMYK = (JCS_CMYK == encodedColorType || JCS_YCCK == encodedColorType);
- if (isCMYK && this->colorXform()) {
- return false;
- }
// Check for valid color types and set the output color space
switch (dstInfo.colorType()) {
@@ -569,7 +578,7 @@ SkCodec::Result SkJpegCodec::onGetPixels(const SkImageInfo& dstInfo,
SkASSERT(1 == dinfo->rec_outbuf_height);
J_COLOR_SPACE colorSpace = dinfo->out_color_space;
- if (JCS_CMYK == colorSpace) {
+ if (JCS_CMYK == colorSpace && nullptr == this->colorXform()) {
this->initializeSwizzler(dstInfo, options);
}