diff options
author | commit-bot@chromium.org <commit-bot@chromium.org@2bbb7eff-a529-9590-31e7-b0007b416f81> | 2013-03-19 14:16:31 +0000 |
---|---|---|
committer | commit-bot@chromium.org <commit-bot@chromium.org@2bbb7eff-a529-9590-31e7-b0007b416f81> | 2013-03-19 14:16:31 +0000 |
commit | e4657ed7e1f4ae5b1834b398724c718f21589ca3 (patch) | |
tree | fd069d58be3d489689375039d74e1b93dc05ec3e /include | |
parent | 14c3fc60b2779b5048df0b3a2569a462a298357c (diff) |
Add a macro for querying the byte order of SkPMColor.
R=reed@google.com
Author: bsalomon@google.com
Reviewed By: reed@google.com,epoger@google.com
Review URL: https://chromiumcodereview.appspot.com/12771010
git-svn-id: http://skia.googlecode.com/svn/trunk@8219 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'include')
-rw-r--r-- | include/core/SkPostConfig.h | 22 | ||||
-rw-r--r-- | include/gpu/GrTypes.h | 6 |
2 files changed, 24 insertions, 4 deletions
diff --git a/include/core/SkPostConfig.h b/include/core/SkPostConfig.h index 5390463a33..c75356155b 100644 --- a/include/core/SkPostConfig.h +++ b/include/core/SkPostConfig.h @@ -187,6 +187,28 @@ #endif #endif +/** + * SK_PMCOLOR_BYTE_ORDER can be used to query the byte order of SkPMColor at compile time. The + * relationship between the byte order and shift values depends on machine endianness. If the shift + * order is R=0, G=8, B=16, A=24 then ((char*)&pmcolor)[0] will produce the R channel on a little + * endian machine and the A channel on a big endian machine. Thus, given those shifts values, + * SK_PMCOLOR_BYTE_ORDER(R,G,B,A) will be true on a little endian machine and + * SK_PMCOLOR_BYTE_ORDER(A,B,G,R) will be true on a big endian machine. + */ +#ifdef SK_CPU_BENDIAN + #define SK_PMCOLOR_BYTE_ORDER(C0, C1, C2, C3) \ + (SK_ ## C3 ## 32_SHIFT == 0 && \ + SK_ ## C2 ## 32_SHIFT == 8 && \ + SK_ ## C1 ## 32_SHIFT == 16 && \ + SK_ ## C0 ## 32_SHIFT == 24) +#else + #define SK_PMCOLOR_BYTE_ORDER(C0, C1, C2, C3) \ + (SK_ ## C0 ## 32_SHIFT == 0 && \ + SK_ ## C1 ## 32_SHIFT == 8 && \ + SK_ ## C2 ## 32_SHIFT == 16 && \ + SK_ ## C3 ## 32_SHIFT == 24) +#endif + // stdlib macros #if 0 diff --git a/include/gpu/GrTypes.h b/include/gpu/GrTypes.h index 2ba499aa2d..f0153dfc56 100644 --- a/include/gpu/GrTypes.h +++ b/include/gpu/GrTypes.h @@ -291,11 +291,9 @@ enum GrPixelConfig { #ifndef SK_CPU_LENDIAN #error "Skia gpu currently assumes little endian" #endif -#if 24 == SK_A32_SHIFT && 16 == SK_R32_SHIFT && \ - 8 == SK_G32_SHIFT && 0 == SK_B32_SHIFT +#if SK_PMCOLOR_BYTE_ORDER(B,G,R,A) static const GrPixelConfig kSkia8888_GrPixelConfig = kBGRA_8888_GrPixelConfig; -#elif 24 == SK_A32_SHIFT && 16 == SK_B32_SHIFT && \ - 8 == SK_G32_SHIFT && 0 == SK_R32_SHIFT +#elif SK_PMCOLOR_BYTE_ORDER(R,G,B,A) static const GrPixelConfig kSkia8888_GrPixelConfig = kRGBA_8888_GrPixelConfig; #else #error "SK_*32_SHIFT values must correspond to GL_BGRA or GL_RGBA format." |