Flutter Engine
The Flutter Engine
Classes | Public Member Functions | Static Public Member Functions | List of all members
GrConicEffect Class Reference

#include <GrBezierEffect.h>

Inheritance diagram for GrConicEffect:
GrGeometryProcessor GrProcessor

Classes

class  Impl
 

Public Member Functions

 ~GrConicEffect () override
 
const char * name () const override
 
void addToKey (const GrShaderCaps &caps, skgpu::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
 
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 GrGeometryProcessorMake (SkArenaAlloc *arena, const SkPMColor4f &color, const SkMatrix &viewMatrix, const GrCaps &caps, const SkMatrix &localMatrix, bool usesLocalCoords, uint8_t coverage=0xff)
 
- Static Public Member Functions inherited from GrGeometryProcessor
static uint32_t ComputeCoordTransformsKey (const GrFragmentProcessor &fp)
 

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

Shader is based off of Loop-Blinn Quadratic GPU Rendering The output of this effect is a hairline edge for conics. Conics specified by implicit equation K^2 - LM. K, L, and M, are the first three values of the vertex attribute, the fourth value is not used. Distance is calculated using a first order approximation from the taylor series. Coverage for AA is max(0, 1-distance).

Test were also run using a second order distance approximation. There were two versions of the second order approx. The first version is of roughly the form: f(q) = |f(p)| - ||f'(p)||*||q-p|| - ||f''(p)||*||q-p||^2. The second is similar: f(q) = |f(p)| + ||f'(p)||*||q-p|| + ||f''(p)||*||q-p||^2. The exact version of the equations can be found in the paper "Distance Approximations for Rasterizing Implicit Curves" by Gabriel Taubin

In both versions we solve the quadratic for ||q-p||. Version 1: gFM is magnitude of first partials and gFM2 is magnitude of 2nd partials (as derived from paper) builder->fsCodeAppend("\t\tedgeAlpha = (sqrt(gFM*gFM+4.0*func*gF2M) - gFM)/(2.0*gF2M);\n"); Version 2: builder->fsCodeAppend("\t\tedgeAlpha = (gFM - sqrt(gFM*gFM-4.0*func*gF2M))/(2.0*gF2M);\n");

Also note that 2nd partials of k,l,m are zero

When comparing the two second order approximations to the first order approximations, the following results were found. Version 1 tends to underestimate the distances, thus it basically increases all the error that we were already seeing in the first order approx. So this version is not the one to use. Version 2 has the opposite effect and tends to overestimate the distances. This is much closer to what we are looking for. It is able to render ellipses (even thin ones) without the need to chop. However, it can not handle thin hyperbolas well and thus would still rely on chopping to tighten the clipping. Another side effect of the overestimating is that the curves become much thinner and "ropey". If all that was ever rendered were "not too thin" curves and ellipses then 2nd order may have an advantage since only one geometry would need to be rendered. However no benches were run comparing chopped first order and non chopped 2nd order.

Definition at line 66 of file GrBezierEffect.h.

Constructor & Destructor Documentation

◆ ~GrConicEffect()

GrConicEffect::~GrConicEffect ( )
overridedefault

Member Function Documentation

◆ addToKey()

void GrConicEffect::addToKey ( const GrShaderCaps ,
skgpu::KeyBuilder  
) const
overridevirtual

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 162 of file GrBezierEffect.cpp.

162 {
163 uint32_t key = 0;
164 key |= fCoverageScale == 0xff ? 0x8 : 0x0;
165 key |= fUsesLocalCoords ? 0x10 : 0x0;
167 key,
168 fViewMatrix,
169 fUsesLocalCoords ? fLocalMatrix : SkMatrix::I());
170 b->add32(key);
171}
static uint32_t AddMatrixKeys(const GrShaderCaps &shaderCaps, uint32_t flags, const SkMatrix &viewMatrix, const SkMatrix &localMatrix)
static const SkMatrix & I()
Definition: SkMatrix.cpp:1544
static bool b

◆ Make()

static GrGeometryProcessor * GrConicEffect::Make ( SkArenaAlloc arena,
const SkPMColor4f color,
const SkMatrix viewMatrix,
const GrCaps caps,
const SkMatrix localMatrix,
bool  usesLocalCoords,
uint8_t  coverage = 0xff 
)
inlinestatic

Definition at line 68 of file GrBezierEffect.h.

74 {
76 return nullptr;
77 }
78
79 return arena->make([&](void* ptr) {
80 return new (ptr) GrConicEffect(color, viewMatrix, coverage, localMatrix,
81 usesLocalCoords);
82 });
83 }
const GrShaderCaps * shaderCaps() const
Definition: GrCaps.h:63
auto make(Ctor &&ctor) -> decltype(ctor(nullptr))
Definition: SkArenaAlloc.h:120
DlColor color
bool fShaderDerivativeSupport
Definition: SkSLUtil.h:85

◆ makeProgramImpl()

std::unique_ptr< GrGeometryProcessor::ProgramImpl > GrConicEffect::makeProgramImpl ( const GrShaderCaps ) const
overridevirtual

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

Implements GrGeometryProcessor.

Definition at line 173 of file GrBezierEffect.cpp.

174 {
175 return std::make_unique<Impl>();
176}

◆ name()

const char * GrConicEffect::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 87 of file GrBezierEffect.h.

87{ return "Conic"; }

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