| 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 313 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 324 if (!dummyTexture1 || ! dummyTexture2) { | 324 if (!dummyTexture1 || ! dummyTexture2) { |
| 325 SkDebugf("Could not allocate dummy textures"); | 325 SkDebugf("Could not allocate dummy textures"); |
| 326 return false; | 326 return false; |
| 327 } | 327 } |
| 328 | 328 |
| 329 GrTexture* dummyTextures[] = {dummyTexture1.get(), dummyTexture2.get()}; | 329 GrTexture* dummyTextures[] = {dummyTexture1.get(), dummyTexture2.get()}; |
| 330 | 330 |
| 331 // dummy scissor state | 331 // dummy scissor state |
| 332 GrScissorState scissor; | 332 GrScissorState scissor; |
| 333 | 333 |
| 334 // wide open clip | |
| 335 GrClip clip; | |
| 336 | |
| 337 SkRandom random; | 334 SkRandom random; |
| 338 static const int NUM_TESTS = 1024; | 335 static const int NUM_TESTS = 1024; |
| 339 for (int t = 0; t < NUM_TESTS; t++) { | 336 for (int t = 0; t < NUM_TESTS; t++) { |
| 340 // setup random render target(can fail) | 337 // setup random render target(can fail) |
| 341 sk_sp<GrRenderTarget> rt(random_render_target( | 338 sk_sp<GrRenderTarget> rt(random_render_target( |
| 342 context->textureProvider(), &random, context->caps())); | 339 context->textureProvider(), &random, context->caps())); |
| 343 if (!rt.get()) { | 340 if (!rt.get()) { |
| 344 SkDebugf("Could not allocate render target"); | 341 SkDebugf("Could not allocate render target"); |
| 345 return false; | 342 return false; |
| 346 } | 343 } |
| 347 | 344 |
| 348 GrPipelineBuilder pipelineBuilder; | 345 GrPipelineBuilder pipelineBuilder; |
| 349 pipelineBuilder.setRenderTarget(rt.get()); | 346 pipelineBuilder.setRenderTarget(rt.get()); |
| 350 pipelineBuilder.setClip(clip); | |
| 351 | 347 |
| 352 SkAutoTUnref<GrDrawBatch> batch(GrRandomDrawBatch(&random, context)); | 348 SkAutoTUnref<GrDrawBatch> batch(GrRandomDrawBatch(&random, context)); |
| 353 SkASSERT(batch); | 349 SkASSERT(batch); |
| 354 | 350 |
| 355 GrProcessorTestData ptd(&random, context, context->caps(), rt.get(), dum
myTextures); | 351 GrProcessorTestData ptd(&random, context, context->caps(), rt.get(), dum
myTextures); |
| 356 set_random_color_coverage_stages(&pipelineBuilder, &ptd, maxStages); | 352 set_random_color_coverage_stages(&pipelineBuilder, &ptd, maxStages); |
| 357 set_random_xpf(&pipelineBuilder, &ptd); | 353 set_random_xpf(&pipelineBuilder, &ptd); |
| 358 set_random_state(&pipelineBuilder, &random); | 354 set_random_state(&pipelineBuilder, &random); |
| 359 set_random_stencil(&pipelineBuilder, &random); | 355 set_random_stencil(&pipelineBuilder, &random); |
| 360 | 356 |
| (...skipping 19 matching lines...) Expand all Loading... |
| 380 int fpFactoryCnt = GrProcessorTestFactory<GrFragmentProcessor>::Count(); | 376 int fpFactoryCnt = GrProcessorTestFactory<GrFragmentProcessor>::Count(); |
| 381 for (int i = 0; i < fpFactoryCnt; ++i) { | 377 for (int i = 0; i < fpFactoryCnt; ++i) { |
| 382 // Since FP factories internally randomize, call each 10 times. | 378 // Since FP factories internally randomize, call each 10 times. |
| 383 for (int j = 0; j < 10; ++j) { | 379 for (int j = 0; j < 10; ++j) { |
| 384 SkAutoTUnref<GrDrawBatch> batch(GrRandomDrawBatch(&random, context))
; | 380 SkAutoTUnref<GrDrawBatch> batch(GrRandomDrawBatch(&random, context))
; |
| 385 SkASSERT(batch); | 381 SkASSERT(batch); |
| 386 GrProcessorTestData ptd(&random, context, context->caps(), rt.get(),
dummyTextures); | 382 GrProcessorTestData ptd(&random, context, context->caps(), rt.get(),
dummyTextures); |
| 387 GrPipelineBuilder builder; | 383 GrPipelineBuilder builder; |
| 388 builder.setXPFactory(GrPorterDuffXPFactory::Create(SkXfermode::kSrc_
Mode))->unref(); | 384 builder.setXPFactory(GrPorterDuffXPFactory::Create(SkXfermode::kSrc_
Mode))->unref(); |
| 389 builder.setRenderTarget(rt.get()); | 385 builder.setRenderTarget(rt.get()); |
| 390 builder.setClip(clip); | |
| 391 | 386 |
| 392 SkAutoTUnref<const GrFragmentProcessor> fp( | 387 SkAutoTUnref<const GrFragmentProcessor> fp( |
| 393 GrProcessorTestFactory<GrFragmentProcessor>::CreateIdx(i, &ptd))
; | 388 GrProcessorTestFactory<GrFragmentProcessor>::CreateIdx(i, &ptd))
; |
| 394 SkAutoTUnref<const GrFragmentProcessor> blockFP( | 389 SkAutoTUnref<const GrFragmentProcessor> blockFP( |
| 395 BlockInputFragmentProcessor::Create(fp)); | 390 BlockInputFragmentProcessor::Create(fp)); |
| 396 builder.addColorFragmentProcessor(blockFP); | 391 builder.addColorFragmentProcessor(blockFP); |
| 397 | 392 |
| 398 sk_sp<GrDrawContext> drawContext(context->drawContext(rt)); | 393 sk_sp<GrDrawContext> drawContext(context->drawContext(rt)); |
| 399 if (!drawContext) { | 394 if (!drawContext) { |
| 400 SkDebugf("Could not allocate a drawcontext"); | 395 SkDebugf("Could not allocate a drawcontext"); |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 473 GrContextOptions opts; | 468 GrContextOptions opts; |
| 474 opts.fSuppressPrints = true; | 469 opts.fSuppressPrints = true; |
| 475 sk_gpu_test::GrContextFactory debugFactory(opts); | 470 sk_gpu_test::GrContextFactory debugFactory(opts); |
| 476 skiatest::RunWithGPUTestContexts(test_glprograms_native, &is_native_gl_conte
xt_type, | 471 skiatest::RunWithGPUTestContexts(test_glprograms_native, &is_native_gl_conte
xt_type, |
| 477 reporter, &debugFactory); | 472 reporter, &debugFactory); |
| 478 skiatest::RunWithGPUTestContexts(test_glprograms_other_contexts, | 473 skiatest::RunWithGPUTestContexts(test_glprograms_other_contexts, |
| 479 &is_other_rendering_gl_context_type, report
er, &debugFactory); | 474 &is_other_rendering_gl_context_type, report
er, &debugFactory); |
| 480 } | 475 } |
| 481 | 476 |
| 482 #endif | 477 #endif |
| OLD | NEW |