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