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

Unified Diff: tests/GLProgramsTest.cpp

Issue 648063002: Fix leak in GLPrograms test. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: wrap line Created 6 years, 2 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 | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tests/GLProgramsTest.cpp
diff --git a/tests/GLProgramsTest.cpp b/tests/GLProgramsTest.cpp
index 75032bdbe6a168b8b0a3daba063b0c9794823711..cf3d90cbca99063f1d5a06b81d2c03ac0cddfa9b 100644
--- a/tests/GLProgramsTest.cpp
+++ b/tests/GLProgramsTest.cpp
@@ -111,14 +111,15 @@ static GrRenderTarget* random_render_target(GrGpuGL* gpu,
texDesc.fOrigin = random->nextBool() == true ? kTopLeft_GrSurfaceOrigin :
kBottomLeft_GrSurfaceOrigin;
- GrTexture* texture = gpu->getContext()->findAndRefTexture(texDesc, cacheId, &params);
- if (NULL == texture) {
- texture = gpu->getContext()->createTexture(&params, texDesc, cacheId, 0, 0);
- if (NULL == texture) {
+ SkAutoTUnref<GrTexture> texture(
+ gpu->getContext()->findAndRefTexture(texDesc, cacheId, &params));
+ if (!texture) {
+ texture.reset(gpu->getContext()->createTexture(&params, texDesc, cacheId, 0, 0));
+ if (!texture) {
return NULL;
}
}
- return texture->asRenderTarget();
+ return SkRef(texture->asRenderTarget());
}
// TODO clean this up, we have to do this to test geometry processors but there has got to be
@@ -417,12 +418,11 @@ bool GrGpuGL::programUnitTest(int maxStages) {
static const int NUM_TESTS = 512;
for (int t = 0; t < NUM_TESTS;) {
// setup random render target(can fail)
- GrRenderTarget* rtPtr = random_render_target(this, glProgramsCacheID, &random);
- if (!rtPtr) {
+ SkAutoTUnref<GrRenderTarget> rt(random_render_target(this, glProgramsCacheID, &random));
+ if (!rt) {
SkDebugf("Could not allocate render target");
return false;
}
- GrTGpuResourceRef<GrRenderTarget> rt(SkRef(rtPtr), kWrite_GrIOType);
GrDrawState* ds = this->drawState();
ds->setRenderTarget(rt.get());
« 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