Flutter Engine
The Flutter Engine
Classes | Public Member Functions | List of all members
skgpu::ganesh::DrawAtlasPathOp Class Referencefinal

#include <DrawAtlasPathOp.h>

Inheritance diagram for skgpu::ganesh::DrawAtlasPathOp:
GrDrawOp GrOp SkNoncopyable

Public Member Functions

DEFINE_OP_CLASS_ID DrawAtlasPathOp (SkArenaAlloc *arena, const SkIRect &fillBounds, const SkMatrix &localToDevice, GrPaint &&paint, SkIPoint16 locationInAtlas, const SkIRect &pathDevIBounds, bool transposedInAtlas, GrSurfaceProxyView atlasView, bool isInverseFill)
 
const char * name () const override
 
FixedFunctionFlags fixedFunctionFlags () const override
 
void visitProxies (const GrVisitProxyFunc &func) const override
 
GrProcessorSet::Analysis finalize (const GrCaps &, const GrAppliedClip *, GrClampType) override
 
CombineResult onCombineIfPossible (GrOp *, SkArenaAlloc *, const GrCaps &) override
 
void onPrePrepare (GrRecordingContext *, const GrSurfaceProxyView &writeView, GrAppliedClip *, const GrDstProxyView &, GrXferBarrierFlags, GrLoadOp colorLoadOp) override
 
void onPrepare (GrOpFlushState *) override
 
void onExecute (GrOpFlushState *, const SkRect &chainBounds) override
 
- Public Member Functions inherited from GrDrawOp
 GrDrawOp (uint32_t classID)
 
virtual bool usesMSAA () const
 
virtual ClipResult clipToShape (skgpu::ganesh::SurfaceDrawContext *, SkClipOp, const SkMatrix &, const GrShape &, GrAA)
 
virtual GrProcessorSet::Analysis finalize (const GrCaps &, const GrAppliedClip *, GrClampType)=0
 
virtual bool usesStencil () const
 
- Public Member Functions inherited from GrOp
virtual ~GrOp ()=default
 
virtual const char * name () const =0
 
virtual void visitProxies (const GrVisitProxyFunc &) const
 
CombineResult combineIfPossible (GrOp *that, SkArenaAlloc *alloc, const GrCaps &caps)
 
const SkRectbounds () const
 
void setClippedBounds (const SkRect &clippedBounds)
 
bool hasAABloat () const
 
bool hasZeroArea () const
 
void operator delete (void *p)
 
template<typename T >
const Tcast () const
 
template<typename T >
Tcast ()
 
uint32_t classID () const
 
uint32_t uniqueID () const
 
void prePrepare (GrRecordingContext *context, const GrSurfaceProxyView &dstView, GrAppliedClip *clip, const GrDstProxyView &dstProxyView, GrXferBarrierFlags renderPassXferBarriers, GrLoadOp colorLoadOp)
 
void prepare (GrOpFlushState *state)
 
void execute (GrOpFlushState *state, const SkRect &chainBounds)
 
void chainConcat (GrOp::Owner)
 
bool isChainHead () const
 
bool isChainTail () const
 
GrOpnextInChain () const
 
GrOpprevInChain () const
 
GrOp::Owner cutChain ()
 
void setBounds (const SkRect &newBounds, HasAABloat aabloat, IsHairline zeroArea)
 
void setTransformedBounds (const SkRect &srcBounds, const SkMatrix &m, HasAABloat aabloat, IsHairline zeroArea)
 
void makeFullScreen (GrSurfaceProxy *proxy)
 

Additional Inherited Members

- Public Types inherited from GrDrawOp
enum class  ClipResult { kFail , kClippedGeometrically , kClippedInShader , kClippedOut }
 
- Public Types inherited from GrOp
enum class  CombineResult { kMerged , kMayChain , kCannotCombine }
 
enum class  HasAABloat : bool { kNo = false , kYes = true }
 
enum class  IsHairline : bool { kNo = false , kYes = true }
 
using Owner = std::unique_ptr< GrOp >
 
