am d68781ac: Merge change 24675 into eclair
Merge commit 'd68781ace179e19b70120411baf307104683fa4b' into eclair-plus-aosp * commit 'd68781ace179e19b70120411baf307104683fa4b': change default for dither to true
This commit is contained in:
@@ -107,6 +107,13 @@ void NinePatch_Draw(SkCanvas* canvas, const SkRect& bounds,
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
SkPaint defaultPaint;
|
||||||
|
if (NULL == paint) {
|
||||||
|
// matches default dither in NinePatchDrawable.java.
|
||||||
|
defaultPaint.setDither(true);
|
||||||
|
paint = &defaultPaint;
|
||||||
|
}
|
||||||
|
|
||||||
// if our canvas is GL, draw this as a mesh, which will be faster than
|
// if our canvas is GL, draw this as a mesh, which will be faster than
|
||||||
// in parts (which is faster for raster)
|
// in parts (which is faster for raster)
|
||||||
if (canvas && canvas->getViewport(NULL)) {
|
if (canvas && canvas->getViewport(NULL)) {
|
||||||
@@ -158,11 +165,6 @@ void NinePatch_Draw(SkCanvas* canvas, const SkRect& bounds,
|
|||||||
if (bitmap.getPixels() == NULL)
|
if (bitmap.getPixels() == NULL)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
SkPaint defaultPaint;
|
|
||||||
if (NULL == paint) {
|
|
||||||
paint = &defaultPaint;
|
|
||||||
}
|
|
||||||
|
|
||||||
const bool hasXfer = paint->getXfermode() != NULL;
|
const bool hasXfer = paint->getXfermode() != NULL;
|
||||||
SkRect dst;
|
SkRect dst;
|
||||||
SkIRect src;
|
SkIRect src;
|
||||||
|
|||||||
@@ -56,7 +56,8 @@ import java.io.IOException;
|
|||||||
*/
|
*/
|
||||||
public class BitmapDrawable extends Drawable {
|
public class BitmapDrawable extends Drawable {
|
||||||
|
|
||||||
private static final int DEFAULT_PAINT_FLAGS = Paint.FILTER_BITMAP_FLAG;
|
private static final int DEFAULT_PAINT_FLAGS =
|
||||||
|
Paint.FILTER_BITMAP_FLAG | Paint.DITHER_FLAG;
|
||||||
private BitmapState mBitmapState;
|
private BitmapState mBitmapState;
|
||||||
private Bitmap mBitmap;
|
private Bitmap mBitmap;
|
||||||
private final Rect mDstRect = new Rect(); // Gravity.apply() sets this
|
private final Rect mDstRect = new Rect(); // Gravity.apply() sets this
|
||||||
|
|||||||
@@ -20,11 +20,22 @@ import android.graphics.*;
|
|||||||
|
|
||||||
public class DrawableContainer extends Drawable implements Drawable.Callback {
|
public class DrawableContainer extends Drawable implements Drawable.Callback {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* To be proper, we should have a getter for dither (and alpha, etc.)
|
||||||
|
* so that proxy classes like this can save/restore their delegates'
|
||||||
|
* values, but we don't have getters. Since we do have setters
|
||||||
|
* (e.g. setDither), which this proxy forwards on, we have to have some
|
||||||
|
* default/initial setting.
|
||||||
|
*
|
||||||
|
* The initial setting for dither is now true, since it almost always seems
|
||||||
|
* to improve the quality at negligible cost.
|
||||||
|
*/
|
||||||
|
private static final boolean DEFAULT_DITHER = true;
|
||||||
private DrawableContainerState mDrawableContainerState;
|
private DrawableContainerState mDrawableContainerState;
|
||||||
private Drawable mCurrDrawable;
|
private Drawable mCurrDrawable;
|
||||||
private int mAlpha = 0xFF;
|
private int mAlpha = 0xFF;
|
||||||
private ColorFilter mColorFilter;
|
private ColorFilter mColorFilter;
|
||||||
private boolean mDither;
|
private boolean mDither = DEFAULT_DITHER;
|
||||||
|
|
||||||
private int mCurIndex = -1;
|
private int mCurIndex = -1;
|
||||||
private boolean mMutated;
|
private boolean mMutated;
|
||||||
|
|||||||
@@ -36,6 +36,8 @@ import java.io.InputStream;
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public class NinePatchDrawable extends Drawable {
|
public class NinePatchDrawable extends Drawable {
|
||||||
|
// dithering helps a lot, and is pretty cheap, so default is true
|
||||||
|
private static final boolean DEFAULT_DITHER = true;
|
||||||
private NinePatchState mNinePatchState;
|
private NinePatchState mNinePatchState;
|
||||||
private NinePatch mNinePatch;
|
private NinePatch mNinePatch;
|
||||||
private Rect mPadding;
|
private Rect mPadding;
|
||||||
@@ -101,7 +103,11 @@ public class NinePatchDrawable extends Drawable {
|
|||||||
mNinePatch = state.mNinePatch;
|
mNinePatch = state.mNinePatch;
|
||||||
mPadding = state.mPadding;
|
mPadding = state.mPadding;
|
||||||
mTargetDensity = state.mTargetDensity;
|
mTargetDensity = state.mTargetDensity;
|
||||||
if (state.mDither) setDither(state.mDither);
|
if (DEFAULT_DITHER != state.mDither) {
|
||||||
|
// avoid calling the setter unless we need to, since it does a
|
||||||
|
// lazy allocation of a paint
|
||||||
|
setDither(state.mDither);
|
||||||
|
}
|
||||||
if (mNinePatch != null) {
|
if (mNinePatch != null) {
|
||||||
computeBitmapSize();
|
computeBitmapSize();
|
||||||
}
|
}
|
||||||
@@ -215,7 +221,8 @@ public class NinePatchDrawable extends Drawable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
final boolean dither = a.getBoolean(
|
final boolean dither = a.getBoolean(
|
||||||
com.android.internal.R.styleable.NinePatchDrawable_dither, false);
|
com.android.internal.R.styleable.NinePatchDrawable_dither,
|
||||||
|
DEFAULT_DITHER);
|
||||||
final BitmapFactory.Options options = new BitmapFactory.Options();
|
final BitmapFactory.Options options = new BitmapFactory.Options();
|
||||||
if (dither) {
|
if (dither) {
|
||||||
options.inDither = false;
|
options.inDither = false;
|
||||||
@@ -251,12 +258,10 @@ public class NinePatchDrawable extends Drawable {
|
|||||||
a.recycle();
|
a.recycle();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public Paint getPaint() {
|
public Paint getPaint() {
|
||||||
if (mPaint == null) {
|
if (mPaint == null) {
|
||||||
mPaint = new Paint();
|
mPaint = new Paint();
|
||||||
// dithering helps a lot, and is pretty cheap, so default on
|
mPaint.setDither(DEFAULT_DITHER);
|
||||||
mPaint.setDither(true);
|
|
||||||
}
|
}
|
||||||
return mPaint;
|
return mPaint;
|
||||||
}
|
}
|
||||||
@@ -327,7 +332,7 @@ public class NinePatchDrawable extends Drawable {
|
|||||||
int mTargetDensity = DisplayMetrics.DENSITY_DEFAULT;
|
int mTargetDensity = DisplayMetrics.DENSITY_DEFAULT;
|
||||||
|
|
||||||
NinePatchState(NinePatch ninePatch, Rect padding) {
|
NinePatchState(NinePatch ninePatch, Rect padding) {
|
||||||
this(ninePatch, padding, false);
|
this(ninePatch, padding, DEFAULT_DITHER);
|
||||||
}
|
}
|
||||||
|
|
||||||
NinePatchState(NinePatch ninePatch, Rect rect, boolean dither) {
|
NinePatchState(NinePatch ninePatch, Rect rect, boolean dither) {
|
||||||
|
|||||||
@@ -50,6 +50,17 @@ import android.util.StateSet;
|
|||||||
* @attr ref android.R.styleable#DrawableStates_state_pressed
|
* @attr ref android.R.styleable#DrawableStates_state_pressed
|
||||||
*/
|
*/
|
||||||
public class StateListDrawable extends DrawableContainer {
|
public class StateListDrawable extends DrawableContainer {
|
||||||
|
/**
|
||||||
|
* To be proper, we should have a getter for dither (and alpha, etc.)
|
||||||
|
* so that proxy classes like this can save/restore their delegates'
|
||||||
|
* values, but we don't have getters. Since we do have setters
|
||||||
|
* (e.g. setDither), which this proxy forwards on, we have to have some
|
||||||
|
* default/initial setting.
|
||||||
|
*
|
||||||
|
* The initial setting for dither is now true, since it almost always seems
|
||||||
|
* to improve the quality at negligible cost.
|
||||||
|
*/
|
||||||
|
private static final boolean DEFAULT_DITHER = true;
|
||||||
private final StateListState mStateListState;
|
private final StateListState mStateListState;
|
||||||
private boolean mMutated;
|
private boolean mMutated;
|
||||||
|
|
||||||
@@ -105,7 +116,8 @@ public class StateListDrawable extends DrawableContainer {
|
|||||||
mStateListState.setConstantSize(a.getBoolean(
|
mStateListState.setConstantSize(a.getBoolean(
|
||||||
com.android.internal.R.styleable.StateListDrawable_constantSize, false));
|
com.android.internal.R.styleable.StateListDrawable_constantSize, false));
|
||||||
|
|
||||||
setDither(a.getBoolean(com.android.internal.R.styleable.StateListDrawable_dither, false));
|
setDither(a.getBoolean(com.android.internal.R.styleable.StateListDrawable_dither,
|
||||||
|
DEFAULT_DITHER));
|
||||||
|
|
||||||
a.recycle();
|
a.recycle();
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user