| 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 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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 |
| 157 sk_sp<GrDrawContext> drawContext(context->newDrawContext(SkBackingFit::kExac
t, | 157 sk_sp<GrDrawContext> drawContext(context->makeDrawContext(SkBackingFit::kExa
ct, |
| 158 kRenderTargetWidth, | 158 kRenderTargetWidth
, |
| 159 kRenderTargetHeight
, | 159 kRenderTargetHeigh
t, |
| 160 kRGBA_8888_GrPixelC
onfig, | 160 kRGBA_8888_GrPixel
Config, |
| 161 nullptr, | 161 nullptr, |
| 162 sampleCnt, | 162 sampleCnt, |
| 163 origin)); | 163 origin)); |
| 164 return drawContext; | 164 return drawContext; |
| 165 } | 165 } |
| 166 | 166 |
| 167 static void set_random_xpf(GrPaint* paint, GrProcessorTestData* d) { | 167 static void set_random_xpf(GrPaint* paint, GrProcessorTestData* d) { |
| 168 sk_sp<GrXPFactory> xpf(GrProcessorTestFactory<GrXPFactory>::Make(d)); | 168 sk_sp<GrXPFactory> xpf(GrProcessorTestFactory<GrXPFactory>::Make(d)); |
| 169 SkASSERT(xpf); | 169 SkASSERT(xpf); |
| 170 paint->setXPFactory(std::move(xpf)); | 170 paint->setXPFactory(std::move(xpf)); |
| 171 } | 171 } |
| 172 | 172 |
| 173 static sk_sp<GrFragmentProcessor> create_random_proc_tree(GrProcessorTestData* d
, | 173 static sk_sp<GrFragmentProcessor> create_random_proc_tree(GrProcessorTestData* d
, |
| (...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 336 set_random_xpf(&grPaint, &ptd); | 336 set_random_xpf(&grPaint, &ptd); |
| 337 bool snapToCenters = set_random_state(&grPaint, &random); | 337 bool snapToCenters = set_random_state(&grPaint, &random); |
| 338 const GrUserStencilSettings* uss = get_random_stencil(&random); | 338 const GrUserStencilSettings* uss = get_random_stencil(&random); |
| 339 | 339 |
| 340 drawContext->drawContextPriv().testingOnly_drawBatch(grPaint, batch, uss
, snapToCenters); | 340 drawContext->drawContextPriv().testingOnly_drawBatch(grPaint, batch, uss
, snapToCenters); |
| 341 } | 341 } |
| 342 // 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) |
| 343 drawingManager->flush(); | 343 drawingManager->flush(); |
| 344 | 344 |
| 345 // Validate that GrFPs work correctly without an input. | 345 // Validate that GrFPs work correctly without an input. |
| 346 sk_sp<GrDrawContext> drawContext(context->newDrawContext(SkBackingFit::kExac
t, | 346 sk_sp<GrDrawContext> drawContext(context->makeDrawContext(SkBackingFit::kExa
ct, |
| 347 kRenderTargetWidth, | 347 kRenderTargetWidth
, |
| 348 kRenderTargetHeight
, | 348 kRenderTargetHeigh
t, |
| 349 kRGBA_8888_GrPixelC
onfig, | 349 kRGBA_8888_GrPixel
Config, |
| 350 nullptr)); | 350 nullptr)); |
| 351 if (!drawContext) { | 351 if (!drawContext) { |
| 352 SkDebugf("Could not allocate a drawContext"); | 352 SkDebugf("Could not allocate a drawContext"); |
| 353 return false; | 353 return false; |
| 354 } | 354 } |
| 355 | 355 |
| 356 int fpFactoryCnt = GrProcessorTestFactory<GrFragmentProcessor>::Count(); | 356 int fpFactoryCnt = GrProcessorTestFactory<GrFragmentProcessor>::Count(); |
| 357 for (int i = 0; i < fpFactoryCnt; ++i) { | 357 for (int i = 0; i < fpFactoryCnt; ++i) { |
| 358 // Since FP factories internally randomize, call each 10 times. | 358 // Since FP factories internally randomize, call each 10 times. |
| 359 for (int j = 0; j < 10; ++j) { | 359 for (int j = 0; j < 10; ++j) { |
| 360 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... |
| 442 GrContextOptions opts; | 442 GrContextOptions opts; |
| 443 opts.fSuppressPrints = true; | 443 opts.fSuppressPrints = true; |
| 444 sk_gpu_test::GrContextFactory debugFactory(opts); | 444 sk_gpu_test::GrContextFactory debugFactory(opts); |
| 445 skiatest::RunWithGPUTestContexts(test_glprograms_native, &is_native_gl_conte
xt_type, | 445 skiatest::RunWithGPUTestContexts(test_glprograms_native, &is_native_gl_conte
xt_type, |
| 446 reporter, &debugFactory); | 446 reporter, &debugFactory); |
| 447 skiatest::RunWithGPUTestContexts(test_glprograms_other_contexts, | 447 skiatest::RunWithGPUTestContexts(test_glprograms_other_contexts, |
| 448 &is_other_rendering_gl_context_type, report
er, &debugFactory); | 448 &is_other_rendering_gl_context_type, report
er, &debugFactory); |
| 449 } | 449 } |
| 450 | 450 |
| 451 #endif | 451 #endif |
| OLD | NEW |