Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
Classes | Public Member Functions | Private Member Functions | List of all members
GrStrokeTessellationShader Class Reference

#include <GrStrokeTessellationShader.h>

Inheritance diagram for GrStrokeTessellationShader:
GrTessellationShader GrGeometryProcessor GrProcessor

Classes

class  Impl
 

Public Member Functions

 GrStrokeTessellationShader (const GrShaderCaps &, PatchAttribs, const SkMatrix &viewMatrix, const SkStrokeRec &, SkPMColor4f)
 
PatchAttribs attribs () const
 
bool hasDynamicStroke () const
 
bool hasDynamicColor () const
 
bool hasExplicitCurveType () const
 
const SkStrokeRecstroke () const
 
- Public Member Functions inherited from GrTessellationShader
 GrTessellationShader (ClassID classID, GrPrimitiveType primitiveType, const SkMatrix &viewMatrix, const SkPMColor4f &color)
 
GrPrimitiveType primitiveType () const
 
const SkMatrixviewMatrix () const
 
const SkPMColor4fcolor () const
 
- Public Member Functions inherited from GrGeometryProcessor
 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
 
void getAttributeKey (skgpu::KeyBuilder *b) const
 
- Public Member Functions inherited from GrProcessor
virtual ~GrProcessor ()=default
 
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
 

Private Member Functions

const char * name () const override
 
void addToKey (const GrShaderCaps &, skgpu::KeyBuilder *) const override
 
std::unique_ptr< ProgramImplmakeProgramImpl (const GrShaderCaps &) const final
 

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
}
 
- Static Public Member Functions inherited from GrTessellationShader
static const GrPipelineMakePipeline (const ProgramArgs &, GrAAType, GrAppliedClip &&, GrProcessorSet &&)
 
static GrProgramInfoMakeProgram (const ProgramArgs &args, const GrTessellationShader *shader, const GrPipeline *pipeline, const GrUserStencilSettings *stencil)
 
static const char * WangsFormulaSkSL ()
 
- Static Public Member Functions inherited from GrGeometryProcessor
static uint32_t ComputeCoordTransformsKey (const GrFragmentProcessor &fp)
 
- Static Public Attributes inherited from GrGeometryProcessor
static constexpr int kCoordTransformKeyBits = 4
 
- Protected Member Functions inherited from GrGeometryProcessor
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 inherited from GrGeometryProcessor
static Attribute MakeColorAttribute (const char *name, bool wideColor)
 
- Protected Attributes inherited from GrProcessor
const ClassID fClassID
 

Detailed Description

Definition at line 24 of file GrStrokeTessellationShader.h.

Constructor & Destructor Documentation

◆ GrStrokeTessellationShader()

GrStrokeTessellationShader::GrStrokeTessellationShader ( const GrShaderCaps shaderCaps,
PatchAttribs  attribs,
const SkMatrix viewMatrix,
const SkStrokeRec stroke,
SkPMColor4f  color 
)

Definition at line 88 of file GrStrokeTessellationShader.cpp.

