Flutter Engine
The Flutter Engine
|
#include <GrBezierEffect.h>
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< ProgramImpl > | makeProgramImpl (const GrShaderCaps &) const override |
Public Member Functions inherited from GrGeometryProcessor | |
GrGeometryProcessor (ClassID) | |
int | numTextureSamplers () const |
const TextureSampler & | textureSampler (int index) const |
int | numVertexAttributes () const |
const AttributeSet & | vertexAttributes () const |
int | numInstanceAttributes () const |
const AttributeSet & | instanceAttributes () 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< ProgramImpl > | makeProgramImpl (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 T & | cast () const |
ClassID | classID () const |
Static Public Member Functions | |
static GrGeometryProcessor * | Make (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) |
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.
|
overridedefault |
|
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.
|
inlinestatic |
Definition at line 68 of file GrBezierEffect.h.
|
overridevirtual |
Returns a new instance of the appropriate implementation class for the given GrGeometryProcessor.
Implements GrGeometryProcessor.
Definition at line 173 of file GrBezierEffect.cpp.
|
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.