aboutsummaryrefslogtreecommitdiff
path: root/samplecode/SampleDitherBitmap.cpp
diff options
context:
space:
mode:
authorreed@android.com <reed@android.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2009-08-22 03:44:57 +0000
committerreed@android.com <reed@android.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2009-08-22 03:44:57 +0000
commitcafc9f9e80e30fa75ad8a952e7a290e72f211ce7 (patch)
tree1aeea3bf9d1c70f89a3ef09201b5814959582739 /samplecode/SampleDitherBitmap.cpp
parentc41513c4dac51d68570b309ec28a315d974edea7 (diff)
fixes around isOpaque and dithering
- copyTo() now preserves isOpaqueness, and BitmapCopyTest tests it - bitmap shader doesn't claim to have shadespan16 if dithering is on, since its sampler doesn't auto-dither (note that gradients do auto-dither in their 16bit sampler) - blitter setup just relies on the shader to report if its 16bit sampler can be called (allowing gradients to say yes regardless of dither, but bitmaps to say no if dithering is on) git-svn-id: http://skia.googlecode.com/svn/trunk@331 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'samplecode/SampleDitherBitmap.cpp')
-rw-r--r--samplecode/SampleDitherBitmap.cpp27
1 files changed, 23 insertions, 4 deletions
diff --git a/samplecode/SampleDitherBitmap.cpp b/samplecode/SampleDitherBitmap.cpp
index bd604cf84c..35816a213a 100644
--- a/samplecode/SampleDitherBitmap.cpp
+++ b/samplecode/SampleDitherBitmap.cpp
@@ -10,7 +10,7 @@ static SkBitmap make_bitmap() {
SkPMColor* c = ctable->lockColors();
for (int i = 0; i < 256; i++) {
- c[i] = SkPackARGB32(0xFF, 0, 0, i);
+ c[i] = SkPackARGB32(0xFF, i, 0, 0);
}
ctable->unlockColors(true);
bm.setConfig(SkBitmap::kIndex8_Config, 256, 32);
@@ -51,12 +51,31 @@ protected:
canvas->drawColor(0xFFDDDDDD);
}
+ static void setBitmapOpaque(SkBitmap* bm, bool isOpaque) {
+ SkAutoLockPixels alp(*bm); // needed for ctable
+ bm->setIsOpaque(isOpaque);
+ SkColorTable* ctable = bm->getColorTable();
+ if (ctable) {
+ ctable->setIsOpaque(isOpaque);
+ }
+ }
+
static void draw2(SkCanvas* canvas, const SkBitmap& bm) {
SkPaint paint;
-
- canvas->drawBitmap(bm, 0, 0, &paint);
+ SkBitmap bitmap(bm);
+
+ setBitmapOpaque(&bitmap, false);
+ paint.setDither(false);
+ canvas->drawBitmap(bitmap, 0, 0, &paint);
+ paint.setDither(true);
+ canvas->drawBitmap(bitmap, 0, SkIntToScalar(bm.height() + 10), &paint);
+
+ setBitmapOpaque(&bitmap, true);
+ SkScalar x = SkIntToScalar(bm.width() + 10);
+ paint.setDither(false);
+ canvas->drawBitmap(bitmap, x, 0, &paint);
paint.setDither(true);
- canvas->drawBitmap(bm, 0, SkIntToScalar(bm.height() + 10), &paint);
+ canvas->drawBitmap(bitmap, x, SkIntToScalar(bm.height() + 10), &paint);
}
virtual void onDraw(SkCanvas* canvas) {