Flutter Engine
The Flutter Engine
Classes | Public Member Functions | Static Public Member Functions | Static Public Attributes | Protected Member Functions | Static Protected Member Functions | Private Member Functions | List of all members
GrGeometryProcessor Class Referenceabstract

#include <GrGeometryProcessor.h>

Inheritance diagram for GrGeometryProcessor:
GrProcessor ButtCapDashedCircleGeometryProcessor CircleGeometryProcessor DIEllipseGeometryProcessor DefaultGeoProc EllipseGeometryProcessor GrBitmapTextGeoProc GrConicEffect GrDistanceFieldA8TextGeoProc GrDistanceFieldLCDTextGeoProc GrDistanceFieldPathGeoProc GrQuadEffect GrRRectShadowGeoProc GrTessellationShader skgpu::ganesh::QuadPerEdgeAA::QuadPerEdgeAAGeometryProcessor

Classes

class  Attribute
 
class  AttributeSet
 
class  ProgramImpl
 
class  TextureSampler
 

Public Member Functions

 GrGeometryProcessor (ClassID)
 
int numTextureSamplers () const
 
const TextureSamplertextureSampler (int index) const
 
int numVertexAttributes () const
 
const AttributeSetvertexAttributes () const
 
int numInstanceAttributes () const
 
const AttributeSetinstanceAttributes () const
 
bool hasVertexAttributes () const
 
bool hasInstanceAttributes () const
 
size_t vertexStride () const
 
size_t instanceStride () const
 
virtual void addToKey (const GrShaderCaps &, skgpu::KeyBuilder *) const =0
 
void getAttributeKey (skgpu::KeyBuilder *b) const
 
virtual std::unique_ptr< ProgramImplmakeProgramImpl (const GrShaderCaps &) const =0
 
- Public Member Functions inherited from GrProcessor
virtual ~GrProcessor ()=default
 
virtual const char * name () const =0
 
void * operator new (size_t size)
 
void * operator new (size_t object_size, size_t footer_size)
 
void operator delete (void *target)
 
void * operator new (size_t size, void *placement)
 
void operator delete (void *target, void *placement)
 
template<typename T >
const Tcast () const
 
ClassID classID () const
 

Static Public Member Functions

static uint32_t ComputeCoordTransformsKey (const GrFragmentProcessor &fp)
 

Static Public Attributes

static constexpr int kCoordTransformKeyBits = 4
 

Protected Member Functions

void setVertexAttributes (const Attribute *attrs, int attrCount, size_t stride)
 
void setInstanceAttributes (const Attribute *attrs, int attrCount, size_t stride)
 
void setVertexAttributesWithImplicitOffsets (const Attribute *attrs, int attrCount)
 
void setInstanceAttributesWithImplicitOffsets (const Attribute *attrs, int attrCount)
 
void setTextureSamplerCnt (int cnt)
 
- Protected Member Functions inherited from GrProcessor
 GrProcessor (ClassID classID)
 
 GrProcessor (const GrProcessor &)=delete
 
GrProcessoroperator= (const GrProcessor &)=delete
 

Static Protected Member Functions

static Attribute MakeColorAttribute (const char *name, bool wideColor)
 

Private Member Functions

virtual const TextureSampleronTextureSampler (int) const
 

Additional Inherited Members

