Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(477)

Side by Side Diff: src/core/SkColorSpaceXform.h

Issue 2341143002: YUV and color xforms
Patch Set: Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/codec/SkJpegCodec.cpp ('k') | src/core/SkColorSpaceXform.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 23 matching lines...) Expand all
34 * @param dstColorType Describes color type of |dst| 34 * @param dstColorType Describes color type of |dst|
35 * @param dstAlphaType Describes alpha type of |dst| 35 * @param dstAlphaType Describes alpha type of |dst|
36 * kUnpremul preserves input alpha values 36 * kUnpremul preserves input alpha values
37 * kPremul performs a premultiplication and also pres erves alpha values 37 * kPremul performs a premultiplication and also pres erves alpha values
38 * kOpaque optimization hint, |dst| alphas set to 1 38 * kOpaque optimization hint, |dst| alphas set to 1
39 * 39 *
40 */ 40 */
41 virtual void apply(void* dst, const uint32_t* src, int len, SkColorType dstC olorType, 41 virtual void apply(void* dst, const uint32_t* src, int len, SkColorType dstC olorType,
42 SkAlphaType dstAlphaType) const = 0; 42 SkAlphaType dstAlphaType) const = 0;
43 43
44 virtual void applyYUV(void* dst, const uint8_t* y, const uint8_t* u, const u int8_t* v, int width) const = 0;
45
44 virtual ~SkColorSpaceXform() {} 46 virtual ~SkColorSpaceXform() {}
45 }; 47 };
46 48
47 enum SrcGamma { 49 enum SrcGamma {
48 kLinear_SrcGamma, 50 kLinear_SrcGamma,
49 kTable_SrcGamma, 51 kTable_SrcGamma,
50 }; 52 };
51 53
52 enum DstGamma { 54 enum DstGamma {
53 kLinear_DstGamma, 55 kLinear_DstGamma,
54 kSRGB_DstGamma, 56 kSRGB_DstGamma,
55 k2Dot2_DstGamma, 57 k2Dot2_DstGamma,
56 kTable_DstGamma, 58 kTable_DstGamma,
57 }; 59 };
58 60
59 enum ColorSpaceMatch { 61 enum ColorSpaceMatch {
60 kNone_ColorSpaceMatch, 62 kNone_ColorSpaceMatch,
61 kGamut_ColorSpaceMatch, 63 kGamut_ColorSpaceMatch,
62 kFull_ColorSpaceMatch, 64 kFull_ColorSpaceMatch,
63 }; 65 };
64 66
65 template <SrcGamma kSrc, DstGamma kDst, ColorSpaceMatch kCSM> 67 template <SrcGamma kSrc, DstGamma kDst, ColorSpaceMatch kCSM>
66 class SkColorSpaceXform_Base : public SkColorSpaceXform { 68 class SkColorSpaceXform_Base : public SkColorSpaceXform {
67 public: 69 public:
68 70
69 void apply(void* dst, const uint32_t* src, int len, SkColorType dstColorType , 71 void apply(void* dst, const uint32_t* src, int len, SkColorType dstColorType ,
70 SkAlphaType dstAlphaType) const override; 72 SkAlphaType dstAlphaType) const override;
71 73
74 void applyYUV(void* dst, const uint8_t* y, const uint8_t* u, const uint8_t* v, int width) const override;
75
72 static constexpr int kDstGammaTableSize = 1024; 76 static constexpr int kDstGammaTableSize = 1024;
73 77
74 private: 78 private:
75 SkColorSpaceXform_Base(const sk_sp<SkColorSpace>& srcSpace, const SkMatrix44 & srcToDst, 79 SkColorSpaceXform_Base(const sk_sp<SkColorSpace>& srcSpace, const SkMatrix44 & srcToDst,
76 const sk_sp<SkColorSpace>& dstSpace); 80 const sk_sp<SkColorSpace>& dstSpace);
77 81
78 sk_sp<SkColorLookUpTable> fColorLUT; 82 sk_sp<SkColorLookUpTable> fColorLUT;
79 83
80 // Contain pointers into storage or pointers into precomputed tables. 84 // Contain pointers into storage or pointers into precomputed tables.
81 const float* fSrcGammaTables[3]; 85 const float* fSrcGammaTables[3];
82 const uint8_t* fDstGammaTables[3]; 86 const uint8_t* fDstGammaTables[3];
83 SkAutoMalloc fStorage; 87 SkAutoMalloc fStorage;
84 88
85 float fSrcToDst[16]; 89 float fSrcToDst[16];
86 90
87 friend class SkColorSpaceXform; 91 friend class SkColorSpaceXform;
88 friend std::unique_ptr<SkColorSpaceXform> SlowIdentityXform(const sk_sp<SkCo lorSpace>& space); 92 friend std::unique_ptr<SkColorSpaceXform> SlowIdentityXform(const sk_sp<SkCo lorSpace>& space);
89 }; 93 };
90 94
91 // For testing. Bypasses opts for when src and dst color spaces are equal. 95 // For testing. Bypasses opts for when src and dst color spaces are equal.
92 std::unique_ptr<SkColorSpaceXform> SlowIdentityXform(const sk_sp<SkColorSpace>& space); 96 std::unique_ptr<SkColorSpaceXform> SlowIdentityXform(const sk_sp<SkColorSpace>& space);
93 97
94 #endif 98 #endif
OLDNEW
« no previous file with comments | « src/codec/SkJpegCodec.cpp ('k') | src/core/SkColorSpaceXform.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698