Chromium Code Reviews| 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 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 146 */ | 146 */ |
| 147 static const int kRenderTargetHeight = 1; | 147 static const int kRenderTargetHeight = 1; |
| 148 static const int kRenderTargetWidth = 1; | 148 static const int kRenderTargetWidth = 1; |
| 149 | 149 |
| 150 static sk_sp<GrDrawContext> random_draw_context(GrContext* context, | 150 static sk_sp<GrDrawContext> random_draw_context(GrContext* context, |
| 151 SkRandom* random, | 151 SkRandom* random, |
| 152 const GrCaps* caps) { | 152 const GrCaps* caps) { |
| 153 GrSurfaceOrigin origin = random->nextBool() ? kTopLeft_GrSurfaceOrigin | 153 GrSurfaceOrigin origin = random->nextBool() ? kTopLeft_GrSurfaceOrigin |
| 154 : kBottomLeft_GrSurfaceOrigin; | 154 : kBottomLeft_GrSurfaceOrigin; |
| 155 int sampleCnt = random->nextBool() ? SkTMin(4, caps->maxSampleCount()) : 0; | 155 int sampleCnt = random->nextBool() ? SkTMin(4, caps->maxSampleCount()) : 0; |
| 156 | 156 |
|
robertphillips
2016/07/21 19:22:41
Should we start to randomly create a color space t
| |
| 157 sk_sp<GrDrawContext> drawContext(context->newDrawContext(SkBackingFit::kExac t, | 157 sk_sp<GrDrawContext> drawContext(context->newDrawContext(SkBackingFit::kExac t, |
| 158 kRenderTargetWidth, | 158 kRenderTargetWidth, |
| 159 kRenderTargetHeight , | 159 kRenderTargetHeight , |
| 160 kRGBA_8888_GrPixelC onfig, | 160 kRGBA_8888_GrPixelC onfig, |
| 161 nullptr, | |
| 161 sampleCnt, | 162 sampleCnt, |
| 162 origin)); | 163 origin)); |
| 163 return drawContext; | 164 return drawContext; |
| 164 } | 165 } |
| 165 | 166 |
| 166 static void set_random_xpf(GrPaint* paint, GrProcessorTestData* d) { | 167 static void set_random_xpf(GrPaint* paint, GrProcessorTestData* d) { |
| 167 sk_sp<GrXPFactory> xpf(GrProcessorTestFactory<GrXPFactory>::Make(d)); | 168 sk_sp<GrXPFactory> xpf(GrProcessorTestFactory<GrXPFactory>::Make(d)); |
| 168 SkASSERT(xpf); | 169 SkASSERT(xpf); |
| 169 paint->setXPFactory(std::move(xpf)); | 170 paint->setXPFactory(std::move(xpf)); |
| 170 } | 171 } |
| (...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 334 set_random_color_coverage_stages(&grPaint, &ptd, maxStages); | 335 set_random_color_coverage_stages(&grPaint, &ptd, maxStages); |
| 335 set_random_xpf(&grPaint, &ptd); | 336 set_random_xpf(&grPaint, &ptd); |
| 336 bool snapToCenters = set_random_state(&grPaint, &random); | 337 bool snapToCenters = set_random_state(&grPaint, &random); |
| 337 const GrUserStencilSettings* uss = get_random_stencil(&random); | 338 const GrUserStencilSettings* uss = get_random_stencil(&random); |
| 338 | 339 |
| 339 drawContext->drawContextPriv().testingOnly_drawBatch(grPaint, batch, uss , snapToCenters); | 340 drawContext->drawContextPriv().testingOnly_drawBatch(grPaint, batch, uss , snapToCenters); |
| 340 } | 341 } |
| 341 // Flush everything, test passes if flush is successful(ie, no asserts are h it, no crashes) | 342 // Flush everything, test passes if flush is successful(ie, no asserts are h it, no crashes) |
| 342 drawingManager->flush(); | 343 drawingManager->flush(); |
| 343 | 344 |
| 344 // Validate that GrFPs work correctly without an input. | 345 // Validate that GrFPs work correctly without an input. |
|
robertphillips
2016/07/21 19:22:41
Any idea why we don't call random_draw_context her
| |
| 345 sk_sp<GrDrawContext> drawContext(context->newDrawContext(SkBackingFit::kExac t, | 346 sk_sp<GrDrawContext> drawContext(context->newDrawContext(SkBackingFit::kExac t, |
| 346 kRenderTargetWidth, | 347 kRenderTargetWidth, |
| 347 kRenderTargetHeight , | 348 kRenderTargetHeight , |
| 348 kRGBA_8888_GrPixelC onfig)); | 349 kRGBA_8888_GrPixelC onfig, |
| 350 nullptr)); | |
| 349 if (!drawContext) { | 351 if (!drawContext) { |
| 350 SkDebugf("Could not allocate a drawContext"); | 352 SkDebugf("Could not allocate a drawContext"); |
| 351 return false; | 353 return false; |
| 352 } | 354 } |
| 353 | 355 |
| 354 int fpFactoryCnt = GrProcessorTestFactory<GrFragmentProcessor>::Count(); | 356 int fpFactoryCnt = GrProcessorTestFactory<GrFragmentProcessor>::Count(); |
| 355 for (int i = 0; i < fpFactoryCnt; ++i) { | 357 for (int i = 0; i < fpFactoryCnt; ++i) { |
| 356 // Since FP factories internally randomize, call each 10 times. | 358 // Since FP factories internally randomize, call each 10 times. |
| 357 for (int j = 0; j < 10; ++j) { | 359 for (int j = 0; j < 10; ++j) { |
| 358 SkAutoTUnref<GrDrawBatch> batch(GrRandomDrawBatch(&random, context)) ; | 360 SkAutoTUnref<GrDrawBatch> batch(GrRandomDrawBatch(&random, context)) ; |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 440 GrContextOptions opts; | 442 GrContextOptions opts; |
| 441 opts.fSuppressPrints = true; | 443 opts.fSuppressPrints = true; |
| 442 sk_gpu_test::GrContextFactory debugFactory(opts); | 444 sk_gpu_test::GrContextFactory debugFactory(opts); |
| 443 skiatest::RunWithGPUTestContexts(test_glprograms_native, &is_native_gl_conte xt_type, | 445 skiatest::RunWithGPUTestContexts(test_glprograms_native, &is_native_gl_conte xt_type, |
| 444 reporter, &debugFactory); | 446 reporter, &debugFactory); |
| 445 skiatest::RunWithGPUTestContexts(test_glprograms_other_contexts, | 447 skiatest::RunWithGPUTestContexts(test_glprograms_other_contexts, |
| 446 &is_other_rendering_gl_context_type, report er, &debugFactory); | 448 &is_other_rendering_gl_context_type, report er, &debugFactory); |
| 447 } | 449 } |
| 448 | 450 |
| 449 #endif | 451 #endif |
| OLD | NEW |