- Public Types inherited from GrProcessor
enum  ClassID {
  kNull_ClassID , kAttributeTestProcessor_ClassID , kBigKeyProcessor_ClassID , kBlendFragmentProcessor_ClassID ,
  kBlockInputFragmentProcessor_ClassID , kButtCapStrokedCircleGeometryProcessor_ClassID , kCircleGeometryProcessor_ClassID , kCircularRRectEffect_ClassID ,
  kClockwiseTestProcessor_ClassID , kColorTableEffect_ClassID , kCoverageSetOpXP_ClassID , kCustomXP_ClassID ,
  kDashingCircleEffect_ClassID , kDashingLineEffect_ClassID , kDefaultGeoProc_ClassID , kDeviceSpace_ClassID ,
  kDIEllipseGeometryProcessor_ClassID , kDisableColorXP_ClassID , kDrawAtlasPathShader_ClassID , kEllipseGeometryProcessor_ClassID ,
  kEllipticalRRectEffect_ClassID , kFwidthSquircleTestProcessor_ClassID , kGP_ClassID , kGrBicubicEffect_ClassID ,
  kGrBitmapTextGeoProc_ClassID , kGrColorSpaceXformEffect_ClassID , kGrConicEffect_ClassID , kGrConvexPolyEffect_ClassID ,
  kGrDiffuseLightingEffect_ClassID , kGrDisplacementMapEffect_ClassID , kGrDistanceFieldA8TextGeoProc_ClassID , kGrDistanceFieldLCDTextGeoProc_ClassID ,
  kGrDistanceFieldPathGeoProc_ClassID , kGrFillRRectOp_Processor_ClassID , kGrGaussianConvolutionFragmentProcessor_ClassID , kGrMatrixConvolutionEffect_ClassID ,
  kGrMatrixEffect_ClassID , kGrMeshTestProcessor_ClassID , kGrMorphologyEffect_ClassID , kGrPerlinNoise2Effect_ClassID ,
  kGrPipelineDynamicStateTestProcessor_ClassID , kGrQuadEffect_ClassID , kGrRRectShadowGeoProc_ClassID , kGrSkSLFP_ClassID ,
  kGrSpecularLightingEffect_ClassID , kGrTextureEffect_ClassID , kGrUnrolledBinaryGradientColorizer_ClassID , kGrYUVtoRGBEffect_ClassID ,
  kHighPrecisionFragmentProcessor_ClassID , kLatticeGP_ClassID , kPDLCDXferProcessor_ClassID , kPorterDuffXferProcessor_ClassID ,
  kPremulFragmentProcessor_ClassID , kQuadEdgeEffect_ClassID , kQuadPerEdgeAAGeometryProcessor_ClassID , kSeriesFragmentProcessor_ClassID ,
  kShaderPDXferProcessor_ClassID , kSurfaceColorProcessor_ClassID , kSwizzleFragmentProcessor_ClassID , kTessellate_BoundingBoxShader_ClassID ,
  kTessellate_GrModulateAtlasCoverageEffect_ClassID , kTessellate_GrStrokeTessellationShader_ClassID , kTessellate_HullShader_ClassID , kTessellate_MiddleOutShader_ClassID ,
  kTessellate_SimpleTriangleShader_ClassID , kTessellationTestTriShader_ClassID , kTestFP_ClassID , kTestRectOp_ClassID ,
  kVertexColorSpaceBenchGP_ClassID , kVerticesGP_ClassID
}
 
- Protected Attributes inherited from GrProcessor
const ClassID fClassID
 

Detailed Description

The GrGeometryProcessor represents some kind of geometric primitive. This includes the shape of the primitive and the inherent color of the primitive. The GrGeometryProcessor is responsible for providing a color and coverage input into the Ganesh rendering pipeline. Through optimization, Ganesh may decide a different color, no color, and / or no coverage are required from the GrGeometryProcessor, so the GrGeometryProcessor must be able to support this functionality.

There are two feedback loops between the GrFragmentProcessors, the GrXferProcessor, and the GrGeometryProcessor. These loops run on the CPU and to determine known properties of the final color and coverage inputs to the GrXferProcessor in order to perform optimizations that preserve correctness. The GrDrawOp seeds these loops with initial color and coverage, in its getProcessorAnalysisInputs implementation. These seed values are processed by the subsequent stages of the rendering pipeline and the output is then fed back into the GrDrawOp in the applyPipelineOptimizations call, where the op can use the information to inform decisions about GrGeometryProcessor creation.

