| 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 "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/files/file_path.h" | 9 #include "base/files/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 "ui/gl/gl_bindings.h" | 12 #include "ui/gl/gl_bindings.h" |
| 13 #include "ui/gl/gl_egl_api_implementation.h" | 13 #include "ui/gl/gl_egl_api_implementation.h" |
| 14 #include "ui/gl/gl_gl_api_implementation.h" | 14 #include "ui/gl/gl_gl_api_implementation.h" |
| 15 #include "ui/gl/gl_implementation_osmesa.h" | 15 #include "ui/gl/gl_implementation_osmesa.h" |
| 16 #include "ui/gl/gl_osmesa_api_implementation.h" | 16 #include "ui/gl/gl_osmesa_api_implementation.h" |
| 17 #include "ui/gl/gl_surface_egl.h" | 17 #include "ui/gl/gl_surface_egl.h" |
| 18 | 18 |
| 19 namespace gl { | 19 namespace gl { |
| 20 namespace init { | 20 namespace init { |
| 21 | 21 |
| 22 namespace { | 22 namespace { |
| 23 | 23 |
| 24 const char kGLESv2LibraryName[] = "libGLESv2.so"; |
| 25 const char kEGLLibraryName[] = "libEGL.so"; |
| 26 |
| 24 bool InitializeStaticEGLInternal() { | 27 bool InitializeStaticEGLInternal() { |
| 25 base::NativeLibrary gles_library = LoadLibraryAndPrintError("libGLESv2.so"); | 28 base::NativeLibrary gles_library = |
| 29 LoadLibraryAndPrintError(kGLESv2LibraryName); |
| 26 if (!gles_library) | 30 if (!gles_library) |
| 27 return false; | 31 return false; |
| 28 base::NativeLibrary egl_library = LoadLibraryAndPrintError("libEGL.so"); | 32 base::NativeLibrary egl_library = LoadLibraryAndPrintError(kEGLLibraryName); |
| 29 if (!egl_library) { | 33 if (!egl_library) { |
| 30 base::UnloadNativeLibrary(gles_library); | 34 base::UnloadNativeLibrary(gles_library); |
| 31 return false; | 35 return false; |
| 32 } | 36 } |
| 33 | 37 |
| 34 GLGetProcAddressProc get_proc_address = | 38 GLGetProcAddressProc get_proc_address = |
| 35 reinterpret_cast<GLGetProcAddressProc>( | 39 reinterpret_cast<GLGetProcAddressProc>( |
| 36 base::GetFunctionPointerFromNativeLibrary(egl_library, | 40 base::GetFunctionPointerFromNativeLibrary(egl_library, |
| 37 "eglGetProcAddress")); | 41 "eglGetProcAddress")); |
| 38 if (!get_proc_address) { | 42 if (!get_proc_address) { |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 95 InitializeDebugGLBindingsGL(); | 99 InitializeDebugGLBindingsGL(); |
| 96 InitializeDebugGLBindingsOSMESA(); | 100 InitializeDebugGLBindingsOSMESA(); |
| 97 } | 101 } |
| 98 | 102 |
| 99 void ClearGLBindingsPlatform() { | 103 void ClearGLBindingsPlatform() { |
| 100 ClearGLBindingsEGL(); | 104 ClearGLBindingsEGL(); |
| 101 ClearGLBindingsGL(); | 105 ClearGLBindingsGL(); |
| 102 ClearGLBindingsOSMESA(); | 106 ClearGLBindingsOSMESA(); |
| 103 } | 107 } |
| 104 | 108 |
| 109 bool GetNativeLibraryNamesFromGLImplementationPlatform( |
| 110 GLImplementation implementation, |
| 111 std::vector<std::string>* required_libraries) { |
| 112 DCHECK(required_libraries); |
| 113 required_libraries->clear(); |
| 114 |
| 115 switch (implementation) { |
| 116 case kGLImplementationEGLGLES2: { |
| 117 required_libraries->push_back(kGLESv2LibraryName); |
| 118 required_libraries->push_back(kEGLLibraryName); |
| 119 break; |
| 120 } |
| 121 default: |
| 122 return false; |
| 123 } |
| 124 |
| 125 return true; |
| 126 } |
| 127 |
| 105 } // namespace init | 128 } // namespace init |
| 106 } // namespace gl | 129 } // namespace gl |
| OLD | NEW |