Flutter Engine
The Flutter Engine
Classes | Public Types | Public Member Functions | Static Public Member Functions | Private Member Functions | List of all members
GrOp Class Referenceabstract

#include <GrOp.h>

Inheritance diagram for GrOp:
SkNoncopyable GrDrawOp skgpu::ganesh::ClearOp skgpu::ganesh::DrawableOp GrMeshDrawOp GrThreadSafeVertexTestOp LazyFailedInstantiationTestOp LazyProxyTest::Op skgpu::ganesh::DrawAtlasPathOp skgpu::ganesh::PathInnerTriangulateOp skgpu::ganesh::PathStencilCoverOp skgpu::ganesh::PathTessellateOp skgpu::ganesh::StrokeTessellateOp

Classes

class  ChainRange
 

Public Types

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 >
 

Public Member Functions

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)
 

Static Public Member Functions

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 ()
 

Private Member Functions

virtual CombineResult onCombineIfPossible (GrOp *, SkArenaAlloc *, const GrCaps &)
 
virtual void onPrePrepare (GrRecordingContext *, const GrSurfaceProxyView &writeView, GrAppliedClip *, const GrDstProxyView &, GrXferBarrierFlags renderPassXferBarriers, GrLoadOp colorLoadOp)=0
 
virtual void onPrepare (GrOpFlushState *)=0
 
virtual void onExecute (GrOpFlushState *, const SkRect &chainBounds)=0
 

Detailed Description

Definition at line 70 of file GrOp.h.

Member Typedef Documentation

◆ Owner

using GrOp::Owner = std::unique_ptr<GrOp>

Definition at line 72 of file GrOp.h.

Member Enumeration Documentation

◆ CombineResult

enum class GrOp::CombineResult
strong
Enumerator
kMerged 

The op that combineIfPossible was called on now represents its own work plus that of the passed op. The passed op should be destroyed without being flushed. Currently it is not legal to merge an op passed to combineIfPossible() the passed op is already in a chain (though the op on which combineIfPossible() was called may be).

kMayChain 

The caller may (but is not required) to chain these ops together. If they are chained then prepare() and execute() will be called on the head op but not the other ops in the chain. The head op will prepare and execute on behalf of all the ops in the chain.

kCannotCombine 

The ops cannot be combined.

Definition at line 99 of file GrOp.h.

99 {
100 /**
101 * The op that combineIfPossible was called on now represents its own work plus that of
102 * the passed op. The passed op should be destroyed without being flushed. Currently it
103 * is not legal to merge an op passed to combineIfPossible() the passed op is already in a
104 * chain (though the op on which combineIfPossible() was called may be).
105 */
106 kMerged,
107 /**
108 * The caller *may* (but is not required) to chain these ops together. If they are chained
109 * then prepare() and execute() will be called on the head op but not the other ops in the
110 * chain. The head op will prepare and execute on behalf of all the ops in the chain.
111 */
112 kMayChain,
113 /**
114 * The ops cannot be combined.
115 */
116 kCannotCombine
117 };

◆ HasAABloat

enum class GrOp::HasAABloat : bool
strong

Indicates that the op will produce geometry that extends beyond its bounds for the purpose of ensuring that the fragment shader runs on partially covered pixels for non-MSAA antialiasing.

Enumerator
kNo 
kYes 

Definition at line 266 of file GrOp.h.

266 : bool {
267 kNo = false,
268 kYes = true
269 };
@ kYes
Do pre-clip the geometry before applying the (perspective) matrix.
@ kNo
Don't pre-clip the geometry before applying the (perspective) matrix.

◆ IsHairline

enum class GrOp::IsHairline : bool
strong

Indicates that the geometry being drawn in a hairline stroke. A point that is drawn in device space is also considered a hairline.

Enumerator
kNo 
kYes 

Definition at line 274 of file GrOp.h.

274 : bool {
275 kNo = false,
276 kYes = true
277 };