95 , fPatchAttribs(attribs | PatchAttribs::kJoinControlPoint)
96 , fStroke(stroke) {
97 // We should use explicit curve type when, and only when, there isn't infinity support.
98 // Otherwise the GPU can infer curve type based on infinity.
99 SkASSERT(shaderCaps.fInfinitySupport != (attribs & PatchAttribs::kExplicitCurveType));
100 // pts 0..3 define the stroke as a cubic bezier. If p3.y is infinity, then it's a conic
101 // with w=p3.x.
102 //
103 // An empty stroke (p0==p1==p2==p3) is a special case that denotes a circle, or
104 // 180-degree point stroke.
105 fAttribs.emplace_back("pts01Attr", kFloat4_GrVertexAttribType, SkSLType::kFloat4);
106 fAttribs.emplace_back("pts23Attr", kFloat4_GrVertexAttribType, SkSLType::kFloat4);
107
108 // argsAttr contains the lastControlPoint for setting up the join.
109 fAttribs.emplace_back("argsAttr", kFloat2_GrVertexAttribType, SkSLType::kFloat2);
110
111 if (fPatchAttribs & PatchAttribs::kStrokeParams) {
112 fAttribs.emplace_back("dynamicStrokeAttr", kFloat2_GrVertexAttribType,
114 }
115 if (fPatchAttribs & PatchAttribs::kColor) {
116 fAttribs.emplace_back("dynamicColorAttr",
117 (fPatchAttribs & PatchAttribs::kWideColorIfEnabled)
121 }
122 if (fPatchAttribs & PatchAttribs::kExplicitCurveType) {
123 // A conic curve is written out with p3=[w,Infinity], but GPUs that don't support
124 // infinity can't detect this. On these platforms we write out an extra float with each
125 // patch that explicitly tells the shader what type of curve it is.
126 fAttribs.emplace_back("curveTypeAttr", kFloat_GrVertexAttribType, SkSLType::kFloat);
127 }
128
129 this->setInstanceAttributesWithImplicitOffsets(fAttribs.data(), fAttribs.size());
130 SkASSERT(this->instanceStride() == sizeof(SkPoint) * 4 + PatchAttribsStride(fPatchAttribs));
131 if (!shaderCaps.fVertexIDSupport) {
132 constexpr static Attribute kVertexAttrib("edgeID", kFloat_GrVertexAttribType,
134 this->setVertexAttributesWithImplicitOffsets(&kVertexAttrib, 1);
135 }
136 SkASSERT(fAttribs.size() <= kMaxAttribCount);
137}
@ kFloat2_GrVertexAttribType
@ kUByte4_norm_GrVertexAttribType
@ kFloat_GrVertexAttribType
@ kFloat4_GrVertexAttribType
#define SkASSERT(cond)
Definition SkAssert.h:116
SkSLType
void setInstanceAttributesWithImplicitOffsets(const Attribute *attrs, int attrCount)
size_t instanceStride() const
void setVertexAttributesWithImplicitOffsets(const Attribute *attrs, int attrCount)
@ kTessellate_GrStrokeTessellationShader_ClassID
Definition GrProcessor.h:87
const SkStrokeRec & stroke() const
const SkPMColor4f & color() const
const SkMatrix & viewMatrix() const
constexpr size_t PatchAttribsStride(PatchAttribs attribs)
bool fVertexIDSupport
bool fInfinitySupport
Definition SkSLUtil.h:103

Member Function Documentation

◆ addToKey()

void GrStrokeTessellationShader::addToKey ( const GrShaderCaps ,
skgpu::KeyBuilder  
) const
overrideprivatevirtual

Adds a key on the skgpu::KeyBuilder that reflects any variety in the code that the geometry processor subclass can emit.

Implements GrGeometryProcessor.

Definition at line 693 of file GrStrokeTessellationShader.cpp.

693 {
694 bool keyNeedsJoin = !(fPatchAttribs & PatchAttribs::kStrokeParams);
695 SkASSERT(fStroke.getJoin() >> 2 == 0);
696 // Attribs get worked into the key automatically during GrGeometryProcessor::getAttributeKey().
697 // When color is in a uniform, it's always wide. kWideColor doesn't need to be considered here.
698 uint32_t key = (uint32_t)(fPatchAttribs & ~PatchAttribs::kColor);
699 key = (key << 2) | ((keyNeedsJoin) ? fStroke.getJoin() : 0);
700 key = (key << 1) | (uint32_t)fStroke.isHairlineStyle();
701 b->add32(key);
702}
bool isHairlineStyle() const
Definition SkStrokeRec.h:47
SkPaint::Join getJoin() const
Definition SkStrokeRec.h:45
static bool b

◆ attribs()

PatchAttribs GrStrokeTessellationShader::attribs ( ) const
inline

Definition at line 33 of file GrStrokeTessellationShader.h.

33{ return fPatchAttribs; }

◆ hasDynamicColor()

bool GrStrokeTessellationShader::hasDynamicColor ( ) const
inline

Definition at line 35 of file GrStrokeTessellationShader.h.

35{ return fPatchAttribs & PatchAttribs::kColor; }

◆ hasDynamicStroke()

bool GrStrokeTessellationShader::hasDynamicStroke ( ) const
inline

Definition at line 34 of file GrStrokeTessellationShader.h.

34{ return fPatchAttribs & PatchAttribs::kStrokeParams; }

◆ hasExplicitCurveType()

bool GrStrokeTessellationShader::hasExplicitCurveType ( ) const
inline

Definition at line 36 of file GrStrokeTessellationShader.h.

36{ return fPatchAttribs & PatchAttribs::kExplicitCurveType; }

◆ makeProgramImpl()

std::unique_ptr< GrGeometryProcessor::ProgramImpl > GrStrokeTessellationShader::makeProgramImpl ( const GrShaderCaps ) const
finalprivatevirtual

Returns a new instance of the appropriate implementation class for the given GrGeometryProcessor.

Implements GrGeometryProcessor.

Definition at line 704 of file GrStrokeTessellationShader.cpp.

705 {
706 return std::make_unique<Impl>();
707}

◆ name()

const char * GrStrokeTessellationShader::name ( ) const
inlineoverrideprivatevirtual

Human-meaningful string to identify this processor; may be embedded in generated shader code and must be a legal SkSL identifier prefix.

Implements GrProcessor.

Definition at line 40 of file GrStrokeTessellationShader.h.

40{ return "GrStrokeTessellationShader"; }

◆ stroke()

const SkStrokeRec & GrStrokeTessellationShader::stroke ( ) const
inline

Definition at line 37 of file GrStrokeTessellationShader.h.

37{ return fStroke;}

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