summaryrefslogtreecommitdiff
path: root/libs/hwui/VectorDrawable.cpp
diff options
context:
space:
mode:
authorDoris Liu <tianliu@google.com>2016-10-12 21:10:47 +0000
committerandroid-build-merger <android-build-merger@google.com>2016-10-12 21:10:47 +0000
commit4e230f4688e85551252dfaf94cbaab3c9087ab3b (patch)
treef06f7406c88a77082c4da81cebef1b123e3f9833 /libs/hwui/VectorDrawable.cpp
parent0ce1865438bdd27174747cadcf407c9da1d71503 (diff)
parent1ef744a3b8f7acd6699bc43ef220745a4b46ce68 (diff)
Fix SkShader leak for Gradient VectorDrawable and test am: fc9cf72339 am: c47199bb6a
am: 1ef744a3b8 Change-Id: Iee4f98f10a4e1b3947166777040918ab779ab023
Diffstat (limited to 'libs/hwui/VectorDrawable.cpp')
-rw-r--r--libs/hwui/VectorDrawable.cpp8
1 files changed, 6 insertions, 2 deletions
diff --git a/libs/hwui/VectorDrawable.cpp b/libs/hwui/VectorDrawable.cpp
index 4e5b9ad2f0a3..a2f3cb6b3d85 100644
--- a/libs/hwui/VectorDrawable.cpp
+++ b/libs/hwui/VectorDrawable.cpp
@@ -202,7 +202,9 @@ void FullPath::drawPath(SkCanvas* outCanvas, SkPath& renderPath, float strokeSca
if (properties.getFillGradient() != nullptr) {
paint.setColor(applyAlpha(SK_ColorBLACK, properties.getFillAlpha()));
SkShader* newShader = properties.getFillGradient()->newWithLocalMatrix(matrix);
- paint.setShader(newShader);
+ // newWithLocalMatrix(...) creates a new SkShader and returns a bare pointer. We need to
+ // remove the extra ref so that the ref count is correctly managed.
+ paint.setShader(newShader)->unref();
needsFill = true;
} else if (properties.getFillColor() != SK_ColorTRANSPARENT) {
paint.setColor(applyAlpha(properties.getFillColor(), properties.getFillAlpha()));
@@ -222,7 +224,9 @@ void FullPath::drawPath(SkCanvas* outCanvas, SkPath& renderPath, float strokeSca
if (properties.getStrokeGradient() != nullptr) {
paint.setColor(applyAlpha(SK_ColorBLACK, properties.getStrokeAlpha()));
SkShader* newShader = properties.getStrokeGradient()->newWithLocalMatrix(matrix);
- paint.setShader(newShader);
+ // newWithLocalMatrix(...) creates a new SkShader and returns a bare pointer. We need to
+ // remove the extra ref so that the ref count is correctly managed.
+ paint.setShader(newShader)->unref();
needsStroke = true;
} else if (properties.getStrokeColor() != SK_ColorTRANSPARENT) {
paint.setColor(applyAlpha(properties.getStrokeColor(), properties.getStrokeAlpha()));