diff options
Diffstat (limited to 'src/utils/mac')
-rw-r--r-- | src/utils/mac/SkCreateCGImageRef.cpp | 21 |
1 files changed, 16 insertions, 5 deletions
diff --git a/src/utils/mac/SkCreateCGImageRef.cpp b/src/utils/mac/SkCreateCGImageRef.cpp index be53f00040..5c96e21ff6 100644 --- a/src/utils/mac/SkCreateCGImageRef.cpp +++ b/src/utils/mac/SkCreateCGImageRef.cpp @@ -16,12 +16,12 @@ static void SkBitmap_ReleaseInfo(void* info, const void* pixelData, size_t size) static SkBitmap* prepareForImageRef(const SkBitmap& bm, size_t* bitsPerComponent, CGBitmapInfo* info) { -#if 0 - SkDebugf("---- %d %d %d %d\n", SK_A32_SHIFT, SK_R32_SHIFT, - SK_G32_SHIFT, SK_B32_SHIFT); -#endif + bool upscaleTo32 = false; switch (bm.config()) { + case SkBitmap::kRGB_565_Config: + upscaleTo32 = true; + // fall through case SkBitmap::kARGB_8888_Config: *bitsPerComponent = 8; #if defined(SK_CPU_LENDIAN) && HAS_ARGB_SHIFTS(24, 0, 8, 16) \ @@ -44,11 +44,13 @@ static SkBitmap* prepareForImageRef(const SkBitmap& bm, kCGImageAlphaPremultipliedLast; #endif break; +#if 0 case SkBitmap::kRGB_565_Config: // doesn't see quite right. Are they thinking 1555? *bitsPerComponent = 5; *info = kCGBitmapByteOrder16Little; break; +#endif case SkBitmap::kARGB_4444_Config: *bitsPerComponent = 4; *info = kCGBitmapByteOrder16Little | kCGImageAlphaPremultipliedLast; @@ -57,7 +59,16 @@ static SkBitmap* prepareForImageRef(const SkBitmap& bm, return NULL; } - return new SkBitmap(bm); + SkBitmap* copy; + if (upscaleTo32) { + copy = new SkBitmap; + // here we make a ceep copy of the pixels, since CG won't take our + // 565 directly + bm.copyTo(copy, SkBitmap::kARGB_8888_Config); + } else { + copy = new SkBitmap(bm); + } + return copy; } #undef HAS_ARGB_SHIFTS |