Flutter Engine
The Flutter Engine
Public Member Functions | Static Public Member Functions | Static Public Attributes | List of all members
GrConvexPolyEffect Class Reference

#include <GrConvexPolyEffect.h>

Inheritance diagram for GrConvexPolyEffect:
GrFragmentProcessor GrProcessor

Public Member Functions

 ~GrConvexPolyEffect () override
 
const char * name () const override
 
std::unique_ptr< GrFragmentProcessorclone () const override
 
- Public Member Functions inherited from GrFragmentProcessor
virtual std::unique_ptr< GrFragmentProcessorclone () const =0
 
const GrFragmentProcessorparent () const
 
std::unique_ptr< ProgramImplmakeProgramImpl () const
 
void addToKey (const GrShaderCaps &caps, skgpu::KeyBuilder *b) const
 
int numChildProcessors () const
 
int numNonNullChildProcessors () const
 
GrFragmentProcessorchildProcessor (int index)
 
const GrFragmentProcessorchildProcessor (int index) const
 
 SkDEBUGCODE (bool isInstantiated() const ;) bool willReadDstColor() const
 
bool isBlendFunction () const
 
bool usesSampleCoordsDirectly () const
 
bool usesSampleCoords () const
 
const SkSL::SampleUsagesampleUsage () const
 
bool compatibleWithCoverageAsAlpha () const
 
bool preservesOpaqueInput () const
 
bool hasConstantOutputForConstantInput (SkPMColor4f inputColor, SkPMColor4f *outputColor) const
 
bool hasConstantOutputForConstantInput () const
 
void clearConstantOutputForConstantInputFlag ()
 
bool isEqual (const GrFragmentProcessor &that) const
 
void visitProxies (const GrVisitProxyFunc &) const
 
void visitTextureEffects (const std::function< void(const GrTextureEffect &)> &) const
 
void visitWithImpls (const std::function< void(const GrFragmentProcessor &, ProgramImpl &)> &, ProgramImpl &) const
 
GrTextureEffectasTextureEffect ()
 
const GrTextureEffectasTextureEffect () const
 
- 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 GrFPResult Make (std::unique_ptr< GrFragmentProcessor > inputFP, GrClipEdgeType edgeType, int n, const float edges[])
 
static GrFPResult Make (std::unique_ptr< GrFragmentProcessor >, GrClipEdgeType, const SkPath &)
 
- Static Public Member Functions inherited from GrFragmentProcessor
static std::unique_ptr< GrFragmentProcessorMakeColor (SkPMColor4f color)
 
static std::unique_ptr< GrFragmentProcessorMulInputByChildAlpha (std::unique_ptr< GrFragmentProcessor > child)
 
static std::unique_ptr< GrFragmentProcessorApplyPaintAlpha (std::unique_ptr< GrFragmentProcessor > child)
 
static std::unique_ptr< GrFragmentProcessorModulateRGBA (std::unique_ptr< GrFragmentProcessor > child, const SkPMColor4f &color)
 
static std::unique_ptr< GrFragmentProcessorOverrideInput (std::unique_ptr< GrFragmentProcessor >, const SkPMColor4f &)
 
static std::unique_ptr< GrFragmentProcessorDisableCoverageAsAlpha (std::unique_ptr< GrFragmentProcessor >)
 
static std::unique_ptr< GrFragmentProcessorDestColor ()
 
static std::unique_ptr< GrFragmentProcessorSwizzleOutput (std::unique_ptr< GrFragmentProcessor >, const skgpu::Swizzle &)
 
static std::unique_ptr< GrFragmentProcessorClampOutput (std::unique_ptr< GrFragmentProcessor >)
 
static std::unique_ptr< GrFragmentProcessorCompose (std::unique_ptr< GrFragmentProcessor > f, std::unique_ptr< GrFragmentProcessor > g)
 
static std::unique_ptr< GrFragmentProcessorColorMatrix (std::unique_ptr< GrFragmentProcessor > child, const float matrix[20], bool unpremulInput, bool clampRGBOutput, bool premulOutput)
 
static std::unique_ptr< GrFragmentProcessorSurfaceColor ()
 
static std::unique_ptr< GrFragmentProcessorDeviceSpace (std::unique_ptr< GrFragmentProcessor >)
 
static std::unique_ptr< GrFragmentProcessorRect (std::unique_ptr< GrFragmentProcessor >, GrClipEdgeType, SkRect)
 
static GrFPResult Circle (std::unique_ptr< GrFragmentProcessor >, GrClipEdgeType, SkPoint center, float radius)
 
static GrFPResult Ellipse (std::unique_ptr< GrFragmentProcessor >, GrClipEdgeType, SkPoint center, SkPoint radii, const GrShaderCaps &)
 
static std::unique_ptr< GrFragmentProcessorHighPrecision (std::unique_ptr< GrFragmentProcessor >)
 

Static Public Attributes

