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 |
11 #include "SkColorSpace.h" | 11 #include "SkColorSpace.h" |
12 #include "SkColorSpace_Base.h" | 12 #include "SkColorSpace_Base.h" |
13 | 13 |
14 class SkColorSpaceXform : SkNoncopyable { | 14 class SkColorSpaceXform : SkNoncopyable { |
15 public: | 15 public: |
16 | 16 |
17 typedef uint32_t RGBA32; | 17 typedef uint32_t RGBA32; |
| 18 typedef uint32_t BGRA32; |
18 typedef uint64_t RGBAF16; | 19 typedef uint64_t RGBAF16; |
19 | 20 |
20 /** | 21 /** |
21 * Create an object to handle color space conversions. | 22 * Create an object to handle color space conversions. |
22 * | 23 * |
23 * @param srcSpace The encoded color space. | 24 * @param srcSpace The encoded color space. |
24 * @param dstSpace The destination color space. | 25 * @param dstSpace The destination color space. |
25 * | 26 * |
26 */ | 27 */ |
27 static std::unique_ptr<SkColorSpaceXform> New(const sk_sp<SkColorSpace>& src
Space, | 28 static std::unique_ptr<SkColorSpaceXform> New(const sk_sp<SkColorSpace>& src
Space, |
28 const sk_sp<SkColorSpace>& dst
Space); | 29 const sk_sp<SkColorSpace>& dst
Space); |
29 | 30 |
30 /** | 31 /** |
31 * Apply the color conversion to a src buffer, storing the output in the ds
t buffer. | 32 * Apply the color conversion to a src buffer, storing the output in the ds
t buffer. |
32 * The src is stored as RGBA (8888) and is treated as opaque. | 33 * The src is stored as RGBA (8888) and is treated as opaque. |
33 * TODO (msarett): Support non-opaque srcs. | 34 * TODO (msarett): Support non-opaque srcs. |
34 */ | 35 */ |
35 virtual void applyTo8888(SkPMColor* dst, const RGBA32* src, int len) const =
0; | 36 virtual void applyToRGBA(RGBA32* dst, const RGBA32* src, int len) const = 0; |
| 37 virtual void applyToBGRA(BGRA32* dst, const RGBA32* src, int len) const = 0; |
36 virtual void applyToF16(RGBAF16* dst, const RGBA32* src, int len) const = 0; | 38 virtual void applyToF16(RGBAF16* dst, const RGBA32* src, int len) const = 0; |
37 | 39 |
38 virtual ~SkColorSpaceXform() {} | 40 virtual ~SkColorSpaceXform() {} |
39 }; | 41 }; |
40 | 42 |
41 template <SkColorSpace::GammaNamed Dst> | 43 template <SkColorSpace::GammaNamed Dst> |
42 class SkColorSpaceXform_Base : public SkColorSpaceXform { | 44 class SkColorSpaceXform_Base : public SkColorSpaceXform { |
43 public: | 45 public: |
44 | 46 |
45 void applyTo8888(SkPMColor* dst, const RGBA32* src, int len) const override; | 47 void applyToRGBA(RGBA32* dst, const RGBA32* src, int len) const override; |
| 48 void applyToBGRA(BGRA32* dst, const RGBA32* src, int len) const override; |
46 void applyToF16(RGBAF16* dst, const RGBA32* src, int len) const override; | 49 void applyToF16(RGBAF16* dst, const RGBA32* src, int len) const override; |
47 | 50 |
48 static constexpr int kDstGammaTableSize = 1024; | 51 static constexpr int kDstGammaTableSize = 1024; |
49 | 52 |
50 private: | 53 private: |
51 SkColorSpaceXform_Base(const sk_sp<SkColorSpace>& srcSpace, const SkMatrix44
& srcToDst, | 54 SkColorSpaceXform_Base(const sk_sp<SkColorSpace>& srcSpace, const SkMatrix44
& srcToDst, |
52 const sk_sp<SkColorSpace>& dstSpace); | 55 const sk_sp<SkColorSpace>& dstSpace); |
53 | 56 |
54 sk_sp<SkColorLookUpTable> fColorLUT; | 57 sk_sp<SkColorLookUpTable> fColorLUT; |
55 | 58 |
56 // May contain pointers into storage or pointers into precomputed tables. | 59 // May contain pointers into storage or pointers into precomputed tables. |
57 const float* fSrcGammaTables[3]; | 60 const float* fSrcGammaTables[3]; |
58 float fSrcGammaTableStorage[3 * 256]; | 61 float fSrcGammaTableStorage[3 * 256]; |
59 | 62 |
60 float fSrcToDst[16]; | 63 float fSrcToDst[16]; |
61 | 64 |
62 // May contain pointers into storage or pointers into precomputed tables. | 65 // May contain pointers into storage or pointers into precomputed tables. |
63 const uint8_t* fDstGammaTables[3]; | 66 const uint8_t* fDstGammaTables[3]; |
64 uint8_t fDstGammaTableStorage[3 * kDstGammaTableSize]; | 67 uint8_t fDstGammaTableStorage[3 * kDstGammaTableSize]; |
65 | 68 |
66 friend class SkColorSpaceXform; | 69 friend class SkColorSpaceXform; |
67 }; | 70 }; |
68 | 71 |
69 #endif | 72 #endif |
OLD | NEW |