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

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

Issue 2347473007: Revert of Support Float32 output from SkColorSpaceXform (Closed)
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/SkWebpCodec.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
11 #include "SkColorSpace.h" 11 #include "SkColorSpace.h"
12 #include "SkColorSpace_Base.h" 12 #include "SkColorSpace_Base.h"
13 #include "SkImageInfo.h" 13 #include "SkImageInfo.h"
14 14
15 class SkColorSpaceXform : SkNoncopyable { 15 class SkColorSpaceXform : SkNoncopyable {
16 public: 16 public:
17 17
18 /** 18 /**
19 * Create an object to handle color space conversions. 19 * Create an object to handle color space conversions.
20 * 20 *
21 * @param srcSpace The encoded color space. 21 * @param srcSpace The encoded color space.
22 * @param dstSpace The destination color space. 22 * @param dstSpace The destination color space.
23 * 23 *
24 */ 24 */
25 static std::unique_ptr<SkColorSpaceXform> New(const sk_sp<SkColorSpace>& src Space, 25 static std::unique_ptr<SkColorSpaceXform> New(const sk_sp<SkColorSpace>& src Space,
26 const sk_sp<SkColorSpace>& dst Space); 26 const sk_sp<SkColorSpace>& dst Space);
27 27
28 enum ColorFormat : uint8_t {
29 kRGBA_8888_ColorFormat,
30 kBGRA_8888_ColorFormat,
31 kRGBA_F16_ColorFormat,
32 kRGBA_F32_ColorFormat,
33 };
34
35 /** 28 /**
36 * Apply the color conversion to a |src| buffer, storing the output in the |dst| buffer. 29 * Apply the color conversion to a |src| buffer, storing the output in the |dst| buffer.
37 * 30 *
38 * @param dst Stored in the format described by |dstColorType| a nd |dstAlphaType| 31 * @param dst Stored in the format described by |dstColorType| and |dstAlphaType|
39 * @param src Stored as RGBA_8888, kUnpremul (note kOpaque is a form of kUnpremul) 32 * @param src Stored as RGBA_8888, kUnpremul (note kOpaque is a fo rm of kUnpremul)
40 * @param len Number of pixels in the buffers 33 * @param len Number of pixels in the buffers
41 * @param dstColorFormat Describes color format of |dst| 34 * @param dstColorType Describes color type of |dst|
42 * @param dstAlphaType Describes alpha type of |dst| 35 * @param dstAlphaType Describes alpha type of |dst|
43 * kUnpremul preserves input alpha values 36 * kUnpremul preserves input alpha values
44 * kPremul performs a premultiplication and also pr eserves alpha values 37 * kPremul performs a premultiplication and also pres erves alpha values
45 * kOpaque optimization hint, |dst| alphas set to 1 38 * kOpaque optimization hint, |dst| alphas set to 1
46 * 39 *
47 */ 40 */
48 virtual void apply(void* dst, const uint32_t* src, int len, ColorFormat dstC olorFormat, 41 virtual void apply(void* dst, const uint32_t* src, int len, SkColorType dstC olorType,
49 SkAlphaType dstAlphaType) const = 0; 42 SkAlphaType dstAlphaType) const = 0;
50 43
51 virtual ~SkColorSpaceXform() {} 44 virtual ~SkColorSpaceXform() {}
52 }; 45 };
53 46
54 enum SrcGamma { 47 enum SrcGamma {
55 kLinear_SrcGamma, 48 kLinear_SrcGamma,
56 kTable_SrcGamma, 49 kTable_SrcGamma,
57 }; 50 };
58 51
59 enum DstGamma { 52 enum DstGamma {
60 kLinear_DstGamma, 53 kLinear_DstGamma,
61 kSRGB_DstGamma, 54 kSRGB_DstGamma,
62 k2Dot2_DstGamma, 55 k2Dot2_DstGamma,
63 kTable_DstGamma, 56 kTable_DstGamma,
64 }; 57 };
65 58
66 enum ColorSpaceMatch { 59 enum ColorSpaceMatch {
67 kNone_ColorSpaceMatch, 60 kNone_ColorSpaceMatch,
68 kGamut_ColorSpaceMatch, 61 kGamut_ColorSpaceMatch,
69 kFull_ColorSpaceMatch, 62 kFull_ColorSpaceMatch,
70 }; 63 };
71 64
72 template <SrcGamma kSrc, DstGamma kDst, ColorSpaceMatch kCSM> 65 template <SrcGamma kSrc, DstGamma kDst, ColorSpaceMatch kCSM>
73 class SkColorSpaceXform_Base : public SkColorSpaceXform { 66 class SkColorSpaceXform_Base : public SkColorSpaceXform {
74 public: 67 public:
75 68
76 void apply(void* dst, const uint32_t* src, int len, ColorFormat dstColorForm at, 69 void apply(void* dst, const uint32_t* src, int len, SkColorType dstColorType ,
77 SkAlphaType dstAlphaType) const override; 70 SkAlphaType dstAlphaType) const override;
78 71
79 static constexpr int kDstGammaTableSize = 1024; 72 static constexpr int kDstGammaTableSize = 1024;
80 73
81 private: 74 private:
82 SkColorSpaceXform_Base(const sk_sp<SkColorSpace>& srcSpace, const SkMatrix44 & srcToDst, 75 SkColorSpaceXform_Base(const sk_sp<SkColorSpace>& srcSpace, const SkMatrix44 & srcToDst,
83 const sk_sp<SkColorSpace>& dstSpace); 76 const sk_sp<SkColorSpace>& dstSpace);
84 77
85 sk_sp<SkColorLookUpTable> fColorLUT; 78 sk_sp<SkColorLookUpTable> fColorLUT;
86 79
87 // Contain pointers into storage or pointers into precomputed tables. 80 // Contain pointers into storage or pointers into precomputed tables.
88 const float* fSrcGammaTables[3]; 81 const float* fSrcGammaTables[3];
89 const uint8_t* fDstGammaTables[3]; 82 const uint8_t* fDstGammaTables[3];
90 SkAutoMalloc fStorage; 83 SkAutoMalloc fStorage;
91 84
92 float fSrcToDst[16]; 85 float fSrcToDst[16];
93 86
94 friend class SkColorSpaceXform; 87 friend class SkColorSpaceXform;
95 friend std::unique_ptr<SkColorSpaceXform> SlowIdentityXform(const sk_sp<SkCo lorSpace>& space); 88 friend std::unique_ptr<SkColorSpaceXform> SlowIdentityXform(const sk_sp<SkCo lorSpace>& space);
96 }; 89 };
97 90
98 // For testing. Bypasses opts for when src and dst color spaces are equal. 91 // For testing. Bypasses opts for when src and dst color spaces are equal.
99 std::unique_ptr<SkColorSpaceXform> SlowIdentityXform(const sk_sp<SkColorSpace>& space); 92 std::unique_ptr<SkColorSpaceXform> SlowIdentityXform(const sk_sp<SkColorSpace>& space);
100 93
101 #endif 94 #endif
OLDNEW
« no previous file with comments | « src/codec/SkWebpCodec.cpp ('k') | src/core/SkColorSpaceXform.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698