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

Side by Side Diff: tests/GLProgramsTest.cpp

Issue 764643004: Create xfer processor backend. (Closed) Base URL: https://skia.googlesource.com/skia.git@xferBlendSolo
Patch Set: updated and rebased from prev cls 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_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 116 matching lines...) Expand 10 before | Expand all | Expand 10 after
250 } 258 }
251 259
252 static void set_random_state(GrDrawState* ds, SkRandom* random) { 260 static void set_random_state(GrDrawState* ds, SkRandom* random) {
253 int state = 0; 261 int state = 0;
254 for (int i = 1; i <= GrDrawState::kLast_StateBit; i <<= 1) { 262 for (int i = 1; i <= GrDrawState::kLast_StateBit; i <<= 1) {
255 state |= random->nextBool() * i; 263 state |= random->nextBool() * i;
256 } 264 }
257 ds->enableState(state); 265 ds->enableState(state);
258 } 266 }
259 267
260 // this function will randomly pick non-self referencing blend modes
261 static void set_random_blend_func(GrDrawState* ds, SkRandom* random) {
262 GrBlendCoeff src;
263 do {
264 src = GrBlendCoeff(random->nextRangeU(kFirstPublicGrBlendCoeff, kLastPub licGrBlendCoeff));
265 } while (GrBlendCoeffRefsSrc(src));
266
267 GrBlendCoeff dst;
268 do {
269 dst = GrBlendCoeff(random->nextRangeU(kFirstPublicGrBlendCoeff, kLastPub licGrBlendCoeff));
270 } while (GrBlendCoeffRefsDst(dst));
271
272 GrXPFactory* xpFactory = GrPorterDuffXPFactory::Create(src, dst);
273 ds->setXPFactory(xpFactory)->unref();
274 }
275
276 // right now, the only thing we seem to care about in drawState's stencil is 'do esWrite()' 268 // right now, the only thing we seem to care about in drawState's stencil is 'do esWrite()'
277 static void set_random_stencil(GrDrawState* ds, SkRandom* random) { 269 static void set_random_stencil(GrDrawState* ds, SkRandom* random) {
278 GR_STATIC_CONST_SAME_STENCIL(kDoesWriteStencil, 270 GR_STATIC_CONST_SAME_STENCIL(kDoesWriteStencil,
279 kReplace_StencilOp, 271 kReplace_StencilOp,
280 kReplace_StencilOp, 272 kReplace_StencilOp,
281 kAlways_StencilFunc, 273 kAlways_StencilFunc,
282 0xffff, 274 0xffff,
283 0xffff, 275 0xffff,
284 0xffff); 276 0xffff);
285 GR_STATIC_CONST_SAME_STENCIL(kDoesNotWriteStencil, 277 GR_STATIC_CONST_SAME_STENCIL(kDoesNotWriteStencil,
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
365 bool hasGeometryProcessor = !usePathRendering; 357 bool hasGeometryProcessor = !usePathRendering;
366 if (hasGeometryProcessor) { 358 if (hasGeometryProcessor) {
367 set_random_gp(fContext, gpu->glCaps(), &ds, &random, dummyTextures); 359 set_random_gp(fContext, gpu->glCaps(), &ds, &random, dummyTextures);
368 } 360 }
369 set_random_color_coverage_stages(gpu, 361 set_random_color_coverage_stages(gpu,
370 &ds, 362 &ds,
371 maxStages - hasGeometryProcessor, 363 maxStages - hasGeometryProcessor,
372 usePathRendering, 364 usePathRendering,
373 &random, 365 &random,
374 dummyTextures); 366 dummyTextures);
367
368 // creates a random xfer processor factory on the draw state
369 set_random_xpf(fContext, gpu->glCaps(), &ds, &random, dummyTextures);
370
375 set_random_color(&ds, &random); 371 set_random_color(&ds, &random);
376 set_random_coverage(&ds, &random); 372 set_random_coverage(&ds, &random);
377 set_random_hints(&ds, &random); 373 set_random_hints(&ds, &random);
378 set_random_state(&ds, &random); 374 set_random_state(&ds, &random);
379 set_random_blend_func(&ds, &random);
380 set_random_stencil(&ds, &random); 375 set_random_stencil(&ds, &random);
381 376
382 GrDeviceCoordTexture dstCopy; 377 GrDeviceCoordTexture dstCopy;
383 378
384 if (!this->setupDstReadIfNecessary(&ds, &dstCopy, NULL)) { 379 if (!this->setupDstReadIfNecessary(&ds, &dstCopy, NULL)) {
385 SkDebugf("Couldn't setup dst read texture"); 380 SkDebugf("Couldn't setup dst read texture");
386 return false; 381 return false;
387 } 382 }
388 383
389 // create optimized draw state, setup readDst texture if required, and b uild a descriptor 384 // create optimized draw state, setup readDst texture if required, and b uild a descriptor
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
434 } 429 }
435 #endif 430 #endif
436 GrTestTarget target; 431 GrTestTarget target;
437 context->getTestTarget(&target); 432 context->getTestTarget(&target);
438 REPORTER_ASSERT(reporter, target.target()->programUnitTest(maxStages )); 433 REPORTER_ASSERT(reporter, target.target()->programUnitTest(maxStages ));
439 } 434 }
440 } 435 }
441 } 436 }
442 437
443 #endif 438 #endif
OLDNEW
« src/gpu/gl/builders/GrGLProgramBuilder.h ('K') | « src/gpu/gl/builders/GrGLProgramBuilder.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698