#include "src/gpu/ganesh/GrResourceAllocator.h"
#include "include/core/SkTypes.h"
#include "include/gpu/GpuTypes.h"
#include "include/gpu/ganesh/GrDirectContext.h"
#include "include/private/gpu/ganesh/GrTypesPriv.h"
#include "src/gpu/ganesh/GrCaps.h"
#include "src/gpu/ganesh/GrDirectContextPriv.h"
#include "src/gpu/ganesh/GrGpuResourcePriv.h"
#include "src/gpu/ganesh/GrResourceCache.h"
#include "src/gpu/ganesh/GrResourceProvider.h"
#include "src/gpu/ganesh/GrSurfaceProxy.h"
#include "src/gpu/ganesh/GrSurfaceProxyPriv.h"
#include "src/gpu/ganesh/GrTexture.h"
#include <cstddef>
#include <limits>
#include <utility>
#ifdef SK_DEBUG
#include <atomic>
uint32_t GrResourceAllocator::Interval::CreateUniqueID() { … }
uint32_t GrResourceAllocator::Register::CreateUniqueID() { … }
#endif
GrResourceAllocator::~GrResourceAllocator() { … }
void GrResourceAllocator::addInterval(GrSurfaceProxy* proxy, unsigned int start, unsigned int end,
ActualUse actualUse, AllowRecycling allowRecycling
SkDEBUGCODE(, bool isDirectDstRead)) { … }
static bool can_proxy_use_scratch(const GrCaps& caps, GrSurfaceProxy* proxy) { … }
GrResourceAllocator::Register::Register(GrSurfaceProxy* originatingProxy,
skgpu::ScratchKey scratchKey,
GrResourceProvider* provider)
: … { … }
bool GrResourceAllocator::Register::isRecyclable(const GrCaps& caps,
GrSurfaceProxy* proxy,
int knownUseCount,
AllowRecycling allowRecycling) const { … }
bool GrResourceAllocator::Register::instantiateSurface(GrSurfaceProxy* proxy,
GrResourceProvider* resourceProvider) { … }
GrResourceAllocator::Interval* GrResourceAllocator::IntervalList::popHead() { … }
void GrResourceAllocator::IntervalList::insertByIncreasingStart(Interval* intvl) { … }
void GrResourceAllocator::IntervalList::insertByIncreasingEnd(Interval* intvl) { … }
#ifdef SK_DEBUG
void GrResourceAllocator::IntervalList::validate() const { … }
#endif
GrResourceAllocator::Register* GrResourceAllocator::findOrCreateRegisterFor(GrSurfaceProxy* proxy) { … }
void GrResourceAllocator::expire(unsigned int curIndex) { … }
bool GrResourceAllocator::planAssignment() { … }
bool GrResourceAllocator::makeBudgetHeadroom() { … }
void GrResourceAllocator::reset() { … }
bool GrResourceAllocator::assign() { … }
#if GR_ALLOCATION_SPEW
void GrResourceAllocator::dumpIntervals() {
SkDebugf("------------------------------------------------------------\n");
unsigned int min = std::numeric_limits<unsigned int>::max();
unsigned int max = 0;
for(const Interval* cur = fIntvlList.peekHead(); cur; cur = cur->next()) {
SkDebugf("{ %3d,%3d }: [%2d, %2d] - refProxys:%d surfaceRefs:%d\n",
cur->proxy()->uniqueID().asUInt(),
cur->proxy()->isInstantiated() ? cur->proxy()->underlyingUniqueID().asUInt() : -1,
cur->start(),
cur->end(),
cur->proxy()->priv().getProxyRefCnt(),
cur->proxy()->testingOnly_getBackingRefCnt());
min = std::min(min, cur->start());
max = std::max(max, cur->end());
}
for(const Interval* cur = fIntvlList.peekHead(); cur; cur = cur->next()) {
SkDebugf("{ %3d,%3d }: ",
cur->proxy()->uniqueID().asUInt(),
cur->proxy()->isInstantiated() ? cur->proxy()->underlyingUniqueID().asUInt() : -1);
for (unsigned int i = min; i <= max; ++i) {
if (i >= cur->start() && i <= cur->end()) {
SkDebugf("x");
} else {
SkDebugf(" ");
}
}
SkDebugf("\n");
}
}
#endif