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" |
Brian Salomon | c7fe0f7 | 2018-05-11 10:14:21 -0400 | [diff] [blame] | 11 | #include "GrContextPriv.h" |
Brian Salomon | 1772663 | 2017-05-12 14:09:46 -0400 | [diff] [blame] | 12 | #include "GrUserStencilSettings.h" |
Brian Salomon | 5ec9def | 2016-12-20 15:34:05 -0500 | [diff] [blame] | 13 | #include "SkRandom.h" |
| 14 | #include "SkTypes.h" |
| 15 | |
Hal Canary | 6f6961e | 2017-01-31 13:50:44 -0500 | [diff] [blame] | 16 | #if GR_TEST_UTILS |
Brian Salomon | 5ec9def | 2016-12-20 15:34:05 -0500 | [diff] [blame] | 17 | |
Brian Salomon | 1772663 | 2017-05-12 14:09:46 -0400 | [diff] [blame] | 18 | const GrUserStencilSettings* GrGetRandomStencil(SkRandom* random, GrContext* context) { |
Brian Salomon | c7fe0f7 | 2018-05-11 10:14:21 -0400 | [diff] [blame] | 19 | if (context->contextPriv().caps()->avoidStencilBuffers()) { |
Brian Salomon | 1772663 | 2017-05-12 14:09:46 -0400 | [diff] [blame] | 20 | return &GrUserStencilSettings::kUnused; |
| 21 | } |
| 22 | static constexpr GrUserStencilSettings kReads( |
| 23 | GrUserStencilSettings::StaticInit< |
| 24 | 0x8080, |
| 25 | GrUserStencilTest::kLess, |
| 26 | 0xffff, |
| 27 | GrUserStencilOp::kKeep, |
| 28 | GrUserStencilOp::kKeep, |
| 29 | 0xffff>() |
| 30 | ); |
| 31 | static constexpr GrUserStencilSettings kWrites( |
| 32 | GrUserStencilSettings::StaticInit< |
| 33 | 0xffff, |
| 34 | GrUserStencilTest::kAlways, |
| 35 | 0xffff, |
| 36 | GrUserStencilOp::kReplace, |
| 37 | GrUserStencilOp::kReplace, |
| 38 | 0xffff>() |
| 39 | ); |
| 40 | static constexpr GrUserStencilSettings kReadsAndWrites( |
| 41 | GrUserStencilSettings::StaticInit< |
| 42 | 0x8000, |
| 43 | GrUserStencilTest::kEqual, |
| 44 | 0x6000, |
| 45 | GrUserStencilOp::kIncWrap, |
| 46 | GrUserStencilOp::kInvert, |
| 47 | 0x77ff>() |
| 48 | ); |
Brian Salomon | 5ec9def | 2016-12-20 15:34:05 -0500 | [diff] [blame] | 49 | |
Brian Salomon | 1772663 | 2017-05-12 14:09:46 -0400 | [diff] [blame] | 50 | static const GrUserStencilSettings* kStencilSettings[] = { |
| 51 | &GrUserStencilSettings::kUnused, |
| 52 | &kReads, |
| 53 | &kWrites, |
| 54 | &kReadsAndWrites, |
Brian Salomon | 5ec9def | 2016-12-20 15:34:05 -0500 | [diff] [blame] | 55 | }; |
Brian Salomon | 1772663 | 2017-05-12 14:09:46 -0400 | [diff] [blame] | 56 | return kStencilSettings[random->nextULessThan(SK_ARRAY_COUNT(kStencilSettings))]; |
Brian Salomon | 5ec9def | 2016-12-20 15:34:05 -0500 | [diff] [blame] | 57 | } |
Brian Salomon | 1772663 | 2017-05-12 14:09:46 -0400 | [diff] [blame] | 58 | |
Brian Salomon | 5ec9def | 2016-12-20 15:34:05 -0500 | [diff] [blame] | 59 | #endif |