OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2016 Google Inc. | 2 * Copyright 2016 Google Inc. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
6 */ | 6 */ |
7 | 7 |
8 #ifndef SkColorSpaceXform_DEFINED | 8 #ifndef SkColorSpaceXform_DEFINED |
9 #define SkColorSpaceXform_DEFINED | 9 #define SkColorSpaceXform_DEFINED |
10 | 10 |
(...skipping 18 matching lines...) Expand all Loading... |
29 * Apply the color conversion to a src buffer, storing the output in the ds
t buffer. | 29 * Apply the color conversion to a src buffer, storing the output in the ds
t buffer. |
30 * The src is stored as RGBA (8888). The dst is stored in the format indic
ated by | 30 * The src is stored as RGBA (8888). The dst is stored in the format indic
ated by |
31 * |dstColorType| and is premultiplied by alpha if |premul| is set. | 31 * |dstColorType| and is premultiplied by alpha if |premul| is set. |
32 */ | 32 */ |
33 virtual void apply(void* dst, const uint32_t* src, int len, SkColorType dstC
olorType, | 33 virtual void apply(void* dst, const uint32_t* src, int len, SkColorType dstC
olorType, |
34 SkAlphaType dstAlphaType) const = 0; | 34 SkAlphaType dstAlphaType) const = 0; |
35 | 35 |
36 virtual ~SkColorSpaceXform() {} | 36 virtual ~SkColorSpaceXform() {} |
37 }; | 37 }; |
38 | 38 |
39 template <SkColorSpace::GammaNamed kDst> | 39 enum ColorSpaceMatch { |
| 40 kNone_ColorSpaceMatch, |
| 41 kGamut_ColorSpaceMatch, |
| 42 kFull_ColorSpaceMatch, |
| 43 }; |
| 44 |
| 45 template <SkColorSpace::GammaNamed kDst, ColorSpaceMatch kCSM> |
40 class SkColorSpaceXform_Base : public SkColorSpaceXform { | 46 class SkColorSpaceXform_Base : public SkColorSpaceXform { |
41 public: | 47 public: |
42 | 48 |
43 void apply(void* dst, const uint32_t* src, int len, SkColorType dstColorType
, | 49 void apply(void* dst, const uint32_t* src, int len, SkColorType dstColorType
, |
44 SkAlphaType dstAlphaType) const override; | 50 SkAlphaType dstAlphaType) const override; |
45 | 51 |
46 static constexpr int kDstGammaTableSize = 1024; | 52 static constexpr int kDstGammaTableSize = 1024; |
47 | 53 |
48 private: | 54 private: |
49 SkColorSpaceXform_Base(const sk_sp<SkColorSpace>& srcSpace, const SkMatrix44
& srcToDst, | 55 SkColorSpaceXform_Base(const sk_sp<SkColorSpace>& srcSpace, const SkMatrix44
& srcToDst, |
50 const sk_sp<SkColorSpace>& dstSpace); | 56 const sk_sp<SkColorSpace>& dstSpace); |
51 | 57 |
52 sk_sp<SkColorLookUpTable> fColorLUT; | 58 sk_sp<SkColorLookUpTable> fColorLUT; |
53 | 59 |
54 // May contain pointers into storage or pointers into precomputed tables. | 60 // May contain pointers into storage or pointers into precomputed tables. |
55 const float* fSrcGammaTables[3]; | 61 const float* fSrcGammaTables[3]; |
56 float fSrcGammaTableStorage[3 * 256]; | 62 float fSrcGammaTableStorage[3 * 256]; |
57 | 63 |
58 float fSrcToDst[16]; | 64 float fSrcToDst[16]; |
59 | 65 |
60 // May contain pointers into storage or pointers into precomputed tables. | 66 // May contain pointers into storage or pointers into precomputed tables. |
61 const uint8_t* fDstGammaTables[3]; | 67 const uint8_t* fDstGammaTables[3]; |
62 uint8_t fDstGammaTableStorage[3 * kDstGammaTableSize]; | 68 uint8_t fDstGammaTableStorage[3 * kDstGammaTableSize]; |
63 | 69 |
64 friend class SkColorSpaceXform; | 70 friend class SkColorSpaceXform; |
65 }; | 71 }; |
66 | 72 |
67 #endif | 73 #endif |
OLD | NEW |