Constructor & Destructor Documentation

◆ ~GrOp()

virtual GrOp::~GrOp ( )
virtualdefault

Member Function Documentation

◆ bounds()

const SkRect & GrOp::bounds ( ) const
inline

Definition at line 122 of file GrOp.h.

122 {
123 SkASSERT(kUninitialized_BoundsFlag != fBoundsFlags);
124 return fBounds;
125 }
#define SkASSERT(cond)
Definition: SkAssert.h:116

◆ cast() [1/2]

template<typename T >
T * GrOp::cast ( )
inline

Definition at line 153 of file GrOp.h.

153 {
154 SkASSERT(T::ClassID() == this->classID());
155 return static_cast<T*>(this);
156 }
uint32_t classID() const
Definition: GrOp.h:158
#define T
Definition: precompiler.cc:65

◆ cast() [2/2]

template<typename T >
const T & GrOp::cast ( ) const
inline

Helper for safely down-casting to a GrOp subclass

Definition at line 148 of file GrOp.h.

148 {
149 SkASSERT(T::ClassID() == this->classID());
150 return *static_cast<const T*>(this);
151 }

◆ chainConcat()

void GrOp::chainConcat ( GrOp::Owner  next)

Concatenates two op chains. This op must be a tail and the passed op must be a head. The ops must be of the same subclass.

Definition at line 31 of file GrOp.cpp.

31 {
33 SkASSERT(this->classID() == next->classID());
34 SkASSERT(this->isChainTail());
35 SkASSERT(next->isChainHead());
36 fNextInChain = std::move(next);
37 fNextInChain->fPrevInChain = this;
38}
static float next(float f)
bool isChainTail() const
Definition: GrOp.h:242

◆ classID()

uint32_t GrOp::classID ( ) const
inline

Definition at line 158 of file GrOp.h.

158{ SkASSERT(kIllegalOpID != fClassID); return fClassID; }

◆ combineIfPossible()

GrOp::CombineResult GrOp::combineIfPossible ( GrOp that,
SkArenaAlloc alloc,
const GrCaps caps 
)

Definition at line 19 of file GrOp.cpp.

19 {
20 SkASSERT(this != that);
21 if (this->classID() != that->classID()) {
23 }
24 auto result = this->onCombineIfPossible(that, alloc, caps);
26 this->joinBounds(*that);
27 }
28 return result;
29}
virtual CombineResult onCombineIfPossible(GrOp *, SkArenaAlloc *, const GrCaps &)
Definition: GrOp.h:305
GAsyncResult * result

◆ cutChain()

GrOp::Owner GrOp::cutChain ( )

Cuts the chain after this op. The returned op is the op that was previously next in the chain or null if this was already a tail.

Definition at line 40 of file GrOp.cpp.

40 {
41 if (fNextInChain) {
42 fNextInChain->fPrevInChain = nullptr;
43 return std::move(fNextInChain);
44 }
45 return nullptr;
46}

◆ execute()

void GrOp::execute ( GrOpFlushState state,
const SkRect chainBounds 
)
inline

Issues the op's commands to GrGpu.

Definition at line 191 of file GrOp.h.

191 {
193 this->onExecute(state, chainBounds);
194 }
#define TRACE_EVENT0_ALWAYS(category_group, name)
#define TRACE_STR_STATIC(str)
Definition: SkTraceEvent.h:73
virtual void onExecute(GrOpFlushState *, const SkRect &chainBounds)=0
virtual const char * name() const =0

◆ GenOpClassID()

static uint32_t GrOp::GenOpClassID ( )
inlinestatic

Definition at line 292 of file GrOp.h.

292{ return GenID(&gCurrOpClassID); }

◆ hasAABloat()

bool GrOp::hasAABloat ( ) const
inline

Definition at line 133 of file GrOp.h.

