aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/utils/mac
diff options
context:
space:
mode:
authorGravatar reed@android.com <reed@android.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2009-07-10 03:33:52 +0000
committerGravatar reed@android.com <reed@android.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2009-07-10 03:33:52 +0000
commit32a4249cbd3ebcb448fb0824afe875cdf9036686 (patch)
tree45987a4dcf0ea45dfeb857ea841c126ab937099b /src/utils/mac
parentdafaf7ac4d89f183dc515907665cdac3e3098466 (diff)
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
Diffstat (limited to 'src/utils/mac')
-rw-r--r--src/utils/mac/SkCreateCGImageRef.cpp21
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