Flutter Engine
The Flutter Engine
Public Member Functions | List of all members
skgpu::graphite::CoverBoundsRenderStep Class Referencefinal

#include <CoverBoundsRenderStep.h>

Inheritance diagram for skgpu::graphite::CoverBoundsRenderStep:
skgpu::graphite::RenderStep

Public Member Functions

 CoverBoundsRenderStep (bool inverseFill)
 
 ~CoverBoundsRenderStep () override
 
std::string vertexSkSL () const override
 
void writeVertices (DrawWriter *, const DrawParams &, skvx::ushort2 ssboIndices) const override
 
void writeUniformsAndTextures (const DrawParams &, PipelineDataGatherer *) const override
 
- Public Member Functions inherited from skgpu::graphite::RenderStep
virtual ~RenderStep ()=default
 
virtual void writeVertices (DrawWriter *, const DrawParams &, skvx::ushort2 ssboIndices) const =0
 
virtual void writeUniformsAndTextures (const DrawParams &, PipelineDataGatherer *) const =0
 
virtual std::string vertexSkSL () const =0
 
virtual std::string texturesAndSamplersSkSL (const ResourceBindingRequirements &, int *nextBindingIndex) const
 
virtual const char * fragmentCoverageSkSL () const
 
virtual const char * fragmentColorSkSL () const
 
uint32_t uniqueID () const
 
const char * name () const
 
bool requiresMSAA () const
 
bool performsShading () const
 
bool hasTextures () const
 
bool emitsPrimitiveColor () const
 
bool outsetBoundsForAA () const
 
Coverage coverage () const
 
PrimitiveType primitiveType () const
 
size_t vertexStride () const
 
size_t instanceStride () const
 
size_t numUniforms () const
 
size_t numVertexAttributes () const
 
size_t numInstanceAttributes () const
 
SkSpan< const Uniformuniforms () const
 
SkSpan< const AttributevertexAttributes () const
 
SkSpan< const AttributeinstanceAttributes () const
 
SkSpan< const Varyingvaryings () const
 
const DepthStencilSettingsdepthStencilSettings () const
 
SkEnumBitMask< DepthStencilFlagsdepthStencilFlags () const
 

Additional Inherited Members

- Static Public Member Functions inherited from skgpu::graphite::RenderStep
static const char * ssboIndicesAttribute ()
 
static const char * ssboIndicesVarying ()
 
- Protected Types inherited from skgpu::graphite::RenderStep
enum class  Flags : unsigned {
  kNone = 0b0000000 , kRequiresMSAA = 0b0000001 , kPerformsShading = 0b0000010 , kHasTextures = 0b0000100 ,
  kEmitsCoverage = 0b0001000 , kLCDCoverage = 0b0010000 , kEmitsPrimitiveColor = 0b0100000 , kOutsetBoundsForAA = 0b1000000
}
 
- Protected Member Functions inherited from skgpu::graphite::RenderStep
 RenderStep (std::string_view className, std::string_view variantName, SkEnumBitMask< Flags > flags, std::initializer_list< Uniform > uniforms, PrimitiveType primitiveType, DepthStencilSettings depthStencilSettings, SkSpan< const Attribute > vertexAttrs, SkSpan< const Attribute > instanceAttrs, SkSpan< const Varying > varyings={})
 

Detailed Description

Definition at line 15 of file CoverBoundsRenderStep.h.

Constructor & Destructor Documentation

◆ CoverBoundsRenderStep()

skgpu::graphite::CoverBoundsRenderStep::CoverBoundsRenderStep ( bool  inverseFill)

Definition at line 17 of file CoverBoundsRenderStep.cpp.

