Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
Public Types | Public Member Functions | Static Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
GrSimpleMeshDrawOpHelper Class Reference

#include <GrSimpleMeshDrawOpHelper.h>

Inheritance diagram for GrSimpleMeshDrawOpHelper:
GrSimpleMeshDrawOpHelperWithStencil

Public Types

enum class  InputFlags : uint8_t { kNone = 0 , kSnapVerticesToPixelCenters = (uint8_t)GrPipeline::InputFlags::kSnapVerticesToPixelCenters , kConservativeRaster = (uint8_t)GrPipeline::InputFlags::kConservativeRaster }
 

Public Member Functions

 GR_DECL_BITFIELD_CLASS_OPS_FRIENDS (InputFlags)
 
 GrSimpleMeshDrawOpHelper (GrProcessorSet *, GrAAType, InputFlags=InputFlags::kNone)
 
 ~GrSimpleMeshDrawOpHelper ()
 
 GrSimpleMeshDrawOpHelper ()=delete
 
 GrSimpleMeshDrawOpHelper (const GrSimpleMeshDrawOpHelper &)=delete
 
GrSimpleMeshDrawOpHelperoperator= (const GrSimpleMeshDrawOpHelper &)=delete
 
GrDrawOp::FixedFunctionFlags fixedFunctionFlags () const
 
bool isCompatible (const GrSimpleMeshDrawOpHelper &that, const GrCaps &, const SkRect &thisBounds, const SkRect &thatBounds, bool ignoreAAType=false) const
 
GrProcessorSet::Analysis finalizeProcessors (const GrCaps &caps, const GrAppliedClip *clip, GrClampType clampType, GrProcessorAnalysisCoverage geometryCoverage, GrProcessorAnalysisColor *geometryColor)
 
GrProcessorSet::Analysis finalizeProcessors (const GrCaps &, const GrAppliedClip *, GrClampType, GrProcessorAnalysisCoverage geometryCoverage, SkPMColor4f *geometryColor, bool *wideColor)
 
bool isTrivial () const
 
bool usesLocalCoords () const
 
bool compatibleWithCoverageAsAlpha () const
 
void visitProxies (const GrVisitProxyFunc &func) const
 
GrAAType aaType () const
 
void setAAType (GrAAType aaType)
 
const GrPipelinecreatePipeline (GrOpFlushState *flushState)
 
const GrPipelinecreatePipeline (const GrCaps *, SkArenaAlloc *, skgpu::Swizzle writeViewSwizzle, GrAppliedClip &&, const GrDstProxyView &)
 
GrProgramInfocreateProgramInfo (const GrCaps *, SkArenaAlloc *, const GrSurfaceProxyView &writeView, bool usesMSAASurface, GrAppliedClip &&, const GrDstProxyView &, GrGeometryProcessor *, GrPrimitiveType, GrXferBarrierFlags renderPassXferBarriers, GrLoadOp colorLoadOp)
 
GrProcessorSet detachProcessorSet ()
 
GrPipeline::InputFlags pipelineFlags () const
 
template<typename Op , typename... OpArgs>
GrOp::Owner FactoryHelper (GrRecordingContext *context, GrPaint &&paint, OpArgs &&... opArgs)
 

Static Public Member Functions

template<typename Op , typename... OpArgs>
static GrOp::Owner FactoryHelper (GrRecordingContext *, GrPaint &&, OpArgs &&...)
 
static const GrPipelineCreatePipeline (const GrCaps *, SkArenaAlloc *, skgpu::Swizzle writeViewSwizzle, GrAppliedClip &&, const GrDstProxyView &, GrProcessorSet &&, GrPipeline::InputFlags pipelineFlags)
 
static const GrPipelineCreatePipeline (GrOpFlushState *, GrProcessorSet &&, GrPipeline::InputFlags pipelineFlags)
 
static GrProgramInfoCreateProgramInfo (const GrCaps *, SkArenaAlloc *, const GrPipeline *, const GrSurfaceProxyView &writeView, bool usesMSAASurface, GrGeometryProcessor *, GrPrimitiveType, GrXferBarrierFlags renderPassXferBarriers, GrLoadOp colorLoadOp, const GrUserStencilSettings *=&GrUserStencilSettings::kUnused)
 
