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

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

Issue 203993002: hide Config8888 entirely (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: Created 6 years, 9 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 | Annotate | Revision Log
OLDNEW
1
2 /* 1 /*
3 * Copyright 2006 The Android Open Source Project 2 * Copyright 2006 The Android Open Source Project
4 * 3 *
5 * 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
6 * found in the LICENSE file. 5 * found in the LICENSE file.
7 */ 6 */
8 7
9
10 #ifndef SkColorPriv_DEFINED 8 #ifndef SkColorPriv_DEFINED
11 #define SkColorPriv_DEFINED 9 #define SkColorPriv_DEFINED
12 10
13 // turn this own for extra debug checking when blending onto 565 11 // turn this own for extra debug checking when blending onto 565
14 #ifdef SK_DEBUG 12 #ifdef SK_DEBUG
15 #define CHECK_FOR_565_OVERFLOW 13 #define CHECK_FOR_565_OVERFLOW
16 #endif 14 #endif
17 15
18 #include "SkColor.h" 16 #include "SkColor.h"
19 #include "SkMath.h" 17 #include "SkMath.h"
20 18
19 //////////////////////////////////////////////////////////////////////////////
20
21 #define SkASSERT_IS_BYTE(x) SkASSERT(0 == ((x) & 0xFF))
bsalomon 2014/03/19 12:36:48 Isn't this asserting that the lower 8 are zero?
reed1 2014/03/19 17:59:58 Doh!
22
23 /*
24 * Skia's 32bit backend only supports 1 sizzle order at a time (compile-time).
25 * This is specified by 4 defines SK_A32_SHIFT, SK_R32_SHIFT, ... for G and B.
26 *
27 * For easier compatibility with Skia's GPU backend, we further restrict these
28 * to either (in memory-byte-order) RGBA or BGRA. Note that this "order" does
29 * not directly correspond to the same shift-order, since we have to take endia ness
30 * into account.
31 *
32 * Here we enforce this constraint.
33 */
34
35 #ifdef SK_CPU_BENDIAN
36 #define SK_RGBA_R32_SHIFT 24
37 #define SK_RGBA_G32_SHIFT 16
38 #define SK_RGBA_B32_SHIFT 8
39 #define SK_RGBA_A32_SHIFT 0
40
41 #define SK_BGRA_B32_SHIFT 24
42 #define SK_BGRA_G32_SHIFT 16
43 #define SK_BGRA_R32_SHIFT 8
44 #define SK_BGRA_A32_SHIFT 0
45 #else
46 #define SK_RGBA_R32_SHIFT 0
47 #define SK_RGBA_G32_SHIFT 8
48 #define SK_RGBA_B32_SHIFT 16
49 #define SK_RGBA_A32_SHIFT 24
50
51 #define SK_BGRA_B32_SHIFT 0
52 #define SK_BGRA_G32_SHIFT 8
53 #define SK_BGRA_R32_SHIFT 16
54 #define SK_BGRA_A32_SHIFT 24
55 #endif
56
57 // Now we check that we are in a support shift-order
58
59 #if SK_A32_SHIFT == SK_RGBA_A32_SHIFT && \
60 SK_R32_SHIFT == SK_RGBA_R32_SHIFT && \
61 SK_G32_SHIFT == SK_RGBA_G32_SHIFT && \
62 SK_B32_SHIFT == SK_RGBA_B32_SHIFT
63 #define SK_PMCOLOR_IS_RGBA
bsalomon 2014/03/19 12:36:48 It'd be nice to allow the user (SkUserConfig.h, gy
reed1 2014/03/19 17:59:58 I can try adding checks now that if they've specif
64 #elif SK_A32_SHIFT == SK_BGRA_A32_SHIFT && \
65 SK_R32_SHIFT == SK_BGRA_R32_SHIFT && \
66 SK_G32_SHIFT == SK_BGRA_G32_SHIFT && \
67 SK_B32_SHIFT == SK_BGRA_B32_SHIFT
68 #define SK_PMCOLOR_IS_BGRA
69 #else
70 #error "need 32bit packing to be either RGBA or BGRA"
71 #endif
72
73 static inline uint32_t SkPackARGB_as_RGBA(U8CPU a, U8CPU r, U8CPU g, U8CPU b) {
74 SkASSERT_IS_BYTE(a);
75 SkASSERT_IS_BYTE(r);
76 SkASSERT_IS_BYTE(g);
77 SkASSERT_IS_BYTE(b);
78 return (a << SK_RGBA_A32_SHIFT) | (r << SK_RGBA_R32_SHIFT) |
79 (g << SK_RGBA_G32_SHIFT) | (b << SK_RGBA_B32_SHIFT);
80 }
81
82 static inline uint32_t SkPackARGB_as_BGRA(U8CPU a, U8CPU r, U8CPU g, U8CPU b) {
83 SkASSERT_IS_BYTE(a);
84 SkASSERT_IS_BYTE(r);
85 SkASSERT_IS_BYTE(g);
86 SkASSERT_IS_BYTE(b);
87 return (a << SK_BGRA_A32_SHIFT) | (r << SK_BGRA_R32_SHIFT) |
88 (g << SK_BGRA_G32_SHIFT) | (b << SK_BGRA_B32_SHIFT);
89 }
90
91 //////////////////////////////////////////////////////////////////////////////
92
21 ///@{ 93 ///@{
22 /** See ITU-R Recommendation BT.709 at http://www.itu.int/rec/R-REC-BT.709/ .*/ 94 /** See ITU-R Recommendation BT.709 at http://www.itu.int/rec/R-REC-BT.709/ .*/
23 #define SK_ITU_BT709_LUM_COEFF_R (0.2126f) 95 #define SK_ITU_BT709_LUM_COEFF_R (0.2126f)
24 #define SK_ITU_BT709_LUM_COEFF_G (0.7152f) 96 #define SK_ITU_BT709_LUM_COEFF_G (0.7152f)
25 #define SK_ITU_BT709_LUM_COEFF_B (0.0722f) 97 #define SK_ITU_BT709_LUM_COEFF_B (0.0722f)
26 ///@} 98 ///@}
27 99
28 ///@{ 100 ///@{
29 /** A float value which specifies this channel's contribution to luminance. */ 101 /** A float value which specifies this channel's contribution to luminance. */
30 #define SK_LUM_COEFF_R SK_ITU_BT709_LUM_COEFF_R 102 #define SK_LUM_COEFF_R SK_ITU_BT709_LUM_COEFF_R
(...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after
232 static inline SkPMColor SkPackARGB32(U8CPU a, U8CPU r, U8CPU g, U8CPU b) { 304 static inline SkPMColor SkPackARGB32(U8CPU a, U8CPU r, U8CPU g, U8CPU b) {
233 SkA32Assert(a); 305 SkA32Assert(a);
234 SkASSERT(r <= a); 306 SkASSERT(r <= a);
235 SkASSERT(g <= a); 307 SkASSERT(g <= a);
236 SkASSERT(b <= a); 308 SkASSERT(b <= a);
237 309
238 return (a << SK_A32_SHIFT) | (r << SK_R32_SHIFT) | 310 return (a << SK_A32_SHIFT) | (r << SK_R32_SHIFT) |
239 (g << SK_G32_SHIFT) | (b << SK_B32_SHIFT); 311 (g << SK_G32_SHIFT) | (b << SK_B32_SHIFT);
240 } 312 }
241 313
314 static inline uint32_t SkPackPMColor_as_RGBA(SkPMColor c) {
315 return SkPackARGB_as_RGBA(SkGetPackedA32(c), SkGetPackedR32(c),
316 SkGetPackedG32(c), SkGetPackedB32(c));
317 }
318
319 static inline uint32_t SkPackPMColor_as_BGRA(SkPMColor c) {
320 return SkPackARGB_as_BGRA(SkGetPackedA32(c), SkGetPackedR32(c),
321 SkGetPackedG32(c), SkGetPackedB32(c));
322 }
323
242 /** 324 /**
243 * Abstract 4-byte interpolation, implemented on top of SkPMColor 325 * Abstract 4-byte interpolation, implemented on top of SkPMColor
244 * utility functions. Third parameter controls blending of the first two: 326 * utility functions. Third parameter controls blending of the first two:
245 * (src, dst, 0) returns dst 327 * (src, dst, 0) returns dst
246 * (src, dst, 0xFF) returns src 328 * (src, dst, 0xFF) returns src
247 * srcWeight is [0..256], unlike SkFourByteInterp which takes [0..255] 329 * srcWeight is [0..256], unlike SkFourByteInterp which takes [0..255]
248 */ 330 */
249 static inline SkPMColor SkFourByteInterp256(SkPMColor src, SkPMColor dst, 331 static inline SkPMColor SkFourByteInterp256(SkPMColor src, SkPMColor dst,
250 unsigned scale) { 332 unsigned scale) {
251 unsigned a = SkAlphaBlend(SkGetPackedA32(src), SkGetPackedA32(dst), scale); 333 unsigned a = SkAlphaBlend(SkGetPackedA32(src), SkGetPackedA32(dst), scale);
(...skipping 655 matching lines...) Expand 10 before | Expand all | Expand 10 after
907 int srcG = SkColorGetG(src); 989 int srcG = SkColorGetG(src);
908 int srcB = SkColorGetB(src); 990 int srcB = SkColorGetB(src);
909 991
910 for (int i = 0; i < width; i++) { 992 for (int i = 0; i < width; i++) {
911 dst[i] = SkBlendLCD16Opaque(srcR, srcG, srcB, dst[i], mask[i], 993 dst[i] = SkBlendLCD16Opaque(srcR, srcG, srcB, dst[i], mask[i],
912 opaqueDst); 994 opaqueDst);
913 } 995 }
914 } 996 }
915 997
916 #endif 998 #endif
OLDNEW
« no previous file with comments | « include/core/SkCanvas.h ('k') | include/core/SkDevice.h » ('j') | src/core/SkConfig8888.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698