Miscellaneous color space refactors
(1) Use float matrix[16] everywhere (enables future code
sharing).
(2) SkColorLookUpTable refactors
*** Store in a single allocation (like SkGammas)
*** Eliminate fOutputChannels (we always require 3,
and probably always will)
(3) Change names of read_big_endian_* helpers
BUG=skia:
GOLD_TRYBOT_URL= https://gold.skia.org/search?issue=2166093003
CQ_INCLUDE_TRYBOTS=master.client.skia:Test-Ubuntu-GCC-GCE-CPU-AVX2-x86_64-Release-SKNX_NO_SIMD-Trybot
Review-Url: https://codereview.chromium.org/2166093003
diff --git a/src/core/SkColorSpace_Base.h b/src/core/SkColorSpace_Base.h
index d18b631..6cfbb8c 100644
--- a/src/core/SkColorSpace_Base.h
+++ b/src/core/SkColorSpace_Base.h
@@ -129,18 +129,27 @@
};
struct SkColorLookUpTable : public SkRefCnt {
- uint8_t fInputChannels;
- uint8_t fOutputChannels;
- uint8_t fGridPoints[3];
- std::unique_ptr<float[]> fTable;
+ static constexpr uint8_t kOutputChannels = 3;
- SkColorLookUpTable()
- : fInputChannels(0)
- , fOutputChannels(0)
- , fTable(nullptr)
- {
- fGridPoints[0] = fGridPoints[1] = fGridPoints[2] = 0;
+ uint8_t fInputChannels;
+ uint8_t fGridPoints[3];
+
+ const float* table() const {
+ return SkTAddOffset<const float>(this, sizeof(SkColorLookUpTable));
}
+
+ SkColorLookUpTable(uint8_t inputChannels, uint8_t gridPoints[3])
+ : fInputChannels(inputChannels)
+ {
+ SkASSERT(3 == inputChannels);
+ memcpy(fGridPoints, gridPoints, 3 * sizeof(uint8_t));
+ }
+
+ // Objects of this type are created in a custom fashion using sk_malloc_throw
+ // and therefore must be sk_freed.
+ void* operator new(size_t size) = delete;
+ void* operator new(size_t, void* p) { return p; }
+ void operator delete(void* p) { sk_free(p); }
};
class SkColorSpace_Base : public SkColorSpace {