From af28dc6030ebb3007f7968b3d5d16637284d254a Mon Sep 17 00:00:00 2001 From: halcanary Date: Thu, 21 Aug 2014 06:30:11 -0700 Subject: [PATCH] Make SkPMColorAssert a macro (all assert-like functions should be macros). R=reed@google.com Author: halcanary@google.com Review URL: https://codereview.chromium.org/494863003 --- include/core/SkColorPriv.h | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/include/core/SkColorPriv.h b/include/core/SkColorPriv.h index 6f23f9be14..c8d71a5a8c 100644 --- a/include/core/SkColorPriv.h +++ b/include/core/SkColorPriv.h @@ -345,17 +345,15 @@ static inline void SkBlendRGB16(const uint16_t src[], uint16_t dst[], #define SkB32Assert(b) SkASSERT((unsigned)(b) <= SK_B32_MASK) #ifdef SK_DEBUG - static inline void SkPMColorAssert(SkPMColor c) { - unsigned a = SkGetPackedA32(c); - unsigned r = SkGetPackedR32(c); - unsigned g = SkGetPackedG32(c); - unsigned b = SkGetPackedB32(c); - - SkA32Assert(a); - SkASSERT(r <= a); - SkASSERT(g <= a); - SkASSERT(b <= a); - } + #define SkPMColorAssert(color_value) \ + do { \ + SkPMColor pm_color_value = (color_value); \ + uint32_t alpha_color_value = SkGetPackedA32(pm_color_value); \ + SkA32Assert(alpha_color_value); \ + SkASSERT(SkGetPackedR32(pm_color_value) <= alpha_color_value); \ + SkASSERT(SkGetPackedG32(pm_color_value) <= alpha_color_value); \ + SkASSERT(SkGetPackedB32(pm_color_value) <= alpha_color_value); \ + } while (false) #else #define SkPMColorAssert(c) #endif