| 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_xpf(GrContext* context, const GrDrawTargetCaps& caps, GrD
rawState* ds, | |
| 125 SkRandom* random, GrTexture* dummyTextures[]) { | |
| 126 SkAutoTUnref<const GrXPFactory> xpf( | |
| 127 GrProcessorTestFactory<GrXPFactory>::CreateStage(random, context, caps,
dummyTextures)); | |
| 128 SkASSERT(xpf); | |
| 129 ds->setXPFactory(xpf.get()); | |
| 130 } | |
| 131 | |
| 132 static void set_random_gp(GrContext* context, | 124 static void set_random_gp(GrContext* context, |
| 133 const GrDrawTargetCaps& caps, | 125 const GrDrawTargetCaps& caps, |
| 134 GrDrawState* ds, | 126 GrDrawState* ds, |
| 135 SkRandom* random, | 127 SkRandom* random, |
| 136 GrTexture* dummyTextures[]) { | 128 GrTexture* dummyTextures[]) { |
| 137 SkAutoTUnref<const GrGeometryProcessor> gp( | 129 SkAutoTUnref<const GrGeometryProcessor> gp( |
| 138 GrProcessorTestFactory<GrGeometryProcessor>::CreateStage(random, | 130 GrProcessorTestFactory<GrGeometryProcessor>::CreateStage(random, |
| 139 context, | 131 context, |
| 140 caps, | 132 caps, |
| 141 dummyTextur
es)); | 133 dummyTextur
es)); |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 196 } | 188 } |
| 197 | 189 |
| 198 static void set_random_state(GrDrawState* ds, SkRandom* random) { | 190 static void set_random_state(GrDrawState* ds, SkRandom* random) { |
| 199 int state = 0; | 191 int state = 0; |
| 200 for (int i = 1; i <= GrDrawState::kLast_StateBit; i <<= 1) { | 192 for (int i = 1; i <= GrDrawState::kLast_StateBit; i <<= 1) { |
| 201 state |= random->nextBool() * i; | 193 state |= random->nextBool() * i; |
| 202 } | 194 } |
| 203 ds->enableState(state); | 195 ds->enableState(state); |
| 204 } | 196 } |
| 205 | 197 |
| 198 // this function will randomly pick non-self referencing blend modes |
| 199 static void set_random_blend_func(GrDrawState* ds, SkRandom* random) { |
| 200 GrBlendCoeff src; |
| 201 do { |
| 202 src = GrBlendCoeff(random->nextRangeU(kFirstPublicGrBlendCoeff, kLastPub
licGrBlendCoeff)); |
| 203 } while (GrBlendCoeffRefsSrc(src)); |
| 204 |
| 205 GrBlendCoeff dst; |
| 206 do { |
| 207 dst = GrBlendCoeff(random->nextRangeU(kFirstPublicGrBlendCoeff, kLastPub
licGrBlendCoeff)); |
| 208 } while (GrBlendCoeffRefsDst(dst)); |
| 209 |
| 210 GrXPFactory* xpFactory = GrPorterDuffXPFactory::Create(src, dst); |
| 211 ds->setXPFactory(xpFactory)->unref(); |
| 212 } |
| 213 |
| 206 // right now, the only thing we seem to care about in drawState's stencil is 'do
esWrite()' | 214 // right now, the only thing we seem to care about in drawState's stencil is 'do
esWrite()' |
| 207 static void set_random_stencil(GrDrawState* ds, SkRandom* random) { | 215 static void set_random_stencil(GrDrawState* ds, SkRandom* random) { |
| 208 GR_STATIC_CONST_SAME_STENCIL(kDoesWriteStencil, | 216 GR_STATIC_CONST_SAME_STENCIL(kDoesWriteStencil, |
| 209 kReplace_StencilOp, | 217 kReplace_StencilOp, |
| 210 kReplace_StencilOp, | 218 kReplace_StencilOp, |
| 211 kAlways_StencilFunc, | 219 kAlways_StencilFunc, |
| 212 0xffff, | 220 0xffff, |
| 213 0xffff, | 221 0xffff, |
| 214 0xffff); | 222 0xffff); |
| 215 GR_STATIC_CONST_SAME_STENCIL(kDoesNotWriteStencil, | 223 GR_STATIC_CONST_SAME_STENCIL(kDoesNotWriteStencil, |
| (...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 295 bool hasGeometryProcessor = !usePathRendering; | 303 bool hasGeometryProcessor = !usePathRendering; |
| 296 if (hasGeometryProcessor) { | 304 if (hasGeometryProcessor) { |
| 297 set_random_gp(fContext, gpu->glCaps(), &ds, &random, dummyTextures); | 305 set_random_gp(fContext, gpu->glCaps(), &ds, &random, dummyTextures); |
| 298 } | 306 } |
| 299 set_random_color_coverage_stages(gpu, | 307 set_random_color_coverage_stages(gpu, |
| 300 &ds, | 308 &ds, |
| 301 maxStages - hasGeometryProcessor, | 309 maxStages - hasGeometryProcessor, |
| 302 usePathRendering, | 310 usePathRendering, |
| 303 &random, | 311 &random, |
| 304 dummyTextures); | 312 dummyTextures); |
| 305 | |
| 306 // creates a random xfer processor factory on the draw state | |
| 307 set_random_xpf(fContext, gpu->glCaps(), &ds, &random, dummyTextures); | |
| 308 | |
| 309 set_random_hints(&ds, &random); | 313 set_random_hints(&ds, &random); |
| 310 set_random_state(&ds, &random); | 314 set_random_state(&ds, &random); |
| 315 set_random_blend_func(&ds, &random); |
| 311 set_random_stencil(&ds, &random); | 316 set_random_stencil(&ds, &random); |
| 312 | 317 |
| 313 GrDeviceCoordTexture dstCopy; | 318 GrDeviceCoordTexture dstCopy; |
| 314 | 319 |
| 315 // TODO take color off the PP when its installed | 320 // TODO take color off the PP when its installed |
| 316 GrColor color = ds.hasGeometryProcessor() ? ds.getGeometryProcessor()->g
etColor() : | 321 GrColor color = ds.hasGeometryProcessor() ? ds.getGeometryProcessor()->g
etColor() : |
| 317 GrColor_WHITE; | 322 GrColor_WHITE; |
| 318 uint8_t coverage = ds.hasGeometryProcessor() ? ds.getGeometryProcessor()
->getCoverage() : | 323 uint8_t coverage = ds.hasGeometryProcessor() ? ds.getGeometryProcessor()
->getCoverage() : |
| 319 0xff; | 324 0xff; |
| 320 if (!this->setupDstReadIfNecessary(&ds, color, coverage, &dstCopy, NULL)
) { | 325 if (!this->setupDstReadIfNecessary(&ds, color, coverage, &dstCopy, NULL)
) { |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 370 } | 375 } |
| 371 #endif | 376 #endif |
| 372 GrTestTarget target; | 377 GrTestTarget target; |
| 373 context->getTestTarget(&target); | 378 context->getTestTarget(&target); |
| 374 REPORTER_ASSERT(reporter, target.target()->programUnitTest(maxStages
)); | 379 REPORTER_ASSERT(reporter, target.target()->programUnitTest(maxStages
)); |
| 375 } | 380 } |
| 376 } | 381 } |
| 377 } | 382 } |
| 378 | 383 |
| 379 #endif | 384 #endif |
| OLD | NEW |