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

Side by Side Diff: src/core/SkPictureShader.cpp

Issue 269163004: don't leak the bitmapShader (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: Created 6 years, 7 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright 2014 Google Inc. 2 * Copyright 2014 Google Inc.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license that can be 4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file. 5 * found in the LICENSE file.
6 */ 6 */
7 7
8 #include "SkPictureShader.h" 8 #include "SkPictureShader.h"
9 9
10 #include "SkBitmap.h" 10 #include "SkBitmap.h"
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
112 112
113 size_t SkPictureShader::contextSize() const { 113 size_t SkPictureShader::contextSize() const {
114 return sizeof(PictureShaderContext); 114 return sizeof(PictureShaderContext);
115 } 115 }
116 116
117 SkShader::Context* SkPictureShader::onCreateContext(const ContextRec& rec, void* storage) const { 117 SkShader::Context* SkPictureShader::onCreateContext(const ContextRec& rec, void* storage) const {
118 SkAutoTUnref<SkShader> bitmapShader(this->refBitmapShader(*rec.fMatrix)); 118 SkAutoTUnref<SkShader> bitmapShader(this->refBitmapShader(*rec.fMatrix));
119 if (NULL == bitmapShader.get()) { 119 if (NULL == bitmapShader.get()) {
120 return NULL; 120 return NULL;
121 } 121 }
122 return PictureShaderContext::Create(storage, *this, rec, bitmapShader.detach ()); 122 return PictureShaderContext::Create(storage, *this, rec, bitmapShader);
123 } 123 }
124 124
125 //////////////////////////////////////////////////////////////////////////////// ///////// 125 //////////////////////////////////////////////////////////////////////////////// /////////
126 126
127 SkShader::Context* SkPictureShader::PictureShaderContext::Create(void* storage, 127 SkShader::Context* SkPictureShader::PictureShaderContext::Create(void* storage,
128 const SkPictureShader& shader, const ContextRec& rec, SkShade r* bitmapShader) { 128 const SkPictureShader& shader, const ContextRec& rec, SkShade r* bitmapShader) {
129 PictureShaderContext* ctx = SkNEW_PLACEMENT_ARGS(storage, PictureShaderConte xt, 129 PictureShaderContext* ctx = SkNEW_PLACEMENT_ARGS(storage, PictureShaderConte xt,
130 (shader, rec, bitmapShader) ); 130 (shader, rec, bitmapShader) );
131 if (NULL == ctx->fBitmapShaderContext) { 131 if (NULL == ctx->fBitmapShaderContext) {
132 ctx->~PictureShaderContext(); 132 ctx->~PictureShaderContext();
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
190 190
191 #if SK_SUPPORT_GPU 191 #if SK_SUPPORT_GPU
192 GrEffectRef* SkPictureShader::asNewEffect(GrContext* context, const SkPaint& pai nt) const { 192 GrEffectRef* SkPictureShader::asNewEffect(GrContext* context, const SkPaint& pai nt) const {
193 SkAutoTUnref<SkShader> bitmapShader(this->refBitmapShader(context->getMatrix ())); 193 SkAutoTUnref<SkShader> bitmapShader(this->refBitmapShader(context->getMatrix ()));
194 if (!bitmapShader) { 194 if (!bitmapShader) {
195 return NULL; 195 return NULL;
196 } 196 }
197 return bitmapShader->asNewEffect(context, paint); 197 return bitmapShader->asNewEffect(context, paint);
198 } 198 }
199 #endif 199 #endif
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698