aboutsummaryrefslogtreecommitdiffhomepage
path: root/tests
diff options
context:
space:
mode:
authorGravatar bsalomon <bsalomon@google.com>2014-10-12 05:40:00 -0700
committerGravatar Commit bot <commit-bot@chromium.org>2014-10-12 05:40:01 -0700
commitd27726eccbb7d6054f6adeda62a37d77fae11a15 (patch)
tree07576af268bc389c060691966a8cd3da10b93f2d /tests
parent09a1d6751c5c7c09d72ff8e195148509d2cb87ce (diff)
Fix leak in GLPrograms test.
TBR=joshualitt@google.com Review URL: https://codereview.chromium.org/648063002
Diffstat (limited to 'tests')
-rw-r--r--tests/GLProgramsTest.cpp16
1 files changed, 8 insertions, 8 deletions
diff --git a/tests/GLProgramsTest.cpp b/tests/GLProgramsTest.cpp
index 75032bdbe6..cf3d90cbca 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());