OLD | NEW |
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 <vector> | 5 #include <vector> |
6 | 6 |
7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
8 #include "base/logging.h" | 8 #include "base/logging.h" |
9 #include "base/threading/thread_restrictions.h" | 9 #include "base/threading/thread_restrictions.h" |
10 #include "ui/gl/gl_bindings.h" | 10 #include "ui/gl/gl_bindings.h" |
(...skipping 25 matching lines...) Expand all Loading... |
36 void GetAllowedGLImplementations(std::vector<GLImplementation>* impls) { | 36 void GetAllowedGLImplementations(std::vector<GLImplementation>* impls) { |
37 impls->push_back(kGLImplementationDesktopGL); | 37 impls->push_back(kGLImplementationDesktopGL); |
38 impls->push_back(kGLImplementationEGLGLES2); | 38 impls->push_back(kGLImplementationEGLGLES2); |
39 impls->push_back(kGLImplementationOSMesaGL); | 39 impls->push_back(kGLImplementationOSMesaGL); |
40 } | 40 } |
41 | 41 |
42 bool InitializeStaticGLBindings(GLImplementation implementation) { | 42 bool InitializeStaticGLBindings(GLImplementation implementation) { |
43 // Prevent reinitialization with a different implementation. Once the gpu | 43 // Prevent reinitialization with a different implementation. Once the gpu |
44 // unit tests have initialized with kGLImplementationMock, we don't want to | 44 // unit tests have initialized with kGLImplementationMock, we don't want to |
45 // later switch to another GL implementation. | 45 // later switch to another GL implementation. |
46 if (GetGLImplementation() != kGLImplementationNone) | 46 DCHECK_EQ(kGLImplementationNone, GetGLImplementation()); |
47 return true; | |
48 | 47 |
49 // Allow the main thread or another to initialize these bindings | 48 // Allow the main thread or another to initialize these bindings |
50 // after instituting restrictions on I/O. Going forward they will | 49 // after instituting restrictions on I/O. Going forward they will |
51 // likely be used in the browser process on most platforms. The | 50 // likely be used in the browser process on most platforms. The |
52 // one-time initialization cost is small, between 2 and 5 ms. | 51 // one-time initialization cost is small, between 2 and 5 ms. |
53 base::ThreadRestrictions::ScopedAllowIO allow_io; | 52 base::ThreadRestrictions::ScopedAllowIO allow_io; |
54 | 53 |
55 switch (implementation) { | 54 switch (implementation) { |
56 case kGLImplementationOSMesaGL: | 55 case kGLImplementationOSMesaGL: |
57 return InitializeStaticGLBindingsOSMesaGL(); | 56 return InitializeStaticGLBindingsOSMesaGL(); |
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
195 return GetGLWindowSystemBindingInfoGLX(info); | 194 return GetGLWindowSystemBindingInfoGLX(info); |
196 case kGLImplementationEGLGLES2: | 195 case kGLImplementationEGLGLES2: |
197 return GetGLWindowSystemBindingInfoEGL(info); | 196 return GetGLWindowSystemBindingInfoEGL(info); |
198 default: | 197 default: |
199 return false; | 198 return false; |
200 } | 199 } |
201 return false; | 200 return false; |
202 } | 201 } |
203 | 202 |
204 } // namespace gfx | 203 } // namespace gfx |
OLD | NEW |