8#ifndef GrResourceAllocator_DEFINED
9#define GrResourceAllocator_DEFINED
23#define GR_ALLOCATION_SPEW 0
26#define GR_TRACK_INTERVAL_CREATION 0
81 : fDContext(dContext) {}
85 unsigned int curOp()
const {
return fNumOps; }
132#if GR_ALLOCATION_SPEW
133 void dumpIntervals();
141 void expire(
unsigned int curIndex);
147 struct FreePoolTraits {
149 return r.scratchKey();
159 struct UniqueKeyHash {
163 UniqueKeyRegisterHash;
175 const skgpu::UniqueKey& uniqueKey()
const {
return fOriginatingProxy->getUniqueKey(); }
177 bool accountedForInBudget()
const {
return fAccountedForInBudget; }
178 void setAccountedForInBudget() { fAccountedForInBudget =
true; }
180 GrSurface* existingSurface()
const {
return fExistingSurface.get(); }
191 SkDEBUGCODE(uint32_t uniqueID()
const {
return fUniqueID; })
197 bool fAccountedForInBudget =
false;
202 static uint32_t CreateUniqueID();
214#if GR_TRACK_INTERVAL_CREATION
223 unsigned int start()
const {
return fStart; }
224 unsigned int end()
const {
return fEnd; }
230 Register* getRegister()
const {
return fRegister; }
231 void setRegister(
Register* r) { fRegister = r; }
233 void addUse() { fUses++; }
234 int uses()
const {
return fUses; }
236 void extendEnd(
unsigned int newEnd) {
239#if GR_TRACK_INTERVAL_CREATION
240 SkDebugf(
"intvl %d: extending from %d to %d\n", fUniqueID, fEnd, newEnd);
245 void disallowRecycling() {
250 SkDEBUGCODE(uint32_t uniqueID()
const {
return fUniqueID; })
257 unsigned int fUses = 0;
264 static uint32_t CreateUniqueID();
270 IntervalList() =
default;
277 const Interval* peekHead()
const {
return fHead; }
278 Interval* peekHead() {
return fHead; }
280 void insertByIncreasingStart(
Interval*);
281 void insertByIncreasingEnd(
Interval*);
291 static const int kInitialArenaSize = 128 *
sizeof(
Interval);
294 FreePoolMultiMap fFreePool;
295 IntvlHash fIntvlHash;
297 IntervalList fIntvlList;
298 IntervalList fActiveIntvls;
300 IntervalList fFinishedIntvls;
302 UniqueKeyRegisterHash fUniqueKeyRegisters;
303 unsigned int fNumOps = 0;
305 SkDEBUGCODE(
bool fPlanned =
false;)
306 SkDEBUGCODE(
bool fAssigned =
false;)
309 bool fFailedInstantiation =
false;
const TextureProxy * fProxy
static float next(float f)
void SK_SPI SkDebugf(const char format[],...) SK_PRINTF_LIKE(1
@ kYes
Do pre-clip the geometry before applying the (perspective) matrix.
@ kNo
Don't pre-clip the geometry before applying the (perspective) matrix.
static constexpr bool SkToBool(const T &x)
void addInterval(GrSurfaceProxy *, unsigned int start, unsigned int end, ActualUse actualUse, AllowRecycling SkDEBUGCODE(, bool isDirectDstRead=false))
bool makeBudgetHeadroom()
bool failedInstantiation() const
GrResourceAllocator(GrDirectContext *dContext)
unsigned int curOp() const
const char * c_str() const
EMSCRIPTEN_KEEPALIVE void empty()
static uint32_t Hash(uint32_t key)