Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 Loading... | |
| 114 SkAutoTUnref<GrTexture> texture(context->findAndRefTexture(texDesc, cacheId, ¶ms)); | 114 SkAutoTUnref<GrTexture> texture(context->findAndRefTexture(texDesc, cacheId, ¶ms)); |
| 115 if (!texture) { | 115 if (!texture) { |
| 116 texture.reset(context->createTexture(¶ms, texDesc, cacheId, 0, 0)); | 116 texture.reset(context->createTexture(¶ms, 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 Loading... | |
| 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 = NULL; | |
| 300 const GrPathProcessor* pp = NULL; | |
|
egdaniel
2014/12/10 15:54:30
since below we have a primP as well, I feel like t
bsalomon
2014/12/10 15:56:05
+1, we should avoid the acronym pp since it is amb
| |
| 304 if (hasGeometryProcessor) { | 301 if (hasGeometryProcessor) { |
| 305 set_random_gp(fContext, gpu->glCaps(), &ds, &random, dummyTextures); | 302 gp = get_random_gp(fContext, gpu->glCaps(), &random, dummyTextures); |
| 303 } else { | |
| 304 pp = GrPathProcessor::Create(GrColor_WHITE); | |
| 306 } | 305 } |
| 307 set_random_color_coverage_stages(gpu, | 306 set_random_color_coverage_stages(gpu, |
| 308 &ds, | 307 &ds, |
| 309 maxStages - hasGeometryProcessor, | 308 maxStages - hasGeometryProcessor, |
| 310 usePathRendering, | 309 usePathRendering, |
| 311 &random, | 310 &random, |
| 312 dummyTextures); | 311 dummyTextures); |
| 313 set_random_hints(&ds, &random); | 312 set_random_hints(&ds, &random); |
| 314 set_random_state(&ds, &random); | 313 set_random_state(&ds, &random); |
| 315 set_random_blend_func(&ds, &random); | 314 set_random_blend_func(&ds, &random); |
| 316 set_random_stencil(&ds, &random); | 315 set_random_stencil(&ds, &random); |
| 317 | 316 |
| 318 GrDeviceCoordTexture dstCopy; | 317 GrDeviceCoordTexture dstCopy; |
| 319 | 318 |
| 320 // TODO take color off the PP when its installed | 319 const GrPrimitiveProcessor* primP; |
| 321 GrColor color = ds.hasGeometryProcessor() ? ds.getGeometryProcessor()->g etColor() : | 320 if (hasGeometryProcessor) { |
| 322 GrColor_WHITE; | 321 primP = gp; |
| 323 uint8_t coverage = ds.hasGeometryProcessor() ? ds.getGeometryProcessor() ->getCoverage() : | 322 } else { |
| 324 GrColor_WHITE; | 323 primP = pp; |
| 325 if (!this->setupDstReadIfNecessary(&ds, color, coverage, &dstCopy, NULL) ) { | 324 } |
| 325 if (!this->setupDstReadIfNecessary(&ds, primP, &dstCopy, NULL)) { | |
| 326 SkDebugf("Couldn't setup dst read texture"); | 326 SkDebugf("Couldn't setup dst read texture"); |
| 327 return false; | 327 return false; |
| 328 } | 328 } |
| 329 | 329 |
| 330 // create optimized draw state, setup readDst texture if required, and b uild a descriptor | 330 // 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 | 331 // and program. ODS creation can fail, so we have to check |
| 332 GrOptDrawState ods(ds, color, coverage, *gpu->caps(), scissor, &dstCopy, drawType); | 332 GrOptDrawState ods(ds, gp, pp, *gpu->caps(), scissor, &dstCopy, drawType ); |
| 333 if (ods.mustSkip()) { | 333 if (ods.mustSkip()) { |
| 334 continue; | 334 continue; |
| 335 } | 335 } |
| 336 ods.finalize(gpu); | 336 ods.finalize(gpu); |
| 337 SkAutoTUnref<GrGLProgram> program(GrGLProgramBuilder::CreateProgram(ods, gpu)); | 337 SkAutoTUnref<GrGLProgram> program(GrGLProgramBuilder::CreateProgram(ods, gpu)); |
| 338 if (NULL == program.get()) { | 338 if (NULL == program.get()) { |
| 339 SkDebugf("Failed to create program!"); | 339 SkDebugf("Failed to create program!"); |
| 340 return false; | 340 return false; |
| 341 } | 341 } |
| 342 | 342 |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 375 } | 375 } |
| 376 #endif | 376 #endif |
| 377 GrTestTarget target; | 377 GrTestTarget target; |
| 378 context->getTestTarget(&target); | 378 context->getTestTarget(&target); |
| 379 REPORTER_ASSERT(reporter, target.target()->programUnitTest(maxStages )); | 379 REPORTER_ASSERT(reporter, target.target()->programUnitTest(maxStages )); |
| 380 } | 380 } |
| 381 } | 381 } |
| 382 } | 382 } |
| 383 | 383 |
| 384 #endif | 384 #endif |
| OLD | NEW |