Flutter Engine
The Flutter Engine
Classes | Public Member Functions | Static Public Member Functions | List of all members
GrMtlDepthStencil Class Reference

#include <GrMtlDepthStencil.h>

Inheritance diagram for GrMtlDepthStencil:
GrManagedResource SkNoncopyable

Classes

struct  Key
 

Public Member Functions

 ~GrMtlDepthStencil () override
 
id< MTLDepthStencilState > mtlDepthStencil () const
 
void freeGPUData () const override
 
- Public Member Functions inherited from GrManagedResource
 GrManagedResource ()
 
virtual ~GrManagedResource ()
 
bool unique () const
 
void ref () const
 
void unref () const
 

Static Public Member Functions

static GrMtlDepthStencilCreate (const GrMtlGpu *, const GrStencilSettings &, GrSurfaceOrigin)
 
static Key GenerateKey (const GrStencilSettings &, GrSurfaceOrigin)
 
static const KeyGetKey (const GrMtlDepthStencil &depthStencil)
 
static uint32_t Hash (const Key &key)
 

Detailed Description

Definition at line 22 of file GrMtlDepthStencil.h.

Constructor & Destructor Documentation

◆ ~GrMtlDepthStencil()

GrMtlDepthStencil::~GrMtlDepthStencil ( )
inlineoverride

Definition at line 26 of file GrMtlDepthStencil.h.

26{ fMtlDepthStencilState = nil; }

Member Function Documentation

◆ Create()

GrMtlDepthStencil * GrMtlDepthStencil::Create ( const GrMtlGpu gpu,
const GrStencilSettings stencil,
GrSurfaceOrigin  origin 
)
static

Definition at line 74 of file GrMtlDepthStencil.mm.

76 {
77 MTLDepthStencilDescriptor* desc = [[MTLDepthStencilDescriptor alloc] init];
78 if (!stencil.isDisabled()) {
79 if (stencil.isTwoSided()) {
80 desc.frontFaceStencil = skia_stencil_to_mtl(stencil.postOriginCCWFace(origin));
81 desc.backFaceStencil = skia_stencil_to_mtl(stencil.postOriginCWFace(origin));
82 }
83 else {
84 desc.frontFaceStencil = skia_stencil_to_mtl(stencil.singleSidedFace());
85 desc.backFaceStencil = desc.frontFaceStencil;
86 }
87 }
88
89 return new GrMtlDepthStencil([gpu->device() newDepthStencilStateWithDescriptor: desc],
90 GenerateKey(stencil, origin));
91}
MTLStencilDescriptor * skia_stencil_to_mtl(GrStencilSettings::Face face)
static Key GenerateKey(const GrStencilSettings &, GrSurfaceOrigin)
id< MTLDevice > device() const
Definition: GrMtlGpu.h:49
bool isTwoSided() const
const Face & postOriginCCWFace(GrSurfaceOrigin origin) const
bool isDisabled() const
const Face & singleSidedFace() const
const Face & postOriginCWFace(GrSurfaceOrigin origin) const
static bool init()

◆ freeGPUData()

void GrMtlDepthStencil::freeGPUData ( ) const
inlineoverridevirtual

Must be implemented by any subclasses. Deletes any GPU data associated with this resource

Implements GrManagedResource.

Definition at line 66 of file GrMtlDepthStencil.h.

66 {
67 fMtlDepthStencilState = nil;
68 }

◆ GenerateKey()

GrMtlDepthStencil::Key GrMtlDepthStencil::GenerateKey ( const GrStencilSettings stencil,
GrSurfaceOrigin  origin 
)
static

Definition at line 110 of file GrMtlDepthStencil.mm.

111 {
112 Key depthStencilKey;
113
114 if (stencil.isDisabled()) {
115 memset(&depthStencilKey, 0, sizeof(Key));
116 } else {
117 if (stencil.isTwoSided()) {
118 skia_stencil_to_key(stencil.postOriginCCWFace(origin), &depthStencilKey.fFront);
119 skia_stencil_to_key(stencil.postOriginCWFace(origin), &depthStencilKey.fBack);
120 }
121 else {
122 skia_stencil_to_key(stencil.singleSidedFace(), &depthStencilKey.fFront);
123 memcpy(&depthStencilKey.fBack, &depthStencilKey.fFront, sizeof(Key::Face));
124 }
125 }
126
127 return depthStencilKey;
128}
void skia_stencil_to_key(GrStencilSettings::Face face, GrMtlDepthStencil::Key::Face *faceKey)

◆ GetKey()

static const Key & GrMtlDepthStencil::GetKey ( const GrMtlDepthStencil depthStencil)
inlinestatic

Definition at line 52 of file GrMtlDepthStencil.h.

52{ return depthStencil.fKey; }

◆ Hash()

static uint32_t GrMtlDepthStencil::Hash ( const Key key)
inlinestatic

Definition at line 53 of file GrMtlDepthStencil.h.

53 {
54 return SkChecksum::Hash32(&key, sizeof(Key));
55 }
uint32_t Hash32(const void *data, size_t bytes, uint32_t seed)
Definition: SkChecksum.cpp:113

◆ mtlDepthStencil()

id< MTLDepthStencilState > GrMtlDepthStencil::mtlDepthStencil ( ) const
inline

Definition at line 28 of file GrMtlDepthStencil.h.

28{ return fMtlDepthStencilState; }

The documentation for this class was generated from the following files: