Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
Public Member Functions | Static Public Member Functions | Private Member Functions | List of all members
skgpu::ganesh::QuadPerEdgeAA::QuadPerEdgeAAGeometryProcessor Class Reference
Inheritance diagram for skgpu::ganesh::QuadPerEdgeAA::QuadPerEdgeAAGeometryProcessor:
GrGeometryProcessor GrProcessor

Public Member Functions

const char * name () const override
 
void addToKey (const GrShaderCaps &, KeyBuilder *b) const override
 
std::unique_ptr< ProgramImplmakeProgramImpl (const GrShaderCaps &) const override
 
- 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
 

Static Public Member Functions

static GrGeometryProcessorMake (SkArenaAlloc *arena, const VertexSpec &spec)
 
static GrGeometryProcessorMake (SkArenaAlloc *arena, const VertexSpec &vertexSpec, const GrShaderCaps &caps, const GrBackendFormat &backendFormat, GrSamplerState samplerState, const skgpu::Swizzle &swizzle, sk_sp< GrColorSpaceXform > textureColorSpaceXform, Saturate saturate)
 
- Static Public Member Functions inherited from GrGeometryProcessor
static uint32_t ComputeCoordTransformsKey (const GrFragmentProcessor &fp)
 

Private Member Functions

const TextureSampleronTextureSampler (int) const override
 

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 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 599 of file QuadPerEdgeAA.cpp.

Member Function Documentation

◆ addToKey()

void skgpu::ganesh::QuadPerEdgeAA::QuadPerEdgeAAGeometryProcessor::addToKey ( const GrShaderCaps ,
KeyBuilder  
) const
inlineoverridevirtual

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 624 of file QuadPerEdgeAA.cpp.

624 {
625 // texturing, device-dimensions are single bit flags
626 b->addBool(fTexSubset.isInitialized(), "subset");
627 b->addBool(fSampler.isInitialized(), "textured");
628 b->addBool(fNeedsPerspective, "perspective");
629 b->addBool((fSaturate == Saturate::kYes), "saturate");
630
631 b->addBool(fLocalCoord.isInitialized(), "hasLocalCoords");
632 if (fLocalCoord.isInitialized()) {
633 // 2D (0) or 3D (1)
634 b->addBits(1, (kFloat3_GrVertexAttribType == fLocalCoord.cpuType()), "localCoordsType");
635 }
636 b->addBool(fColor.isInitialized(), "hasColor");
637 if (fColor.isInitialized()) {
638 // bytes (0) or floats (1)
639 b->addBits(1, (kFloat4_GrVertexAttribType == fColor.cpuType()), "colorType");
640 }
641 // and coverage mode, 00 for none, 01 for withposition, 10 for withcolor, 11 for
642 // position+geomsubset
643 uint32_t coverageKey = 0;
644 SkASSERT(!fGeomSubset.isInitialized() || fCoverageMode == CoverageMode::kWithPosition);
645 if (fCoverageMode != CoverageMode::kNone) {
646 coverageKey = fGeomSubset.isInitialized()
647 ? 0x3
648 : (CoverageMode::kWithPosition == fCoverageMode ? 0x1 : 0x2);
649 }
650 b->addBits(2, coverageKey, "coverageMode");
651
652 b->add32(GrColorSpaceXform::XformKey(fTextureColorSpaceXform.get()), "colorSpaceXform");
653 }
@ kFloat3_GrVertexAttribType
@ kFloat4_GrVertexAttribType
#define SkASSERT(cond)
Definition SkAssert.h:116
static uint32_t XformKey(const GrColorSpaceXform *xform)
constexpr GrVertexAttribType cpuType() const
constexpr bool isInitialized() const
T * get() const
Definition SkRefCnt.h:303
static bool b

◆ Make() [1/2]

static GrGeometryProcessor * skgpu::ganesh::QuadPerEdgeAA::QuadPerEdgeAAGeometryProcessor::Make ( SkArenaAlloc arena,
const VertexSpec spec 
)
inlinestatic

Definition at line 601 of file QuadPerEdgeAA.cpp.

601 {
602 return arena->make([&](void* ptr) {
603 return new (ptr) QuadPerEdgeAAGeometryProcessor(spec);
604 });
605 }
auto make(Ctor &&ctor) -> decltype(ctor(nullptr))

◆ Make() [2/2]

static GrGeometryProcessor * skgpu::ganesh::QuadPerEdgeAA::QuadPerEdgeAAGeometryProcessor::Make ( SkArenaAlloc arena,
const VertexSpec vertexSpec,
const GrShaderCaps caps,
const GrBackendFormat backendFormat,
GrSamplerState  samplerState,
const skgpu::Swizzle swizzle,
sk_sp< GrColorSpaceXform textureColorSpaceXform,
Saturate  saturate 
)
inlinestatic

