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

Unified 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: include/core/SkColorPriv.h
diff --git a/include/core/SkColorPriv.h b/include/core/SkColorPriv.h
index 6f23f9be149816ccea0f290cfb9b05756e3b016e..c8d71a5a8c21c22c5cdb81caca94b2be44208a0b 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
« 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