diff --git a/samplecode/SampleGradients.cpp b/samplecode/SampleGradients.cpp index f8fa042d0d..dff96baad7 100644 --- a/samplecode/SampleGradients.cpp +++ b/samplecode/SampleGradients.cpp @@ -118,6 +118,7 @@ protected: SkRect r = { 0, 0, SkIntToScalar(100), SkIntToScalar(100) }; SkPaint paint; paint.setAntiAlias(true); + paint.setDither(true); canvas->save(); canvas->translate(SkIntToScalar(20), SkIntToScalar(20)); diff --git a/src/core/SkPictureRecord.cpp b/src/core/SkPictureRecord.cpp index 5c00ab9bfe..c7f2c6c041 100644 --- a/src/core/SkPictureRecord.cpp +++ b/src/core/SkPictureRecord.cpp @@ -63,7 +63,7 @@ void SkPictureRecord::restore() { *peek = restoreOffset; } fRestoreOffsetStack.pop(); - + addDraw(RESTORE); validate(); return this->INHERITED::restore(); 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