Index: gpu/gles2_conform_support/egl/display.cc |
diff --git a/gpu/gles2_conform_support/egl/display.cc b/gpu/gles2_conform_support/egl/display.cc |
index 6152408876763fd1e4d80e8510f8a858da11a2c4..2603e4a3840eced1d9695a2f45a6b3ee246a9a51 100644 |
--- a/gpu/gles2_conform_support/egl/display.cc |
+++ b/gpu/gles2_conform_support/egl/display.cc |
@@ -29,21 +29,49 @@ const int32_t kTransferBufferSize = 512 * 1024; |
} |
namespace egl { |
+#if defined(COMMAND_BUFFER_GLES_LIB_SUPPORT_ONLY) |
+// elg::Display is used for comformance tests and command_buffer_gles. We only |
piman
2016/01/21 20:30:47
nit: typo elg->egl
Kimmo Kinnunen
2016/01/22 06:53:30
Done.
|
+// need the exit manager for the command_buffer_gles library. |
+// TODO(hendrikw): Find a cleaner solution for this. |
+namespace { |
+base::Lock g_exit_manager_lock; |
piman
2016/01/21 20:30:47
We don't allow non-POD globals per style (causes g
Kimmo Kinnunen
2016/01/22 06:53:30
Done.
|
+int g_exit_manager_use_count; |
+base::AtExitManager* g_exit_manager; |
+void RefAtExitManager() { |
+ base::AutoLock lock(g_exit_manager_lock); |
+ if (g_exit_manager_use_count == 0) { |
+ g_exit_manager = new base::AtExitManager; |
+ } |
+ ++g_exit_manager_use_count; |
+} |
+void ReleaseAtExitManager() { |
+ base::AutoLock lock(g_exit_manager_lock); |
+ --g_exit_manager_use_count; |
+ if (g_exit_manager_use_count == 0) { |
+ delete g_exit_manager; |
+ g_exit_manager = nullptr; |
+ } |
+} |
+} |
+#endif |
Display::Display(EGLNativeDisplayType display_id) |
: display_id_(display_id), |
is_initialized_(false), |
-#if defined(COMMAND_BUFFER_GLES_LIB_SUPPORT_ONLY) |
- exit_manager_(new base::AtExitManager), |
-#endif |
create_offscreen_(false), |
create_offscreen_width_(0), |
create_offscreen_height_(0), |
next_fence_sync_release_(1) { |
+#if defined(COMMAND_BUFFER_GLES_LIB_SUPPORT_ONLY) |
+ RefAtExitManager(); |
+#endif |
} |
Display::~Display() { |
gles2::Terminate(); |
+#if defined(COMMAND_BUFFER_GLES_LIB_SUPPORT_ONLY) |
+ ReleaseAtExitManager(); |
+#endif |
} |
bool Display::Initialize() { |