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

Side by Side 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 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 /* 2 /*
3 * Copyright 2011 Google Inc. 3 * Copyright 2011 Google Inc.
4 * 4 *
5 * Use of this source code is governed by a BSD-style license that can be 5 * Use of this source code is governed by a BSD-style license that can be
6 * found in the LICENSE file. 6 * found in the LICENSE file.
7 */ 7 */
8 8
9 // This is a GPU-backend specific test. It relies on static intializers to work 9 // This is a GPU-backend specific test. It relies on static intializers to work
10 10
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
104 // setup render target 104 // setup render target
105 GrTextureParams params; 105 GrTextureParams params;
106 GrTextureDesc texDesc; 106 GrTextureDesc texDesc;
107 texDesc.fWidth = kRenderTargetWidth; 107 texDesc.fWidth = kRenderTargetWidth;
108 texDesc.fHeight = kRenderTargetHeight; 108 texDesc.fHeight = kRenderTargetHeight;
109 texDesc.fFlags = kRenderTarget_GrTextureFlagBit; 109 texDesc.fFlags = kRenderTarget_GrTextureFlagBit;
110 texDesc.fConfig = kRGBA_8888_GrPixelConfig; 110 texDesc.fConfig = kRGBA_8888_GrPixelConfig;
111 texDesc.fOrigin = random->nextBool() == true ? kTopLeft_GrSurfaceOrigin : 111 texDesc.fOrigin = random->nextBool() == true ? kTopLeft_GrSurfaceOrigin :
112 kBottomLeft_GrSurfaceOrigin; 112 kBottomLeft_GrSurfaceOrigin;
113 113
114 GrTexture* texture = gpu->getContext()->findAndRefTexture(texDesc, cacheId, &params); 114 SkAutoTUnref<GrTexture> texture(
115 if (NULL == texture) { 115 gpu->getContext()->findAndRefTexture(texDesc, cacheId, &params));
116 texture = gpu->getContext()->createTexture(&params, texDesc, cacheId, 0, 0); 116 if (!texture) {
117 if (NULL == texture) { 117 texture.reset(gpu->getContext()->createTexture(&params, texDesc, cacheId , 0, 0));
118 if (!texture) {
118 return NULL; 119 return NULL;
119 } 120 }
120 } 121 }
121 return texture->asRenderTarget(); 122 return SkRef(texture->asRenderTarget());
122 } 123 }
123 124
124 // TODO clean this up, we have to do this to test geometry processors but there has got to be 125 // TODO clean this up, we have to do this to test geometry processors but there has got to be
125 // a better way. In the mean time, we actually fill out these generic vertex at tribs below with 126 // a better way. In the mean time, we actually fill out these generic vertex at tribs below with
126 // the correct vertex attribs from the GP. We have to ensure, however, we don't try to add more 127 // the correct vertex attribs from the GP. We have to ensure, however, we don't try to add more
127 // than two attributes. In addition, we 'pad' the below array with GPs up to 6 entries, 4 fixed 128 // than two attributes. In addition, we 'pad' the below array with GPs up to 6 entries, 4 fixed
128 // function vertex attributes and 2 GP custom attributes. 129 // function vertex attributes and 2 GP custom attributes.
129 GrVertexAttrib kGenericVertexAttribs[] = { 130 GrVertexAttrib kGenericVertexAttribs[] = {
130 { kVec2f_GrVertexAttribType, 0, kPosition_GrVertexAttribBinding }, 131 { kVec2f_GrVertexAttribType, 0, kPosition_GrVertexAttribBinding },
131 { kVec2f_GrVertexAttribType, 0, kGeometryProcessor_GrVertexAttribBinding } , 132 { kVec2f_GrVertexAttribType, 0, kGeometryProcessor_GrVertexAttribBinding } ,
(...skipping 278 matching lines...) Expand 10 before | Expand all | Expand 10 after
410 411
411 // wrap the SkClipStack in a GrClipData 412 // wrap the SkClipStack in a GrClipData
412 GrClipData clipData; 413 GrClipData clipData;
413 clipData.fClipStack = &stack; 414 clipData.fClipStack = &stack;
414 this->setClip(&clipData); 415 this->setClip(&clipData);
415 416
416 SkRandom random; 417 SkRandom random;
417 static const int NUM_TESTS = 512; 418 static const int NUM_TESTS = 512;
418 for (int t = 0; t < NUM_TESTS;) { 419 for (int t = 0; t < NUM_TESTS;) {
419 // setup random render target(can fail) 420 // setup random render target(can fail)
420 GrRenderTarget* rtPtr = random_render_target(this, glProgramsCacheID, &r andom); 421 SkAutoTUnref<GrRenderTarget> rt(random_render_target(this, glProgramsCac heID, &random));
421 if (!rtPtr) { 422 if (!rt) {
422 SkDebugf("Could not allocate render target"); 423 SkDebugf("Could not allocate render target");
423 return false; 424 return false;
424 } 425 }
425 GrTGpuResourceRef<GrRenderTarget> rt(SkRef(rtPtr), kWrite_GrIOType);
426 426
427 GrDrawState* ds = this->drawState(); 427 GrDrawState* ds = this->drawState();
428 ds->setRenderTarget(rt.get()); 428 ds->setRenderTarget(rt.get());
429 429
430 // if path rendering we have to setup a couple of things like the draw t ype 430 // if path rendering we have to setup a couple of things like the draw t ype
431 bool usePathRendering = this->glCaps().pathRenderingSupport() && random. nextBool(); 431 bool usePathRendering = this->glCaps().pathRenderingSupport() && random. nextBool();
432 432
433 GrGpu::DrawType drawType = usePathRendering ? GrGpu::kDrawPath_DrawType : 433 GrGpu::DrawType drawType = usePathRendering ? GrGpu::kDrawPath_DrawType :
434 GrGpu::kDrawPoints_DrawTyp e; 434 GrGpu::kDrawPoints_DrawTyp e;
435 435
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
514 if (type == GrContextFactory::kANGLE_GLContextType) { 514 if (type == GrContextFactory::kANGLE_GLContextType) {
515 maxStages = 3; 515 maxStages = 3;
516 } 516 }
517 #endif 517 #endif
518 REPORTER_ASSERT(reporter, gpu->programUnitTest(maxStages)); 518 REPORTER_ASSERT(reporter, gpu->programUnitTest(maxStages));
519 } 519 }
520 } 520 }
521 } 521 }
522 522
523 #endif 523 #endif
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