Index: src/effects/SkRectShaderImageFilter.cpp |
diff --git a/src/effects/SkRectShaderImageFilter.cpp b/src/effects/SkRectShaderImageFilter.cpp |
index fb34ed0007152f124ae557a5567aad4effa3bed5..09417c8840f9fe8c0ef3ae6cfe1a789ed4064e56 100644 |
--- a/src/effects/SkRectShaderImageFilter.cpp |
+++ b/src/effects/SkRectShaderImageFilter.cpp |
@@ -20,20 +20,18 @@ SkRectShaderImageFilter* SkRectShaderImageFilter::Create(SkShader* s, const SkRe |
flags = 0x0; |
} |
CropRect cropRect(rect, flags); |
- return SkNEW_ARGS(SkRectShaderImageFilter, (s, &cropRect)); |
+ return s ? SkNEW_ARGS(SkRectShaderImageFilter, (s, &cropRect)) : NULL; |
} |
SkRectShaderImageFilter* SkRectShaderImageFilter::Create(SkShader* s, const CropRect* cropRect, uint32_t uniqueID) { |
SkASSERT(s); |
- return SkNEW_ARGS(SkRectShaderImageFilter, (s, cropRect, uniqueID)); |
+ return s ? SkNEW_ARGS(SkRectShaderImageFilter, (s, cropRect, uniqueID)) : NULL; |
} |
SkRectShaderImageFilter::SkRectShaderImageFilter(SkShader* s, const CropRect* cropRect, |
uint32_t uniqueID) |
: INHERITED(0, NULL, cropRect, uniqueID) |
- , fShader(s) { |
- SkASSERT(s); |
- s->ref(); |
+ , fShader(SkRef(s)) { |
} |
#ifdef SK_SUPPORT_LEGACY_DEEPFLATTENING |
@@ -55,7 +53,7 @@ void SkRectShaderImageFilter::flatten(SkWriteBuffer& buffer) const { |
} |
SkRectShaderImageFilter::~SkRectShaderImageFilter() { |
- SkSafeUnref(fShader); |
+ fShader->unref(); |
} |
bool SkRectShaderImageFilter::onFilterImage(Proxy* proxy, |
@@ -78,7 +76,7 @@ bool SkRectShaderImageFilter::onFilterImage(Proxy* proxy, |
SkPaint paint; |
SkMatrix matrix(ctx.ctm()); |
matrix.postTranslate(SkIntToScalar(-bounds.left()), SkIntToScalar(-bounds.top())); |
- paint.setShader(SkShader::CreateLocalMatrixShader(fShader, matrix))->unref(); |
+ SkSafeUnref(paint.setShader(SkShader::CreateLocalMatrixShader(fShader, matrix))); |
SkRect rect = SkRect::MakeWH(SkIntToScalar(bounds.width()), SkIntToScalar(bounds.height())); |
canvas.drawRect(rect, paint); |