summaryrefslogtreecommitdiffstats
path: root/core/jni/android/graphics
diff options
context:
space:
mode:
authorMike Reed <reed@google.com>2010-03-24 10:08:50 -0400
committerMike Reed <reed@google.com>2010-03-24 10:12:35 -0400
commit39f10ec7dac59b5a8bc6f7e5b86846da77c30337 (patch)
tree8e8ac2050786cc693a0e15904887c4e1ccb8521d /core/jni/android/graphics
parent7f49b9e47416808d7ef5de77b4094fd83f50134d (diff)
downloadframeworks_base-39f10ec7dac59b5a8bc6f7e5b86846da77c30337.zip
frameworks_base-39f10ec7dac59b5a8bc6f7e5b86846da77c30337.tar.gz
frameworks_base-39f10ec7dac59b5a8bc6f7e5b86846da77c30337.tar.bz2
If we detect a 9patch chunk, force the config chooser to avoid 565, with its pre-dithering madness
Change-Id: I0a2d1b094ccb16d479524779acec0216dc7a80ee
Diffstat (limited to 'core/jni/android/graphics')
-rw-r--r--core/jni/android/graphics/BitmapFactory.cpp20
1 files changed, 18 insertions, 2 deletions
diff --git a/core/jni/android/graphics/BitmapFactory.cpp b/core/jni/android/graphics/BitmapFactory.cpp
index b6f3997..b41bad0 100644
--- a/core/jni/android/graphics/BitmapFactory.cpp
+++ b/core/jni/android/graphics/BitmapFactory.cpp
@@ -164,8 +164,11 @@ void AutoDecoderCancel::Validate() {
using namespace android;
class NinePatchPeeker : public SkImageDecoder::Peeker {
+ SkImageDecoder* fHost;
public:
- NinePatchPeeker() {
+ NinePatchPeeker(SkImageDecoder* host) {
+ // the host lives longer than we do, so a raw ptr is safe
+ fHost = host;
fPatchIsValid = false;
}
@@ -197,6 +200,19 @@ public:
// fPatch.sizeLeft, fPatch.sizeTop,
// fPatch.sizeRight, fPatch.sizeBottom);
fPatchIsValid = true;
+
+ // now update our host to force index or 32bit config
+ // 'cause we don't want 565 predithered, since as a 9patch, we know
+ // we will be stretched, and therefore we want to dither afterwards.
+ static const SkBitmap::Config gNo565Pref[] = {
+ SkBitmap::kIndex8_Config,
+ SkBitmap::kIndex8_Config,
+ SkBitmap::kARGB_8888_Config,
+ SkBitmap::kARGB_8888_Config,
+ SkBitmap::kARGB_8888_Config,
+ SkBitmap::kARGB_8888_Config,
+ };
+ fHost->setPrefConfigTable(gNo565Pref);
} else {
fPatch = NULL;
}
@@ -364,7 +380,7 @@ static jobject doDecode(JNIEnv* env, SkStream* stream, jobject padding,
decoder->setSampleSize(sampleSize);
decoder->setDitherImage(doDither);
- NinePatchPeeker peeker;
+ NinePatchPeeker peeker(decoder);
JavaPixelAllocator javaAllocator(env, reportSizeToVM);
SkBitmap* bitmap = new SkBitmap;
Res_png_9patch dummy9Patch;