Chromium Code Reviews| Index: src/core/SkColorSpace.h |
| diff --git a/src/core/SkColorSpace.h b/src/core/SkColorSpace.h |
| index 2b3b15fe95576c33f5def8e4a341c5797a9bac30..9bbc20826dccecb4be8408b7d6fa58793a06cbcb 100644 |
| --- a/src/core/SkColorSpace.h |
| +++ b/src/core/SkColorSpace.h |
| @@ -22,6 +22,7 @@ |
| // |
| #include "SkRefCnt.h" |
| +#include "SkTArray.h" |
| struct SkFloat3 { |
| float fVec[3]; |
| @@ -35,6 +36,39 @@ struct SkFloat3x3 { |
| void dump() const; |
| }; |
| +struct SkGammaCurve { |
| + bool isValue() const { return 0.0f != fValue; } |
| + bool isTable() const { return 0 != fTableSize; } |
| + bool isParametric() const { return false; } |
| + |
| + // We have three different ways to represent gamma. |
| + // (1) A single value: |
| + float fValue; |
| + |
| + // (2) A lookup table: |
| + uint32_t fTableSize; |
| + std::unique_ptr<float[]> fTable; |
| + |
| + // (3) Parameters for a curve: |
| + // FIXME (msarett): Handle parametric curves. |
| + |
| + SkGammaCurve() { |
| + memset(this, 0, sizeof(struct SkGammaCurve)); |
| + } |
| + |
| + SkGammaCurve(float value) |
| + : fValue(value) |
| + , fTableSize(0) |
| + , fTable(nullptr) |
| + {} |
| +}; |
| + |
| +struct SkGammas { |
| + SkGammaCurve fRed; |
| + SkGammaCurve fGreen; |
| + SkGammaCurve fBlue; |
| +}; |
| + |
| struct SkColorLookUpTable { |
| static const uint8_t kMaxChannels = 16; |
| @@ -46,14 +80,6 @@ struct SkColorLookUpTable { |
| SkColorLookUpTable() { |
| memset(this, 0, sizeof(struct SkColorLookUpTable)); |
| } |
| - |
| - SkColorLookUpTable(SkColorLookUpTable&& that) |
|
msarett
2016/04/28 21:26:48
Now that we are on VS 2015, I think that this is n
|
| - : fInputChannels(that.fInputChannels) |
| - , fOutputChannels(that.fOutputChannels) |
| - , fTable(std::move(that.fTable)) |
| - { |
| - memcpy(fGridPoints, that.fGridPoints, kMaxChannels); |
| - } |
| }; |
| class SkColorSpace : public SkRefCnt { |
| @@ -67,25 +93,25 @@ public: |
| * Return a colorspace instance, given a 3x3 transform from linear_RGB to D50_XYZ |
| * and the src-gamma, return a ColorSpace |
| */ |
| - static sk_sp<SkColorSpace> NewRGB(const SkFloat3x3& toXYZD50, const SkFloat3& gamma); |
| + static sk_sp<SkColorSpace> NewRGB(const SkFloat3x3& toXYZD50, SkGammas gammas); |
| static sk_sp<SkColorSpace> NewNamed(Named); |
| static sk_sp<SkColorSpace> NewICC(const void*, size_t); |
| - SkFloat3 gamma() const { return fGamma; } |
| + const SkGammas& gammas() const { return fGammas; } |
| SkFloat3x3 xyz() const { return fToXYZD50; } |
| SkFloat3 xyzOffset() const { return fToXYZOffset; } |
| Named named() const { return fNamed; } |
| uint32_t uniqueID() const { return fUniqueID; } |
| private: |
| - SkColorSpace(const SkFloat3& gamma, const SkFloat3x3& toXYZ, Named); |
| + SkColorSpace(SkGammas gammas, const SkFloat3x3& toXYZ, Named); |
| - SkColorSpace(SkColorLookUpTable colorLUT, const SkFloat3& gamma, const SkFloat3x3& toXYZ, |
| - const SkFloat3& toXYZOffset); |
| + SkColorSpace(SkColorLookUpTable colorLUT, SkGammas gammas, |
| + const SkFloat3x3& toXYZ, const SkFloat3& toXYZOffset); |
| const SkColorLookUpTable fColorLUT; |
| - const SkFloat3 fGamma; |
| + const SkGammas fGammas; |
| const SkFloat3x3 fToXYZD50; |
| const SkFloat3 fToXYZOffset; |