Merge "Fix ref count of fillGradient and strokeGradient" into nyc-dev

This commit is contained in:
Doris Liu
2016-04-15 17:47:21 +00:00
committed by Android (Google) Code Review

View File

@@ -219,22 +219,24 @@ public:
int fillType = 0; /* non-zero or kWinding_FillType in Skia */ int fillType = 0; /* non-zero or kWinding_FillType in Skia */
}; };
FullPathProperties(Node* mNode) : Properties(mNode), mTrimDirty(false) {} FullPathProperties(Node* mNode) : Properties(mNode), mTrimDirty(false) {}
~FullPathProperties() {
SkSafeUnref(fillGradient);
SkSafeUnref(strokeGradient);
}
void syncProperties(const FullPathProperties& prop) { void syncProperties(const FullPathProperties& prop) {
mPrimitiveFields = prop.mPrimitiveFields; mPrimitiveFields = prop.mPrimitiveFields;
mTrimDirty = true; mTrimDirty = true;
fillGradient.reset(prop.fillGradient); UPDATE_SKPROP(fillGradient, prop.fillGradient);
strokeGradient.reset(prop.strokeGradient); UPDATE_SKPROP(strokeGradient, prop.strokeGradient);
onPropertyChanged(); onPropertyChanged();
} }
void setFillGradient(SkShader* gradient) { void setFillGradient(SkShader* gradient) {
if(fillGradient != gradient){ if(UPDATE_SKPROP(fillGradient, gradient)) {
fillGradient.reset(gradient);
onPropertyChanged(); onPropertyChanged();
} }
} }
void setStrokeGradient(SkShader* gradient) { void setStrokeGradient(SkShader* gradient) {
if(strokeGradient != gradient){ if(UPDATE_SKPROP(strokeGradient, gradient)) {
strokeGradient.reset(gradient);
onPropertyChanged(); onPropertyChanged();
} }
} }
@@ -346,8 +348,8 @@ public:
count, count,
}; };
PrimitiveFields mPrimitiveFields; PrimitiveFields mPrimitiveFields;
SkAutoTUnref<SkShader> fillGradient; SkShader* fillGradient = nullptr;
SkAutoTUnref<SkShader> strokeGradient; SkShader* strokeGradient = nullptr;
}; };
// Called from UI thread // Called from UI thread