Skia
2D Graphics Library
SkMesh Class Reference

A vertex buffer, a topology, optionally an index buffer, and a compatible SkMeshSpecification. More...

#include <SkMesh.h>

Classes

class  IndexBuffer
 
struct  Result
 
class  VertexBuffer
 

Public Types

enum class  Mode { kTriangles , kTriangleStrip }
 
using ChildPtr = SkRuntimeEffect::ChildPtr
 

Public Member Functions

 SkMesh ()
 
 ~SkMesh ()
 
 SkMesh (const SkMesh &)
 
 SkMesh (SkMesh &&)
 
SkMeshoperator= (const SkMesh &)
 
SkMeshoperator= (SkMesh &&)
 
sk_sp< SkMeshSpecificationrefSpec () const
 
SkMeshSpecificationspec () const
 
Mode mode () const
 
sk_sp< VertexBufferrefVertexBuffer () const
 
VertexBuffervertexBuffer () const
 
size_t vertexOffset () const
 
size_t vertexCount () const
 
sk_sp< IndexBufferrefIndexBuffer () const
 
IndexBufferindexBuffer () const
 
size_t indexOffset () const
 
size_t indexCount () const
 
sk_sp< const SkDatarefUniforms () const
 
const SkDatauniforms () const
 
SkSpan< const ChildPtrchildren () const
 
SkRect bounds () const
 
bool isValid () const
 

Static Public Member Functions

static Result Make (sk_sp< SkMeshSpecification >, Mode, sk_sp< VertexBuffer >, size_t vertexCount, size_t vertexOffset, sk_sp< const SkData > uniforms, SkSpan< ChildPtr > children, const SkRect &bounds)
 Creates a non-indexed SkMesh. More...
 
static Result MakeIndexed (sk_sp< SkMeshSpecification >, Mode, sk_sp< VertexBuffer >, size_t vertexCount, size_t vertexOffset, sk_sp< IndexBuffer >, size_t indexCount, size_t indexOffset, sk_sp< const SkData > uniforms, SkSpan< ChildPtr > children, const SkRect &bounds)
 Creates an indexed SkMesh. More...
 

Detailed Description

A vertex buffer, a topology, optionally an index buffer, and a compatible SkMeshSpecification.

The data in the vertex buffer is expected to contain the attributes described by the spec for vertexCount vertices, beginning at vertexOffset. vertexOffset must be aligned to the SkMeshSpecification's vertex stride. The size of the buffer must be at least vertexOffset + spec->stride()*vertexCount (even if vertex attributes contains pad at the end of the stride). If the specified bounds do not contain all the points output by the spec's vertex program when applied to the vertices in the custom mesh, then the result is undefined.

MakeIndexed may be used to create an indexed mesh. indexCount indices are read from the index buffer at the specified offset, which must be aligned to 2. The indices are always unsigned 16-bit integers. The index count must be at least 3.

If Make() is used, the implicit index sequence is 0, 1, 2, 3, ... and vertexCount must be at least 3.

Both Make() and MakeIndexed() take a SkData with the uniform values. See SkMeshSpecification::uniformSize() and SkMeshSpecification::uniforms() for sizing and packing uniforms into the SkData.

Member Typedef Documentation

◆ ChildPtr

Member Enumeration Documentation

◆ Mode

enum SkMesh::Mode
strong
Enumerator
kTriangles 
kTriangleStrip 

Constructor & Destructor Documentation

◆ SkMesh() [1/3]

SkMesh::SkMesh ( )

◆ ~SkMesh()

SkMesh::~SkMesh ( )

◆ SkMesh() [2/3]

SkMesh::SkMesh ( const SkMesh )

◆ SkMesh() [3/3]

SkMesh::SkMesh ( SkMesh &&  )

Member Function Documentation

◆ bounds()

SkRect SkMesh::bounds ( ) const
inline

◆ children()

SkSpan<const ChildPtr> SkMesh::children ( ) const
inline

◆ indexBuffer()

IndexBuffer* SkMesh::indexBuffer ( ) const
inline

◆ indexCount()

size_t SkMesh::indexCount ( ) const
inline

◆ indexOffset()

size_t SkMesh::indexOffset ( ) const
inline

◆ isValid()

bool SkMesh::isValid ( ) const

◆ Make()

static Result SkMesh::Make ( sk_sp< SkMeshSpecification ,
Mode  ,
sk_sp< VertexBuffer ,
size_t  vertexCount,
size_t  vertexOffset,
sk_sp< const SkData uniforms,
SkSpan< ChildPtr children,
const SkRect bounds 
)
static

Creates a non-indexed SkMesh.

The returned SkMesh can be tested for validity using SkMesh::isValid(). An invalid mesh simply fails to draws if passed to SkCanvas::drawMesh(). If the mesh is invalid the returned string give contain the reason for the failure (e.g. the vertex buffer was null or uniform data too small).

◆ MakeIndexed()

static Result SkMesh::MakeIndexed ( sk_sp< SkMeshSpecification ,
Mode  ,
sk_sp< VertexBuffer ,
size_t  vertexCount,
size_t  vertexOffset,
sk_sp< IndexBuffer ,
size_t  indexCount,
size_t  indexOffset,
sk_sp< const SkData uniforms,
SkSpan< ChildPtr children,
const SkRect bounds 
)
static

Creates an indexed SkMesh.

The returned SkMesh can be tested for validity using SkMesh::isValid(). A invalid mesh simply fails to draw if passed to SkCanvas::drawMesh(). If the mesh is invalid the returned string give contain the reason for the failure (e.g. the index buffer was null or uniform data too small).

◆ mode()

Mode SkMesh::mode ( ) const
inline

◆ operator=() [1/2]

SkMesh& SkMesh::operator= ( const SkMesh )

◆ operator=() [2/2]

SkMesh& SkMesh::operator= ( SkMesh &&  )

◆ refIndexBuffer()

sk_sp<IndexBuffer> SkMesh::refIndexBuffer ( ) const
inline

◆ refSpec()

sk_sp<SkMeshSpecification> SkMesh::refSpec ( ) const
inline

◆ refUniforms()

sk_sp<const SkData> SkMesh::refUniforms ( ) const
inline

◆ refVertexBuffer()

sk_sp<VertexBuffer> SkMesh::refVertexBuffer ( ) const
inline

◆ spec()

SkMeshSpecification* SkMesh::spec ( ) const
inline

◆ uniforms()

const SkData* SkMesh::uniforms ( ) const
inline

◆ vertexBuffer()

VertexBuffer* SkMesh::vertexBuffer ( ) const
inline

◆ vertexCount()

size_t SkMesh::vertexCount ( ) const
inline

◆ vertexOffset()

size_t SkMesh::vertexOffset ( ) const
inline

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