Give GrResourceAllocator a GrDirectContext
This allows it to access the resource cache as well as the provider,
and paves the way for memory budgeting inside the resource allocator.
Bug: skia:10877
Change-Id: I01e9c02e445494ac431b288f41006ae7360ff791
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/394116
Auto-Submit: Adlai Holler <adlai@google.com>
Commit-Queue: Robert Phillips <robertphillips@google.com>
Reviewed-by: Robert Phillips <robertphillips@google.com>
diff --git a/src/gpu/GrResourceAllocator.cpp b/src/gpu/GrResourceAllocator.cpp
index f5a48fa..9efdebf 100644
--- a/src/gpu/GrResourceAllocator.cpp
+++ b/src/gpu/GrResourceAllocator.cpp
@@ -7,6 +7,7 @@
#include "src/gpu/GrResourceAllocator.h"
+#include "src/gpu/GrDirectContextPriv.h"
#include "src/gpu/GrGpuResourcePriv.h"
#include "src/gpu/GrOpsTask.h"
#include "src/gpu/GrRenderTargetProxy.h"
@@ -56,7 +57,8 @@
// recycled. We don't need to assign a texture to it and no other proxy can be instantiated
// with the same texture.
if (proxy->readOnly()) {
- if (proxy->isLazy() && !proxy->priv().doLazyInstantiation(fResourceProvider)) {
+ auto resourceProvider = fDContext->priv().resourceProvider();
+ if (proxy->isLazy() && !proxy->priv().doLazyInstantiation(resourceProvider)) {
fFailedInstantiation = true;
} else {
// Since we aren't going to add an interval we won't revisit this proxy in assign(). So
@@ -262,7 +264,7 @@
// Then look in the free pool
GrScratchKey scratchKey;
- proxy->priv().computeScratchKey(*fResourceProvider->caps(), &scratchKey);
+ proxy->priv().computeScratchKey(*fDContext->priv().caps(), &scratchKey);
auto filter = [] (const Register* r) {
return true;
@@ -282,7 +284,7 @@
SkASSERT(!intvl->next());
Register* r = intvl->getRegister();
- if (r && r->isRecyclable(*fResourceProvider->caps(), intvl->proxy(), intvl->uses())) {
+ if (r && r->isRecyclable(*fDContext->priv().caps(), intvl->proxy(), intvl->uses())) {
#if GR_ALLOCATION_SPEW
SkDebugf("putting register %d back into pool\n", r->uniqueID());
#endif
@@ -337,6 +339,7 @@
// instantiating anything.
// Instantiate surfaces
+ auto resourceProvider = fDContext->priv().resourceProvider();
while (Interval* cur = fFinishedIntvls.popHead()) {
if (fFailedInstantiation) {
break;
@@ -345,12 +348,12 @@
continue;
}
if (cur->proxy()->isLazy()) {
- fFailedInstantiation = !cur->proxy()->priv().doLazyInstantiation(fResourceProvider);
+ fFailedInstantiation = !cur->proxy()->priv().doLazyInstantiation(resourceProvider);
continue;
}
Register* r = cur->getRegister();
SkASSERT(r);
- fFailedInstantiation = !r->instantiateSurface(cur->proxy(), fResourceProvider);
+ fFailedInstantiation = !r->instantiateSurface(cur->proxy(), resourceProvider);
}
return !fFailedInstantiation;
}