Refactored SkColorSpace and added in a Lab PCS GM
The refactoring breaks off A2B0 tag support into a separate
subclass of SkColorSpace_Base, while keeping the current
(besides CLUT) functionality in a XYZTRC subclass.
ICC profile loading is now aware of this and creates the A2B0
subclass when SkColorSpace::NewICC() is called on a profile
in need of the A2B0 functionality.
The LabPCSDemo GM loads a .icc profile containing a LAB PCS and
then runs a Lab->XYZ conversion on an image using it so we can
display it and test out the A2B0 SkColorSpace functionality,
sans a/b/m-curves, as well as the Lab->XYZ conversion code.
BUG=skia:
GOLD_TRYBOT_URL= https://gold.skia.org/search?issue=2389983002
Review-Url: https://codereview.chromium.org/2389983002
diff --git a/dm/DMSrcSink.cpp b/dm/DMSrcSink.cpp
index e777815..8b62864 100644
--- a/dm/DMSrcSink.cpp
+++ b/dm/DMSrcSink.cpp
@@ -11,7 +11,7 @@
#include "SkCodec.h"
#include "SkCodecImageGenerator.h"
#include "SkColorSpace.h"
-#include "SkColorSpace_Base.h"
+#include "SkColorSpace_XYZ.h"
#include "SkColorSpaceXform.h"
#include "SkCommonFlags.h"
#include "SkData.h"
@@ -920,7 +920,9 @@
decodeInfo = decodeInfo.makeAlphaType(kPremul_SkAlphaType);
}
if (kRGBA_F16_SkColorType == fColorType) {
- decodeInfo = decodeInfo.makeColorSpace(as_CSB(decodeInfo.colorSpace())->makeLinearGamma());
+ SkASSERT(SkColorSpace_Base::Type::kXYZ == as_CSB(decodeInfo.colorSpace())->type());
+ SkColorSpace_XYZ* csXYZ = static_cast<SkColorSpace_XYZ*>(decodeInfo.colorSpace());
+ decodeInfo = decodeInfo.makeColorSpace(csXYZ->makeLinearGamma());
}
SkImageInfo bitmapInfo = decodeInfo;
@@ -939,7 +941,15 @@
size_t rowBytes = bitmap.rowBytes();
SkCodec::Result r = codec->getPixels(decodeInfo, bitmap.getPixels(), rowBytes);
if (SkCodec::kSuccess != r && SkCodec::kIncompleteInput != r) {
- return SkStringPrintf("Couldn't getPixels %s. Error code %d", fPath.c_str(), r);
+ if (kRGBA_F16_SkColorType == decodeInfo.colorType()) {
+ // FIXME (raftias):
+ // Get the codecs to not fail when there is no color xform,
+ // which currently happens in F16 mode.
+ return Error::Nonfatal(SkStringPrintf("Couldn't getPixels %s in F16. Error code %d",
+ fPath.c_str()));
+ } else {
+ return SkStringPrintf("Couldn't getPixels %s. Error code %d", fPath.c_str(), r);
+ }
}
switch (fMode) {