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

Side by Side 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 unified diff | 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 »
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>
11 #include "base/at_exit.h" 11 #include "base/at_exit.h"
12 #include "base/bind.h" 12 #include "base/bind.h"
13 #include "base/bind_helpers.h" 13 #include "base/bind_helpers.h"
14 #include "base/lazy_instance.h"
14 #include "gpu/command_buffer/client/gles2_implementation.h" 15 #include "gpu/command_buffer/client/gles2_implementation.h"
15 #include "gpu/command_buffer/client/gles2_lib.h" 16 #include "gpu/command_buffer/client/gles2_lib.h"
16 #include "gpu/command_buffer/client/transfer_buffer.h" 17 #include "gpu/command_buffer/client/transfer_buffer.h"
17 #include "gpu/command_buffer/common/value_state.h" 18 #include "gpu/command_buffer/common/value_state.h"
18 #include "gpu/command_buffer/service/context_group.h" 19 #include "gpu/command_buffer/service/context_group.h"
19 #include "gpu/command_buffer/service/mailbox_manager.h" 20 #include "gpu/command_buffer/service/mailbox_manager.h"
20 #include "gpu/command_buffer/service/memory_tracking.h" 21 #include "gpu/command_buffer/service/memory_tracking.h"
21 #include "gpu/command_buffer/service/transfer_buffer_manager.h" 22 #include "gpu/command_buffer/service/transfer_buffer_manager.h"
22 #include "gpu/command_buffer/service/valuebuffer_manager.h" 23 #include "gpu/command_buffer/service/valuebuffer_manager.h"
23 #include "gpu/gles2_conform_support/egl/config.h" 24 #include "gpu/gles2_conform_support/egl/config.h"
24 #include "gpu/gles2_conform_support/egl/surface.h" 25 #include "gpu/gles2_conform_support/egl/surface.h"
25 26
26 namespace { 27 namespace {
27 const int32_t kCommandBufferSize = 1024 * 1024; 28 const int32_t kCommandBufferSize = 1024 * 1024;
28 const int32_t kTransferBufferSize = 512 * 1024; 29 const int32_t kTransferBufferSize = 512 * 1024;
29 } 30 }
30 31
31 namespace egl { 32 namespace egl {
33 #if defined(COMMAND_BUFFER_GLES_LIB_SUPPORT_ONLY)
34 // egl::Display is used for comformance tests and command_buffer_gles. We only
35 // need the exit manager for the command_buffer_gles library.
36 // TODO(hendrikw): Find a cleaner solution for this.
37 namespace {
38 base::LazyInstance<base::Lock>::Leaky g_exit_manager_lock;
39 int g_exit_manager_use_count;
40 base::AtExitManager* g_exit_manager;
41 void RefAtExitManager() {
42 base::AutoLock lock(g_exit_manager_lock.Get());
43 if (g_exit_manager_use_count == 0) {
44 g_exit_manager = new base::AtExitManager;
45 }
46 ++g_exit_manager_use_count;
47 }
48 void ReleaseAtExitManager() {
49 base::AutoLock lock(g_exit_manager_lock.Get());
50 --g_exit_manager_use_count;
51 if (g_exit_manager_use_count == 0) {
52 delete g_exit_manager;
53 g_exit_manager = nullptr;
54 }
55 }
56 }
57 #endif
32 58
33 Display::Display(EGLNativeDisplayType display_id) 59 Display::Display(EGLNativeDisplayType display_id)
34 : display_id_(display_id), 60 : display_id_(display_id),
35 is_initialized_(false), 61 is_initialized_(false),
36 #if defined(COMMAND_BUFFER_GLES_LIB_SUPPORT_ONLY)
37 exit_manager_(new base::AtExitManager),
38 #endif
39 create_offscreen_(false), 62 create_offscreen_(false),
40 create_offscreen_width_(0), 63 create_offscreen_width_(0),
41 create_offscreen_height_(0), 64 create_offscreen_height_(0),
42 next_fence_sync_release_(1) { 65 next_fence_sync_release_(1) {
66 #if defined(COMMAND_BUFFER_GLES_LIB_SUPPORT_ONLY)
67 RefAtExitManager();
68 #endif
43 } 69 }
44 70
45 Display::~Display() { 71 Display::~Display() {
46 gles2::Terminate(); 72 gles2::Terminate();
73 #if defined(COMMAND_BUFFER_GLES_LIB_SUPPORT_ONLY)
74 ReleaseAtExitManager();
75 #endif
47 } 76 }
48 77
49 bool Display::Initialize() { 78 bool Display::Initialize() {
50 gles2::Initialize(); 79 gles2::Initialize();
51 is_initialized_ = true; 80 is_initialized_ = true;
52 return true; 81 return true;
53 } 82 }
54 83
55 bool Display::IsValidConfig(EGLConfig config) { 84 bool Display::IsValidConfig(EGLConfig config) {
56 return (config != NULL) && (config == config_.get()); 85 return (config != NULL) && (config == config_.get());
(...skipping 318 matching lines...) Expand 10 before | Expand all | Expand 10 after
375 void Display::SignalSyncToken(const gpu::SyncToken& sync_token, 404 void Display::SignalSyncToken(const gpu::SyncToken& sync_token,
376 const base::Closure& callback) { 405 const base::Closure& callback) {
377 NOTIMPLEMENTED(); 406 NOTIMPLEMENTED();
378 } 407 }
379 408
380 bool Display::CanWaitUnverifiedSyncToken(const gpu::SyncToken* sync_token) { 409 bool Display::CanWaitUnverifiedSyncToken(const gpu::SyncToken* sync_token) {
381 return false; 410 return false;
382 } 411 }
383 412
384 } // namespace egl 413 } // namespace egl
OLDNEW
« 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