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

This commit is contained in:
Matej Knopp
2021-04-08 23:44:02 +02:00
committed by GitHub
parent 479283fe6e
commit 8b818c63b9
2 changed files with 12 additions and 1 deletions

View File

@@ -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;
}
}

View File

@@ -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