未验证 提交 994531d3 编写于 作者: M Matej Knopp 提交者: GitHub

Windows: Only terminate display for last instance (#25477)

上级 134f0a69
......@@ -26,6 +26,8 @@ static void LogEglError(std::string message) {
namespace flutter {
int AngleSurfaceManager::instance_count_ = 0;
std::unique_ptr<AngleSurfaceManager> AngleSurfaceManager::Create() {
std::unique_ptr<AngleSurfaceManager> manager;
manager.reset(new AngleSurfaceManager());
......@@ -40,10 +42,12 @@ AngleSurfaceManager::AngleSurfaceManager()
egl_display_(EGL_NO_DISPLAY),
egl_context_(EGL_NO_CONTEXT) {
initialize_succeeded_ = Initialize();
++instance_count_;
}
AngleSurfaceManager::~AngleSurfaceManager() {
CleanUp();
--instance_count_;
}
bool AngleSurfaceManager::InitializeEGL(
......@@ -200,7 +204,11 @@ void AngleSurfaceManager::CleanUp() {
}
if (egl_display_ != EGL_NO_DISPLAY) {
eglTerminate(egl_display_);
// Display is reused between instances so only terminate display
// if destroying last instance
if (instance_count_ == 1) {
eglTerminate(egl_display_);
}
egl_display_ = EGL_NO_DISPLAY;
}
}
......
......@@ -107,6 +107,9 @@ class AngleSurfaceManager {
// Requested dimensions for current surface
EGLint surface_width_ = 0;
EGLint surface_height_ = 0;
// Number of active instances of AngleSurfaceManager
static int instance_count_;
};
} // namespace flutter
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册