Note that all derived classes should hide their constructors and provide a Make factory function that takes an arena (except for Tesselation-specific classes). This is because geometry processors can be created in either the record-time or flush-time arenas which define their lifetimes (i.e., a DDLs life time in the first case and a single flush in the second case).

Definition at line 53 of file GrGeometryProcessor.h.

Constructor & Destructor Documentation

◆ GrGeometryProcessor()

GrGeometryProcessor::GrGeometryProcessor ( ClassID  classID)

Definition at line 20 of file GrGeometryProcessor.cpp.

GrProcessor(ClassID classID)
Definition: GrProcessor.h:132
ClassID classID() const
Definition: GrProcessor.h:129

Member Function Documentation

◆ addToKey()

virtual void GrGeometryProcessor::addToKey ( const GrShaderCaps ,
skgpu::KeyBuilder  
) const
pure virtual

◆ ComputeCoordTransformsKey()

uint32_t GrGeometryProcessor::ComputeCoordTransformsKey ( const GrFragmentProcessor fp)
static

Computes a key for the transforms owned by an FP based on the shader code that will be emitted by the primitive processor to implement them.

Definition at line 27 of file GrGeometryProcessor.cpp.

27 {
28 // This is highly coupled with the code in ProgramImpl::collectTransforms().
29 uint32_t key = static_cast<uint32_t>(fp.sampleUsage().kind()) << 1;
30 // This needs to be updated if GP starts specializing varyings on additional matrix types.
31 if (fp.sampleUsage().hasPerspective()) {
32 key |= 0b1;
33 }
34 return key;
35}
const uint32_t fp

◆ getAttributeKey()

void GrGeometryProcessor::getAttributeKey ( skgpu::KeyBuilder b) const

Definition at line 37 of file GrGeometryProcessor.cpp.

37 {
38 b->appendComment("vertex attributes");
39 fVertexAttributes.addToKey(b);
40 b->appendComment("instance attributes");
41 fInstanceAttributes.addToKey(b);
42}
void addToKey(skgpu::KeyBuilder *b) const
static bool b

◆ hasInstanceAttributes()

bool GrGeometryProcessor::hasInstanceAttributes ( ) const
inline

Definition at line 189 of file GrGeometryProcessor.h.

189{ return SkToBool(fInstanceAttributes.count()); }
static constexpr bool SkToBool(const T &x)
Definition: SkTo.h:35

◆ hasVertexAttributes()

bool GrGeometryProcessor::hasVertexAttributes ( ) const
inline

Definition at line 188 of file GrGeometryProcessor.h.

188{ return SkToBool(fVertexAttributes.count()); }

◆ instanceAttributes()

const AttributeSet & GrGeometryProcessor::instanceAttributes ( ) const
inline

Definition at line 186 of file GrGeometryProcessor.h.

186{ return fInstanceAttributes; }

◆ instanceStride()

size_t GrGeometryProcessor::instanceStride ( ) const
inline

Definition at line 197 of file GrGeometryProcessor.h.

197{ return fInstanceAttributes.stride(); }

◆ MakeColorAttribute()

static Attribute GrGeometryProcessor::MakeColorAttribute ( const char *  name,
bool  wideColor 
)
inlinestaticprotected

Definition at line 224 of file GrGeometryProcessor.h.

