/* * Copyright 2016 Google Inc. * * Use of this source code is governed by a BSD-style license that can be * found in the LICENSE file. */ #ifndef GrUserStencilSettings_DEFINED #define GrUserStencilSettings_DEFINED #include "include/gpu/ganesh/GrTypes.h" // IWYU pragma: keep #include <cstdint> /** * Gr uses the stencil buffer to implement complex clipping inside the * OpsTask class. The OpsTask makes a subset of the stencil buffer * bits available for other uses by external code (user bits). Client code can * modify these bits. OpsTask will ignore ref, mask, and writemask bits * provided by clients that fall outside the user range. * * When code outside the OpsTask class uses the stencil buffer the contract * is as follows: * * > Normal stencil funcs allow the client to pass / fail regardless of the * reserved clip bits. * > Additional functions allow a test against the clip along with a limited * set of tests against the user bits. * > Client can assume all user bits are zero initially. * > Client must ensure that after all its passes are finished it has only * written to the color buffer in the region inside the clip. Furthermore, it * must zero all user bits that were modifed (both inside and outside the * clip). */ enum GrStencilFlags : int { … }; template<typename TTest, typename TOp> struct GrTStencilFaceSettings { … }; enum class GrUserStencilTest : uint16_t { … }; constexpr static GrUserStencilTest kLastClippedStencilTest = …; constexpr static int kGrUserStencilTestCount = …; enum class GrUserStencilOp : uint8_t { … }; constexpr static GrUserStencilOp kLastUserOnlyStencilOp = …; constexpr static GrUserStencilOp kLastClipOnlyStencilOp = …; constexpr static int kGrUserStencilOpCount = …; /** * This struct is a compile-time constant representation of user stencil settings. It describes in * abstract terms how a draw will use the stencil buffer. It gets ODR-used at runtime to define a * draw's stencil settings, and is later translated into concrete settings when the pipeline is * finalized. */ struct GrUserStencilSettings { … }; template<GrUserStencilTest Test, GrUserStencilOp PassOp, GrUserStencilOp FailOp> struct GrUserStencilSettings::Attrs { … }; #endif