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

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>
(...skipping 11 matching lines...) Expand all
22 #include "gpu/command_buffer/service/valuebuffer_manager.h" 22 #include "gpu/command_buffer/service/valuebuffer_manager.h"
23 #include "gpu/gles2_conform_support/egl/config.h" 23 #include "gpu/gles2_conform_support/egl/config.h"
24 #include "gpu/gles2_conform_support/egl/surface.h" 24 #include "gpu/gles2_conform_support/egl/surface.h"
25 25
26 namespace { 26 namespace {
27 const int32_t kCommandBufferSize = 1024 * 1024; 27 const int32_t kCommandBufferSize = 1024 * 1024;
28 const int32_t kTransferBufferSize = 512 * 1024; 28 const int32_t kTransferBufferSize = 512 * 1024;
29 } 29 }
30 30
31 namespace egl { 31 namespace egl {
32 #if defined(COMMAND_BUFFER_GLES_LIB_SUPPORT_ONLY)
33 // 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.
34 // need the exit manager for the command_buffer_gles library.
35 // TODO(hendrikw): Find a cleaner solution for this.
36 namespace {
37 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.
38 int g_exit_manager_use_count;
39 base::AtExitManager* g_exit_manager;
40 void RefAtExitManager() {
41 base::AutoLock lock(g_exit_manager_lock);
42 if (g_exit_manager_use_count == 0) {
43 g_exit_manager = new base::AtExitManager;
44 }
45 ++g_exit_manager_use_count;
46 }
47 void ReleaseAtExitManager() {
48 base::AutoLock lock(g_exit_manager_lock);
49 --g_exit_manager_use_count;
50 if (g_exit_manager_use_count == 0) {
51 delete g_exit_manager;
52 g_exit_manager = nullptr;
53 }
54 }
55 }
56 #endif
32 57
33 Display::Display(EGLNativeDisplayType display_id) 58 Display::Display(EGLNativeDisplayType display_id)
34 : display_id_(display_id), 59 : display_id_(display_id),
35 is_initialized_(false), 60 is_initialized_(false),
36 #if defined(COMMAND_BUFFER_GLES_LIB_SUPPORT_ONLY)
37 exit_manager_(new base::AtExitManager),
38 #endif
39 create_offscreen_(false), 61 create_offscreen_(false),
40 create_offscreen_width_(0), 62 create_offscreen_width_(0),
41 create_offscreen_height_(0), 63 create_offscreen_height_(0),
42 next_fence_sync_release_(1) { 64 next_fence_sync_release_(1) {
65 #if defined(COMMAND_BUFFER_GLES_LIB_SUPPORT_ONLY)
66 RefAtExitManager();
67 #endif
43 } 68 }
44 69
45 Display::~Display() { 70 Display::~Display() {
46 gles2::Terminate(); 71 gles2::Terminate();
72 #if defined(COMMAND_BUFFER_GLES_LIB_SUPPORT_ONLY)
73 ReleaseAtExitManager();
74 #endif
47 } 75 }
48 76
49 bool Display::Initialize() { 77 bool Display::Initialize() {
50 gles2::Initialize(); 78 gles2::Initialize();
51 is_initialized_ = true; 79 is_initialized_ = true;
52 return true; 80 return true;
53 } 81 }
54 82
55 bool Display::IsValidConfig(EGLConfig config) { 83 bool Display::IsValidConfig(EGLConfig config) {
56 return (config != NULL) && (config == config_.get()); 84 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, 403 void Display::SignalSyncToken(const gpu::SyncToken& sync_token,
376 const base::Closure& callback) { 404 const base::Closure& callback) {
377 NOTIMPLEMENTED(); 405 NOTIMPLEMENTED();
378 } 406 }
379 407
380 bool Display::CanWaitUnverifiedSyncToken(const gpu::SyncToken* sync_token) { 408 bool Display::CanWaitUnverifiedSyncToken(const gpu::SyncToken* sync_token) {
381 return false; 409 return false;
382 } 410 }
383 411
384 } // namespace egl 412 } // 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