static constexpr int kMaxEdges = 8
 

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 Types inherited from GrFragmentProcessor
enum  OptimizationFlags : uint32_t {
  kNone_OptimizationFlags , kCompatibleWithCoverageAsAlpha_OptimizationFlag = 0x1 , kPreservesOpaqueInput_OptimizationFlag = 0x2 , kConstantOutputForConstantInput_OptimizationFlag = 0x4 ,
  kAll_OptimizationFlags
}
 
- Protected Member Functions inherited from GrFragmentProcessor
 GrFragmentProcessor (ClassID classID, OptimizationFlags optimizationFlags)
 
 GrFragmentProcessor (const GrFragmentProcessor &src)
 
OptimizationFlags optimizationFlags () const
 
void registerChild (std::unique_ptr< GrFragmentProcessor > child, SkSL::SampleUsage sampleUsage=SkSL::SampleUsage::PassThrough())
 
void cloneAndRegisterAllChildProcessors (const GrFragmentProcessor &src)
 
void setUsesSampleCoordsDirectly ()
 
void setWillReadDstColor ()
 
void setIsBlendFunction ()
 
void mergeOptimizationFlags (OptimizationFlags flags)
 
- Protected Member Functions inherited from GrProcessor
 GrProcessor (ClassID classID)
 
 GrProcessor (const GrProcessor &)=delete
 
GrProcessoroperator= (const GrProcessor &)=delete
 
- Static Protected Member Functions inherited from GrFragmentProcessor
static OptimizationFlags ModulateForSamplerOptFlags (SkAlphaType alphaType, bool samplingDecal)
 
static OptimizationFlags ModulateForClampedSamplerOptFlags (SkAlphaType alphaType)
 
static OptimizationFlags ProcessorOptimizationFlags (const GrFragmentProcessor *fp)
 
static SkPMColor4f ConstantOutputForConstantInput (const GrFragmentProcessor *fp, const SkPMColor4f &input)
 
- Protected Attributes inherited from GrProcessor
const ClassID fClassID
 

Detailed Description

An effect that renders a convex polygon. It is intended to be used as a coverage effect. Bounding geometry is rendered and the effect computes coverage based on the fragment's position relative to the polygon.

Definition at line 30 of file GrConvexPolyEffect.h.

Constructor & Destructor Documentation

◆ ~GrConvexPolyEffect()

GrConvexPolyEffect::~GrConvexPolyEffect ( )
override

Definition at line 104 of file GrConvexPolyEffect.cpp.

104{}

Member Function Documentation

◆ clone()

std::unique_ptr< GrFragmentProcessor > GrConvexPolyEffect::clone ( ) const
overridevirtual

Makes a copy of this fragment processor that draws equivalently to the original. If the processor has child processors they are cloned as well.

Implements GrFragmentProcessor.

Definition at line 193 of file GrConvexPolyEffect.cpp.

193 {
194 return std::unique_ptr<GrFragmentProcessor>(new GrConvexPolyEffect(*this));
195}

◆ Make() [1/2]

static GrFPResult GrConvexPolyEffect::Make ( std::unique_ptr< GrFragmentProcessor inputFP,
GrClipEdgeType  edgeType,
int  n,
const float  edges[] 
)
inlinestatic

edges is a set of n edge equations where n is limited to kMaxEdges. It contains 3*n values. The edges should form a convex polygon. The positive half-plane is considered to be the inside. The equations should be normalized such that the first two coefficients are a unit 2d vector.

Currently the edges are specified in device space. In the future we may prefer to specify them in src space. There are a number of ways this could be accomplished but we'd probably have to modify the effect/shaderbuilder interface to make it possible (e.g. give access to the view matrix or untransformed positions in the fragment shader).

Definition at line 45 of file GrConvexPolyEffect.h.

48 {
49 if (n <= 0 || n > kMaxEdges) {
50 return GrFPFailure(std::move(inputFP));
51 }
52
53 return GrFPSuccess(std::unique_ptr<GrFragmentProcessor>(
54 new GrConvexPolyEffect(std::move(inputFP), edgeType, n, edges)));
55 }
static GrFPResult GrFPSuccess(std::unique_ptr< GrFragmentProcessor > fp)
static GrFPResult GrFPFailure(std::unique_ptr< GrFragmentProcessor > fp)
static constexpr int kMaxEdges

◆ Make() [2/2]

GrFPResult GrConvexPolyEffect::Make ( std::unique_ptr< GrFragmentProcessor inputFP,
GrClipEdgeType  type,
const SkPath path 
)
static

Creates an effect that clips against the path. If the path is not a convex polygon, is inverse filled, or has too many edges, creation will fail.

Definition at line 35 of file GrConvexPolyEffect.cpp.

