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

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

Issue 2166093003: Miscellaneous color space refactors (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Tweak SkColorLookUpTable constructor Created 4 years, 5 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/core/SkColorSpaceXform.cpp ('k') | src/core/SkColorSpace_ICC.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 SkColorSpace_Base_DEFINED 8 #ifndef SkColorSpace_Base_DEFINED
9 #define SkColorSpace_Base_DEFINED 9 #define SkColorSpace_Base_DEFINED
10 10
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after
122 // sk_malloc_throw and therefore must be sk_freed. We overload new to 122 // sk_malloc_throw and therefore must be sk_freed. We overload new to
123 // also call sk_malloc_throw so that memory can be unconditionally released 123 // also call sk_malloc_throw so that memory can be unconditionally released
124 // using sk_free in an overloaded delete. Overloading regular new means we 124 // using sk_free in an overloaded delete. Overloading regular new means we
125 // must also overload placement new. 125 // must also overload placement new.
126 void* operator new(size_t size) { return sk_malloc_throw(size); } 126 void* operator new(size_t size) { return sk_malloc_throw(size); }
127 void* operator new(size_t, void* p) { return p; } 127 void* operator new(size_t, void* p) { return p; }
128 void operator delete(void* p) { sk_free(p); } 128 void operator delete(void* p) { sk_free(p); }
129 }; 129 };
130 130
131 struct SkColorLookUpTable : public SkRefCnt { 131 struct SkColorLookUpTable : public SkRefCnt {
132 static constexpr uint8_t kOutputChannels = 3;
133
132 uint8_t fInputChannels; 134 uint8_t fInputChannels;
mtklein 2016/07/21 19:46:45 Is this one ever going to be not 3?
msarett 2016/07/21 19:49:28 Once we support CMYK, yes. That's why I'm letting
133 uint8_t fOutputChannels;
134 uint8_t fGridPoints[3]; 135 uint8_t fGridPoints[3];
135 std::unique_ptr<float[]> fTable;
136 136
137 SkColorLookUpTable() 137 const float* table() const {
138 : fInputChannels(0) 138 return SkTAddOffset<const float>(this, sizeof(SkColorLookUpTable));
139 , fOutputChannels(0) 139 }
140 , fTable(nullptr) 140
141 SkColorLookUpTable(uint8_t inputChannels, uint8_t gridPoints[3])
142 : fInputChannels(inputChannels)
141 { 143 {
142 fGridPoints[0] = fGridPoints[1] = fGridPoints[2] = 0; 144 SkASSERT(3 == inputChannels);
145 memcpy(fGridPoints, gridPoints, 3 * sizeof(uint8_t));
mtklein 2016/07/21 19:46:45 a.k.a, 3
msarett 2016/07/21 19:49:28 True.
143 } 146 }
147
148 // Objects of this type are created in a custom fashion using sk_malloc_thro w
149 // and therefore must be sk_freed.
150 void* operator new(size_t size) = delete;
151 void* operator new(size_t, void* p) { return p; }
152 void operator delete(void* p) { sk_free(p); }
144 }; 153 };
145 154
146 class SkColorSpace_Base : public SkColorSpace { 155 class SkColorSpace_Base : public SkColorSpace {
147 public: 156 public:
148 157
149 static sk_sp<SkColorSpace> NewRGB(float gammas[3], const SkMatrix44& toXYZD5 0); 158 static sk_sp<SkColorSpace> NewRGB(float gammas[3], const SkMatrix44& toXYZD5 0);
150 159
151 const SkGammas* gammas() const { return fGammas.get(); } 160 const SkGammas* gammas() const { return fGammas.get(); }
152 161
153 const SkColorLookUpTable* colorLUT() const { return fColorLUT.get(); } 162 const SkColorLookUpTable* colorLUT() const { return fColorLUT.get(); }
(...skipping 27 matching lines...) Expand all
181 190
182 static inline const SkColorSpace_Base* as_CSB(const SkColorSpace* colorSpace) { 191 static inline const SkColorSpace_Base* as_CSB(const SkColorSpace* colorSpace) {
183 return static_cast<const SkColorSpace_Base*>(colorSpace); 192 return static_cast<const SkColorSpace_Base*>(colorSpace);
184 } 193 }
185 194
186 static inline SkColorSpace_Base* as_CSB(const sk_sp<SkColorSpace>& colorSpace) { 195 static inline SkColorSpace_Base* as_CSB(const sk_sp<SkColorSpace>& colorSpace) {
187 return static_cast<SkColorSpace_Base*>(colorSpace.get()); 196 return static_cast<SkColorSpace_Base*>(colorSpace.get());
188 } 197 }
189 198
190 #endif 199 #endif
OLDNEW
« no previous file with comments | « src/core/SkColorSpaceXform.cpp ('k') | src/core/SkColorSpace_ICC.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698