Flutter Engine
The Flutter Engine
|
#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 |
SkSpan< const Uniform > | uniforms () const |
SkSpan< const Child > | children () const |
const Child * | findChild (std::string_view name) const |
const Uniform * | findUniform (std::string_view name) const |
const Attribute * | findAttribute (std::string_view name) const |
const Varying * | findVarying (std::string_view name) const |
size_t | stride () const |
SkColorSpace * | colorSpace () const |
Public Member Functions inherited from SkNVRefCnt< SkMeshSpecification > | |
SkNVRefCnt () | |
~SkNVRefCnt () | |
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) |
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 |
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.
|
default |
|
inline |
const Attribute * SkMeshSpecification::findAttribute | ( | std::string_view | name | ) | const |
Returns a pointer to the named attribute, or nullptr if not found.
Definition at line 665 of file SkMesh.cpp.
const Child * SkMeshSpecification::findChild | ( | std::string_view | name | ) | const |
Returns a pointer to the named child's description, or nullptr if not found.
Definition at line 656 of file SkMesh.cpp.
const Uniform * SkMeshSpecification::findUniform | ( | std::string_view | name | ) | const |
Returns a pointer to the named uniform variable's description, or nullptr if not found.
Definition at line 647 of file SkMesh.cpp.
const Varying * SkMeshSpecification::findVarying | ( | std::string_view | name | ) | const |
Returns a pointer to the named varying, or nullptr if not found.
Definition at line 674 of file SkMesh.cpp.
|
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. |
Definition at line 389 of file SkMesh.cpp.
|
static |
Definition at line 403 of file SkMesh.cpp.
|
static |
Definition at line 412 of file SkMesh.cpp.
|
inline |
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.
Definition at line 642 of file SkMesh.cpp.
|
friend |
|
staticconstexpr |
|
staticconstexpr |
|
staticconstexpr |
|
staticconstexpr |
|
staticconstexpr |