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

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

Issue 2449243003: Initial implementation of a SkColorSpace_A2B xform (Closed)
Patch Set: fixed compile error on certain trybots related to RVO move-elision Created 4 years, 1 month 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/core/SkColorSpace_A2B.h ('k') | src/core/SkRasterPipeline.h » ('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 SkColorSpace_Base_DEFINED 8 #ifndef SkColorSpace_Base_DEFINED
9 #define SkColorSpace_Base_DEFINED 9 #define SkColorSpace_Base_DEFINED
10 10
11 #include "SkColorLookUpTable.h"
11 #include "SkColorSpace.h" 12 #include "SkColorSpace.h"
12 #include "SkData.h" 13 #include "SkData.h"
13 #include "SkOnce.h" 14 #include "SkOnce.h"
14 #include "SkTemplates.h" 15 #include "SkTemplates.h"
15 16
16 enum SkGammaNamed : uint8_t { 17 enum SkGammaNamed : uint8_t {
17 kLinear_SkGammaNamed, 18 kLinear_SkGammaNamed,
18 kSRGB_SkGammaNamed, 19 kSRGB_SkGammaNamed,
19 k2Dot2Curve_SkGammaNamed, 20 k2Dot2Curve_SkGammaNamed,
20 kNonStandard_SkGammaNamed, 21 kNonStandard_SkGammaNamed,
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after
136 // Objects of this type are sometimes created in a custom fashion using 137 // Objects of this type are sometimes created in a custom fashion using
137 // sk_malloc_throw and therefore must be sk_freed. We overload new to 138 // sk_malloc_throw and therefore must be sk_freed. We overload new to
138 // also call sk_malloc_throw so that memory can be unconditionally released 139 // also call sk_malloc_throw so that memory can be unconditionally released
139 // using sk_free in an overloaded delete. Overloading regular new means we 140 // using sk_free in an overloaded delete. Overloading regular new means we
140 // must also overload placement new. 141 // must also overload placement new.
141 void* operator new(size_t size) { return sk_malloc_throw(size); } 142 void* operator new(size_t size) { return sk_malloc_throw(size); }
142 void* operator new(size_t, void* p) { return p; } 143 void* operator new(size_t, void* p) { return p; }
143 void operator delete(void* p) { sk_free(p); } 144 void operator delete(void* p) { sk_free(p); }
144 }; 145 };
145 146
146 struct SkColorLookUpTable : public SkRefCnt {
147 static constexpr uint8_t kOutputChannels = 3;
148
149 uint8_t fInputChannels;
150 uint8_t fGridPoints[3];
151
152 const float* table() const {
153 return SkTAddOffset<const float>(this, sizeof(SkColorLookUpTable));
154 }
155
156 SkColorLookUpTable(uint8_t inputChannels, uint8_t gridPoints[3])
157 : fInputChannels(inputChannels)
158 {
159 SkASSERT(3 == inputChannels);
160 memcpy(fGridPoints, gridPoints, 3 * sizeof(uint8_t));
161 }
162
163 // Objects of this type are created in a custom fashion using sk_malloc_thro w
164 // and therefore must be sk_freed.
165 void* operator new(size_t size) = delete;
166 void* operator new(size_t, void* p) { return p; }
167 void operator delete(void* p) { sk_free(p); }
168 };
169
170 class SkColorSpace_Base : public SkColorSpace { 147 class SkColorSpace_Base : public SkColorSpace {
171 public: 148 public:
172 149
173 /** 150 /**
174 * Describes color space gamut as a transformation to XYZ D50. 151 * Describes color space gamut as a transformation to XYZ D50.
175 * Returns nullptr if color gamut cannot be described in terms of XYZ D50. 152 * Returns nullptr if color gamut cannot be described in terms of XYZ D50.
176 */ 153 */
177 virtual const SkMatrix44* toXYZD50() const = 0; 154 virtual const SkMatrix44* toXYZD50() const = 0;
178 155
179 /** 156 /**
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
247 224
248 static inline const SkColorSpace_Base* as_CSB(const SkColorSpace* colorSpace) { 225 static inline const SkColorSpace_Base* as_CSB(const SkColorSpace* colorSpace) {
249 return static_cast<const SkColorSpace_Base*>(colorSpace); 226 return static_cast<const SkColorSpace_Base*>(colorSpace);
250 } 227 }
251 228
252 static inline SkColorSpace_Base* as_CSB(const sk_sp<SkColorSpace>& colorSpace) { 229 static inline SkColorSpace_Base* as_CSB(const sk_sp<SkColorSpace>& colorSpace) {
253 return static_cast<SkColorSpace_Base*>(colorSpace.get()); 230 return static_cast<SkColorSpace_Base*>(colorSpace.get());
254 } 231 }
255 232
256 #endif 233 #endif
OLDNEW
« no previous file with comments | « src/core/SkColorSpace_A2B.h ('k') | src/core/SkRasterPipeline.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698