133 {
134 SkASSERT(fBoundsFlags != kUninitialized_BoundsFlag);
135 return SkToBool(fBoundsFlags & kAABloat_BoundsFlag);
136 }
static constexpr bool SkToBool(const T &x)
Definition: SkTo.h:35

◆ hasZeroArea()

bool GrOp::hasZeroArea ( ) const
inline

Definition at line 138 of file GrOp.h.

138 {
139 SkASSERT(fBoundsFlags != kUninitialized_BoundsFlag);
140 return SkToBool(fBoundsFlags & kZeroArea_BoundsFlag);
141 }

◆ isChainHead()

bool GrOp::isChainHead ( ) const
inline

Returns true if this is the head of a chain (including a length 1 chain).

Definition at line 240 of file GrOp.h.

240{ return !fPrevInChain; }

◆ isChainTail()

bool GrOp::isChainTail ( ) const
inline

Returns true if this is the tail of a chain (including a length 1 chain).

Definition at line 242 of file GrOp.h.

242{ return !fNextInChain; }

◆ Make()

template<typename Op , typename... Args>
static Owner GrOp::Make ( GrRecordingContext context,
Args &&...  args 
)
inlinestatic

Definition at line 75 of file GrOp.h.

75 {
76 return Owner{new Op(std::forward<Args>(args)...)};
77 }
std::unique_ptr< GrOp > Owner
Definition: GrOp.h:72
G_BEGIN_DECLS G_MODULE_EXPORT FlValue * args

◆ makeFullScreen()

void GrOp::makeFullScreen ( GrSurfaceProxy proxy)
inline

Definition at line 288 of file GrOp.h.

288 {
290 }
void setBounds(const SkRect &newBounds, HasAABloat aabloat, IsHairline zeroArea)
Definition: GrOp.h:279
SkRect getBoundsRect() const

◆ MakeWithExtraMemory()

template<typename Op , typename... Args>
static Owner GrOp::MakeWithExtraMemory ( GrRecordingContext context,
size_t  extraSize,
Args &&...  args 
)
inlinestatic

Definition at line 85 of file GrOp.h.

86 {
87 void* bytes = ::operator new(sizeof(Op) + extraSize);
88 return Owner{new (bytes) Op(std::forward<Args>(args)...)};
89 }

◆ MakeWithProcessorSet()

template<typename Op , typename... Args>
GrOp::Owner GrOp::MakeWithProcessorSet ( GrRecordingContext context,
const SkPMColor4f color,
GrPaint &&  paint,
Args &&...  args 
)
static

Definition at line 197 of file GrSimpleMeshDrawOpHelper.h.

199 {
200 char* bytes = (char*)::operator new(sizeof(Op) + sizeof(GrProcessorSet));
201 char* setMem = bytes + sizeof(Op);
202 GrProcessorSet* processorSet = new (setMem) GrProcessorSet{std::move(paint)};
203 return Owner{new (bytes) Op(processorSet, color, std::forward<Args>(args)...)};
204}
const Paint & paint
Definition: color_source.cc:38
DlColor color

◆ name()

virtual const char * GrOp::name ( ) const
pure virtual

◆ nextInChain()

GrOp * GrOp::nextInChain ( ) const
inline

The next op in the chain.

Definition at line 244 of file GrOp.h.

244{ return fNextInChain.get(); }

◆ onCombineIfPossible()

virtual CombineResult GrOp::onCombineIfPossible ( GrOp ,
SkArenaAlloc ,
const GrCaps  
)
inlineprivatevirtual

Reimplemented in skgpu::ganesh::DrawAtlasPathOp.

Definition at line 305 of file GrOp.h.

305 {
307 }

◆ onExecute()

virtual void GrOp::onExecute ( GrOpFlushState ,
const SkRect chainBounds 
)
privatepure virtual

◆ onPrepare()

virtual void GrOp::onPrepare ( GrOpFlushState )
privatepure virtual

◆ onPrePrepare()

