Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(199)

Unified Diff: gpu/gles2_conform_support/egl/display.cc

Issue 1617653003: command_buffer_gles2: Avoid creating multiple AtExitManagers (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « gpu/gles2_conform_support/egl/display.h ('k') | gpu/gles2_conform_support/egl/egl.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..c6ea7d80854cbba389ce3ae0a67df02bef299829 100644
--- a/gpu/gles2_conform_support/egl/display.cc
+++ b/gpu/gles2_conform_support/egl/display.cc
@@ -11,6 +11,7 @@
#include "base/at_exit.h"
#include "base/bind.h"
#include "base/bind_helpers.h"
+#include "base/lazy_instance.h"
#include "gpu/command_buffer/client/gles2_implementation.h"
#include "gpu/command_buffer/client/gles2_lib.h"
#include "gpu/command_buffer/client/transfer_buffer.h"
@@ -29,21 +30,49 @@ const int32_t kTransferBufferSize = 512 * 1024;
}
namespace egl {
+#if defined(COMMAND_BUFFER_GLES_LIB_SUPPORT_ONLY)
+// egl::Display is used for comformance tests and command_buffer_gles. We only
+// need the exit manager for the command_buffer_gles library.
+// TODO(hendrikw): Find a cleaner solution for this.
+namespace {
+base::LazyInstance<base::Lock>::Leaky g_exit_manager_lock;
+int g_exit_manager_use_count;
+base::AtExitManager* g_exit_manager;
+void RefAtExitManager() {
+ base::AutoLock lock(g_exit_manager_lock.Get());
+ 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.Get());
+ --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() {
« no previous file with comments | « gpu/gles2_conform_support/egl/display.h ('k') | gpu/gles2_conform_support/egl/egl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698