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

Side by Side Diff: gpu/gles2_conform_support/egl/display.cc

Issue 1714023002: Revert of Only call gles2::Terminate when all Display objects are deleted (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@egl_test_branch
Patch Set: Created 4 years, 10 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 unified diff | Download patch
« no previous file with comments | « gpu/command_buffer/tests/egl_test.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "gpu/gles2_conform_support/egl/display.h" 5 #include "gpu/gles2_conform_support/egl/display.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <vector> 10 #include <vector>
(...skipping 13 matching lines...) Expand all
24 #include "gpu/gles2_conform_support/egl/config.h" 24 #include "gpu/gles2_conform_support/egl/config.h"
25 #include "gpu/gles2_conform_support/egl/surface.h" 25 #include "gpu/gles2_conform_support/egl/surface.h"
26 #include "gpu/gles2_conform_support/egl/test_support.h" 26 #include "gpu/gles2_conform_support/egl/test_support.h"
27 27
28 namespace { 28 namespace {
29 const int32_t kCommandBufferSize = 1024 * 1024; 29 const int32_t kCommandBufferSize = 1024 * 1024;
30 const int32_t kTransferBufferSize = 512 * 1024; 30 const int32_t kTransferBufferSize = 512 * 1024;
31 } 31 }
32 32
33 namespace egl { 33 namespace egl {
34 34 #if defined(COMMAND_BUFFER_GLES_LIB_SUPPORT_ONLY)
35 // egl::Display is used for comformance tests and command_buffer_gles. We only 35 // egl::Display is used for comformance tests and command_buffer_gles. We only
36 // need the exit manager for the command_buffer_gles library. 36 // need the exit manager for the command_buffer_gles library.
37 // TODO(hendrikw): Find a cleaner solution for this. 37 // TODO(hendrikw): Find a cleaner solution for this.
38 namespace { 38 namespace {
39 base::LazyInstance<base::Lock>::Leaky g_init_lock; 39 base::LazyInstance<base::Lock>::Leaky g_exit_manager_lock;
40 int g_init_count; 40 int g_exit_manager_use_count;
41
42 #if defined(COMMAND_BUFFER_GLES_LIB_SUPPORT_ONLY)
43 base::AtExitManager* g_exit_manager; 41 base::AtExitManager* g_exit_manager;
44 #endif 42 void RefAtExitManager() {
45 43 base::AutoLock lock(g_exit_manager_lock.Get());
46 void InitGlobal() {
47 base::AutoLock lock(g_init_lock.Get());
48 if (g_init_count == 0) {
49 gles2::Initialize();
50 }
51
52 #if defined(COMMAND_BUFFER_GLES_LIB_SUPPORT_ONLY)
53 #if defined(COMPONENT_BUILD)
54 if (g_command_buffer_gles_has_atexit_manager) {
55 ++g_init_count;
56 return;
57 }
58 #endif
59 if (g_init_count == 0) {
60 g_exit_manager = new base::AtExitManager;
61 }
62 #endif
63
64 ++g_init_count;
65
66 }
67 void ReleaseGlobal() {
68 base::AutoLock lock(g_init_lock.Get());
69 --g_init_count;
70 if (g_init_count == 0) {
71 gles2::Terminate();
72 }
73
74 #if defined(COMMAND_BUFFER_GLES_LIB_SUPPORT_ONLY)
75 #if defined(COMPONENT_BUILD) 44 #if defined(COMPONENT_BUILD)
76 if (g_command_buffer_gles_has_atexit_manager) { 45 if (g_command_buffer_gles_has_atexit_manager) {
77 return; 46 return;
78 } 47 }
79 #endif 48 #endif
80 if (g_init_count == 0) { 49 if (g_exit_manager_use_count == 0) {
50 g_exit_manager = new base::AtExitManager;
51 }
52 ++g_exit_manager_use_count;
53 }
54 void ReleaseAtExitManager() {
55 base::AutoLock lock(g_exit_manager_lock.Get());
56 #if defined(COMPONENT_BUILD)
57 if (g_command_buffer_gles_has_atexit_manager) {
58 return;
59 }
60 #endif
61 --g_exit_manager_use_count;
62 if (g_exit_manager_use_count == 0) {
81 delete g_exit_manager; 63 delete g_exit_manager;
82 g_exit_manager = nullptr; 64 g_exit_manager = nullptr;
83 } 65 }
66 }
67 }
84 #endif 68 #endif
85 }
86 } // namespace
87
88 69
89 Display::Display(EGLNativeDisplayType display_id) 70 Display::Display(EGLNativeDisplayType display_id)
90 : display_id_(display_id), 71 : display_id_(display_id),
91 is_initialized_(false), 72 is_initialized_(false),
92 create_offscreen_(false), 73 create_offscreen_(false),
93 create_offscreen_width_(0), 74 create_offscreen_width_(0),
94 create_offscreen_height_(0), 75 create_offscreen_height_(0),
95 next_fence_sync_release_(1) { 76 next_fence_sync_release_(1) {
96 77 #if defined(COMMAND_BUFFER_GLES_LIB_SUPPORT_ONLY)
97 InitGlobal(); 78 RefAtExitManager();
98 79 #endif
99 } 80 }
100 81
101 Display::~Display() { 82 Display::~Display() {
102 83 gles2::Terminate();
103 ReleaseGlobal(); 84 #if defined(COMMAND_BUFFER_GLES_LIB_SUPPORT_ONLY)
104 85 ReleaseAtExitManager();
86 #endif
105 } 87 }
106 88
107 bool Display::Initialize() { 89 bool Display::Initialize() {
90 gles2::Initialize();
108 is_initialized_ = true; 91 is_initialized_ = true;
109 return true; 92 return true;
110 } 93 }
111 94
112 bool Display::IsValidConfig(EGLConfig config) { 95 bool Display::IsValidConfig(EGLConfig config) {
113 return (config != NULL) && (config == config_.get()); 96 return (config != NULL) && (config == config_.get());
114 } 97 }
115 98
116 bool Display::ChooseConfigs(EGLConfig* configs, 99 bool Display::ChooseConfigs(EGLConfig* configs,
117 EGLint config_size, 100 EGLint config_size,
(...skipping 295 matching lines...) Expand 10 before | Expand all | Expand 10 after
413 void Display::SignalSyncToken(const gpu::SyncToken& sync_token, 396 void Display::SignalSyncToken(const gpu::SyncToken& sync_token,
414 const base::Closure& callback) { 397 const base::Closure& callback) {
415 NOTIMPLEMENTED(); 398 NOTIMPLEMENTED();
416 } 399 }
417 400
418 bool Display::CanWaitUnverifiedSyncToken(const gpu::SyncToken* sync_token) { 401 bool Display::CanWaitUnverifiedSyncToken(const gpu::SyncToken* sync_token) {
419 return false; 402 return false;
420 } 403 }
421 404
422 } // namespace egl 405 } // namespace egl
OLDNEW
« no previous file with comments | « gpu/command_buffer/tests/egl_test.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698