static GrProgramInfoCreateProgramInfo (const GrCaps *, SkArenaAlloc *, const GrSurfaceProxyView &writeView, bool usesMSAASurface, GrAppliedClip &&, const GrDstProxyView &, GrGeometryProcessor *, GrProcessorSet &&, GrPrimitiveType, GrXferBarrierFlags renderPassXferBarriers, GrLoadOp colorLoadOp, GrPipeline::InputFlags pipelineFlags=GrPipeline::InputFlags::kNone, const GrUserStencilSettings *=&GrUserStencilSettings::kUnused)
 

Protected Member Functions

GrProcessorSet::Analysis finalizeProcessors (const GrCaps &caps, const GrAppliedClip *, const GrUserStencilSettings *, GrClampType, GrProcessorAnalysisCoverage geometryCoverage, GrProcessorAnalysisColor *geometryColor)
 

Protected Attributes

GrProcessorSetfProcessors
 
GrPipeline::InputFlags fPipelineFlags
 
unsigned fAAType: 2
 
unsigned fUsesLocalCoords: 1
 
unsigned fCompatibleWithCoverageAsAlpha: 1
 

Detailed Description

This class can be used to help implement simple mesh draw ops. It reduces the amount of boilerplate code to type and also provides a mechanism for optionally allocating space for a GrProcessorSet based on a GrPaint. It is intended to be used by ops that construct a single GrPipeline for a uniform primitive color and a GrPaint.

Definition at line 28 of file GrSimpleMeshDrawOpHelper.h.

Member Enumeration Documentation

◆ InputFlags

enum class GrSimpleMeshDrawOpHelper::InputFlags : uint8_t
strong

Constructor & Destructor Documentation

◆ GrSimpleMeshDrawOpHelper() [1/3]

GrSimpleMeshDrawOpHelper::GrSimpleMeshDrawOpHelper ( GrProcessorSet processorSet,
GrAAType  aaType,
InputFlags  inputFlags = InputFlags::kNone 
)

Definition at line 17 of file GrSimpleMeshDrawOpHelper.cpp.

20 : fProcessors(processorSet)
22 , fAAType((int)aaType)
23 , fUsesLocalCoords(false)
25 SkDEBUGCODE(fDidAnalysis = false);
26 SkDEBUGCODE(fMadePipeline = false);
27}
#define SkDEBUGCODE(...)
Definition SkDebug.h:23
GrPipeline::InputFlags fPipelineFlags

◆ ~GrSimpleMeshDrawOpHelper()

GrSimpleMeshDrawOpHelper::~GrSimpleMeshDrawOpHelper ( )

Definition at line 29 of file GrSimpleMeshDrawOpHelper.cpp.

29 {
30 if (fProcessors) {
32 }
33}

◆ GrSimpleMeshDrawOpHelper() [2/3]

GrSimpleMeshDrawOpHelper::GrSimpleMeshDrawOpHelper ( )
delete

◆ GrSimpleMeshDrawOpHelper() [3/3]

GrSimpleMeshDrawOpHelper::GrSimpleMeshDrawOpHelper ( const GrSimpleMeshDrawOpHelper )
delete

Member Function Documentation

◆ aaType()

GrAAType GrSimpleMeshDrawOpHelper::aaType ( ) const
inline

Definition at line 107 of file GrSimpleMeshDrawOpHelper.h.

107{ return static_cast<GrAAType>(fAAType); }
GrAAType

◆ compatibleWithCoverageAsAlpha()

bool GrSimpleMeshDrawOpHelper::compatibleWithCoverageAsAlpha ( ) const
inline

Definition at line 96 of file GrSimpleMeshDrawOpHelper.h.

◆ createPipeline() [1/2]

const GrPipeline * GrSimpleMeshDrawOpHelper::createPipeline ( const GrCaps caps,
SkArenaAlloc arena,
skgpu::Swizzle  writeViewSwizzle,
GrAppliedClip &&  appliedClip,
const GrDstProxyView dstProxyView 
)

Definition at line 148 of file GrSimpleMeshDrawOpHelper.cpp.

