| 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  | 
|   11 #include "SkTypes.h" |   11 #include "SkTypes.h" | 
|   12  |   12  | 
|   13 #if SK_SUPPORT_GPU && SK_ALLOW_STATIC_GLOBAL_INITIALIZERS |   13 #if SK_SUPPORT_GPU && SK_ALLOW_STATIC_GLOBAL_INITIALIZERS | 
|   14  |   14  | 
|   15 #include "GrAutoLocaleSetter.h" |   15 #include "GrAutoLocaleSetter.h" | 
|   16 #include "GrBatchTest.h" |   16 #include "GrBatchTest.h" | 
|   17 #include "GrContextFactory.h" |   17 #include "GrContextFactory.h" | 
 |   18 #include "GrDrawContext.h" | 
|   18 #include "GrDrawingManager.h" |   19 #include "GrDrawingManager.h" | 
|   19 #include "GrInvariantOutput.h" |   20 #include "GrInvariantOutput.h" | 
|   20 #include "GrPipeline.h" |   21 #include "GrPipeline.h" | 
|   21 #include "GrResourceProvider.h" |   22 #include "GrResourceProvider.h" | 
|   22 #include "GrTest.h" |   23 #include "GrTest.h" | 
|   23 #include "GrXferProcessor.h" |   24 #include "GrXferProcessor.h" | 
|   24 #include "SkChecksum.h" |   25 #include "SkChecksum.h" | 
|   25 #include "SkRandom.h" |   26 #include "SkRandom.h" | 
|   26 #include "Test.h" |   27 #include "Test.h" | 
|   27  |   28  | 
| (...skipping 321 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  349  |  350  | 
|  350         SkAutoTUnref<GrDrawBatch> batch(GrRandomDrawBatch(&random, context)); |  351         SkAutoTUnref<GrDrawBatch> batch(GrRandomDrawBatch(&random, context)); | 
|  351         SkASSERT(batch); |  352         SkASSERT(batch); | 
|  352  |  353  | 
|  353         GrProcessorTestData ptd(&random, context, context->caps(), rt, dummyText
     ures); |  354         GrProcessorTestData ptd(&random, context, context->caps(), rt, dummyText
     ures); | 
|  354         set_random_color_coverage_stages(&pipelineBuilder, &ptd, maxStages); |  355         set_random_color_coverage_stages(&pipelineBuilder, &ptd, maxStages); | 
|  355         set_random_xpf(&pipelineBuilder, &ptd); |  356         set_random_xpf(&pipelineBuilder, &ptd); | 
|  356         set_random_state(&pipelineBuilder, &random); |  357         set_random_state(&pipelineBuilder, &random); | 
|  357         set_random_stencil(&pipelineBuilder, &random); |  358         set_random_stencil(&pipelineBuilder, &random); | 
|  358  |  359  | 
|  359         GrTestTarget tt; |  360         SkAutoTUnref<GrDrawContext> drawContext(context->drawContext(rt)); | 
|  360         context->getTestTarget(&tt, rt); |  361         if (!drawContext) { | 
 |  362             SkDebugf("Could not allocate drawContext"); | 
 |  363             return false; | 
 |  364         } | 
|  361  |  365  | 
|  362         tt.target()->drawBatch(pipelineBuilder, batch); |  366         drawContext->internal_drawBatch(pipelineBuilder, batch); | 
|  363     } |  367     } | 
|  364     // Flush everything, test passes if flush is successful(ie, no asserts are h
     it, no crashes) |  368     // Flush everything, test passes if flush is successful(ie, no asserts are h
     it, no crashes) | 
