make a deep copy in CreateCGImageRef if we're 565, but first upscale to 32bit.
this at least draws the right colors, since we're 565 and CG only supports 1555
(unless someone knows how to tell CG we're 565...)
Fix ws in picturerecord
Enable dither in sample gradients, so the 4444 case isn't so ugly
git-svn-id: http://skia.googlecode.com/svn/trunk@264 2bbb7eff-a529-9590-31e7-b0007b416f81
diff --git a/src/utils/mac/SkCreateCGImageRef.cpp b/src/utils/mac/SkCreateCGImageRef.cpp
index be53f00..5c96e21 100644
--- a/src/utils/mac/SkCreateCGImageRef.cpp
+++ b/src/utils/mac/SkCreateCGImageRef.cpp
@@ -16,12 +16,12 @@
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 @@
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 @@
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