diff options
Diffstat (limited to 'skia/ext/skia_utils_mac.mm')
-rw-r--r-- | skia/ext/skia_utils_mac.mm | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/skia/ext/skia_utils_mac.mm b/skia/ext/skia_utils_mac.mm index 6880ea8..463fd52 100644 --- a/skia/ext/skia_utils_mac.mm +++ b/skia/ext/skia_utils_mac.mm @@ -127,11 +127,20 @@ SkBitmap NSImageToSkBitmap(NSImage* image, NSSize size, bool is_opaque) { // Allocate a bitmap context with 4 components per pixel (BGRA). Apple // recommends these flags for improved CG performance. +#define HAS_ARGB_SHIFTS(a, r, g, b) \ + (SK_A32_SHIFT == (a) && SK_R32_SHIFT == (r) \ + && SK_G32_SHIFT == (g) && SK_B32_SHIFT == (b)) +#if defined(SK_CPU_LENDIAN) && HAS_ARGB_SHIFTS(24, 16, 8, 0) scoped_cftyperef<CGContextRef> context( CGBitmapContextCreate(data, size.width, size.height, 8, size.width*4, color_space, kCGImageAlphaPremultipliedFirst | kCGBitmapByteOrder32Host)); +#else +#error We require that Skia's and CoreGraphics's recommended \ + image memory layout match. +#endif +#undef HAS_ARGB_SHIFTS // Something went really wrong. Best guess is that the bitmap data is invalid. DCHECK(context != NULL); |