|  365     drawingManager->flush(); |  369     drawingManager->flush(); | 
|  366  |  370  | 
|  367     // Validate that GrFPs work correctly without an input. |  371     // Validate that GrFPs work correctly without an input. | 
|  368     GrSurfaceDesc rtDesc; |  372     GrSurfaceDesc rtDesc; | 
|  369     rtDesc.fWidth = kRenderTargetWidth; |  373     rtDesc.fWidth = kRenderTargetWidth; | 
|  370     rtDesc.fHeight = kRenderTargetHeight; |  374     rtDesc.fHeight = kRenderTargetHeight; | 
|  371     rtDesc.fFlags = kRenderTarget_GrSurfaceFlag; |  375     rtDesc.fFlags = kRenderTarget_GrSurfaceFlag; | 
|  372     rtDesc.fConfig = kRGBA_8888_GrPixelConfig; |  376     rtDesc.fConfig = kRGBA_8888_GrPixelConfig; | 
| (...skipping 10 matching lines...) Expand all  Loading... | 
|  383             builder.setXPFactory(GrPorterDuffXPFactory::Create(SkXfermode::kSrc_
     Mode))->unref(); |  387             builder.setXPFactory(GrPorterDuffXPFactory::Create(SkXfermode::kSrc_
     Mode))->unref(); | 
|  384             builder.setRenderTarget(rt); |  388             builder.setRenderTarget(rt); | 
|  385             builder.setClip(clip); |  389             builder.setClip(clip); | 
|  386  |  390  | 
|  387             SkAutoTUnref<const GrFragmentProcessor> fp( |  391             SkAutoTUnref<const GrFragmentProcessor> fp( | 
|  388                 GrProcessorTestFactory<GrFragmentProcessor>::CreateIdx(i, &ptd))
     ; |  392                 GrProcessorTestFactory<GrFragmentProcessor>::CreateIdx(i, &ptd))
     ; | 
|  389             SkAutoTUnref<const GrFragmentProcessor> blockFP( |  393             SkAutoTUnref<const GrFragmentProcessor> blockFP( | 
|  390                 BlockInputFragmentProcessor::Create(fp)); |  394                 BlockInputFragmentProcessor::Create(fp)); | 
|  391             builder.addColorFragmentProcessor(blockFP); |  395             builder.addColorFragmentProcessor(blockFP); | 
|  392  |  396  | 
|  393             GrTestTarget tt; |  397             SkAutoTUnref<GrDrawContext> drawContext(context->drawContext(rt)); | 
|  394             context->getTestTarget(&tt, rt); |  398             if (!drawContext) { | 
 |  399                 SkDebugf("Could not allocate a drawcontext"); | 
 |  400                 return false; | 
 |  401             } | 
|  395  |  402  | 
|  396             tt.target()->drawBatch(builder, batch); |  403             drawContext->internal_drawBatch(builder, batch); | 
|  397             drawingManager->flush(); |  404             drawingManager->flush(); | 
|  398         } |  405         } | 
|  399     } |  406     } | 
|  400  |  407  | 
|  401     return true; |  408     return true; | 
|  402 } |  409 } | 
|  403  |  410  | 
|  404 static int get_glprograms_max_stages(GrContext* context) { |  411 static int get_glprograms_max_stages(GrContext* context) { | 
|  405     GrGLGpu* gpu = static_cast<GrGLGpu*>(context->getGpu()); |  412     GrGLGpu* gpu = static_cast<GrGLGpu*>(context->getGpu()); | 
|  406     /* |  413     /* | 
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  452     GrContextOptions opts; |  459     GrContextOptions opts; | 
|  453     opts.fSuppressPrints = true; |  460     opts.fSuppressPrints = true; | 
|  454     GrContextFactory debugFactory(opts); |  461     GrContextFactory debugFactory(opts); | 
|  455     skiatest::RunWithGPUTestContexts(test_glprograms_native, skiatest::kNative_G
     PUTestContexts, |  462     skiatest::RunWithGPUTestContexts(test_glprograms_native, skiatest::kNative_G
     PUTestContexts, | 
|  456                                      reporter, &debugFactory); |  463                                      reporter, &debugFactory); | 
|  457     skiatest::RunWithGPUTestContexts(test_glprograms_other_contexts, |  464     skiatest::RunWithGPUTestContexts(test_glprograms_other_contexts, | 
|  458                                      skiatest::kOther_GPUTestContexts, reporter,
      &debugFactory); |  465                                      skiatest::kOther_GPUTestContexts, reporter,
      &debugFactory); | 
|  459 } |  466 } | 
|  460  |  467  | 
|  461 #endif |  468 #endif | 
| OLD | NEW |