- Static Public Member Functions inherited from GrOp
template<typename Op , typename... Args>
static Owner Make (GrRecordingContext *context, Args &&... args)
 
template<typename Op , typename... Args>
static Owner MakeWithProcessorSet (GrRecordingContext *context, const SkPMColor4f &color, GrPaint &&paint, Args &&... args)
 
template<typename Op , typename... Args>
static Owner MakeWithExtraMemory (GrRecordingContext *context, size_t extraSize, Args &&... args)
 
static uint32_t GenOpClassID ()
 
- Protected Types inherited from GrDrawOp
enum class  FixedFunctionFlags : uint32_t { kNone = 0x0 , kUsesHWAA = 0x1 , kUsesStencil = 0x2 }
 
- Protected Member Functions inherited from GrDrawOp
 GR_DECL_BITFIELD_CLASS_OPS_FRIENDS (FixedFunctionFlags)
 
virtual FixedFunctionFlags fixedFunctionFlags () const
 

Detailed Description

Definition at line 42 of file DrawAtlasPathOp.h.

Constructor & Destructor Documentation

◆ DrawAtlasPathOp()

DEFINE_OP_CLASS_ID skgpu::ganesh::DrawAtlasPathOp::DrawAtlasPathOp ( SkArenaAlloc arena,
const SkIRect fillBounds,
const SkMatrix localToDevice,
GrPaint &&  paint,
SkIPoint16  locationInAtlas,
const SkIRect pathDevIBounds,
bool  transposedInAtlas,
GrSurfaceProxyView  atlasView,
bool  isInverseFill 
)
inline

Definition at line 46 of file DrawAtlasPathOp.h.

