Make the GrSmallPathAtlasMgr a flush-time object
This will allow the small path renderer to be used w/ DDLs.
This is broken out of the omnibus CL:
https://skia-review.googlesource.com/c/skia/+/307776 (Split the small path renderer into record-time and flush-time pieces)
Bug: 1108408
Change-Id: I64cc6ff677d0aead7cf2f097c0e7fbb15b49d49d
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/309304
Reviewed-by: Brian Salomon <bsalomon@google.com>
Commit-Queue: Robert Phillips <robertphillips@google.com>
diff --git a/src/gpu/GrDirectContext.cpp b/src/gpu/GrDirectContext.cpp
index 4ae1831..6f04a5f 100644
--- a/src/gpu/GrDirectContext.cpp
+++ b/src/gpu/GrDirectContext.cpp
@@ -59,16 +59,25 @@
void GrDirectContext::abandonContext() {
INHERITED::abandonContext();
+ if (fSmallPathAtlasMgr) {
+ fSmallPathAtlasMgr->reset();
+ }
fAtlasManager->freeAll();
}
void GrDirectContext::releaseResourcesAndAbandonContext() {
INHERITED::releaseResourcesAndAbandonContext();
+ if (fSmallPathAtlasMgr) {
+ fSmallPathAtlasMgr->reset();
+ }
fAtlasManager->freeAll();
}
void GrDirectContext::freeGpuResources() {
this->flushAndSubmit();
+ if (fSmallPathAtlasMgr) {
+ fSmallPathAtlasMgr->reset();
+ }
fAtlasManager->freeAll();
INHERITED::freeGpuResources();
@@ -115,8 +124,17 @@
}
GrSmallPathAtlasMgr* GrDirectContext::onGetSmallPathAtlasMgr() {
- // The small path renderer atlas will be created here
- return nullptr;
+ if (!fSmallPathAtlasMgr) {
+ fSmallPathAtlasMgr = std::make_unique<GrSmallPathAtlasMgr>();
+
+ this->priv().addOnFlushCallbackObject(fSmallPathAtlasMgr.get());
+ }
+
+ if (!fSmallPathAtlasMgr->initAtlas(this->proxyProvider(), this->caps())) {
+ return nullptr;
+ }
+
+ return fSmallPathAtlasMgr.get();
}
#ifdef SK_GL