File tree Expand file tree Collapse file tree
engine/src/flutter/impeller/playground Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -83,7 +83,9 @@ std::string PlaygroundBackendToString(PlaygroundBackend backend) {
8383 FML_UNREACHABLE ();
8484}
8585
86- static void InitializeGLFWOnce () {
86+ std::atomic<bool > Playground::glfw_initialized_ = false ;
87+
88+ void Playground::InitializeGLFWOnce () {
8789 // This guard is a hack to work around a problem where glfwCreateWindow
8890 // hangs when opening a second window after GLFW has been reinitialized (for
8991 // example, when flipping through multiple playground tests).
@@ -106,9 +108,16 @@ static void InitializeGLFWOnce() {
106108 FML_LOG (ERROR ) << " GLFW Error '" << description << " ' (" << code << " )." ;
107109 });
108110 FML_CHECK (::glfwInit () == GLFW_TRUE );
111+ glfw_initialized_ = true ;
109112 });
110113}
111114
115+ void Playground::OnTearDownTestEnvironment () {
116+ if (glfw_initialized_) {
117+ ::glfwTerminate ();
118+ }
119+ }
120+
112121testing::GoldenDigestManager* Playground::GetGoldenDigestManager () const {
113122 return nullptr ;
114123}
Original file line number Diff line number Diff line change 55#ifndef FLUTTER_IMPELLER_PLAYGROUND_PLAYGROUND_H_
66#define FLUTTER_IMPELLER_PLAYGROUND_PLAYGROUND_H_
77
8+ #include < atomic>
89#include < chrono>
910#include < memory>
1011
@@ -47,6 +48,8 @@ class Playground {
4748
4849 virtual ~Playground ();
4950
51+ static void OnTearDownTestEnvironment ();
52+
5053 static bool ShouldOpenNewPlaygrounds ();
5154
5255 bool IsPlaygroundEnabled () const ;
@@ -197,6 +200,9 @@ class Playground {
197200 virtual testing::GoldenDigestManager* GetGoldenDigestManager () const ;
198201
199202 private:
203+ static void InitializeGLFWOnce ();
204+ static std::atomic<bool > glfw_initialized_;
205+
200206 const PlaygroundBackend backend_;
201207 PlaygroundSwitches switches_;
202208
Original file line number Diff line number Diff line change @@ -115,6 +115,7 @@ class PlaygroundTestEnvironment : public ::testing::Environment {
115115 golden_manager_.reset ();
116116 }
117117 PlaygroundImpl::OnTearDownTestEnvironment ();
118+ Playground::OnTearDownTestEnvironment ();
118119 }
119120
120121 static testing::GoldenDigestManager* GetGoldenDigestManager () {
You can’t perform that action at this time.
0 commit comments