aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/core/SkColorSpace_A2B.h
diff options
context:
space:
mode:
authorGravatar raftias <raftias@google.com>2016-10-24 09:52:26 -0700
committerGravatar Commit bot <commit-bot@chromium.org>2016-10-24 09:52:26 -0700
commit026f223d8641beeae19ed0bdbeca738be62256f5 (patch)
tree95e5b4af3e8bacd95bedd5626b132843ec99f446 /src/core/SkColorSpace_A2B.h
parent3cc2d2050983bd3bbab4bf4cc714fa4d7199c959 (diff)
Refactored SkColorSpace_A2B to allow arbitrary ordering of elements
This is essential for representing non-lutAtoBType A2B tags such as lut16Type, lut8Type, mpet. Parsing of A2B0 tags was also moved ahead of the TRC/XYZ-matrix parsing, as profiles examined with both tags either had the TRC/XYZ tags as a fall-back or were incorrectly displayed if only the TRC/XYZ tags were used. This was submitted alone to reduce CL size. Tests that will use these changes will be introduced in the subsequent CLs that add on lut8/16Type A2B0 parsing. We already have lut16Type test images and these have been tested locally, but require additional code not submitted yet for lut16Type ICC profile parsing and A2B colorspace xforms. BUG=skia: GOLD_TRYBOT_URL= https://gold.skia.org/search?issue=2444553002 Review-Url: https://codereview.chromium.org/2444553002
Diffstat (limited to 'src/core/SkColorSpace_A2B.h')
-rw-r--r--src/core/SkColorSpace_A2B.h106
1 files changed, 72 insertions, 34 deletions
diff --git a/src/core/SkColorSpace_A2B.h b/src/core/SkColorSpace_A2B.h
index a0bd4a0319..844800588b 100644
--- a/src/core/SkColorSpace_A2B.h
+++ b/src/core/SkColorSpace_A2B.h
@@ -10,6 +10,8 @@
#include "SkColorSpace_Base.h"
+#include <vector>
+
// An alternative SkColorSpace that represents all the color space data that
// is stored in an A2B0 ICC tag. This allows us to use alternative profile
// connection spaces (CIELAB instead of just CIEXYZ), use color-lookup-tables
@@ -18,9 +20,8 @@
// the potential to allow conversion from input color spaces with a different
// number of channels such as CMYK (4) or GRAY (1), but that is not supported yet.
//
-// Evaluation is done: A-curve => CLUT => M-curve => Matrix => B-curve
-//
-// There are also multi-processing-elements in the A2B0 tag which allow you to
+// Currently AtoBType A2B0 tag types are supported. There are also lut8Type,
+// lut16Type and MPET (multi-processing-elements) A2B0 tags which allow you to
// combine these 3 primitives (TRC, CLUT, matrix) in any order/quantitiy,
// but support for that is not implemented.
class SkColorSpace_A2B : public SkColorSpace_Base {
@@ -55,21 +56,72 @@ public:
return false;
}
- SkGammaNamed aCurveNamed() const { return fACurveNamed; }
-
- const SkGammas* aCurve() const { return fACurve.get(); }
-
- const SkColorLookUpTable* colorLUT() const { return fColorLUT.get(); }
+ Type type() const override { return Type::kA2B; }
- SkGammaNamed mCurveNamed() const { return fMCurveNamed; }
+ class Element {
+ public:
+ explicit Element(SkGammaNamed gammaNamed)
+ : fType(Type::kGammaNamed)
+ , fGammaNamed(gammaNamed)
+ , fMatrix(SkMatrix44::kUninitialized_Constructor)
+ {}
+
+ explicit Element(sk_sp<SkGammas> gammas)
+ : fType(Type::kGammas)
+ , fGammas(std::move(gammas))
+ , fMatrix(SkMatrix44::kUninitialized_Constructor)
+ {}
+
+ explicit Element(sk_sp<SkColorLookUpTable> colorLUT)
+ : fType(Type::kCLUT)
+ , fCLUT(std::move(colorLUT))
+ , fMatrix(SkMatrix44::kUninitialized_Constructor)
+ {}
+
+ explicit Element(const SkMatrix44& matrix)
+ : fType(Type::kMatrix)
+ , fMatrix(matrix)
+ {}
- const SkGammas* mCurve() const { return fMCurve.get(); }
-
- const SkMatrix44& matrix() const { return fMatrix; }
-
- SkGammaNamed bCurveNamed() const { return fBCurveNamed; }
+ enum class Type {
+ kGammaNamed,
+ kGammas,
+ kCLUT,
+ kMatrix
+ };
+
+ Type type() const { return fType; }
+
+ SkGammaNamed gammaNamed() const {
+ SkASSERT(Type::kGammaNamed == fType);
+ return fGammaNamed;
+ }
+
+ const SkGammas& gammas() const {
+ SkASSERT(Type::kGammas == fType);
+ return *fGammas;
+ }
+
+ const SkColorLookUpTable& colorLUT() const {
+ SkASSERT(Type::kCLUT == fType);
+ return *fCLUT;
+ }
+
+ const SkMatrix44& matrix() const {
+ SkASSERT(Type::kMatrix == fType);
+ return fMatrix;
+ }
+
+ private:
+ Type fType;
+ SkGammaNamed fGammaNamed;
+ sk_sp<SkGammas> fGammas;
+ sk_sp<SkColorLookUpTable> fCLUT;
+ SkMatrix44 fMatrix;
+ };
+ const Element& element(size_t i) const { return fElements[i]; }
- const SkGammas* bCurve() const { return fBCurve.get(); }
+ size_t count() const { return fElements.size(); }
// the intermediate profile connection space that this color space
// represents the transformation to
@@ -80,26 +132,12 @@ public:
PCS pcs() const { return fPCS; }
- Type type() const override { return Type::kA2B; }
-
private:
- SkColorSpace_A2B(SkGammaNamed aCurveNamed, sk_sp<SkGammas> aCurve,
- sk_sp<SkColorLookUpTable> colorLUT,
- SkGammaNamed mCurveNamed, sk_sp<SkGammas> mCurve,
- const SkMatrix44& matrix,
- SkGammaNamed bCurveNamed, sk_sp<SkGammas> bCurve,
- PCS pcs, sk_sp<SkData> profileData);
-
- const SkGammaNamed fACurveNamed;
- sk_sp<SkGammas> fACurve;
- sk_sp<SkColorLookUpTable> fColorLUT;
- const SkGammaNamed fMCurveNamed;
- sk_sp<SkGammas> fMCurve;
- SkMatrix44 fMatrix;
- const SkGammaNamed fBCurveNamed;
- sk_sp<SkGammas> fBCurve;
- PCS fPCS;
-
+ SkColorSpace_A2B(PCS pcs, sk_sp<SkData> profileData, std::vector<Element> elements);
+
+ PCS fPCS;
+ std::vector<Element> fElements;
+
friend class SkColorSpace;
typedef SkColorSpace_Base INHERITED;
};