152 {
154 arena,
155 writeViewSwizzle,
156 std::move(appliedClip),
157 dstProxyView,
158 this->detachProcessorSet(),
159 this->pipelineFlags());
160}
GrPipeline::InputFlags pipelineFlags() const
static const GrPipeline * CreatePipeline(const GrCaps *, SkArenaAlloc *, skgpu::Swizzle writeViewSwizzle, GrAppliedClip &&, const GrDstProxyView &, GrProcessorSet &&, GrPipeline::InputFlags pipelineFlags)

◆ CreatePipeline() [1/2]

const GrPipeline * GrSimpleMeshDrawOpHelper::CreatePipeline ( const GrCaps caps,
SkArenaAlloc arena,
skgpu::Swizzle  writeViewSwizzle,
GrAppliedClip &&  appliedClip,
const GrDstProxyView dstProxyView,
GrProcessorSet &&  processorSet,
GrPipeline::InputFlags  pipelineFlags 
)
static

Definition at line 107 of file GrSimpleMeshDrawOpHelper.cpp.

113 {
114 GrPipeline::InitArgs pipelineArgs;
115
116 pipelineArgs.fInputFlags = pipelineFlags;
117 pipelineArgs.fCaps = caps;
118 pipelineArgs.fDstProxyView = dstProxyView;
119 pipelineArgs.fWriteSwizzle = writeViewSwizzle;
120
121 return arena->make<GrPipeline>(pipelineArgs,
122 std::move(processorSet),
123 std::move(appliedClip));
124}
auto make(Ctor &&ctor) -> decltype(ctor(nullptr))
skgpu::Swizzle fWriteSwizzle
Definition GrPipeline.h:66
InputFlags fInputFlags
Definition GrPipeline.h:63
const GrCaps * fCaps
Definition GrPipeline.h:64
GrDstProxyView fDstProxyView
Definition GrPipeline.h:65

◆ CreatePipeline() [2/2]

const GrPipeline * GrSimpleMeshDrawOpHelper::CreatePipeline ( GrOpFlushState flushState,
GrProcessorSet &&  processorSet,
GrPipeline::InputFlags  pipelineFlags 
)
static

Definition at line 126 of file GrSimpleMeshDrawOpHelper.cpp.