224 {
225 return { name,
228 }
@ kUByte4_norm_GrVertexAttribType
Definition: GrTypesPriv.h:334
@ kFloat4_GrVertexAttribType
Definition: GrTypesPriv.h:316
virtual const char * name() const =0

◆ makeProgramImpl()

virtual std::unique_ptr< ProgramImpl > GrGeometryProcessor::makeProgramImpl ( const GrShaderCaps ) const
pure virtual

◆ numInstanceAttributes()

int GrGeometryProcessor::numInstanceAttributes ( ) const
inline

Definition at line 185 of file GrGeometryProcessor.h.

185{ return fInstanceAttributes.count(); }

◆ numTextureSamplers()

int GrGeometryProcessor::numTextureSamplers ( ) const
inline

Definition at line 181 of file GrGeometryProcessor.h.

181{ return fTextureSamplerCnt; }

◆ numVertexAttributes()

int GrGeometryProcessor::numVertexAttributes ( ) const
inline

Definition at line 183 of file GrGeometryProcessor.h.

183{ return fVertexAttributes.count(); }

◆ onTextureSampler()

virtual const TextureSampler & GrGeometryProcessor::onTextureSampler ( int  ) const
inlineprivatevirtual

Definition at line 250 of file GrGeometryProcessor.h.

250{ SK_ABORT("no texture samplers"); }
#define SK_ABORT(message,...)
Definition: SkAssert.h:70

◆ setInstanceAttributes()

void GrGeometryProcessor::setInstanceAttributes ( const Attribute attrs,
int  attrCount,
size_t  stride 
)
inlineprotected

Definition at line 232 of file GrGeometryProcessor.h.

232 {
233 SkASSERT(attrCount >= 0);
234 fInstanceAttributes.initExplicit(attrs, attrCount, stride);
235 }
#define SkASSERT(cond)
Definition: SkAssert.h:116
void initExplicit(const Attribute *attrs, int count, size_t stride)

◆ setInstanceAttributesWithImplicitOffsets()

void GrGeometryProcessor::setInstanceAttributesWithImplicitOffsets ( const Attribute attrs,
int  attrCount 
)
inlineprotected

Definition at line 240 of file GrGeometryProcessor.h.

240 {
241 SkASSERT(attrCount >= 0);
242 fInstanceAttributes.initImplicit(attrs, attrCount);
243 }
void initImplicit(const Attribute *attrs, int count)

◆ setTextureSamplerCnt()

void GrGeometryProcessor::setTextureSamplerCnt ( int  cnt)
inlineprotected

Definition at line 244 of file GrGeometryProcessor.h.

244 {
245 SkASSERT(cnt >= 0);
246 fTextureSamplerCnt = cnt;
247 }

◆ setVertexAttributes()

void GrGeometryProcessor::setVertexAttributes ( const Attribute attrs,
int  attrCount,
size_t  stride 
)
inlineprotected

Definition at line 229 of file GrGeometryProcessor.h.

229 {
230 fVertexAttributes.initExplicit(attrs, attrCount, stride);
231 }

◆ setVertexAttributesWithImplicitOffsets()

void GrGeometryProcessor::setVertexAttributesWithImplicitOffsets ( const Attribute attrs,
int  attrCount 
)
inlineprotected

Definition at line 237 of file GrGeometryProcessor.h.

237 {
238 fVertexAttributes.initImplicit(attrs, attrCount);
239 }

◆ textureSampler()

const GrGeometryProcessor::TextureSampler & GrGeometryProcessor::textureSampler ( int  index) const

Definition at line 22 of file GrGeometryProcessor.cpp.

22 {
23 SkASSERT(i >= 0 && i < this->numTextureSamplers());
24 return this->onTextureSampler(i);
25}
virtual const TextureSampler & onTextureSampler(int) const

◆ vertexAttributes()

const AttributeSet & GrGeometryProcessor::vertexAttributes ( ) const
inline

Definition at line 184 of file GrGeometryProcessor.h.

184{ return fVertexAttributes; }

◆ vertexStride()

size_t GrGeometryProcessor::vertexStride ( ) const
inline

A common practice is to populate the the vertex/instance's memory using an implicit array of structs. In this case, it is best to assert that: stride == sizeof(struct)

Definition at line 196 of file GrGeometryProcessor.h.

196{ return fVertexAttributes.stride(); }

Member Data Documentation

◆ kCoordTransformKeyBits

constexpr int GrGeometryProcessor::kCoordTransformKeyBits = 4
inlinestaticconstexpr

Definition at line 205 of file GrGeometryProcessor.h.


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