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

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

Issue 494863003: Make SkPMColorAssert a macro (all assert-like functions should be macros). (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 6 years, 4 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 | no next file » | 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 SkColorPriv_DEFINED 8 #ifndef SkColorPriv_DEFINED
9 #define SkColorPriv_DEFINED 9 #define SkColorPriv_DEFINED
10 10
(...skipping 327 matching lines...) Expand 10 before | Expand all | Expand 10 after
338 #define SkGetPackedR32(packed) ((uint32_t)((packed) << (24 - SK_R32_SHIFT)) >> 24) 338 #define SkGetPackedR32(packed) ((uint32_t)((packed) << (24 - SK_R32_SHIFT)) >> 24)
339 #define SkGetPackedG32(packed) ((uint32_t)((packed) << (24 - SK_G32_SHIFT)) >> 24) 339 #define SkGetPackedG32(packed) ((uint32_t)((packed) << (24 - SK_G32_SHIFT)) >> 24)
340 #define SkGetPackedB32(packed) ((uint32_t)((packed) << (24 - SK_B32_SHIFT)) >> 24) 340 #define SkGetPackedB32(packed) ((uint32_t)((packed) << (24 - SK_B32_SHIFT)) >> 24)
341 341
342 #define SkA32Assert(a) SkASSERT((unsigned)(a) <= SK_A32_MASK) 342 #define SkA32Assert(a) SkASSERT((unsigned)(a) <= SK_A32_MASK)
343 #define SkR32Assert(r) SkASSERT((unsigned)(r) <= SK_R32_MASK) 343 #define SkR32Assert(r) SkASSERT((unsigned)(r) <= SK_R32_MASK)
344 #define SkG32Assert(g) SkASSERT((unsigned)(g) <= SK_G32_MASK) 344 #define SkG32Assert(g) SkASSERT((unsigned)(g) <= SK_G32_MASK)
345 #define SkB32Assert(b) SkASSERT((unsigned)(b) <= SK_B32_MASK) 345 #define SkB32Assert(b) SkASSERT((unsigned)(b) <= SK_B32_MASK)
346 346
347 #ifdef SK_DEBUG 347 #ifdef SK_DEBUG
348 static inline void SkPMColorAssert(SkPMColor c) { 348 #define SkPMColorAssert(color_value) \
349 unsigned a = SkGetPackedA32(c); 349 do { \
350 unsigned r = SkGetPackedR32(c); 350 SkPMColor pm_color_value = (color_value); \
351 unsigned g = SkGetPackedG32(c); 351 uint32_t alpha_color_value = SkGetPackedA32(pm_color_value); \
352 unsigned b = SkGetPackedB32(c); 352 SkA32Assert(alpha_color_value); \
353 353 SkASSERT(SkGetPackedR32(pm_color_value) <= alpha_color_value); \
354 SkA32Assert(a); 354 SkASSERT(SkGetPackedG32(pm_color_value) <= alpha_color_value); \
355 SkASSERT(r <= a); 355 SkASSERT(SkGetPackedB32(pm_color_value) <= alpha_color_value); \
356 SkASSERT(g <= a); 356 } while (false)
357 SkASSERT(b <= a);
358 }
359 #else 357 #else
360 #define SkPMColorAssert(c) 358 #define SkPMColorAssert(c)
361 #endif 359 #endif
362 360
363 /** 361 /**
364 * Pack the components into a SkPMColor, checking (in the debug version) that 362 * Pack the components into a SkPMColor, checking (in the debug version) that
365 * the components are 0..255, and are already premultiplied (i.e. alpha >= colo r) 363 * the components are 0..255, and are already premultiplied (i.e. alpha >= colo r)
366 */ 364 */
367 static inline SkPMColor SkPackARGB32(U8CPU a, U8CPU r, U8CPU g, U8CPU b) { 365 static inline SkPMColor SkPackARGB32(U8CPU a, U8CPU r, U8CPU g, U8CPU b) {
368 SkA32Assert(a); 366 SkA32Assert(a);
(...skipping 681 matching lines...) Expand 10 before | Expand all | Expand 10 after
1050 int srcG = SkColorGetG(src); 1048 int srcG = SkColorGetG(src);
1051 int srcB = SkColorGetB(src); 1049 int srcB = SkColorGetB(src);
1052 1050
1053 for (int i = 0; i < width; i++) { 1051 for (int i = 0; i < width; i++) {
1054 dst[i] = SkBlendLCD16Opaque(srcR, srcG, srcB, dst[i], mask[i], 1052 dst[i] = SkBlendLCD16Opaque(srcR, srcG, srcB, dst[i], mask[i],
1055 opaqueDst); 1053 opaqueDst);
1056 } 1054 }
1057 } 1055 }
1058 1056
1059 #endif 1057 #endif
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698