Skia
2D Graphics Library
|
A specification for custom meshes. More...
#include <SkMesh.h>
Classes | |
struct | Attribute |
struct | Result |
struct | Varying |
Public Types | |
using | Uniform = SkRuntimeEffect::Uniform |
using | Child = SkRuntimeEffect::Child |
Public Member Functions | |
~SkMeshSpecification () | |
SkSpan< const Attribute > | attributes () const |
size_t | uniformSize () const |
Combined size of all 'uniform' variables. More... | |
SkSpan< const Uniform > | uniforms () const |
Provides info about individual uniforms including the offset into an SkData where each uniform value should be placed. More... | |
SkSpan< const Child > | children () const |
Provides basic info about individual children: names, indices and runtime effect type. More... | |
const Child * | findChild (std::string_view name) const |
Returns a pointer to the named child's description, or nullptr if not found. More... | |
const Uniform * | findUniform (std::string_view name) const |
Returns a pointer to the named uniform variable's description, or nullptr if not found. More... | |
const Attribute * | findAttribute (std::string_view name) const |
Returns a pointer to the named attribute, or nullptr if not found. More... | |
const Varying * | findVarying (std::string_view name) const |
Returns a pointer to the named varying, or nullptr if not found. More... | |
size_t | stride () const |
bool | unique () const |
void | ref () const |
void | unref () const |
void | deref () const |
bool | refCntGreaterThan (int32_t threadIsolatedTestCnt) const |
Static Public Member Functions | |
static Result | Make (SkSpan< const Attribute > attributes, size_t vertexStride, SkSpan< const Varying > varyings, const SkString &vs, const SkString &fs) |
If successful the return is a specification and an empty error string. More... | |
static Result | Make (SkSpan< const Attribute > attributes, size_t vertexStride, SkSpan< const Varying > varyings, const SkString &vs, const SkString &fs, sk_sp< SkColorSpace > cs) |
static Result | Make (SkSpan< const Attribute > attributes, size_t vertexStride, SkSpan< const Varying > varyings, const SkString &vs, const SkString &fs, sk_sp< SkColorSpace > cs, SkAlphaType at) |
Static Public Attributes | |
static constexpr size_t | kMaxStride = 1024 |
These values are enforced when creating a specification. More... | |
static constexpr size_t | kMaxAttributes = 8 |
static constexpr size_t | kStrideAlignment = 4 |
static constexpr size_t | kOffsetAlignment = 4 |
static constexpr size_t | kMaxVaryings = 6 |
Friends | |
struct | SkMeshSpecificationPriv |
A specification for custom meshes.
Specifies the vertex buffer attributes and stride, the vertex program that produces a user-defined set of varyings, and a fragment program that ingests the interpolated varyings and produces local coordinates for shading and optionally a color.
The varyings must include a float2 named "position". If the passed varyings does not contain such a varying then one is implicitly added to the final specification and the SkSL Varyings struct described below. It is an error to have a varying named "position" that has a type other than float2.
The provided attributes and varyings are used to create Attributes and Varyings structs in SkSL that are used by the shaders. Each attribute from the Attribute span becomes a member of the SkSL Attributes struct and likewise for the varyings.
The signature of the vertex program must be: Varyings main(const Attributes).
The signature of the fragment program must be either: float2 main(const Varyings) or float2 main(const Varyings, out (half4|float4) color)
where the return value is the local coordinates that will be used to access SkShader. If the color variant is used, the returned color will be blended with SkPaint's SkShader (or SkPaint color in absence of a SkShader) using the SkBlender passed to SkCanvas drawMesh(). To use interpolated local space positions as the shader coordinates, equivalent to how SkPaths are shaded, return the position field from the Varying struct as the coordinates.
The vertex and fragment programs may both contain uniforms. Uniforms with the same name are assumed to be shared between stages. It is an error to specify uniforms in the vertex and fragment program with the same name but different types, dimensionality, or layouts.
SkMeshSpecification::~SkMeshSpecification | ( | ) |
|
inline |
|
inline |
Provides basic info about individual children: names, indices and runtime effect type.
|
inlineinherited |
const Attribute* SkMeshSpecification::findAttribute | ( | std::string_view | name | ) | const |
Returns a pointer to the named attribute, or nullptr if not found.
const Child* SkMeshSpecification::findChild | ( | std::string_view | name | ) | const |
Returns a pointer to the named child's description, or nullptr if not found.
const Uniform* SkMeshSpecification::findUniform | ( | std::string_view | name | ) | const |
Returns a pointer to the named uniform variable's description, or nullptr if not found.
const Varying* SkMeshSpecification::findVarying | ( | std::string_view | name | ) | const |
Returns a pointer to the named varying, or nullptr if not found.
|
static |
If successful the return is a specification and an empty error string.
Otherwise, it is a null specification a non-empty error string.
attributes | The vertex attributes that will be consumed by 'vs'. Attributes need not be tightly packed but attribute offsets must be aligned to kOffsetAlignment and offset + size may not be greater than 'vertexStride'. At least one attribute is required. |
vertexStride | The offset between successive attribute values. This must be aligned to kStrideAlignment. |
varyings | The varyings that will be written by 'vs' and read by 'fs'. This may be empty. |
vs | The vertex shader code that computes a vertex position and the varyings from the attributes. |
fs | The fragment code that computes a local coordinate and optionally a color from the varyings. The local coordinate is used to sample SkShader. |
cs | The colorspace of the color produced by 'fs'. Ignored if 'fs's main() function does not have a color out param. |
at | The alpha type of the color produced by 'fs'. Ignored if 'fs's main() function does not have a color out param. Cannot be kUnknown. |
|
static |
|
static |
|
inlineinherited |
|
inlineinherited |
|
inline |
|
inline |
Provides info about individual uniforms including the offset into an SkData where each uniform value should be placed.
size_t SkMeshSpecification::uniformSize | ( | ) | const |
Combined size of all 'uniform' variables.
When creating a SkMesh with this specification provide an SkData of this size, containing values for all of those variables. Use uniforms() to get the offset of each uniform within the SkData.
|
inlineinherited |
|
inlineinherited |
|
friend |
|
staticconstexpr |
|
staticconstexpr |
These values are enforced when creating a specification.
|
staticconstexpr |
|
staticconstexpr |
|
staticconstexpr |