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

Side by Side Diff: src/image/SkImage_Gpu.cpp

Issue 2003573002: Fix leak in SkImage_Gpu::onMakeSubset(). (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 4 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
« 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 2012 Google Inc. 2 * Copyright 2012 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 "SkAutoPixmapStorage.h" 8 #include "SkAutoPixmapStorage.h"
9 #include "GrCaps.h" 9 #include "GrCaps.h"
10 #include "GrContext.h" 10 #include "GrContext.h"
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after
133 } 133 }
134 return true; 134 return true;
135 } 135 }
136 136
137 sk_sp<SkImage> SkImage_Gpu::onMakeSubset(const SkIRect& subset) const { 137 sk_sp<SkImage> SkImage_Gpu::onMakeSubset(const SkIRect& subset) const {
138 GrContext* ctx = fTexture->getContext(); 138 GrContext* ctx = fTexture->getContext();
139 GrSurfaceDesc desc = fTexture->desc(); 139 GrSurfaceDesc desc = fTexture->desc();
140 desc.fWidth = subset.width(); 140 desc.fWidth = subset.width();
141 desc.fHeight = subset.height(); 141 desc.fHeight = subset.height();
142 142
143 GrTexture* subTx = ctx->textureProvider()->createTexture(desc, fBudgeted); 143 sk_sp<GrTexture> subTx(ctx->textureProvider()->createTexture(desc, fBudgeted ));
144 if (!subTx) { 144 if (!subTx) {
145 return nullptr; 145 return nullptr;
146 } 146 }
147 ctx->copySurface(subTx, fTexture, subset, SkIPoint::Make(0, 0)); 147 ctx->copySurface(subTx.get(), fTexture, subset, SkIPoint::Make(0, 0));
148 return sk_make_sp<SkImage_Gpu>(desc.fWidth, desc.fHeight, kNeedNewImageUniqu eID, 148 return sk_make_sp<SkImage_Gpu>(desc.fWidth, desc.fHeight, kNeedNewImageUniqu eID,
149 fAlphaType, subTx, fBudgeted); 149 fAlphaType, subTx.get(), fBudgeted);
150 } 150 }
151 151
152 //////////////////////////////////////////////////////////////////////////////// /////////////////// 152 //////////////////////////////////////////////////////////////////////////////// ///////////////////
153 153
154 static sk_sp<SkImage> new_wrapped_texture_common(GrContext* ctx, const GrBackend TextureDesc& desc, 154 static sk_sp<SkImage> new_wrapped_texture_common(GrContext* ctx, const GrBackend TextureDesc& desc,
155 SkAlphaType at, GrWrapOwnership ownership, 155 SkAlphaType at, GrWrapOwnership ownership,
156 SkImage::TextureReleaseProc rel easeProc, 156 SkImage::TextureReleaseProc rel easeProc,
157 SkImage::ReleaseContext release Ctx) { 157 SkImage::ReleaseContext release Ctx) {
158 if (desc.fWidth <= 0 || desc.fHeight <= 0) { 158 if (desc.fWidth <= 0 || desc.fHeight <= 0) {
159 return nullptr; 159 return nullptr;
(...skipping 289 matching lines...) Expand 10 before | Expand all | Expand 10 after
449 return nullptr; 449 return nullptr;
450 } 450 }
451 451
452 const SkIRect srcR = SkIRect::MakeWH(desc.fWidth, desc.fHeight); 452 const SkIRect srcR = SkIRect::MakeWH(desc.fWidth, desc.fHeight);
453 const SkIPoint dstP = SkIPoint::Make(0, 0); 453 const SkIPoint dstP = SkIPoint::Make(0, 0);
454 ctx->copySurface(dst, src, srcR, dstP); 454 ctx->copySurface(dst, src, srcR, dstP);
455 ctx->flushSurfaceWrites(dst); 455 ctx->flushSurfaceWrites(dst);
456 return dst; 456 return dst;
457 } 457 }
458 458
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