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

Side by Side Diff: include/core/SkColor.h

Issue 1622483002: Revert[2] of float color components (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: fix inversion of unpremul check Created 4 years, 11 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 | « no previous file | include/core/SkColorFilter.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 2006 The Android Open Source Project 2 * Copyright 2006 The Android Open Source Project
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 SkColor_DEFINED 8 #ifndef SkColor_DEFINED
9 #define SkColor_DEFINED 9 #define SkColor_DEFINED
10 10
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after
153 /** Return a SkPMColor value from a SkColor value. This is done by multiplying t he color 153 /** Return a SkPMColor value from a SkColor value. This is done by multiplying t he color
154 components by the color's alpha, and by arranging the bytes in a configurati on 154 components by the color's alpha, and by arranging the bytes in a configurati on
155 dependent order, to match the format of kARGB32 bitmaps. 155 dependent order, to match the format of kARGB32 bitmaps.
156 */ 156 */
157 SK_API SkPMColor SkPreMultiplyColor(SkColor c); 157 SK_API SkPMColor SkPreMultiplyColor(SkColor c);
158 158
159 /** Define a function pointer type for combining two premultiplied colors 159 /** Define a function pointer type for combining two premultiplied colors
160 */ 160 */
161 typedef SkPMColor (*SkXfermodeProc)(SkPMColor src, SkPMColor dst); 161 typedef SkPMColor (*SkXfermodeProc)(SkPMColor src, SkPMColor dst);
162 162
163 //////////////////////////////////////////////////////////////////////////////// ///////////////////
164
165 /*
166 * The float values are 0...1 premultiplied
167 */
168 struct SK_ATTRIBUTE(aligned(16)) SkPM4f {
169 float fVec[4];
170
171 float a() const { return fVec[SK_A32_SHIFT/8]; }
172 };
173
174 /*
175 * The float values are 0...1 unpremultiplied
176 */
177 struct SkColor4f {
178 float fA;
179 float fR;
180 float fG;
181 float fB;
182
183 bool operator==(const SkColor4f& other) const {
184 return fA == other.fA && fR == other.fR && fG == other.fG && fB == other .fB;
185 }
186 bool operator!=(const SkColor4f& other) const {
187 return !(*this == other);
188 }
189
190 const float* vec() const { return &fA; }
191 float* vec() { return &fA; }
192
193 static SkColor4f Pin(float a, float r, float g, float b);
194 static SkColor4f FromColor(SkColor);
195
196 SkColor4f pin() const {
197 return Pin(fA, fR, fG, fB);
198 }
199
200 SkPM4f premul() const;
201 };
202
163 #endif 203 #endif
OLDNEW
« no previous file with comments | « no previous file | include/core/SkColorFilter.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698