From 8e15cdf778401e919ddcd3b553b64ddeffd85fa1 Mon Sep 17 00:00:00 2001 From: Robert Phillips Date: Thu, 23 Feb 2017 11:32:32 -0500 Subject: Fix memory leak: adopt rather than ref GrTexture* in GrTextureStripAtlas This was introduced in: https://skia-review.googlesource.com/c/8881/ (Switch GrTextureStripAtlas over to GrTextureProxies) Change-Id: I6635e9fee9f63d703373b31c31fda459f5b63763 Reviewed-on: https://skia-review.googlesource.com/8916 Reviewed-by: Brian Salomon Reviewed-by: Robert Phillips Commit-Queue: Brian Salomon --- src/gpu/effects/GrTextureStripAtlas.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'src') diff --git a/src/gpu/effects/GrTextureStripAtlas.cpp b/src/gpu/effects/GrTextureStripAtlas.cpp index 2de70762cb..6bc7ec0480 100644 --- a/src/gpu/effects/GrTextureStripAtlas.cpp +++ b/src/gpu/effects/GrTextureStripAtlas.cpp @@ -207,24 +207,24 @@ void GrTextureStripAtlas::lockTexture() { builder.finish(); // MDB TODO (caching): this side-steps the issue of proxies with unique IDs - GrTexture* texture = fDesc.fContext->textureProvider()->findAndRefTextureByUniqueKey(key); + sk_sp texture(fDesc.fContext->textureProvider()->findAndRefTextureByUniqueKey(key)); if (!texture) { - texture = fDesc.fContext->textureProvider()->createTexture(texDesc, SkBudgeted::kYes, - nullptr, 0); + texture.reset(fDesc.fContext->textureProvider()->createTexture(texDesc, SkBudgeted::kYes, + nullptr, 0)); if (!texture) { return; } // We will be issuing writes to the surface using kDontFlush_PixelOpsFlag, so we // need to make sure any existing IO is flushed - fDesc.fContext->flushSurfaceIO(texture); - fDesc.fContext->textureProvider()->assignUniqueKeyToTexture(key, texture); + fDesc.fContext->flushSurfaceIO(texture.get()); + fDesc.fContext->textureProvider()->assignUniqueKeyToTexture(key, texture.get()); // This is a new texture, so all of our cache info is now invalid this->initLRU(); fKeyTable.rewind(); } SkASSERT(texture); - fTexContext = fDesc.fContext->contextPriv().makeWrappedSurfaceContext(sk_ref_sp(texture)); + fTexContext = fDesc.fContext->contextPriv().makeWrappedSurfaceContext(std::move(texture)); } void GrTextureStripAtlas::unlockTexture() { -- cgit v1.2.3