Definition at line 607 of file QuadPerEdgeAA.cpp.

614 {
615 return arena->make([&](void* ptr) {
616 return new (ptr) QuadPerEdgeAAGeometryProcessor(
617 vertexSpec, caps, backendFormat, samplerState, swizzle,
618 std::move(textureColorSpaceXform), saturate);
619 });
620 }

◆ makeProgramImpl()

std::unique_ptr< ProgramImpl > skgpu::ganesh::QuadPerEdgeAA::QuadPerEdgeAAGeometryProcessor::makeProgramImpl ( const GrShaderCaps ) const
inlineoverridevirtual

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

Implements GrGeometryProcessor.

Definition at line 655 of file QuadPerEdgeAA.cpp.

655 {
656 class Impl : public ProgramImpl {
657 public:
658 void setData(const GrGLSLProgramDataManager& pdman,
659 const GrShaderCaps&,
660 const GrGeometryProcessor& geomProc) override {
661 const auto& gp = geomProc.cast<QuadPerEdgeAAGeometryProcessor>();
662 fTextureColorSpaceXformHelper.setData(pdman, gp.fTextureColorSpaceXform.get());
663 }
664
665 private:
666 void onEmitCode(EmitArgs& args, GrGPArgs* gpArgs) override {
667 using Interpolation = GrGLSLVaryingHandler::Interpolation;
668
669 const auto& gp = args.fGeomProc.cast<QuadPerEdgeAAGeometryProcessor>();
670 fTextureColorSpaceXformHelper.emitCode(args.fUniformHandler,
671 gp.fTextureColorSpaceXform.get());
672
673 args.fVaryingHandler->emitAttributes(gp);
674
675 if (gp.fCoverageMode == CoverageMode::kWithPosition) {
676 // Strip last channel from the vertex attribute to remove coverage and get the
677 // actual position
678 if (gp.fNeedsPerspective) {
679 args.fVertBuilder->codeAppendf("float3 position = %s.xyz;",
680 gp.fPosition.name());
681 } else {
682 args.fVertBuilder->codeAppendf("float2 position = %s.xy;",
683 gp.fPosition.name());
684 }
685 gpArgs->fPositionVar = {"position",
686 gp.fNeedsPerspective ? SkSLType::kFloat3
689 } else {
690 // No coverage to eliminate
691 gpArgs->fPositionVar = gp.fPosition.asShaderVar();
692 }
693
694 // This attribute will be uninitialized if earlier FP analysis determined no
695 // local coordinates are needed (and this will not include the inline texture
696 // fetch this GP does before invoking FPs).
697 gpArgs->fLocalCoordVar = gp.fLocalCoord.asShaderVar();
698
699 // Solid color before any texturing gets modulated in
700 const char* blendDst;
701 if (gp.fColor.isInitialized()) {
702 SkASSERT(gp.fCoverageMode != CoverageMode::kWithColor || !gp.fNeedsPerspective);
703 // The color cannot be flat if the varying coverage has been modulated into it
704 args.fFragBuilder->codeAppendf("half4 %s;", args.fOutputColor);
705 args.fVaryingHandler->addPassThroughAttribute(
706 gp.fColor.asShaderVar(),
707 args.fOutputColor,
708 gp.fCoverageMode == CoverageMode::kWithColor
709 ? Interpolation::kInterpolated
710 : Interpolation::kCanBeFlat);
711 blendDst = args.fOutputColor;
712 } else {
713 // Output color must be initialized to something
714 args.fFragBuilder->codeAppendf("half4 %s = half4(1);", args.fOutputColor);
715 blendDst = nullptr;
716 }
717
718 // If there is a texture, must also handle texture coordinates and reading from
719 // the texture in the fragment shader before continuing to fragment processors.
720 if (gp.fSampler.isInitialized()) {
721 // Texture coordinates clamped by the subset on the fragment shader; if the GP
722 // has a texture, it's guaranteed to have local coordinates
723 args.fFragBuilder->codeAppend("float2 texCoord;");
724 if (gp.fLocalCoord.cpuType() == kFloat3_GrVertexAttribType) {
725 // Can't do a pass through since we need to perform perspective division
726 GrGLSLVarying v(gp.fLocalCoord.gpuType());
727 args.fVaryingHandler->addVarying(gp.fLocalCoord.name(), &v);
728 args.fVertBuilder->codeAppendf("%s = %s;",
729 v.vsOut(), gp.fLocalCoord.name());
730 args.fFragBuilder->codeAppendf("texCoord = %s.xy / %s.z;",
731 v.fsIn(), v.fsIn());
732 } else {
733 args.fVaryingHandler->addPassThroughAttribute(gp.fLocalCoord.asShaderVar(),
734 "texCoord");
735 }
736
737 // Clamp the now 2D localCoordName variable by the subset if it is provided
738 if (gp.fTexSubset.isInitialized()) {
739 args.fFragBuilder->codeAppend("float4 subset;");
740 args.fVaryingHandler->addPassThroughAttribute(gp.fTexSubset.asShaderVar(),
741 "subset",
742 Interpolation::kCanBeFlat);
743 args.fFragBuilder->codeAppend(
744 "texCoord = clamp(texCoord, subset.LT, subset.RB);");
745 }
746
747 // Now modulate the starting output color by the texture lookup
748 args.fFragBuilder->codeAppendf(
749 "%s = %s(",
750 args.fOutputColor,
751 (gp.fSaturate == Saturate::kYes) ? "saturate" : "");
752 args.fFragBuilder->appendTextureLookupAndBlend(
753 blendDst, SkBlendMode::kModulate, args.fTexSamplers[0],
754 "texCoord", &fTextureColorSpaceXformHelper);
755 args.fFragBuilder->codeAppend(");");
756 } else {
757 // Saturate is only intended for use with a proxy to account for the fact
758 // that TextureOp skips SkPaint conversion, which normally handles this.
759 SkASSERT(gp.fSaturate == Saturate::kNo);
760 }
761
762 // And lastly, output the coverage calculation code
763 if (gp.fCoverageMode == CoverageMode::kWithPosition) {
765 args.fVaryingHandler->addVarying("coverage", &coverage);
766 if (gp.fNeedsPerspective) {
767 // Multiply by "W" in the vertex shader, then by 1/w (sk_FragCoord.w) in
768 // the fragment shader to get screen-space linear coverage.
769 args.fVertBuilder->codeAppendf("%s = %s.w * %s.z;",
770 coverage.vsOut(), gp.fPosition.name(),
771 gp.fPosition.name());
772 args.fFragBuilder->codeAppendf("float coverage = %s * sk_FragCoord.w;",
773 coverage.fsIn());
774 } else {
775 args.fVertBuilder->codeAppendf("%s = %s;",
776 coverage.vsOut(), gp.fCoverage.name());
777 args.fFragBuilder->codeAppendf("float coverage = %s;", coverage.fsIn());
778 }
779
780 if (gp.fGeomSubset.isInitialized()) {
781 // Calculate distance from sk_FragCoord to the 4 edges of the subset
782 // and clamp them to (0, 1). Use the minimum of these and the original
783 // coverage. This only has to be done in the exterior triangles, the
784 // interior of the quad geometry can never be clipped by the subset box.
785 args.fFragBuilder->codeAppend("float4 geoSubset;");
786 args.fVaryingHandler->addPassThroughAttribute(gp.fGeomSubset.asShaderVar(),
787 "geoSubset",
788 Interpolation::kCanBeFlat);
789 args.fFragBuilder->codeAppend(
790 // This is lifted from GrFragmentProcessor::Rect.
791 "float4 dists4 = saturate(float4(1, 1, -1, -1) * "
792 "(sk_FragCoord.xyxy - geoSubset));"
793 "float2 dists2 = dists4.xy + dists4.zw - 1;"
794 "coverage = min(coverage, dists2.x * dists2.y);");
795 }
796
797 args.fFragBuilder->codeAppendf("half4 %s = half4(coverage);",
798 args.fOutputCoverage);
799 } else {
800 // Set coverage to 1, since it's either non-AA or the coverage was already
801 // folded into the output color
802 SkASSERT(!gp.fGeomSubset.isInitialized());
803 args.fFragBuilder->codeAppendf("const half4 %s = half4(1);",
804 args.fOutputCoverage);
805 }
806 }
807
808 GrGLSLColorSpaceXformHelper fTextureColorSpaceXformHelper;
809 };
810
811 return std::make_unique<Impl>();
812 }
@ kModulate
r = s*d
const T & cast() const
G_BEGIN_DECLS G_MODULE_EXPORT FlValue * args

◆ name()

const char * skgpu::ganesh::QuadPerEdgeAA::QuadPerEdgeAAGeometryProcessor::name ( ) const
inlineoverridevirtual

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 622 of file QuadPerEdgeAA.cpp.

622{ return "QuadPerEdgeAAGeometryProcessor"; }

◆ onTextureSampler()

const TextureSampler & skgpu::ganesh::QuadPerEdgeAA::QuadPerEdgeAAGeometryProcessor::onTextureSampler ( int  ) const
inlineoverrideprivatevirtual

Reimplemented from GrGeometryProcessor.

Definition at line 885 of file QuadPerEdgeAA.cpp.

885{ return fSampler; }

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