OLD | NEW |
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 351 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
362 uint32_t alpha_color_value = SkGetPackedA32(pm_color_value); \ | 362 uint32_t alpha_color_value = SkGetPackedA32(pm_color_value); \ |
363 SkA32Assert(alpha_color_value); \ | 363 SkA32Assert(alpha_color_value); \ |
364 SkASSERT(SkGetPackedR32(pm_color_value) <= alpha_color_value); \ | 364 SkASSERT(SkGetPackedR32(pm_color_value) <= alpha_color_value); \ |
365 SkASSERT(SkGetPackedG32(pm_color_value) <= alpha_color_value); \ | 365 SkASSERT(SkGetPackedG32(pm_color_value) <= alpha_color_value); \ |
366 SkASSERT(SkGetPackedB32(pm_color_value) <= alpha_color_value); \ | 366 SkASSERT(SkGetPackedB32(pm_color_value) <= alpha_color_value); \ |
367 } while (false) | 367 } while (false) |
368 #else | 368 #else |
369 #define SkPMColorAssert(c) | 369 #define SkPMColorAssert(c) |
370 #endif | 370 #endif |
371 | 371 |
| 372 static inline bool SkPMColorValid(SkPMColor c) { |
| 373 auto a = SkGetPackedA32(c); |
| 374 bool valid = a <= SK_A32_MASK |
| 375 && SkGetPackedR32(c) <= a |
| 376 && SkGetPackedG32(c) <= a |
| 377 && SkGetPackedB32(c) <= a; |
| 378 if (valid) { |
| 379 SkPMColorAssert(c); // Make sure we're consistent when it counts. |
| 380 } |
| 381 return valid; |
| 382 } |
| 383 |
372 /** | 384 /** |
373 * Pack the components into a SkPMColor, checking (in the debug version) that | 385 * Pack the components into a SkPMColor, checking (in the debug version) that |
374 * the components are 0..255, and are already premultiplied (i.e. alpha >= colo
r) | 386 * the components are 0..255, and are already premultiplied (i.e. alpha >= colo
r) |
375 */ | 387 */ |
376 static inline SkPMColor SkPackARGB32(U8CPU a, U8CPU r, U8CPU g, U8CPU b) { | 388 static inline SkPMColor SkPackARGB32(U8CPU a, U8CPU r, U8CPU g, U8CPU b) { |
377 SkA32Assert(a); | 389 SkA32Assert(a); |
378 SkASSERT(r <= a); | 390 SkASSERT(r <= a); |
379 SkASSERT(g <= a); | 391 SkASSERT(g <= a); |
380 SkASSERT(b <= a); | 392 SkASSERT(b <= a); |
381 | 393 |
(...skipping 649 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1031 int srcG = SkColorGetG(src); | 1043 int srcG = SkColorGetG(src); |
1032 int srcB = SkColorGetB(src); | 1044 int srcB = SkColorGetB(src); |
1033 | 1045 |
1034 for (int i = 0; i < width; i++) { | 1046 for (int i = 0; i < width; i++) { |
1035 dst[i] = SkBlendLCD16Opaque(srcR, srcG, srcB, dst[i], mask[i], | 1047 dst[i] = SkBlendLCD16Opaque(srcR, srcG, srcB, dst[i], mask[i], |
1036 opaqueDst); | 1048 opaqueDst); |
1037 } | 1049 } |
1038 } | 1050 } |
1039 | 1051 |
1040 #endif | 1052 #endif |
OLD | NEW |