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

Side by Side Diff: src/effects/SkRectShaderImageFilter.cpp

Issue 501563002: Don't leak the shader by reffing twice in SkRectShaderImageFilter. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 6 years, 4 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
« 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 2013 Google Inc. 2 * Copyright 2013 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 "SkRectShaderImageFilter.h" 8 #include "SkRectShaderImageFilter.h"
9 #include "SkBitmap.h" 9 #include "SkBitmap.h"
10 #include "SkCanvas.h" 10 #include "SkCanvas.h"
(...skipping 26 matching lines...) Expand all
37 37
38 #ifdef SK_SUPPORT_LEGACY_DEEPFLATTENING 38 #ifdef SK_SUPPORT_LEGACY_DEEPFLATTENING
39 SkRectShaderImageFilter::SkRectShaderImageFilter(SkReadBuffer& buffer) 39 SkRectShaderImageFilter::SkRectShaderImageFilter(SkReadBuffer& buffer)
40 : INHERITED(0, buffer) { 40 : INHERITED(0, buffer) {
41 fShader = buffer.readShader(); 41 fShader = buffer.readShader();
42 } 42 }
43 #endif 43 #endif
44 44
45 SkFlattenable* SkRectShaderImageFilter::CreateProc(SkReadBuffer& buffer) { 45 SkFlattenable* SkRectShaderImageFilter::CreateProc(SkReadBuffer& buffer) {
46 SK_IMAGEFILTER_UNFLATTEN_COMMON(common, 0); 46 SK_IMAGEFILTER_UNFLATTEN_COMMON(common, 0);
47 return Create(buffer.readShader(), &common.cropRect()); 47 SkAutoTUnref<SkShader> shader(buffer.readShader());
48 return Create(shader.get(), &common.cropRect());
48 } 49 }
49 50
50 void SkRectShaderImageFilter::flatten(SkWriteBuffer& buffer) const { 51 void SkRectShaderImageFilter::flatten(SkWriteBuffer& buffer) const {
51 this->INHERITED::flatten(buffer); 52 this->INHERITED::flatten(buffer);
52 buffer.writeFlattenable(fShader); 53 buffer.writeFlattenable(fShader);
53 } 54 }
54 55
55 SkRectShaderImageFilter::~SkRectShaderImageFilter() { 56 SkRectShaderImageFilter::~SkRectShaderImageFilter() {
56 SkSafeUnref(fShader); 57 SkSafeUnref(fShader);
57 } 58 }
(...skipping 21 matching lines...) Expand all
79 paint.setShader(SkShader::CreateLocalMatrixShader(fShader, matrix))->unref() ; 80 paint.setShader(SkShader::CreateLocalMatrixShader(fShader, matrix))->unref() ;
80 81
81 SkRect rect = SkRect::MakeWH(SkIntToScalar(bounds.width()), SkIntToScalar(bo unds.height())); 82 SkRect rect = SkRect::MakeWH(SkIntToScalar(bounds.width()), SkIntToScalar(bo unds.height()));
82 canvas.drawRect(rect, paint); 83 canvas.drawRect(rect, paint);
83 84
84 *result = device.get()->accessBitmap(false); 85 *result = device.get()->accessBitmap(false);
85 offset->fX = bounds.fLeft; 86 offset->fX = bounds.fLeft;
86 offset->fY = bounds.fTop; 87 offset->fY = bounds.fTop;
87 return true; 88 return true;
88 } 89 }
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