| 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 e5cc1178bcdef3223e5c53f4b6fdb5e53b7f0e33..bf63108662beb6f4b25b7e14e37bc10084b8b783 100644
|
| --- a/gpu/gles2_conform_support/egl/display.cc
|
| +++ b/gpu/gles2_conform_support/egl/display.cc
|
| @@ -31,60 +31,41 @@
|
| }
|
|
|
| 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_init_lock;
|
| -int g_init_count;
|
| -
|
| -#if defined(COMMAND_BUFFER_GLES_LIB_SUPPORT_ONLY)
|
| +base::LazyInstance<base::Lock>::Leaky g_exit_manager_lock;
|
| +int g_exit_manager_use_count;
|
| base::AtExitManager* g_exit_manager;
|
| -#endif
|
| -
|
| -void InitGlobal() {
|
| - base::AutoLock lock(g_init_lock.Get());
|
| - if (g_init_count == 0) {
|
| - gles2::Initialize();
|
| - }
|
| -
|
| -#if defined(COMMAND_BUFFER_GLES_LIB_SUPPORT_ONLY)
|
| -#if defined(COMPONENT_BUILD)
|
| - if (g_command_buffer_gles_has_atexit_manager) {
|
| - ++g_init_count;
|
| - return;
|
| - }
|
| -#endif
|
| - if (g_init_count == 0) {
|
| - g_exit_manager = new base::AtExitManager;
|
| - }
|
| -#endif
|
| -
|
| - ++g_init_count;
|
| -
|
| -}
|
| -void ReleaseGlobal() {
|
| - base::AutoLock lock(g_init_lock.Get());
|
| - --g_init_count;
|
| - if (g_init_count == 0) {
|
| - gles2::Terminate();
|
| - }
|
| -
|
| -#if defined(COMMAND_BUFFER_GLES_LIB_SUPPORT_ONLY)
|
| +void RefAtExitManager() {
|
| + base::AutoLock lock(g_exit_manager_lock.Get());
|
| #if defined(COMPONENT_BUILD)
|
| if (g_command_buffer_gles_has_atexit_manager) {
|
| return;
|
| }
|
| #endif
|
| - if (g_init_count == 0) {
|
| + 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());
|
| +#if defined(COMPONENT_BUILD)
|
| + if (g_command_buffer_gles_has_atexit_manager) {
|
| + return;
|
| + }
|
| +#endif
|
| + --g_exit_manager_use_count;
|
| + if (g_exit_manager_use_count == 0) {
|
| delete g_exit_manager;
|
| g_exit_manager = nullptr;
|
| }
|
| +}
|
| +}
|
| #endif
|
| -}
|
| -} // namespace
|
| -
|
|
|
| Display::Display(EGLNativeDisplayType display_id)
|
| : display_id_(display_id),
|
| @@ -93,18 +74,20 @@
|
| create_offscreen_width_(0),
|
| create_offscreen_height_(0),
|
| next_fence_sync_release_(1) {
|
| -
|
| - InitGlobal();
|
| -
|
| +#if defined(COMMAND_BUFFER_GLES_LIB_SUPPORT_ONLY)
|
| + RefAtExitManager();
|
| +#endif
|
| }
|
|
|
| Display::~Display() {
|
| -
|
| - ReleaseGlobal();
|
| -
|
| + gles2::Terminate();
|
| +#if defined(COMMAND_BUFFER_GLES_LIB_SUPPORT_ONLY)
|
| + ReleaseAtExitManager();
|
| +#endif
|
| }
|
|
|
| bool Display::Initialize() {
|
| + gles2::Initialize();
|
| is_initialized_ = true;
|
| return true;
|
| }
|
|
|