aboutsummaryrefslogtreecommitdiffhomepage
path: root/tools
diff options
context:
space:
mode:
authorGravatar joshualitt <joshualitt@chromium.org>2015-10-21 08:04:24 -0700
committerGravatar Commit bot <commit-bot@chromium.org>2015-10-21 08:04:24 -0700
commitfb02cdafda5781acdb3a3e12073809d208d05b6a (patch)
treeaa0681cec7a3fdd41a1d13026c1e88678aae0f8d /tools
parentb64b195dbde1b3854ab8285c1db2c3b1fb217971 (diff)
Force VisualBench to reset GLContext on GrContext reset
Diffstat (limited to 'tools')
-rw-r--r--tools/VisualBench/VisualBench.cpp30
-rw-r--r--tools/VisualBench/VisualBench.h2
-rw-r--r--tools/VisualBench/VisualStreamTimingModule.cpp4
3 files changed, 29 insertions, 7 deletions
diff --git a/tools/VisualBench/VisualBench.cpp b/tools/VisualBench/VisualBench.cpp
index 9cc2ec1c3b..893dba6ab3 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();
+ fContext.reset();
+ fSurface.reset();
+ fInterface.reset();
+ this->detach();
+ }
+}
+
void VisualBench::setupRenderTarget() {
if (fContext) {
fRenderTarget.reset(this->renderTarget(fAttachmentInfo, fInterface, fContext));
diff --git a/tools/VisualBench/VisualBench.h b/tools/VisualBench/VisualBench.h
index c1f61d9519..1920a52b2b 100644
--- a/tools/VisualBench/VisualBench.h
+++ b/tools/VisualBench/VisualBench.h
@@ -48,6 +48,8 @@ private:
void resetContext();
void setupRenderTarget();
bool onHandleChar(SkUnichar unichar) override;
+ void tearDownContext();
+ void setupContext();
// support framework
SkAutoTDelete<VisualModule> fModule;
diff --git a/tools/VisualBench/VisualStreamTimingModule.cpp b/tools/VisualBench/VisualStreamTimingModule.cpp
index 0a57e67221..cecc5acca7 100644
--- a/tools/VisualBench/VisualStreamTimingModule.cpp
+++ b/tools/VisualBench/VisualStreamTimingModule.cpp
@@ -19,10 +19,12 @@ VisualStreamTimingModule::VisualStreamTimingModule(VisualBench* owner, bool preW
inline void VisualStreamTimingModule::handleInitState(SkCanvas* canvas) {
switch (fInitState) {
case kNewBenchmark_InitState:
- fOwner->clear(canvas, SK_ColorWHITE, 2);
fBenchmarkStream->current()->delayedSetup();
// fallthrough
case kReset_InitState:
+ // This will flicker unfortunately, but as we are reseting the GLContext each bench,
+ // we unfortunately don't have a choice
+ fOwner->clear(canvas, SK_ColorWHITE, 2);
fBenchmarkStream->current()->preTimingHooks(canvas);
break;
case kNone_InitState: