Brian Salomon | 5ec9def | 2016-12-20 15:34:05 -0500 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2015 Google Inc. |
| 3 | * |
| 4 | * Use of this source code is governed by a BSD-style license that can be |
| 5 | * found in the LICENSE file. |
| 6 | */ |
| 7 | |
| 8 | #include "GrDrawOpTest.h" |
Brian Salomon | 1772663 | 2017-05-12 14:09:46 -0400 | [diff] [blame] | 9 | #include "GrCaps.h" |
| 10 | #include "GrContext.h" |
| 11 | #include "GrUserStencilSettings.h" |
Brian Salomon | 5ec9def | 2016-12-20 15:34:05 -0500 | [diff] [blame] | 12 | #include "SkRandom.h" |
| 13 | #include "SkTypes.h" |
| 14 | |
Hal Canary | 6f6961e | 2017-01-31 13:50:44 -0500 | [diff] [blame] | 15 | #if GR_TEST_UTILS |
Brian Salomon | 5ec9def | 2016-12-20 15:34:05 -0500 | [diff] [blame] | 16 | |
Brian Salomon | 1772663 | 2017-05-12 14:09:46 -0400 | [diff] [blame] | 17 | const GrUserStencilSettings* GrGetRandomStencil(SkRandom* random, GrContext* context) { |
| 18 | if (context->caps()->avoidStencilBuffers()) { |
| 19 | return &GrUserStencilSettings::kUnused; |
| 20 | } |
| 21 | static constexpr GrUserStencilSettings kReads( |
| 22 | GrUserStencilSettings::StaticInit< |
| 23 | 0x8080, |
| 24 | GrUserStencilTest::kLess, |
| 25 | 0xffff, |
| 26 | GrUserStencilOp::kKeep, |
| 27 | GrUserStencilOp::kKeep, |
| 28 | 0xffff>() |
| 29 | ); |
| 30 | static constexpr GrUserStencilSettings kWrites( |
| 31 | GrUserStencilSettings::StaticInit< |
| 32 | 0xffff, |
| 33 | GrUserStencilTest::kAlways, |
| 34 | 0xffff, |
| 35 | GrUserStencilOp::kReplace, |
| 36 | GrUserStencilOp::kReplace, |
| 37 | 0xffff>() |
| 38 | ); |
| 39 | static constexpr GrUserStencilSettings kReadsAndWrites( |
| 40 | GrUserStencilSettings::StaticInit< |
| 41 | 0x8000, |
| 42 | GrUserStencilTest::kEqual, |
| 43 | 0x6000, |
| 44 | GrUserStencilOp::kIncWrap, |
| 45 | GrUserStencilOp::kInvert, |
| 46 | 0x77ff>() |
| 47 | ); |
Brian Salomon | 5ec9def | 2016-12-20 15:34:05 -0500 | [diff] [blame] | 48 | |
Brian Salomon | 1772663 | 2017-05-12 14:09:46 -0400 | [diff] [blame] | 49 | static const GrUserStencilSettings* kStencilSettings[] = { |
| 50 | &GrUserStencilSettings::kUnused, |
| 51 | &kReads, |
| 52 | &kWrites, |
| 53 | &kReadsAndWrites, |
Brian Salomon | 5ec9def | 2016-12-20 15:34:05 -0500 | [diff] [blame] | 54 | }; |
Brian Salomon | 1772663 | 2017-05-12 14:09:46 -0400 | [diff] [blame] | 55 | return kStencilSettings[random->nextULessThan(SK_ARRAY_COUNT(kStencilSettings))]; |
Brian Salomon | 5ec9def | 2016-12-20 15:34:05 -0500 | [diff] [blame] | 56 | } |
Brian Salomon | 1772663 | 2017-05-12 14:09:46 -0400 | [diff] [blame] | 57 | |
Brian Salomon | 5ec9def | 2016-12-20 15:34:05 -0500 | [diff] [blame] | 58 | #endif |