53 #define GrOP_SPEW(code) code
54 #define GrOP_INFO(...) SkDebugf(__VA_ARGS__)
56 #define GrOP_SPEW(code)
57 #define GrOP_INFO(...)
61#define GR_FLUSH_TIME_OP_SPEW 0
64#define DEFINE_OP_CLASS_ID \
65 static uint32_t ClassID() { \
66 static uint32_t kClassID = GenOpClassID(); \
72 using Owner = std::unique_ptr<GrOp>;
74 template<
typename Op,
typename... Args>
79 template<
typename Op,
typename... Args>
84 template<
typename Op,
typename... Args>
87 void* bytes = ::operator
new(
sizeof(
Op) + extraSize);
88 return Owner{
new (bytes)
Op(std::forward<Args>(
args)...)};
93 virtual const char*
name()
const = 0;
123 SkASSERT(kUninitialized_BoundsFlag != fBoundsFlags);
128 fBounds = clippedBounds;
134 SkASSERT(fBoundsFlags != kUninitialized_BoundsFlag);
135 return SkToBool(fBoundsFlags & kAABloat_BoundsFlag);
139 SkASSERT(fBoundsFlags != kUninitialized_BoundsFlag);
140 return SkToBool(fBoundsFlags & kZeroArea_BoundsFlag);
143 void operator delete(
void*
p) { ::operator
delete(
p); }
148 template <
typename T>
const T&
cast()
const {
150 return *
static_cast<const T*
>(
this);
155 return static_cast<T*
>(
this);
162 if (kIllegalOpID == fUniqueID) {
163 fUniqueID = GenOpID();
177 this->
onPrePrepare(context, dstView,
clip, dstProxyView, renderPassXferBarriers,
197#if defined(GR_TEST_UTILS)
198 virtual SkString dumpInfo() const final {
199 return SkStringPrintf(
"%s\nOpBounds: [L: %.2f, T: %.2f, R: %.2f, B: %.2f]",
200 this->onDumpInfo().c_str(), fBounds.
fLeft, fBounds.
fTop,
216 explicit Iter(
const OpSubclass*
head) : fCurr(
head) {}
217 inline Iter& operator++() {
218 return *
this = Iter(
static_cast<const OpSubclass*
>(fCurr->nextInChain()));
220 const OpSubclass&
operator*()
const {
return *fCurr; }
221 bool operator!=(
const Iter& that)
const {
return fCurr != that.fCurr; }
224 const OpSubclass* fCurr;
226 const OpSubclass* fHead;
230 Iter
begin() {
return Iter(fHead); }
231 Iter
end() {
return Iter(
nullptr); }
252 SkDEBUGCODE(
void validateChain(
GrOp* expectedTail =
nullptr)
const;)
255 virtual void validate()
const {}
281 this->setBoundsFlags(aabloat, zeroArea);
285 m.mapRect(&fBounds, srcBounds);
286 this->setBoundsFlags(aabloat, zeroArea);
295 void joinBounds(
const GrOp& that) {
297 fBoundsFlags |= kAABloat_BoundsFlag;
300 fBoundsFlags |= kZeroArea_BoundsFlag;
320#if defined(GR_TEST_UTILS)
324 static uint32_t GenID(std::atomic<uint32_t>* idCounter) {
325 uint32_t
id = idCounter->fetch_add(1, std::memory_order_relaxed);
327 SK_ABORT(
"This should never wrap as it should only be called once for each GrOp "
344 kAABloat_BoundsFlag = 0x1,
345 kZeroArea_BoundsFlag = 0x2,
346 SkDEBUGCODE(kUninitialized_BoundsFlag = 0x4)
349 Owner fNextInChain{
nullptr};
350 GrOp* fPrevInChain =
nullptr;
351 const uint16_t fClassID;
352 uint16_t fBoundsFlags;
354 static uint32_t GenOpID() {
return GenID(&gCurrOpUniqueID); }
358 static std::atomic<uint32_t> gCurrOpUniqueID;
359 static std::atomic<uint32_t> gCurrOpClassID;
std::function< void(GrSurfaceProxy *, skgpu::Mipmapped)> GrVisitProxyFunc
#define SK_ABORT(message,...)
@ kYes
Do pre-clip the geometry before applying the (perspective) matrix.
@ kNo
Don't pre-clip the geometry before applying the (perspective) matrix.
static SkPath clip(const SkPath &path, const SkHalfPlane &plane)
SK_API SkString SkStringPrintf(const char *format,...) SK_PRINTF_LIKE(1
Creates a new string and writes into it using a printf()-style format.
static constexpr bool SkToBool(const T &x)
#define TRACE_EVENT0_ALWAYS(category_group, name)
#define TRACE_STR_STATIC(str)
static constexpr uint32_t SK_InvalidUniqueID
ChainRange(const OpSubclass *head)
CombineResult combineIfPossible(GrOp *that, SkArenaAlloc *alloc, const GrCaps &caps)
GrOp * prevInChain() const
virtual void onExecute(GrOpFlushState *, const SkRect &chainBounds)=0
static Owner Make(GrRecordingContext *context, Args &&... args)
std::unique_ptr< GrOp > Owner
GrOp * nextInChain() const
static Owner MakeWithExtraMemory(GrRecordingContext *context, size_t extraSize, Args &&... args)
void execute(GrOpFlushState *state, const SkRect &chainBounds)
virtual void onPrepare(GrOpFlushState *)=0
void setClippedBounds(const SkRect &clippedBounds)
static uint32_t GenOpClassID()
void prepare(GrOpFlushState *state)
uint32_t uniqueID() const
static Owner MakeWithProcessorSet(GrRecordingContext *context, const SkPMColor4f &color, GrPaint &&paint, Args &&... args)
void prePrepare(GrRecordingContext *context, const GrSurfaceProxyView &dstView, GrAppliedClip *clip, const GrDstProxyView &dstProxyView, GrXferBarrierFlags renderPassXferBarriers, GrLoadOp colorLoadOp)
virtual const char * name() const =0
virtual void onPrePrepare(GrRecordingContext *, const GrSurfaceProxyView &writeView, GrAppliedClip *, const GrDstProxyView &, GrXferBarrierFlags renderPassXferBarriers, GrLoadOp colorLoadOp)=0
const SkRect & bounds() const
virtual void visitProxies(const GrVisitProxyFunc &) const
void chainConcat(GrOp::Owner)
void setBounds(const SkRect &newBounds, HasAABloat aabloat, IsHairline zeroArea)
void makeFullScreen(GrSurfaceProxy *proxy)
virtual CombineResult onCombineIfPossible(GrOp *, SkArenaAlloc *, const GrCaps &)
void setTransformedBounds(const SkRect &srcBounds, const SkMatrix &m, HasAABloat aabloat, IsHairline zeroArea)
SkRect getBoundsRect() const
G_BEGIN_DECLS G_MODULE_EXPORT FlValue * args
bool operator!=(C p1, const scoped_nsprotocol< C > &p2)
constexpr Color operator*(T value, const Color &c)
SkScalar fBottom
larger y-axis bounds
void joinPossiblyEmptyRect(const SkRect &r)
SkScalar fLeft
smaller x-axis bounds
SkScalar fRight
larger x-axis bounds
SkScalar fTop
smaller y-axis bounds