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

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

Issue 85463005: remove SkFloatToScalar macro (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: add flag to expose SkFloatToScalar to chromium Created 7 years 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 | Annotate | Revision Log
« no previous file with comments | « src/core/SkLineClipper.cpp ('k') | src/core/SkMaskGamma.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 2012 Google Inc. 2 * Copyright 2012 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 SkMaskGamma_DEFINED 8 #ifndef SkMaskGamma_DEFINED
9 #define SkMaskGamma_DEFINED 9 #define SkMaskGamma_DEFINED
10 10
(...skipping 17 matching lines...) Expand all
28 virtual SkScalar toLuma(SkScalar gamma, SkScalar luminance) const = 0; 28 virtual SkScalar toLuma(SkScalar gamma, SkScalar luminance) const = 0;
29 /** Converts a linear luma to a color component luminance in the color space . */ 29 /** Converts a linear luma to a color component luminance in the color space . */
30 virtual SkScalar fromLuma(SkScalar gamma, SkScalar luma) const = 0; 30 virtual SkScalar fromLuma(SkScalar gamma, SkScalar luma) const = 0;
31 31
32 /** Converts a color to a luminance value. */ 32 /** Converts a color to a luminance value. */
33 static U8CPU computeLuminance(SkScalar gamma, SkColor c) { 33 static U8CPU computeLuminance(SkScalar gamma, SkColor c) {
34 const SkColorSpaceLuminance& luminance = Fetch(gamma); 34 const SkColorSpaceLuminance& luminance = Fetch(gamma);
35 SkScalar r = luminance.toLuma(gamma, SkIntToScalar(SkColorGetR(c)) / 255 ); 35 SkScalar r = luminance.toLuma(gamma, SkIntToScalar(SkColorGetR(c)) / 255 );
36 SkScalar g = luminance.toLuma(gamma, SkIntToScalar(SkColorGetG(c)) / 255 ); 36 SkScalar g = luminance.toLuma(gamma, SkIntToScalar(SkColorGetG(c)) / 255 );
37 SkScalar b = luminance.toLuma(gamma, SkIntToScalar(SkColorGetB(c)) / 255 ); 37 SkScalar b = luminance.toLuma(gamma, SkIntToScalar(SkColorGetB(c)) / 255 );
38 SkScalar luma = r * SkFloatToScalar(SK_LUM_COEFF_R) + 38 SkScalar luma = r * SK_LUM_COEFF_R +
39 g * SkFloatToScalar(SK_LUM_COEFF_G) + 39 g * SK_LUM_COEFF_G +
40 b * SkFloatToScalar(SK_LUM_COEFF_B); 40 b * SK_LUM_COEFF_B;
41 SkASSERT(luma <= SK_Scalar1); 41 SkASSERT(luma <= SK_Scalar1);
42 return SkScalarRoundToInt(luminance.fromLuma(gamma, luma) * 255); 42 return SkScalarRoundToInt(luminance.fromLuma(gamma, luma) * 255);
43 } 43 }
44 44
45 /** Retrieves the SkColorSpaceLuminance for the given gamma. */ 45 /** Retrieves the SkColorSpaceLuminance for the given gamma. */
46 static const SkColorSpaceLuminance& Fetch(SkScalar gamma); 46 static const SkColorSpaceLuminance& Fetch(SkScalar gamma);
47 }; 47 };
48 48
49 ///@{ 49 ///@{
50 /** 50 /**
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after
212 */ 212 */
213 template<bool APPLY_LUT> static inline U8CPU sk_apply_lut_if(U8CPU component, co nst uint8_t*) { 213 template<bool APPLY_LUT> static inline U8CPU sk_apply_lut_if(U8CPU component, co nst uint8_t*) {
214 return component; 214 return component;
215 } 215 }
216 template<> /*static*/ inline U8CPU sk_apply_lut_if<true>(U8CPU component, const uint8_t* lut) { 216 template<> /*static*/ inline U8CPU sk_apply_lut_if<true>(U8CPU component, const uint8_t* lut) {
217 return lut[component]; 217 return lut[component];
218 } 218 }
219 ///@} 219 ///@}
220 220
221 #endif 221 #endif
OLDNEW
« no previous file with comments | « src/core/SkLineClipper.cpp ('k') | src/core/SkMaskGamma.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698