Index: tools/VisualBench/VisualBench.cpp |
diff --git a/tools/VisualBench/VisualBench.cpp b/tools/VisualBench/VisualBench.cpp |
index 9cc2ec1c3bcd5941421c0abfe97eca8bf7064e60..893dba6ab3ff9741207654664716d90da69d60c6 100644 |
--- a/tools/VisualBench/VisualBench.cpp |
+++ b/tools/VisualBench/VisualBench.cpp |
@@ -40,7 +40,7 @@ VisualBench::VisualBench(void* hwnd, int argc, char** argv) |
} |
VisualBench::~VisualBench() { |
- INHERITED::detach(); |
+ this->tearDownContext(); |
} |
void VisualBench::setTitle() { |
@@ -68,18 +68,25 @@ bool VisualBench::setupBackend() { |
SkDebugf("Could not go fullscreen!"); |
} |
} |
+ |
+ this->resetContext(); |
+ return true; |
+} |
+ |
+void VisualBench::resetContext() { |
+ this->tearDownContext(); |
+ this->setupContext(); |
+} |
+ |
+void VisualBench::setupContext() { |
if (!this->attach(kNativeGL_BackEndType, FLAGS_msaa, &fAttachmentInfo)) { |
SkDebugf("Not possible to create backend.\n"); |
INHERITED::detach(); |
- return false; |
+ SkFAIL("Could not create backend\n"); |
} |
this->setVsync(false); |
- this->resetContext(); |
- return true; |
-} |
-void VisualBench::resetContext() { |
fSurface.reset(nullptr); |
fInterface.reset(GrGLCreateNativeInterface()); |
@@ -98,6 +105,17 @@ void VisualBench::resetContext() { |
this->setupRenderTarget(); |
} |
+void VisualBench::tearDownContext() { |
+ if (fContext) { |
+ // We abandon the context in case SkWindow has kept a ref to the surface |
+ fContext->abandonContext(); |
bsalomon
2015/10/21 14:52:05
It'd be really nice to refactor SkOSWindow a littl
|
+ fContext.reset(); |
+ fSurface.reset(); |
+ fInterface.reset(); |
+ this->detach(); |
+ } |
+} |
+ |
void VisualBench::setupRenderTarget() { |
if (fContext) { |
fRenderTarget.reset(this->renderTarget(fAttachmentInfo, fInterface, fContext)); |