Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(18)

Unified Diff: tools/VisualBench/VisualBench.cpp

Issue 1416063002: Force VisualBench to reset GLContext on GrContext reset (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: tweaks Created 5 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « tools/VisualBench/VisualBench.h ('k') | tools/VisualBench/VisualStreamTimingModule.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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));
« no previous file with comments | « tools/VisualBench/VisualBench.h ('k') | tools/VisualBench/VisualStreamTimingModule.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698