Index: src/core/SkPictureShader.cpp |
diff --git a/src/core/SkPictureShader.cpp b/src/core/SkPictureShader.cpp |
index 7110a5ba2f0cbe229e89de3e0f8e4354382dc042..1e9507190c60a4ac4e8b16785c9dc06948f13e55 100644 |
--- a/src/core/SkPictureShader.cpp |
+++ b/src/core/SkPictureShader.cpp |
@@ -55,7 +55,7 @@ |
} |
} |
-SkShader* SkPictureShader::refBitmapShader(const SkMatrix& matrix) const { |
+SkShader* SkPictureShader::buildBitmapShader(const SkMatrix& matrix) const { |
if (!fPicture || (0 == fPicture->width() && 0 == fPicture->height())) { |
return NULL; |
} |
@@ -121,12 +121,17 @@ |
return NULL; |
} |
- SkAutoTUnref<SkShader> bitmapShader(this->refBitmapShader(matrix)); |
- if (!bitmapShader || !bitmapShader->validContext(device, paint, matrix)) { |
- return NULL; |
- } |
- |
- return bitmapShader.detach(); |
+ SkShader* bitmapShader = this->buildBitmapShader(matrix); |
+ if (!bitmapShader) { |
+ return NULL; |
+ } |
+ |
+ if (!bitmapShader->validContext(device, paint, matrix)) { |
+ bitmapShader->unref(); |
+ return NULL; |
+ } |
+ |
+ return bitmapShader; |
} |
bool SkPictureShader::validContext(const SkBitmap& device, const SkPaint& paint, |
@@ -137,13 +142,13 @@ |
SkShader::Context* SkPictureShader::createContext(const SkBitmap& device, const SkPaint& paint, |
const SkMatrix& matrix, void* storage) const { |
- SkAutoTUnref<SkShader> bitmapShader(this->validInternal(device, paint, matrix, NULL)); |
+ SkShader* bitmapShader = this->validInternal(device, paint, matrix, NULL); |
if (!bitmapShader) { |
return NULL; |
} |
return SkNEW_PLACEMENT_ARGS(storage, PictureShaderContext, |
- (*this, device, paint, matrix, bitmapShader.detach())); |
+ (*this, device, paint, matrix, bitmapShader)); |
} |
size_t SkPictureShader::contextSize() const { |
@@ -204,7 +209,7 @@ |
#if SK_SUPPORT_GPU |
GrEffectRef* SkPictureShader::asNewEffect(GrContext* context, const SkPaint& paint) const { |
- SkAutoTUnref<SkShader> bitmapShader(this->refBitmapShader(context->getMatrix())); |
+ SkAutoTUnref<SkShader> bitmapShader(this->buildBitmapShader(context->getMatrix())); |
if (!bitmapShader) { |
return NULL; |
} |