Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(150)

Unified Diff: src/core/SkPictureShader.cpp

Issue 241603002: Revert of Fix memory leak in SkGradientShader. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 6 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/core/SkPictureShader.h ('k') | src/effects/gradients/SkGradientShader.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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;
}
« no previous file with comments | « src/core/SkPictureShader.h ('k') | src/effects/gradients/SkGradientShader.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698