• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 "src/gpu/GrDrawOpTest.h"
9 
10 #include "include/core/SkTypes.h"
11 #include "include/private/GrContext_Base.h"
12 #include "include/utils/SkRandom.h"
13 #include "src/gpu/GrBaseContextPriv.h"
14 #include "src/gpu/GrCaps.h"
15 #include "src/gpu/GrUserStencilSettings.h"
16 
17 #if GR_TEST_UTILS
18 
GrGetRandomStencil(SkRandom * random,GrContext_Base * context)19 const GrUserStencilSettings* GrGetRandomStencil(SkRandom* random, GrContext_Base* context) {
20     if (context->priv().caps()->avoidStencilBuffers()) {
21         return &GrUserStencilSettings::kUnused;
22     }
23     static constexpr GrUserStencilSettings kReads(
24         GrUserStencilSettings::StaticInit<
25             0x8080,
26             GrUserStencilTest::kLess,
27             0xffff,
28             GrUserStencilOp::kKeep,
29             GrUserStencilOp::kKeep,
30             0xffff>()
31     );
32     static constexpr GrUserStencilSettings kWrites(
33         GrUserStencilSettings::StaticInit<
34             0xffff,
35             GrUserStencilTest::kAlways,
36             0xffff,
37             GrUserStencilOp::kReplace,
38             GrUserStencilOp::kReplace,
39             0xffff>()
40     );
41     static constexpr GrUserStencilSettings kReadsAndWrites(
42         GrUserStencilSettings::StaticInit<
43             0x8000,
44             GrUserStencilTest::kEqual,
45             0x6000,
46             GrUserStencilOp::kIncWrap,
47             GrUserStencilOp::kInvert,
48             0x77ff>()
49     );
50 
51     static const GrUserStencilSettings* kStencilSettings[] = {
52             &GrUserStencilSettings::kUnused,
53             &kReads,
54             &kWrites,
55             &kReadsAndWrites,
56     };
57     return kStencilSettings[random->nextULessThan(SK_ARRAY_COUNT(kStencilSettings))];
58 }
59 
60 #endif
61