summaryrefslogtreecommitdiff
path: root/libs/hwui/VectorDrawable.cpp
diff options
context:
space:
mode:
authorDoris Liu <tianliu@google.com>2015-12-29 14:57:49 -0800
committerDoris Liu <tianliu@google.com>2015-12-30 10:57:15 -0800
commita0e61572ab2ec23f1329a04f6a8065721a1efbdb (patch)
tree3d7b743fe220fb750673296572f7d3d86d640026 /libs/hwui/VectorDrawable.cpp
parentbd0d937303ae54d8a5bb5f08080c4164302daefc (diff)
VectorDrawable: Use the matrix scale only if the matrix has no rotation or skew.
When canvas is rotated or skewed, the scale factor is affected. Conservatively reset the scale used to modify path stroke size to 1 in these cases, since the image will be somewhat blurry anyway with rotation / skew.. b/25418943 Change-Id: I6dff1bca5fac5500fa688c68f8b81b6212526b6b
Diffstat (limited to 'libs/hwui/VectorDrawable.cpp')
-rw-r--r--libs/hwui/VectorDrawable.cpp11
1 files changed, 9 insertions, 2 deletions
diff --git a/libs/hwui/VectorDrawable.cpp b/libs/hwui/VectorDrawable.cpp
index e13a2bb2a38b..56cb10476118 100644
--- a/libs/hwui/VectorDrawable.cpp
+++ b/libs/hwui/VectorDrawable.cpp
@@ -403,8 +403,15 @@ void Tree::draw(Canvas* outCanvas, SkColorFilter* colorFilter,
// canvas scale.
outCanvas->getMatrix(&mCanvasMatrix);
mBounds = bounds;
- int scaledWidth = (int) (mBounds.width() * mCanvasMatrix.getScaleX());
- int scaledHeight = (int) (mBounds.height() * mCanvasMatrix.getScaleY());
+ float canvasScaleX = 1.0f;
+ float canvasScaleY = 1.0f;
+ if (mCanvasMatrix.getSkewX() == 0 && mCanvasMatrix.getSkewY() == 0) {
+ // Only use the scale value when there's no skew or rotation in the canvas matrix.
+ canvasScaleX = mCanvasMatrix.getScaleX();
+ canvasScaleY = mCanvasMatrix.getScaleY();
+ }
+ int scaledWidth = (int) (mBounds.width() * canvasScaleX);
+ int scaledHeight = (int) (mBounds.height() * canvasScaleY);
scaledWidth = std::min(Tree::MAX_CACHED_BITMAP_SIZE, scaledWidth);
scaledHeight = std::min(Tree::MAX_CACHED_BITMAP_SIZE, scaledHeight);