36 {
37 if (path.getSegmentMasks() != SkPath::kLine_SegmentMask || !path.isConvex()) {
38 return GrFPFailure(std::move(inputFP));
39 }
40
42 // The only way this should fail is if the clip is effectively a infinitely thin line. In that
43 // case nothing is inside the clip. It'd be nice to detect this at a higher level and either
44 // skip the draw or omit the clip element.
47 return GrFPSuccess(
49 }
50 // This could use ConstColor instead of ModulateRGBA but it would trigger a debug print
51 // about a coverage processor not being compatible with the alpha-as-coverage optimization.
52 // We don't really care about this unlikely case so we just use ModulateRGBA to suppress
53 // the print.
54 return GrFPSuccess(
56 }
57
58 SkScalar edges[3 * kMaxEdges];
59 SkPoint pts[4];
60 SkPath::Verb verb;
61 SkPath::Iter iter(path, true);
62
63 // SkPath considers itself convex so long as there is a convex contour within it,
64 // regardless of any degenerate contours such as a string of moveTos before it.
65 // Iterate here to consume any degenerate contours and only process the points
66 // on the actual convex contour.
67 int n = 0;
68 while ((verb = iter.next(pts)) != SkPath::kDone_Verb) {
69 switch (verb) {
72 break;
73 case SkPath::kLine_Verb: {
74 if (n >= kMaxEdges) {
75 return GrFPFailure(std::move(inputFP));
76 }
77 if (pts[0] != pts[1]) {
78 SkVector v = pts[1] - pts[0];
79 v.normalize();
81 edges[3 * n] = v.fY;
82 edges[3 * n + 1] = -v.fX;
83 } else {
84 edges[3 * n] = -v.fY;
85 edges[3 * n + 1] = v.fX;
86 }
87 edges[3 * n + 2] = -(edges[3 * n] * pts[1].fX + edges[3 * n + 1] * pts[1].fY);
88 ++n;
89 }
90 break;
91 }
92 default:
93 // Non-linear segment so not a polygon.
94 return GrFPFailure(std::move(inputFP));
95 }
96 }
97
98 if (path.isInverseFillType()) {
100 }
101 return GrConvexPolyEffect::Make(std::move(inputFP), type, n, edges);
102}
static constexpr bool GrClipEdgeTypeIsInverseFill(const GrClipEdgeType edgeType)
Definition: GrTypesPriv.h:375
static GrClipEdgeType GrInvertClipEdgeType(const GrClipEdgeType edgeType)
Definition: GrTypesPriv.h:385
constexpr SkPMColor4f SK_PMColor4fWHITE
Definition: SkColorData.h:380
constexpr SkPMColor4f SK_PMColor4fTRANSPARENT
Definition: SkColorData.h:378
SkPathFirstDirection
Definition: SkPathEnums.h:19
GLenum type
static GrFPResult Make(std::unique_ptr< GrFragmentProcessor > inputFP, GrClipEdgeType edgeType, int n, const float edges[])
static std::unique_ptr< GrFragmentProcessor > ModulateRGBA(std::unique_ptr< GrFragmentProcessor > child, const SkPMColor4f &color)
static SkPathFirstDirection ComputeFirstDirection(const SkPath &)
Definition: SkPath.cpp:2627
@ kLine_SegmentMask
Definition: SkPath.h:1445
@ kClose_Verb
Definition: SkPath.h:1471
@ kMove_Verb
Definition: SkPath.h:1466
@ kDone_Verb
Definition: SkPath.h:1472
@ kLine_Verb
Definition: SkPath.h:1467
float SkScalar
Definition: extension.cpp:12
DEF_SWITCHES_START aot vmservice shared library Name of the *so containing AOT compiled Dart assets for launching the service isolate vm snapshot The VM snapshot data that will be memory mapped as read only SnapshotAssetPath must be present isolate snapshot The isolate snapshot data that will be memory mapped as read only SnapshotAssetPath must be present cache dir path
Definition: switches.h:57
DEF_SWITCHES_START aot vmservice shared library Name of the *so containing AOT compiled Dart assets for launching the service isolate vm snapshot The VM snapshot data that will be memory mapped as read only SnapshotAssetPath must be present isolate snapshot The isolate snapshot data that will be memory mapped as read only SnapshotAssetPath must be present cache dir Path to the cache directory This is different from the persistent_cache_path in embedder which is used for Skia shader cache icu native lib Path to the library file that exports the ICU data vm service The hostname IP address on which the Dart VM Service should be served If not defaults to or::depending on whether ipv6 is specified vm service A custom Dart VM Service port The default is to pick a randomly available open port disable vm Disable the Dart VM Service The Dart VM Service is never available in release mode disable vm service Disable mDNS Dart VM Service publication Bind to the IPv6 localhost address for the Dart VM Service Ignored if vm service host is set endless trace Enable an endless trace buffer The default is a ring buffer This is useful when very old events need to viewed For during application launch Memory usage will continue to grow indefinitely however Start app with an specific route defined on the framework flutter assets dir
Definition: switches.h:145
float fX
x-axis value
Definition: SkPoint_impl.h:164
float fY
y-axis value
Definition: SkPoint_impl.h:165
bool normalize()
Definition: SkPoint.cpp:22

◆ name()

const char * GrConvexPolyEffect::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 65 of file GrConvexPolyEffect.h.

65{ return "ConvexPoly"; }

Member Data Documentation

◆ kMaxEdges

constexpr int GrConvexPolyEffect::kMaxEdges = 8
inlinestaticconstexpr

Definition at line 32 of file GrConvexPolyEffect.h.


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