virtual void GrOp::onPrePrepare ( GrRecordingContext ,
const GrSurfaceProxyView writeView,
GrAppliedClip ,
const GrDstProxyView ,
GrXferBarrierFlags  renderPassXferBarriers,
GrLoadOp  colorLoadOp 
)
privatepure virtual

◆ operator delete()

void GrOp::operator delete ( void *  p)
inline

Definition at line 143 of file GrOp.h.

143{ ::operator delete(p); }

◆ prepare()

void GrOp::prepare ( GrOpFlushState state)
inline

Called prior to executing. The op should perform any resource creation or data transfers necessary before execute() is called.

Definition at line 185 of file GrOp.h.

185 {
187 this->onPrepare(state);
188 }
virtual void onPrepare(GrOpFlushState *)=0

◆ prePrepare()

void GrOp::prePrepare ( GrRecordingContext context,
const GrSurfaceProxyView dstView,
GrAppliedClip clip,
const GrDstProxyView dstProxyView,
GrXferBarrierFlags  renderPassXferBarriers,
GrLoadOp  colorLoadOp 
)
inline

This can optionally be called before 'prepare' (but after sorting). Each op that overrides onPrePrepare must be prepared to handle both cases (when onPrePrepare has been called ahead of time and when it has not been called).

Definition at line 173 of file GrOp.h.

175 {
177 this->onPrePrepare(context, dstView, clip, dstProxyView, renderPassXferBarriers,
178 colorLoadOp);
179 }
static SkPath clip(const SkPath &path, const SkHalfPlane &plane)
Definition: SkPath.cpp:3892
virtual void onPrePrepare(GrRecordingContext *, const GrSurfaceProxyView &writeView, GrAppliedClip *, const GrDstProxyView &, GrXferBarrierFlags renderPassXferBarriers, GrLoadOp colorLoadOp)=0

◆ prevInChain()

GrOp * GrOp::prevInChain ( ) const
inline

The previous op in the chain.

Definition at line 246 of file GrOp.h.

246{ return fPrevInChain; }

◆ setBounds()

void GrOp::setBounds ( const SkRect newBounds,
HasAABloat  aabloat,
IsHairline  zeroArea 
)
inline

Definition at line 279 of file GrOp.h.

279 {
280 fBounds = newBounds;
281 this->setBoundsFlags(aabloat, zeroArea);
282 }

◆ setClippedBounds()

void GrOp::setClippedBounds ( const SkRect clippedBounds)
inline

Definition at line 127 of file GrOp.h.

127 {
128 fBounds = clippedBounds;
129 // The clipped bounds already incorporate any effect of the bounds flags.
130 fBoundsFlags = 0;
131 }

◆ setTransformedBounds()

void GrOp::setTransformedBounds ( const SkRect srcBounds,
const SkMatrix m,
HasAABloat  aabloat,
IsHairline  zeroArea 
)
inline

Definition at line 283 of file GrOp.h.

284 {
285 m.mapRect(&fBounds, srcBounds);
286 this->setBoundsFlags(aabloat, zeroArea);
287 }

◆ uniqueID()

uint32_t GrOp::uniqueID ( ) const
inline

Definition at line 161 of file GrOp.h.

161 {
162 if (kIllegalOpID == fUniqueID) {
163 fUniqueID = GenOpID();
164 }
165 return fUniqueID;
166 }

◆ visitProxies()

virtual void GrOp::visitProxies ( const GrVisitProxyFunc ) const
inlinevirtual

Reimplemented in skgpu::ganesh::AtlasTextOp, skiagm::BezierTestOp, skgpu::ganesh::DrawAtlasPathOp, CircleOp, ButtCapDashedCircleOp, EllipseOp, DIEllipseOp, CircularRRectOp, EllipticalRRectOp, TestVertexOp, LazyProxyTest::Op, and LazyFailedInstantiationTestOp.

Definition at line 95 of file GrOp.h.

95 {
96 // This default implementation assumes the op has no proxies
97 }

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