summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDanny Baumann <dannybaumann@web.de>2016-01-11 13:39:10 +0100
committerSteve Kondik <shade@chemlab.org>2016-01-11 14:51:44 -0800
commit2b30269d11f85fea9f942471193f1d59e7b6d7ac (patch)
treecfaaa35fc4a9802c6c50349b21c63e2b18cac5d1
parente62097f1444929fe3291b6af2b24f9d77db73e59 (diff)
downloadframeworks_base-2b30269d11f85fea9f942471193f1d59e7b6d7ac.zip
frameworks_base-2b30269d11f85fea9f942471193f1d59e7b6d7ac.tar.gz
frameworks_base-2b30269d11f85fea9f942471193f1d59e7b6d7ac.tar.bz2
Fix drawing of VectorDrawables that are rotated by 90 or 270 degrees.
The SCALE_X / SCALE_Y values of rotated matrices are set to the cosine of the rotation angle, which is 0 for drawables that are rotated by 90 or 270 degrees. Map the matrix onto the bounds rectangle and use the resulting size to determine the scaled size instead. Change-Id: I6cc0f0b5569d43434c829cb5f6e5f848cad995ec
-rw-r--r--graphics/java/android/graphics/drawable/VectorDrawable.java12
1 files changed, 6 insertions, 6 deletions
diff --git a/graphics/java/android/graphics/drawable/VectorDrawable.java b/graphics/java/android/graphics/drawable/VectorDrawable.java
index 1cfccc4..6d3bf3e 100644
--- a/graphics/java/android/graphics/drawable/VectorDrawable.java
+++ b/graphics/java/android/graphics/drawable/VectorDrawable.java
@@ -32,6 +32,7 @@ import android.graphics.PathMeasure;
import android.graphics.PixelFormat;
import android.graphics.PorterDuffColorFilter;
import android.graphics.Rect;
+import android.graphics.RectF;
import android.graphics.PorterDuff.Mode;
import android.util.ArrayMap;
import android.util.AttributeSet;
@@ -225,9 +226,9 @@ public class VectorDrawable extends Drawable {
private Insets mDpiScaleInsets = Insets.NONE;
// Temp variable, only for saving "new" operation at the draw() time.
- private final float[] mTmpFloats = new float[9];
private final Matrix mTmpMatrix = new Matrix();
private final Rect mTmpBounds = new Rect();
+ private final RectF mTmpDstBounds = new RectF();
public VectorDrawable() {
this(null, null);
@@ -288,11 +289,10 @@ public class VectorDrawable extends Drawable {
// size first. This bitmap size is determined by the bounds and the
// canvas scale.
canvas.getMatrix(mTmpMatrix);
- mTmpMatrix.getValues(mTmpFloats);
- float canvasScaleX = Math.abs(mTmpFloats[Matrix.MSCALE_X]);
- float canvasScaleY = Math.abs(mTmpFloats[Matrix.MSCALE_Y]);
- int scaledWidth = (int) (mTmpBounds.width() * canvasScaleX);
- int scaledHeight = (int) (mTmpBounds.height() * canvasScaleY);
+ mTmpDstBounds.set(mTmpBounds);
+ mTmpMatrix.mapRect(mTmpDstBounds);
+ int scaledWidth = (int) mTmpDstBounds.width();
+ int scaledHeight = (int) mTmpDstBounds.height();
scaledWidth = Math.min(MAX_CACHED_BITMAP_SIZE, scaledWidth);
scaledHeight = Math.min(MAX_CACHED_BITMAP_SIZE, scaledHeight);