| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2011 Google Inc. | 2 * Copyright 2011 Google Inc. |
| 3 * | 3 * |
| 4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
| 5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
| 6 */ | 6 */ |
| 7 | 7 |
| 8 // This is a GPU-backend specific test. It relies on static intializers to work | 8 // This is a GPU-backend specific test. It relies on static intializers to work |
| 9 | 9 |
| 10 #include "SkTypes.h" | 10 #include "SkTypes.h" |
| (...skipping 332 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 343 static const int NUM_TESTS = 1024; | 343 static const int NUM_TESTS = 1024; |
| 344 for (int t = 0; t < NUM_TESTS; t++) { | 344 for (int t = 0; t < NUM_TESTS; t++) { |
| 345 // setup random render target(can fail) | 345 // setup random render target(can fail) |
| 346 sk_sp<GrDrawContext> drawContext(random_draw_context(context, &random, c
ontext->caps())); | 346 sk_sp<GrDrawContext> drawContext(random_draw_context(context, &random, c
ontext->caps())); |
| 347 if (!drawContext) { | 347 if (!drawContext) { |
| 348 SkDebugf("Could not allocate drawContext"); | 348 SkDebugf("Could not allocate drawContext"); |
| 349 return false; | 349 return false; |
| 350 } | 350 } |
| 351 | 351 |
| 352 GrPipelineBuilder pipelineBuilder; | 352 GrPipelineBuilder pipelineBuilder; |
| 353 pipelineBuilder.setRenderTarget(drawContext->accessRenderTarget()); | |
| 354 | 353 |
| 355 SkAutoTUnref<GrDrawBatch> batch(GrRandomDrawBatch(&random, context)); | 354 SkAutoTUnref<GrDrawBatch> batch(GrRandomDrawBatch(&random, context)); |
| 356 SkASSERT(batch); | 355 SkASSERT(batch); |
| 357 | 356 |
| 358 GrProcessorTestData ptd(&random, context, context->caps(), | 357 GrProcessorTestData ptd(&random, context, context->caps(), |
| 359 drawContext.get(), dummyTextures); | 358 drawContext.get(), dummyTextures); |
| 360 set_random_color_coverage_stages(&pipelineBuilder, &ptd, maxStages); | 359 set_random_color_coverage_stages(&pipelineBuilder, &ptd, maxStages); |
| 361 set_random_xpf(&pipelineBuilder, &ptd); | 360 set_random_xpf(&pipelineBuilder, &ptd); |
| 362 set_random_state(&pipelineBuilder, drawContext.get(), &random); | 361 set_random_state(&pipelineBuilder, drawContext.get(), &random); |
| 363 set_random_stencil(&pipelineBuilder, &random); | 362 set_random_stencil(&pipelineBuilder, &random); |
| (...skipping 16 matching lines...) Expand all Loading... |
| 380 int fpFactoryCnt = GrProcessorTestFactory<GrFragmentProcessor>::Count(); | 379 int fpFactoryCnt = GrProcessorTestFactory<GrFragmentProcessor>::Count(); |
| 381 for (int i = 0; i < fpFactoryCnt; ++i) { | 380 for (int i = 0; i < fpFactoryCnt; ++i) { |
| 382 // Since FP factories internally randomize, call each 10 times. | 381 // Since FP factories internally randomize, call each 10 times. |
| 383 for (int j = 0; j < 10; ++j) { | 382 for (int j = 0; j < 10; ++j) { |
| 384 SkAutoTUnref<GrDrawBatch> batch(GrRandomDrawBatch(&random, context))
; | 383 SkAutoTUnref<GrDrawBatch> batch(GrRandomDrawBatch(&random, context))
; |
| 385 SkASSERT(batch); | 384 SkASSERT(batch); |
| 386 GrProcessorTestData ptd(&random, context, context->caps(), | 385 GrProcessorTestData ptd(&random, context, context->caps(), |
| 387 drawContext.get(), dummyTextures); | 386 drawContext.get(), dummyTextures); |
| 388 GrPipelineBuilder builder; | 387 GrPipelineBuilder builder; |
| 389 builder.setXPFactory(GrPorterDuffXPFactory::Create(SkXfermode::kSrc_
Mode))->unref(); | 388 builder.setXPFactory(GrPorterDuffXPFactory::Create(SkXfermode::kSrc_
Mode))->unref(); |
| 390 builder.setRenderTarget(drawContext->accessRenderTarget()); | |
| 391 | 389 |
| 392 SkAutoTUnref<const GrFragmentProcessor> fp( | 390 SkAutoTUnref<const GrFragmentProcessor> fp( |
| 393 GrProcessorTestFactory<GrFragmentProcessor>::CreateIdx(i, &ptd))
; | 391 GrProcessorTestFactory<GrFragmentProcessor>::CreateIdx(i, &ptd))
; |
| 394 SkAutoTUnref<const GrFragmentProcessor> blockFP( | 392 SkAutoTUnref<const GrFragmentProcessor> blockFP( |
| 395 BlockInputFragmentProcessor::Create(fp)); | 393 BlockInputFragmentProcessor::Create(fp)); |
| 396 builder.addColorFragmentProcessor(blockFP); | 394 builder.addColorFragmentProcessor(blockFP); |
| 397 | 395 |
| 398 drawContext->drawContextPriv().testingOnly_drawBatch(builder, batch)
; | 396 drawContext->drawContextPriv().testingOnly_drawBatch(builder, batch)
; |
| 399 drawingManager->flush(); | 397 drawingManager->flush(); |
| 400 } | 398 } |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 467 GrContextOptions opts; | 465 GrContextOptions opts; |
| 468 opts.fSuppressPrints = true; | 466 opts.fSuppressPrints = true; |
| 469 sk_gpu_test::GrContextFactory debugFactory(opts); | 467 sk_gpu_test::GrContextFactory debugFactory(opts); |
| 470 skiatest::RunWithGPUTestContexts(test_glprograms_native, &is_native_gl_conte
xt_type, | 468 skiatest::RunWithGPUTestContexts(test_glprograms_native, &is_native_gl_conte
xt_type, |
| 471 reporter, &debugFactory); | 469 reporter, &debugFactory); |
| 472 skiatest::RunWithGPUTestContexts(test_glprograms_other_contexts, | 470 skiatest::RunWithGPUTestContexts(test_glprograms_other_contexts, |
| 473 &is_other_rendering_gl_context_type, report
er, &debugFactory); | 471 &is_other_rendering_gl_context_type, report
er, &debugFactory); |
| 474 } | 472 } |
| 475 | 473 |
| 476 #endif | 474 #endif |
| OLD | NEW |