49 : GrDrawOp(ClassID())
50 , fHeadInstance(arena->make<Instance>(fillBounds, localToDevice, paint.getColor4f(),
51 locationInAtlas, pathDevIBounds,
52 transposedInAtlas))
53 , fTailInstance(&fHeadInstance->fNext)
54 , fAtlasHelper(std::move(atlasView),
58 , fProcessors(std::move(paint)) {
60 }
GrDrawOp(uint32_t classID)
Definition: GrDrawOp.h:31
void setBounds(const SkRect &newBounds, HasAABloat aabloat, IsHairline zeroArea)
Definition: GrOp.h:279
auto make(Ctor &&ctor) -> decltype(ctor(nullptr))
Definition: SkArenaAlloc.h:120
const Paint & paint
Definition: color_source.cc:38
static SkRect Make(const SkISize &size)
Definition: SkRect.h:669

Member Function Documentation

◆ finalize()

GrProcessorSet::Analysis skgpu::ganesh::DrawAtlasPathOp::finalize ( const GrCaps ,
const GrAppliedClip ,
GrClampType   
)
overridevirtual

This is called after the GrAppliedClip has been computed and just prior to recording the op or combining it with a previously recorded op. The op should convert any proxies or resources it owns to "pending io" status so that resource allocation can be more optimal. Additionally, at this time the op must report whether a copy of the destination (or destination texture itself) needs to be provided to the GrXferProcessor when this op executes.

Implements GrDrawOp.

Definition at line 156 of file DrawAtlasPathOp.cpp.

157 {
158 const GrProcessorSet::Analysis& analysis = fProcessors.finalize(
160 &GrUserStencilSettings::kUnused, caps, clampType, &fHeadInstance->fColor);
161 fUsesLocalCoords = analysis.usesLocalCoords();
162 return analysis;
163}
static SkPath clip(const SkPath &path, const SkHalfPlane &plane)
Definition: SkPath.cpp:3892
bool usesLocalCoords() const
Analysis finalize(const GrProcessorAnalysisColor &, const GrProcessorAnalysisCoverage, const GrAppliedClip *, const GrUserStencilSettings *, const GrCaps &, GrClampType, SkPMColor4f *inputColorOverride)
static const GrUserStencilSettings & kUnused

◆ fixedFunctionFlags()

FixedFunctionFlags skgpu::ganesh::DrawAtlasPathOp::fixedFunctionFlags ( ) const
inlineoverridevirtual

Reimplemented from GrDrawOp.

Definition at line 63 of file DrawAtlasPathOp.h.

◆ name()

const char * skgpu::ganesh::DrawAtlasPathOp::name ( ) const
inlineoverridevirtual

Implements GrOp.

Definition at line 62 of file DrawAtlasPathOp.h.

62{ return "DrawAtlasPathOp"; }

◆ onCombineIfPossible()

GrOp::CombineResult skgpu::ganesh::DrawAtlasPathOp::onCombineIfPossible ( GrOp op,
SkArenaAlloc ,
const GrCaps  
)
overridevirtual

Reimplemented from GrOp.

Definition at line 165 of file DrawAtlasPathOp.cpp.

165 {
166 auto that = op->cast<DrawAtlasPathOp>();
167
168 if (!fAtlasHelper.isCompatible(that->fAtlasHelper) ||
169 fProcessors != that->fProcessors) {
171 }
172
173 SkASSERT(fUsesLocalCoords == that->fUsesLocalCoords);
174 *fTailInstance = that->fHeadInstance;
175 fTailInstance = that->fTailInstance;
176 fInstanceCount += that->fInstanceCount;
178}
#define SkASSERT(cond)
Definition: SkAssert.h:116
const T & cast() const
Definition: GrOp.h:148
bool isCompatible(const AtlasInstancedHelper &helper)
DEFINE_OP_CLASS_ID DrawAtlasPathOp(SkArenaAlloc *arena, const SkIRect &fillBounds, const SkMatrix &localToDevice, GrPaint &&paint, SkIPoint16 locationInAtlas, const SkIRect &pathDevIBounds, bool transposedInAtlas, GrSurfaceProxyView atlasView, bool isInverseFill)

◆ onExecute()

void skgpu::ganesh::DrawAtlasPathOp::onExecute ( GrOpFlushState flushState,
const SkRect chainBounds 
)
overridevirtual

Implements GrOp.

Definition at line 248 of file DrawAtlasPathOp.cpp.

248 {
249 if (fProgram->geomProc().hasVertexAttributes() && !fVertexBufferIfNoIDSupport) {
250 return;
251 }
252 flushState->bindPipelineAndScissorClip(*fProgram, this->bounds());
253 flushState->bindTextures(fProgram->geomProc(), *fAtlasHelper.proxy(), fProgram->pipeline());
254 flushState->bindBuffers(nullptr, std::move(fInstanceBuffer), fVertexBufferIfNoIDSupport);
255 flushState->drawInstanced(fInstanceCount, fBaseInstance, 4, 0);
256}
bool hasVertexAttributes() const
void bindPipelineAndScissorClip(const GrProgramInfo &programInfo, const SkRect &drawBounds)
void bindBuffers(sk_sp< const GrBuffer > indexBuffer, sk_sp< const GrBuffer > instanceBuffer, sk_sp< const GrBuffer > vertexBuffer, GrPrimitiveRestart primitiveRestart=GrPrimitiveRestart::kNo)
void drawInstanced(int instanceCount, int baseInstance, int vertexCount, int baseVertex)
void bindTextures(const GrGeometryProcessor &geomProc, const GrSurfaceProxy &singleGeomProcTexture, const GrPipeline &pipeline)
const SkRect & bounds() const
Definition: GrOp.h:122
const GrPipeline & pipeline() const
Definition: GrProgramInfo.h:39
const GrGeometryProcessor & geomProc() const
Definition: GrProgramInfo.h:40

◆ onPrepare()

void skgpu::ganesh::DrawAtlasPathOp::onPrepare ( GrOpFlushState flushState)
overridevirtual

Implements GrOp.

Definition at line 217 of file DrawAtlasPathOp.cpp.

217 {
218 if (!fProgram) {
219 this->prepareProgram(flushState->caps(), flushState->allocator(), flushState->writeView(),
220 flushState->usesMSAASurface(), flushState->detachAppliedClip(),
221 flushState->dstProxyView(), flushState->renderPassBarriers(),
222 flushState->colorLoadOp());
223 SkASSERT(fProgram);
224 }
225
226 if (VertexWriter instanceWriter = flushState->makeVertexWriter(
227 fProgram->geomProc().instanceStride(), fInstanceCount, &fInstanceBuffer,
228 &fBaseInstance)) {
229 for (const Instance* i = fHeadInstance; i; i = i->fNext) {
230 instanceWriter << SkRect::Make(i->fFillBounds)
231 << VertexWriter::If(fUsesLocalCoords,
232 i->fLocalToDeviceIfUsingLocalCoords)
233 << i->fColor;
234 fAtlasHelper.writeInstanceData(&instanceWriter, &i->fAtlasInstance);
235 }
236 }
237
238 if (!flushState->caps().shaderCaps()->fVertexIDSupport) {
239 constexpr static SkPoint kUnitQuad[4] = {{0,0}, {0,1}, {1,0}, {1,1}};
240
241 SKGPU_DEFINE_STATIC_UNIQUE_KEY(gUnitQuadBufferKey);
242
243 fVertexBufferIfNoIDSupport = flushState->resourceProvider()->findOrMakeStaticBuffer(
244 GrGpuBufferType::kVertex, sizeof(kUnitQuad), kUnitQuad, gUnitQuadBufferKey);
245 }
246}
#define SKGPU_DEFINE_STATIC_UNIQUE_KEY(name)
Definition: ResourceKey.h:324
const GrShaderCaps * shaderCaps() const
Definition: GrCaps.h:63
size_t instanceStride() const
skgpu::VertexWriter makeVertexWriter(size_t vertexSize, int vertexCount, sk_sp< const GrBuffer > *, int *startVertex)
GrLoadOp colorLoadOp() const final
const GrDstProxyView & dstProxyView() const final
GrXferBarrierFlags renderPassBarriers() const final
SkArenaAlloc * allocator() override
const GrSurfaceProxyView & writeView() const final
GrResourceProvider * resourceProvider() const final
GrAppliedClip detachAppliedClip() final
const GrCaps & caps() const final
bool usesMSAASurface() const final
sk_sp< const GrGpuBuffer > findOrMakeStaticBuffer(GrGpuBufferType intendedType, size_t size, const skgpu::UniqueKey &key, InitializeBufferFn)
void writeInstanceData(VertexWriter *instanceWriter, const Instance *) const
bool fVertexIDSupport
Definition: GrShaderCaps.h:36
static Conditional< T > If(bool condition, const T &value)
Definition: BufferWriter.h:153

◆ onPrePrepare()

void skgpu::ganesh::DrawAtlasPathOp::onPrePrepare ( GrRecordingContext rContext,
const GrSurfaceProxyView writeView,
GrAppliedClip appliedClip,
const GrDstProxyView dstProxyView,
GrXferBarrierFlags  renderPassXferBarriers,
GrLoadOp  colorLoadOp 
)
overridevirtual

Implements GrOp.

Definition at line 201 of file DrawAtlasPathOp.cpp.

205 {
206 // DMSAA is not supported on DDL.
207 bool usesMSAASurface = writeView.asRenderTargetProxy()->numSamples() > 1;
208 this->prepareProgram(*rContext->priv().caps(), rContext->priv().recordTimeAllocator(),
209 writeView, usesMSAASurface, std::move(*appliedClip), dstProxyView,
210 renderPassXferBarriers, colorLoadOp);
211 SkASSERT(fProgram);
212 rContext->priv().recordProgramInfo(fProgram);
213}
const GrCaps * caps() const
void recordProgramInfo(const GrProgramInfo *programInfo)
SkArenaAlloc * recordTimeAllocator()
GrRecordingContextPriv priv()
GrRenderTargetProxy * asRenderTargetProxy() const

◆ visitProxies()

void skgpu::ganesh::DrawAtlasPathOp::visitProxies ( const GrVisitProxyFunc func) const
inlineoverridevirtual

Reimplemented from GrOp.

Definition at line 64 of file DrawAtlasPathOp.h.

64 {
65 func(fAtlasHelper.proxy(), skgpu::Mipmapped::kNo);
66 fProcessors.visitProxies(func);
67 }
void visitProxies(const GrVisitProxyFunc &) const

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