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

Side by Side Diff: tests/GLProgramsTest.cpp

Issue 791743003: Remove GP from drawstate, revision of invariant output for GP (Closed) Base URL: https://skia.googlesource.com/skia.git@color-to-gp
Patch Set: Created 6 years 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
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 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
114 SkAutoTUnref<GrTexture> texture(context->findAndRefTexture(texDesc, cacheId, &params)); 114 SkAutoTUnref<GrTexture> texture(context->findAndRefTexture(texDesc, cacheId, &params));
115 if (!texture) { 115 if (!texture) {
116 texture.reset(context->createTexture(&params, texDesc, cacheId, 0, 0)); 116 texture.reset(context->createTexture(&params, texDesc, cacheId, 0, 0));
117 if (!texture) { 117 if (!texture) {
118 return NULL; 118 return NULL;
119 } 119 }
120 } 120 }
121 return SkRef(texture->asRenderTarget()); 121 return SkRef(texture->asRenderTarget());
122 } 122 }
123 123
124 static void set_random_gp(GrContext* context, 124 static const GrGeometryProcessor* get_random_gp(GrContext* context,
125 const GrDrawTargetCaps& caps, 125 const GrDrawTargetCaps& caps,
126 GrDrawState* ds, 126 SkRandom* random,
127 SkRandom* random, 127 GrTexture* dummyTextures[]) {
128 GrTexture* dummyTextures[]) { 128 return GrProcessorTestFactory<GrGeometryProcessor>::CreateStage(random,
129 SkAutoTUnref<const GrGeometryProcessor> gp( 129 context,
130 GrProcessorTestFactory<GrGeometryProcessor>::CreateStage(random, 130 caps,
131 context, 131 dummyTexture s);
132 caps,
133 dummyTextur es));
134 SkASSERT(gp);
135
136 ds->setGeometryProcessor(gp);
137 } 132 }
138 133
139 static void set_random_color_coverage_stages(GrGpuGL* gpu, 134 static void set_random_color_coverage_stages(GrGpuGL* gpu,
140 GrDrawState* ds, 135 GrDrawState* ds,
141 int maxStages, 136 int maxStages,
142 bool usePathRendering, 137 bool usePathRendering,
143 SkRandom* random, 138 SkRandom* random,
144 GrTexture* dummyTextures[]) { 139 GrTexture* dummyTextures[]) {
145 int numProcs = random->nextULessThan(maxStages + 1); 140 int numProcs = random->nextULessThan(maxStages + 1);
146 int numColorProcs = random->nextULessThan(numProcs + 1); 141 int numColorProcs = random->nextULessThan(numProcs + 1);
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after
294 ds.setRenderTarget(rt.get()); 289 ds.setRenderTarget(rt.get());
295 290
296 // if path rendering we have to setup a couple of things like the draw t ype 291 // if path rendering we have to setup a couple of things like the draw t ype
297 bool usePathRendering = gpu->glCaps().pathRenderingSupport() && random.n extBool(); 292 bool usePathRendering = gpu->glCaps().pathRenderingSupport() && random.n extBool();
298 293
299 GrGpu::DrawType drawType = usePathRendering ? GrGpu::kDrawPath_DrawType : 294 GrGpu::DrawType drawType = usePathRendering ? GrGpu::kDrawPath_DrawType :
300 GrGpu::kDrawPoints_DrawTyp e; 295 GrGpu::kDrawPoints_DrawTyp e;
301 296
302 // twiddle drawstate knobs randomly 297 // twiddle drawstate knobs randomly
303 bool hasGeometryProcessor = !usePathRendering; 298 bool hasGeometryProcessor = !usePathRendering;
299 const GrGeometryProcessor* gp;
304 if (hasGeometryProcessor) { 300 if (hasGeometryProcessor) {
305 set_random_gp(fContext, gpu->glCaps(), &ds, &random, dummyTextures); 301 gp = get_random_gp(fContext, gpu->glCaps(), &ds, &random, dummyTextu res);
306 } 302 }
307 set_random_color_coverage_stages(gpu, 303 set_random_color_coverage_stages(gpu,
308 &ds, 304 &ds,
309 maxStages - hasGeometryProcessor, 305 maxStages - hasGeometryProcessor,
310 usePathRendering, 306 usePathRendering,
311 &random, 307 &random,
312 dummyTextures); 308 dummyTextures);
313 set_random_hints(&ds, &random); 309 set_random_hints(&ds, &random);
314 set_random_state(&ds, &random); 310 set_random_state(&ds, &random);
315 set_random_blend_func(&ds, &random); 311 set_random_blend_func(&ds, &random);
316 set_random_stencil(&ds, &random); 312 set_random_stencil(&ds, &random);
317 313
318 GrDeviceCoordTexture dstCopy; 314 GrDeviceCoordTexture dstCopy;
319 315
320 // TODO take color off the PP when its installed 316 // TODO take color off the PP when its installed
321 GrColor color = ds.hasGeometryProcessor() ? ds.getGeometryProcessor()->g etColor() : 317 GrColor color = hasGeometryProcessor ? gp->getColor() : GrColor_WHITE;
322 GrColor_WHITE; 318 uint8_t coverage = hasGeometryProcessor ? gp->getCoverage() : GrColor_WH ITE;
323 uint8_t coverage = ds.hasGeometryProcessor() ? ds.getGeometryProcessor() ->getCoverage() : 319 if (!this->setupDstReadIfNecessary(&ds, gp, color, coverage, &dstCopy, N ULL)) {
324 GrColor_WHITE;
325 if (!this->setupDstReadIfNecessary(&ds, color, coverage, &dstCopy, NULL) ) {
326 SkDebugf("Couldn't setup dst read texture"); 320 SkDebugf("Couldn't setup dst read texture");
327 return false; 321 return false;
328 } 322 }
329 323
330 // create optimized draw state, setup readDst texture if required, and b uild a descriptor 324 // create optimized draw state, setup readDst texture if required, and b uild a descriptor
331 // and program. ODS creation can fail, so we have to check 325 // and program. ODS creation can fail, so we have to check
332 GrOptDrawState ods(ds, color, coverage, *gpu->caps(), scissor, &dstCopy, drawType); 326 GrOptDrawState ods(ds, gp, color, coverage, *gpu->caps(), scissor, &dstC opy, drawType);
333 if (ods.mustSkip()) { 327 if (ods.mustSkip()) {
334 continue; 328 continue;
335 } 329 }
336 ods.finalize(gpu); 330 ods.finalize(gpu);
337 SkAutoTUnref<GrGLProgram> program(GrGLProgramBuilder::CreateProgram(ods, gpu)); 331 SkAutoTUnref<GrGLProgram> program(GrGLProgramBuilder::CreateProgram(ods, gpu));
338 if (NULL == program.get()) { 332 if (NULL == program.get()) {
339 SkDebugf("Failed to create program!"); 333 SkDebugf("Failed to create program!");
340 return false; 334 return false;
341 } 335 }
342 336
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
375 } 369 }
376 #endif 370 #endif
377 GrTestTarget target; 371 GrTestTarget target;
378 context->getTestTarget(&target); 372 context->getTestTarget(&target);
379 REPORTER_ASSERT(reporter, target.target()->programUnitTest(maxStages )); 373 REPORTER_ASSERT(reporter, target.target()->programUnitTest(maxStages ));
380 } 374 }
381 } 375 }
382 } 376 }
383 377
384 #endif 378 #endif
OLDNEW
« include/gpu/GrXferProcessor.h ('K') | « src/gpu/effects/GrDistanceFieldTextureEffect.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698