12#if !__has_feature(objc_arc)
13#error This file must be compiled with Arc. Use -fobjc-arc flag
21 return MTLStencilOperationKeep;
23 return MTLStencilOperationZero;
25 return MTLStencilOperationReplace;
27 return MTLStencilOperationInvert;
29 return MTLStencilOperationIncrementWrap;
31 return MTLStencilOperationDecrementWrap;
33 return MTLStencilOperationIncrementClamp;
35 return MTLStencilOperationDecrementClamp;
40 MTLStencilDescriptor*
result = [[MTLStencilDescriptor alloc]
init];
43 result.stencilCompareFunction = MTLCompareFunctionAlways;
46 result.stencilCompareFunction = MTLCompareFunctionNever;
49 result.stencilCompareFunction = MTLCompareFunctionGreater;
52 result.stencilCompareFunction = MTLCompareFunctionGreaterEqual;
55 result.stencilCompareFunction = MTLCompareFunctionLess;
58 result.stencilCompareFunction = MTLCompareFunctionLessEqual;
61 result.stencilCompareFunction = MTLCompareFunctionEqual;
64 result.stencilCompareFunction = MTLCompareFunctionNotEqual;
77 MTLDepthStencilDescriptor*
desc = [[MTLDepthStencilDescriptor alloc]
init];
85 desc.backFaceStencil =
desc.frontFaceStencil;
94 const int kPassOpShift = 3;
95 const int kFailOpShift = 6;
101 faceKey->
fOps =
static_cast<uint32_t
>(face.
fTest);
104 faceKey->
fOps |= (
static_cast<uint32_t
>(face.
fPassOp) << kPassOpShift);
107 faceKey->
fOps |= (
static_cast<uint32_t
>(face.
fFailOp) << kFailOpShift);
115 memset(&depthStencilKey, 0,
sizeof(
Key));
123 memcpy(&depthStencilKey.
fBack, &depthStencilKey.
fFront,
sizeof(Key::Face));
127 return depthStencilKey;
MTLStencilDescriptor * skia_stencil_to_mtl(GrStencilSettings::Face face)
void skia_stencil_to_key(GrStencilSettings::Face face, GrMtlDepthStencil::Key::Face *faceKey)
GR_NORETAIN_BEGIN MTLStencilOperation skia_stencil_op_to_mtl(GrStencilOp op)
static Key GenerateKey(const GrStencilSettings &, GrSurfaceOrigin)
static GrMtlDepthStencil * Create(const GrMtlGpu *, const GrStencilSettings &, GrSurfaceOrigin)
id< MTLDevice > device() const
const Face & postOriginCCWFace(GrSurfaceOrigin origin) const
const Face & singleSidedFace() const
const Face & postOriginCWFace(GrSurfaceOrigin origin) const