| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 "ui/gl/init/gl_initializer.h" | 5 #include "ui/gl/init/gl_initializer.h" |
| 6 | 6 |
| 7 #include <dwmapi.h> | 7 #include <dwmapi.h> |
| 8 | 8 |
| 9 #include "base/at_exit.h" | 9 #include "base/at_exit.h" |
| 10 #include "base/base_paths.h" | 10 #include "base/base_paths.h" |
| (...skipping 232 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 243 } | 243 } |
| 244 break; | 244 break; |
| 245 case kGLImplementationEGLGLES2: | 245 case kGLImplementationEGLGLES2: |
| 246 if (!GLSurfaceEGL::InitializeOneOff(GetDC(nullptr))) { | 246 if (!GLSurfaceEGL::InitializeOneOff(GetDC(nullptr))) { |
| 247 LOG(ERROR) << "GLSurfaceEGL::InitializeOneOff failed."; | 247 LOG(ERROR) << "GLSurfaceEGL::InitializeOneOff failed."; |
| 248 return false; | 248 return false; |
| 249 } | 249 } |
| 250 break; | 250 break; |
| 251 case kGLImplementationOSMesaGL: | 251 case kGLImplementationOSMesaGL: |
| 252 case kGLImplementationMockGL: | 252 case kGLImplementationMockGL: |
| 253 case kGLImplementationStubGL: |
| 253 break; | 254 break; |
| 254 default: | 255 default: |
| 255 NOTREACHED(); | 256 NOTREACHED(); |
| 256 } | 257 } |
| 257 return true; | 258 return true; |
| 258 } | 259 } |
| 259 | 260 |
| 260 bool InitializeStaticGLBindings(GLImplementation implementation) { | 261 bool InitializeStaticGLBindings(GLImplementation implementation) { |
| 261 // Prevent reinitialization with a different implementation. Once the gpu | 262 // Prevent reinitialization with a different implementation. Once the gpu |
| 262 // unit tests have initialized with kGLImplementationMock, we don't want to | 263 // unit tests have initialized with kGLImplementationMock, we don't want to |
| 263 // later switch to another GL implementation. | 264 // later switch to another GL implementation. |
| 264 DCHECK_EQ(kGLImplementationNone, GetGLImplementation()); | 265 DCHECK_EQ(kGLImplementationNone, GetGLImplementation()); |
| 265 | 266 |
| 266 // Allow the main thread or another to initialize these bindings | 267 // Allow the main thread or another to initialize these bindings |
| 267 // after instituting restrictions on I/O. Going forward they will | 268 // after instituting restrictions on I/O. Going forward they will |
| 268 // likely be used in the browser process on most platforms. The | 269 // likely be used in the browser process on most platforms. The |
| 269 // one-time initialization cost is small, between 2 and 5 ms. | 270 // one-time initialization cost is small, between 2 and 5 ms. |
| 270 base::ThreadRestrictions::ScopedAllowIO allow_io; | 271 base::ThreadRestrictions::ScopedAllowIO allow_io; |
| 271 | 272 |
| 272 switch (implementation) { | 273 switch (implementation) { |
| 273 case kGLImplementationOSMesaGL: | 274 case kGLImplementationOSMesaGL: |
| 274 return InitializeStaticOSMesaInternal(); | 275 return InitializeStaticOSMesaInternal(); |
| 275 case kGLImplementationEGLGLES2: | 276 case kGLImplementationEGLGLES2: |
| 276 return InitializeStaticEGLInternal(); | 277 return InitializeStaticEGLInternal(); |
| 277 case kGLImplementationDesktopGL: | 278 case kGLImplementationDesktopGL: |
| 278 return InitializeStaticWGLInternal(); | 279 return InitializeStaticWGLInternal(); |
| 279 case kGLImplementationMockGL: | 280 case kGLImplementationMockGL: |
| 280 SetGLImplementation(kGLImplementationMockGL); | 281 case kGLImplementationStubGL: |
| 282 SetGLImplementation(implementation); |
| 281 InitializeStaticGLBindingsGL(); | 283 InitializeStaticGLBindingsGL(); |
| 282 return true; | 284 return true; |
| 283 default: | 285 default: |
| 284 NOTREACHED(); | 286 NOTREACHED(); |
| 285 } | 287 } |
| 286 | 288 |
| 287 return false; | 289 return false; |
| 288 } | 290 } |
| 289 | 291 |
| 290 void InitializeDebugGLBindings() { | 292 void InitializeDebugGLBindings() { |
| 291 InitializeDebugGLBindingsEGL(); | 293 InitializeDebugGLBindingsEGL(); |
| 292 InitializeDebugGLBindingsGL(); | 294 InitializeDebugGLBindingsGL(); |
| 293 InitializeDebugGLBindingsOSMESA(); | 295 InitializeDebugGLBindingsOSMESA(); |
| 294 InitializeDebugGLBindingsWGL(); | 296 InitializeDebugGLBindingsWGL(); |
| 295 } | 297 } |
| 296 | 298 |
| 297 void ShutdownGLPlatform() { | 299 void ShutdownGLPlatform() { |
| 298 GLSurfaceEGL::ShutdownOneOff(); | 300 GLSurfaceEGL::ShutdownOneOff(); |
| 299 ClearBindingsEGL(); | 301 ClearBindingsEGL(); |
| 300 ClearBindingsGL(); | 302 ClearBindingsGL(); |
| 301 ClearBindingsOSMESA(); | 303 ClearBindingsOSMESA(); |
| 302 ClearBindingsWGL(); | 304 ClearBindingsWGL(); |
| 303 } | 305 } |
| 304 | 306 |
| 305 } // namespace init | 307 } // namespace init |
| 306 } // namespace gl | 308 } // namespace gl |
| OLD | NEW |