18 : RenderStep("CoverBoundsRenderStep",
19 inverseFill ? "inverse" : "regular",
21 /*uniforms=*/{},
24 /*vertexAttrs=*/{{"position",
27 /*instanceAttrs=*/{{"bounds", VertexAttribType::kFloat4, SkSLType::kFloat4},
33 , fInverseFill(inverseFill) {}
RenderStep(std::string_view className, std::string_view variantName, SkEnumBitMask< Flags > flags, std::initializer_list< Uniform > uniforms, PrimitiveType primitiveType, DepthStencilSettings depthStencilSettings, SkSpan< const Attribute > vertexAttrs, SkSpan< const Attribute > instanceAttrs, SkSpan< const Varying > varyings={})
Definition: Renderer.cpp:19
constexpr DepthStencilSettings kRegularCoverPass
constexpr DepthStencilSettings kInverseCoverPass

◆ ~CoverBoundsRenderStep()

skgpu::graphite::CoverBoundsRenderStep::~CoverBoundsRenderStep ( )
override

Definition at line 35 of file CoverBoundsRenderStep.cpp.

35{}

Member Function Documentation

◆ vertexSkSL()

std::string skgpu::graphite::CoverBoundsRenderStep::vertexSkSL ( ) const
overridevirtual

Implements skgpu::graphite::RenderStep.

Definition at line 37 of file CoverBoundsRenderStep.cpp.

37 {
38 // Returns the body of a vertex function, which must define a float4 devPosition variable and
39 // must write to an already-defined float2 stepLocalCoords variable.
40 return "float4 devPosition = cover_bounds_vertex_fn("
41 "float2(sk_VertexID / 2, sk_VertexID % 2), "
42 "bounds, depth, float3x3(mat0, mat1, mat2), "
43 "stepLocalCoords);\n";
44}

◆ writeUniformsAndTextures()

void skgpu::graphite::CoverBoundsRenderStep::writeUniformsAndTextures ( const DrawParams ,
PipelineDataGatherer  
) const
overridevirtual

Implements skgpu::graphite::RenderStep.

Definition at line 74 of file CoverBoundsRenderStep.cpp.

75 {
76 // All data is uploaded as instance attributes, so no uniforms are needed.
77}

◆ writeVertices()

void skgpu::graphite::CoverBoundsRenderStep::writeVertices ( DrawWriter writer,
const DrawParams params,
skvx::ushort2  ssboIndices 
) const
overridevirtual

Implements skgpu::graphite::RenderStep.

Definition at line 46 of file CoverBoundsRenderStep.cpp.

48 {
49 // Each instance is 4 vertices, forming 2 triangles from a single triangle strip, so no indices
50 // are needed. sk_VertexID is used to place vertex positions, so no vertex buffer is needed.
51 DrawWriter::Instances instances{*writer, {}, {}, 4};
52
54 const SkM44* m;
55 if (fInverseFill) {
56 // Normally all bounding boxes are sorted such that l<r and t<b. We upload an inverted
57 // rectangle [r,b,l,t] when it's an inverse fill to encode that the bounds are already in
58 // device space and then use the inverse of the transform to compute local coordinates.
59 bounds = skvx::shuffle</*R*/2, /*B*/3, /*L*/0, /*T*/1>(
60 skvx::cast<float>(skvx::int4::Load(&params.clip().scissor())));
61 m = &params.transform().inverse();
62 } else {
63 bounds = params.geometry().bounds().ltrb();
64 m = &params.transform().matrix();
65 }
66
67 // Since the local coords always have Z=0, we can discard the 3rd row and column of the matrix.
68 instances.append(1) << bounds << params.order().depthAsFloat() << ssboIndices
69 << m->rc(0,0) << m->rc(1,0) << m->rc(3,0)
70 << m->rc(0,1) << m->rc(1,1) << m->rc(3,1)
71 << m->rc(0,3) << m->rc(1,3) << m->rc(3,3);
72}
Definition: SkM44.h:150
const EmbeddedViewParams * params
Optional< SkRect > bounds
Definition: SkRecords.h:189
SI Vec< sizeof...(Ix), T > shuffle(const Vec< N, T > &)
Definition: SkVx.h:667
Definition: SkVx.h:83
static SKVX_ALWAYS_INLINE Vec Load(const void *ptr)
Definition: SkVx.h:109

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