Index: src/core/SkColorSpacePriv.h |
diff --git a/src/core/SkColorSpacePriv.h b/src/core/SkColorSpacePriv.h |
new file mode 100644 |
index 0000000000000000000000000000000000000000..a07640b555f9857154bb3a039669d1df70a3080f |
--- /dev/null |
+++ b/src/core/SkColorSpacePriv.h |
@@ -0,0 +1,83 @@ |
+/* |
+ * Copyright 2016 Google Inc. |
+ * |
+ * Use of this source code is governed by a BSD-style license that can be |
+ * found in the LICENSE file. |
+ */ |
+ |
+#ifndef SkColorSpacePriv_DEFINED |
+#define SkColorSpacePriv_DEFINED |
+ |
+struct SkGammaCurve { |
+ bool isValue() const { |
+ bool result = (0.0f != fValue); |
+ SkASSERT(!result || (0 == fTableSize)); |
+ return result; |
+ } |
+ |
+ bool isTable() const { |
+ bool result = (0 != fTableSize); |
+ SkASSERT(!result || (0.0f == fValue)); |
+ SkASSERT(!result || fTable); |
+ return result; |
+ } |
+ |
+ 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 : public SkRefCnt { |
scroggo
2016/05/17 16:54:27
Why is gamma ref counted? I guess it's because of
msarett
2016/05/17 17:27:13
A couple reasons:
(1) As you say, it's nice to not
|
+public: |
+ bool isValues() const { |
+ return fRed.isValue() && fGreen.isValue() && fBlue.isValue(); |
+ } |
+ |
+ SkGammaCurve fRed; |
+ SkGammaCurve fGreen; |
+ SkGammaCurve fBlue; |
+ |
+ SkGammas(float red, float green, float blue) |
+ : fRed(red) |
+ , fGreen(green) |
+ , fBlue(blue) |
+ {} |
+ |
+ SkGammas() {} |
+ |
+ friend class SkColorSpace; |
+}; |
+ |
+struct SkColorLookUpTable { |
+ static const uint8_t kMaxChannels = 16; |
+ |
+ uint8_t fInputChannels; |
+ uint8_t fOutputChannels; |
+ uint8_t fGridPoints[kMaxChannels]; |
+ std::unique_ptr<float[]> fTable; |
+ |
+ SkColorLookUpTable() { |
+ memset(this, 0, sizeof(struct SkColorLookUpTable)); |
+ } |
+}; |
+ |
+#endif |