128 {
129 return CreatePipeline(&flushState->caps(),
130 flushState->allocator(),
131 flushState->writeView().swizzle(),
132 flushState->detachAppliedClip(),
133 flushState->dstProxyView(),
134 std::move(processorSet),
136}
const GrDstProxyView & dstProxyView() const final
SkArenaAlloc * allocator() override
const GrSurfaceProxyView & writeView() const final
GrAppliedClip detachAppliedClip() final
const GrCaps & caps() const final
skgpu::Swizzle swizzle() const

◆ createPipeline() [2/2]

const GrPipeline * GrSimpleMeshDrawOpHelper::createPipeline ( GrOpFlushState flushState)

Definition at line 138 of file GrSimpleMeshDrawOpHelper.cpp.

138 {
139 return CreatePipeline(&flushState->caps(),
140 flushState->allocator(),
141 flushState->writeView().swizzle(),
142 flushState->detachAppliedClip(),
143 flushState->dstProxyView(),
144 this->detachProcessorSet(),
145 this->pipelineFlags());
146}

◆ CreateProgramInfo() [1/2]

GrProgramInfo * GrSimpleMeshDrawOpHelper::CreateProgramInfo ( const GrCaps caps,
SkArenaAlloc arena,
const GrPipeline pipeline,
const GrSurfaceProxyView writeView,
bool  usesMSAASurface,
GrGeometryProcessor geometryProcessor,
GrPrimitiveType  primitiveType,
GrXferBarrierFlags  renderPassXferBarriers,
GrLoadOp  colorLoadOp,
const GrUserStencilSettings stencilSettings = &GrUserStencilSettings::kUnused 
)
static

Definition at line 188 of file GrSimpleMeshDrawOpHelper.cpp.

197 {
198 auto tmp = arena->make<GrProgramInfo>(*caps,
199 writeView,
200 usesMSAASurface,
201 pipeline,
202 stencilSettings,
203 geometryProcessor,
204 primitiveType,
205 xferBarrierFlags,
206 colorLoadOp);
207 return tmp;
208}

◆ createProgramInfo()

GrProgramInfo * GrSimpleMeshDrawOpHelper::createProgramInfo ( const GrCaps caps,
SkArenaAlloc arena,
const GrSurfaceProxyView writeView,
bool  usesMSAASurface,
GrAppliedClip &&  appliedClip,
const GrDstProxyView dstProxyView,
GrGeometryProcessor gp,
GrPrimitiveType  primType,
GrXferBarrierFlags  renderPassXferBarriers,
GrLoadOp  colorLoadOp 
)

Definition at line 210 of file GrSimpleMeshDrawOpHelper.cpp.

220 {
221 return CreateProgramInfo(caps,
222 arena,
223 writeView,
224 usesMSAASurface,
225 std::move(appliedClip),
226 dstProxyView,
227 gp,
228 this->detachProcessorSet(),
229 primType,
230 renderPassXferBarriers,
231 colorLoadOp,
232 this->pipelineFlags());
233}
static GrProgramInfo * CreateProgramInfo(const GrCaps *, SkArenaAlloc *, const GrPipeline *, const GrSurfaceProxyView &writeView, bool usesMSAASurface, GrGeometryProcessor *, GrPrimitiveType, GrXferBarrierFlags renderPassXferBarriers, GrLoadOp colorLoadOp, const GrUserStencilSettings *=&GrUserStencilSettings::kUnused)

◆ CreateProgramInfo() [2/2]

GrProgramInfo * GrSimpleMeshDrawOpHelper::CreateProgramInfo ( const GrCaps caps,
SkArenaAlloc arena,
const GrSurfaceProxyView writeView,
bool  usesMSAASurface,
GrAppliedClip &&  appliedClip,
const GrDstProxyView dstProxyView,
GrGeometryProcessor geometryProcessor,
GrProcessorSet &&  processorSet,
GrPrimitiveType  primitiveType,
GrXferBarrierFlags  renderPassXferBarriers,
GrLoadOp  colorLoadOp,
GrPipeline::InputFlags  pipelineFlags = GrPipeline::InputFlags::kNone,
const GrUserStencilSettings stencilSettings = &GrUserStencilSettings::kUnused 
)
static

Definition at line 162 of file GrSimpleMeshDrawOpHelper.cpp.

175 {
176 auto pipeline = CreatePipeline(caps,
177 arena,
178 writeView.swizzle(),
179 std::move(appliedClip),
180 dstProxyView,
181 std::move(processorSet),
183
184 return CreateProgramInfo(caps, arena, pipeline, writeView, usesMSAASurface, geometryProcessor,
185 primitiveType, renderPassXferBarriers, colorLoadOp, stencilSettings);
186}

◆ detachProcessorSet()

GrProcessorSet GrSimpleMeshDrawOpHelper::detachProcessorSet ( )
inline

Definition at line 175 of file GrSimpleMeshDrawOpHelper.h.

175 {
176 return fProcessors ? std::move(*fProcessors) : GrProcessorSet::MakeEmptySet();
177 }

◆ FactoryHelper() [1/2]

template<typename Op , typename... OpArgs>
static GrOp::Owner GrSimpleMeshDrawOpHelper::FactoryHelper ( GrRecordingContext ,
GrPaint &&  ,
OpArgs &&  ... 
)
static

This can be used by a Op class to perform allocation and initialization such that a GrProcessorSet (if required) is allocated as part of the the same allocation that as the Op instance. It requires that Op implements a constructor of the form: Op(ProcessorSet*, GrColor, OpArgs...).

◆ FactoryHelper() [2/2]

template<typename Op , typename... OpArgs>
GrOp::Owner GrSimpleMeshDrawOpHelper::FactoryHelper ( GrRecordingContext context,
GrPaint &&  paint,
OpArgs &&...  opArgs 
)

Definition at line 207 of file GrSimpleMeshDrawOpHelper.h.

209 {
210 auto color = paint.getColor4f();
211 if (paint.isTrivial()) {
212 return GrOp::Make<Op>(context, nullptr, color, std::forward<OpArgs>(opArgs)...);
213 } else {
214 return GrOp::MakeWithProcessorSet<Op>(
215 context, color, std::move(paint), std::forward<OpArgs>(opArgs)...);
216 }
217}
SkColor4f color
const Paint & paint

◆ finalizeProcessors() [1/3]

GrProcessorSet::Analysis GrSimpleMeshDrawOpHelper::finalizeProcessors ( const GrCaps caps,
const GrAppliedClip clip,
GrClampType  clampType,
GrProcessorAnalysisCoverage  geometryCoverage,
SkPMColor4f geometryColor,
bool *  wideColor 
)

Version of above that can be used by ops that have a constant color geometry processor output. The op passes this color as 'geometryColor' and after return if 'geometryColor' has changed the op must override its geometry processor color output with the new color.

Definition at line 68 of file GrSimpleMeshDrawOpHelper.cpp.

70 {
71 GrProcessorAnalysisColor color = *geometryColor;
72 auto result = this->finalizeProcessors(caps, clip, clampType, geometryCoverage, &color);
73 color.isConstant(geometryColor);
74 if (wideColor) {
75 *wideColor = !geometryColor->fitsInBytes();
76 }
77 return result;
78}
static SkPath clip(const SkPath &path, const SkHalfPlane &plane)
Definition SkPath.cpp:3824
GrProcessorSet::Analysis finalizeProcessors(const GrCaps &caps, const GrAppliedClip *clip, GrClampType clampType, GrProcessorAnalysisCoverage geometryCoverage, GrProcessorAnalysisColor *geometryColor)
GAsyncResult * result
bool fitsInBytes() const
Definition SkColor.h:350

◆ finalizeProcessors() [2/3]

GrProcessorSet::Analysis GrSimpleMeshDrawOpHelper::finalizeProcessors ( const GrCaps caps,
const GrAppliedClip clip,
const GrUserStencilSettings userStencil,
GrClampType  clampType,
GrProcessorAnalysisCoverage  geometryCoverage,
GrProcessorAnalysisColor geometryColor 
)
protected

Definition at line 80 of file GrSimpleMeshDrawOpHelper.cpp.

83 {
84 SkDEBUGCODE(fDidAnalysis = true);
86 if (fProcessors) {
87 GrProcessorAnalysisCoverage coverage = geometryCoverage;
88 if (GrProcessorAnalysisCoverage::kNone == coverage) {
89 coverage = (clip && clip->hasCoverageFragmentProcessor())
92 }
93 SkPMColor4f overrideColor;
94 analysis = fProcessors->finalize(*geometryColor, coverage, clip, userStencil, caps,
95 clampType, &overrideColor);
96 if (analysis.inputColorIsOverridden()) {
97 *geometryColor = overrideColor;
98 }
99 } else {
101 }
104 return analysis;
105}
GrProcessorAnalysisCoverage
bool inputColorIsOverridden() const
bool isCompatibleWithCoverageAsAlpha() const
static constexpr Analysis EmptySetAnalysis()
Analysis finalize(const GrProcessorAnalysisColor &, const GrProcessorAnalysisCoverage, const GrAppliedClip *, const GrUserStencilSettings *, const GrCaps &, GrClampType, SkPMColor4f *inputColorOverride)

◆ finalizeProcessors() [3/3]

GrProcessorSet::Analysis GrSimpleMeshDrawOpHelper::finalizeProcessors ( const GrCaps caps,
const GrAppliedClip clip,
GrClampType  clampType,
GrProcessorAnalysisCoverage  geometryCoverage,
GrProcessorAnalysisColor geometryColor 
)
inline

Finalizes the processor set and determines whether the destination must be provided to the fragment shader as a texture for blending.

Parameters
geometryCoverageDescribes the coverage output of the op's geometry processor
geometryColorAn in/out param. As input this informs processor analysis about the color the op expects to output from its geometry processor. As output this may be set to a known color in which case the op must output this color from its geometry processor instead.

Definition at line 70 of file GrSimpleMeshDrawOpHelper.h.

73 {
74 return this->finalizeProcessors(caps, clip, &GrUserStencilSettings::kUnused, clampType,
75 geometryCoverage, geometryColor);
76 }
static const GrUserStencilSettings & kUnused

◆ fixedFunctionFlags()

GrDrawOp::FixedFunctionFlags GrSimpleMeshDrawOpHelper::fixedFunctionFlags ( ) const

Definition at line 35 of file GrSimpleMeshDrawOpHelper.cpp.

◆ GR_DECL_BITFIELD_CLASS_OPS_FRIENDS()

GrSimpleMeshDrawOpHelper::GR_DECL_BITFIELD_CLASS_OPS_FRIENDS ( InputFlags  )

◆ isCompatible()

bool GrSimpleMeshDrawOpHelper::isCompatible ( const GrSimpleMeshDrawOpHelper that,
const GrCaps caps,
const SkRect thisBounds,
const SkRect thatBounds,
bool  ignoreAAType = false 
) const

Definition at line 40 of file GrSimpleMeshDrawOpHelper.cpp.

42 {
44 return false;
45 }
46 if (fProcessors) {
47 if (*fProcessors != *that.fProcessors) {
48 return false;
49 }
50 }
51
52#ifdef SK_DEBUG
53 if (ignoreAAType) {
54 // If we're ignoring AA it should be bc we already know they are the same or that
55 // the are different but are compatible (i.e., one is AA and the other is None)
56 SkASSERT(fAAType == that.fAAType ||
57 GrMeshDrawOp::CanUpgradeAAOnMerge(this->aaType(), that.aaType()));
58 }
59#endif
60
61 bool result = fPipelineFlags == that.fPipelineFlags &&
62 (ignoreAAType || fAAType == that.fAAType);
65 return result;
66}
#define SkASSERT(cond)
Definition SkAssert.h:116
static constexpr bool SkToBool(const T &x)
Definition SkTo.h:35
static bool CanUpgradeAAOnMerge(GrAAType aa1, GrAAType aa2)

◆ isTrivial()

bool GrSimpleMeshDrawOpHelper::isTrivial ( ) const
inline

Definition at line 87 of file GrSimpleMeshDrawOpHelper.h.

87 {
88 return fProcessors == nullptr;
89 }

◆ operator=()

GrSimpleMeshDrawOpHelper & GrSimpleMeshDrawOpHelper::operator= ( const GrSimpleMeshDrawOpHelper )
delete

◆ pipelineFlags()

GrPipeline::InputFlags GrSimpleMeshDrawOpHelper::pipelineFlags ( ) const
inline

Definition at line 179 of file GrSimpleMeshDrawOpHelper.h.

179{ return fPipelineFlags; }

◆ setAAType()

void GrSimpleMeshDrawOpHelper::setAAType ( GrAAType  aaType)
inline

Definition at line 109 of file GrSimpleMeshDrawOpHelper.h.

109 {
110 fAAType = static_cast<unsigned>(aaType);
111 }

◆ usesLocalCoords()

bool GrSimpleMeshDrawOpHelper::usesLocalCoords ( ) const
inline

Definition at line 91 of file GrSimpleMeshDrawOpHelper.h.

91 {
92 SkASSERT(fDidAnalysis);
93 return fUsesLocalCoords;
94 }

◆ visitProxies()

void GrSimpleMeshDrawOpHelper::visitProxies ( const GrVisitProxyFunc func) const
inline

Definition at line 98 of file GrSimpleMeshDrawOpHelper.h.

98 {
99 if (fProcessors) {
101 }
102 }
void visitProxies(const GrVisitProxyFunc &) const

Member Data Documentation

◆ fAAType

unsigned GrSimpleMeshDrawOpHelper::fAAType
protected

Definition at line 189 of file GrSimpleMeshDrawOpHelper.h.

◆ fCompatibleWithCoverageAsAlpha

unsigned GrSimpleMeshDrawOpHelper::fCompatibleWithCoverageAsAlpha
protected

Definition at line 191 of file GrSimpleMeshDrawOpHelper.h.

◆ fPipelineFlags

GrPipeline::InputFlags GrSimpleMeshDrawOpHelper::fPipelineFlags
protected

Definition at line 188 of file GrSimpleMeshDrawOpHelper.h.

◆ fProcessors

GrProcessorSet* GrSimpleMeshDrawOpHelper::fProcessors
protected

Definition at line 187 of file GrSimpleMeshDrawOpHelper.h.

◆ fUsesLocalCoords

unsigned GrSimpleMeshDrawOpHelper::fUsesLocalCoords
protected

Definition at line 190 of file GrSimpleMeshDrawOpHelper.h.


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