diff options
author | Dianne Hackborn <hackbod@google.com> | 2009-07-29 15:41:19 -0700 |
---|---|---|
committer | Dianne Hackborn <hackbod@google.com> | 2009-07-29 19:44:01 -0700 |
commit | 0d221012ff5fd314711c00ed30e9b807b9c454c1 (patch) | |
tree | 328d42900c9765e3bde9ad98a936a9122c679e5e /graphics/java | |
parent | c6eb5ac988518f41938c4f021003d6c202d84819 (diff) | |
download | frameworks_base-0d221012ff5fd314711c00ed30e9b807b9c454c1.zip frameworks_base-0d221012ff5fd314711c00ed30e9b807b9c454c1.tar.gz frameworks_base-0d221012ff5fd314711c00ed30e9b807b9c454c1.tar.bz2 |
Fix #2018814: System cannot correctly render assets with "wrap_content" attribute in QVGA
It turns out we were not returning the density for anything retrieved from a
TypedArray... which basically means any bitmap references from a layout or style...!!!
This is now fixed.
Also fiddle with the density compatibility mode to turn on smoothing in certain situations,
helping the look of things when they need to scale and we couldn't do the scaling at
load time.
Diffstat (limited to 'graphics/java')
-rw-r--r-- | graphics/java/android/graphics/Canvas.java | 29 |
1 files changed, 23 insertions, 6 deletions
diff --git a/graphics/java/android/graphics/Canvas.java b/graphics/java/android/graphics/Canvas.java index bc2e42e..345f810 100644 --- a/graphics/java/android/graphics/Canvas.java +++ b/graphics/java/android/graphics/Canvas.java @@ -50,6 +50,9 @@ public class Canvas { // Package-scoped for quick access. /*package*/ int mDensity = Bitmap.DENSITY_NONE; + + // Used to determine when compatibility scaling is in effect. + private int mScreenDensity = Bitmap.DENSITY_NONE; // Used by native code @SuppressWarnings({"UnusedDeclaration"}) @@ -219,6 +222,11 @@ public class Canvas { mDensity = density; } + /** @hide */ + public void setScreenDensity(int density) { + mScreenDensity = density; + } + // the SAVE_FLAG constants must match their native equivalents /** restore the current matrix when restore() is called */ @@ -971,7 +979,8 @@ public class Canvas { public void drawBitmap(Bitmap bitmap, float left, float top, Paint paint) { throwIfRecycled(bitmap); native_drawBitmap(mNativeCanvas, bitmap.ni(), left, top, - paint != null ? paint.mNativePaint : 0, mDensity, bitmap.mDensity); + paint != null ? paint.mNativePaint : 0, mDensity, mScreenDensity, + bitmap.mDensity); } /** @@ -1002,7 +1011,8 @@ public class Canvas { } throwIfRecycled(bitmap); native_drawBitmap(mNativeCanvas, bitmap.ni(), src, dst, - paint != null ? paint.mNativePaint : 0); + paint != null ? paint.mNativePaint : 0, + mScreenDensity, bitmap.mDensity); } /** @@ -1033,7 +1043,8 @@ public class Canvas { } throwIfRecycled(bitmap); native_drawBitmap(mNativeCanvas, bitmap.ni(), src, dst, - paint != null ? paint.mNativePaint : 0); + paint != null ? paint.mNativePaint : 0, + mScreenDensity, bitmap.mDensity); } /** @@ -1513,13 +1524,19 @@ public class Canvas { private native void native_drawBitmap(int nativeCanvas, int bitmap, float left, float top, int nativePaintOrZero, - int canvasDensity, int bitmapDensity); + int canvasDensity, + int screenDensity, + int bitmapDensity); private native void native_drawBitmap(int nativeCanvas, int bitmap, Rect src, RectF dst, - int nativePaintOrZero); + int nativePaintOrZero, + int screenDensity, + int bitmapDensity); private static native void native_drawBitmap(int nativeCanvas, int bitmap, Rect src, Rect dst, - int nativePaintOrZero); + int nativePaintOrZero, + int screenDensity, + int bitmapDensity); private static native void native_drawBitmap(int nativeCanvas, int[] colors, int offset, int stride, float x, float y, int width, int height, |