Add GrContext::releaseAndAbandonContext()
Like abandonContext() this disconnects the GrContext from the underlying 3D API. However, unlike abandonContext it first frees all allocated GPU resources.
BUG=skia:5142
GOLD_TRYBOT_URL= https://gold.skia.org/search2?unt=true&query=source_type%3Dgm&master=false&issue=1852733002
Review URL: https://codereview.chromium.org/1852733002
diff --git a/tools/gpu/GrContextFactory.cpp b/tools/gpu/GrContextFactory.cpp
index bae73a4..c232121 100755
--- a/tools/gpu/GrContextFactory.cpp
+++ b/tools/gpu/GrContextFactory.cpp
@@ -63,6 +63,17 @@
}
}
+void GrContextFactory::releaseResourcesAndAbandonContexts() {
+ for (Context& context : fContexts) {
+ if (context.fGLContext) {
+ context.fGLContext->makeCurrent();
+ context.fGrContext->releaseResourcesAndAbandonContext();
+ delete(context.fGLContext);
+ context.fGLContext = nullptr;
+ }
+ }
+}
+
GrContextFactory::ContextInfo GrContextFactory::getContextInfo(GLContextType type,
GLContextOptions options) {
for (int i = 0; i < fContexts.count(); ++i) {