| 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 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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 |
| 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 167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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. |
| 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 |