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

Side by Side Diff: ui/gfx/gl/gl_implementation_linux.cc

Issue 7724003: Lock the initialization of the GL bindings. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 9 years, 4 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | 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) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 <vector> 5 #include <vector>
6 6
7 #include "base/base_paths.h" 7 #include "base/base_paths.h"
8 #include "base/command_line.h" 8 #include "base/command_line.h"
9 #include "base/file_path.h" 9 #include "base/file_path.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
11 #include "base/native_library.h" 11 #include "base/native_library.h"
12 #include "base/path_service.h" 12 #include "base/path_service.h"
13 #include "base/synchronization/lock.h"
13 #include "ui/gfx/gl/gl_bindings.h" 14 #include "ui/gfx/gl/gl_bindings.h"
14 #include "ui/gfx/gl/gl_implementation.h" 15 #include "ui/gfx/gl/gl_implementation.h"
15 16
16 namespace gfx { 17 namespace gfx {
17 namespace { 18 namespace {
18 19
19 // TODO(piman): it should be Desktop GL marshalling from double to float. Today 20 // TODO(piman): it should be Desktop GL marshalling from double to float. Today
20 // on native GLES, we do float->double->float. 21 // on native GLES, we do float->double->float.
21 void GL_BINDING_CALL MarshalClearDepthToClearDepthf(GLclampd depth) { 22 void GL_BINDING_CALL MarshalClearDepthToClearDepthf(GLclampd depth) {
22 glClearDepthf(static_cast<GLclampf>(depth)); 23 glClearDepthf(static_cast<GLclampf>(depth));
(...skipping 13 matching lines...) Expand all
36 VLOG(1) << "Failed to load " << filename.MaybeAsASCII() << ": " << error; 37 VLOG(1) << "Failed to load " << filename.MaybeAsASCII() << ": " << error;
37 return NULL; 38 return NULL;
38 } 39 }
39 return library; 40 return library;
40 } 41 }
41 42
42 base::NativeLibrary LoadLibrary(const char* filename) { 43 base::NativeLibrary LoadLibrary(const char* filename) {
43 return LoadLibrary(FilePath(filename)); 44 return LoadLibrary(FilePath(filename));
44 } 45 }
45 46
47 // TODO(backer): Find a more principled (less heavy handed) way to prevent a
48 // race in the bindings initialization.
49 #if defined(TOUCH_UI)
50 base::Lock g_lock;
Ken Russell (switch to Gerrit) 2011/08/25 04:19:54 This isn't legal according to the Google C++ style
51 #endif
52
46 } // namespace anonymous 53 } // namespace anonymous
47 54
48 bool InitializeGLBindings(GLImplementation implementation) { 55 bool InitializeGLBindings(GLImplementation implementation) {
56 #if defined(TOUCH_UI)
57 base::AutoLock locked(g_lock);
58 #endif
49 // Prevent reinitialization with a different implementation. Once the gpu 59 // Prevent reinitialization with a different implementation. Once the gpu
50 // unit tests have initialized with kGLImplementationMock, we don't want to 60 // unit tests have initialized with kGLImplementationMock, we don't want to
51 // later switch to another GL implementation. 61 // later switch to another GL implementation.
52 if (GetGLImplementation() != kGLImplementationNone) 62 if (GetGLImplementation() != kGLImplementationNone)
53 return true; 63 return true;
54 64
55 switch (implementation) { 65 switch (implementation) {
56 #if !defined(USE_WAYLAND) 66 #if !defined(USE_WAYLAND)
57 case kGLImplementationOSMesaGL: { 67 case kGLImplementationOSMesaGL: {
58 FilePath module_path; 68 FilePath module_path;
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
160 void InitializeDebugGLBindings() { 170 void InitializeDebugGLBindings() {
161 InitializeDebugGLBindingsEGL(); 171 InitializeDebugGLBindingsEGL();
162 InitializeDebugGLBindingsGL(); 172 InitializeDebugGLBindingsGL();
163 #if !defined(USE_WAYLAND) 173 #if !defined(USE_WAYLAND)
164 InitializeDebugGLBindingsGLX(); 174 InitializeDebugGLBindingsGLX();
165 InitializeDebugGLBindingsOSMESA(); 175 InitializeDebugGLBindingsOSMESA();
166 #endif 176 #endif
167 } 177 }
168 178
169 } // namespace gfx 179 } // namespace gfx
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698