| 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/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" |
| (...skipping 16 matching lines...) Expand all Loading... |
| 27 void GL_BINDING_CALL MarshalClearDepthToClearDepthf(GLclampd depth) { | 27 void GL_BINDING_CALL MarshalClearDepthToClearDepthf(GLclampd depth) { |
| 28 glClearDepthf(static_cast<GLclampf>(depth)); | 28 glClearDepthf(static_cast<GLclampf>(depth)); |
| 29 } | 29 } |
| 30 | 30 |
| 31 void GL_BINDING_CALL MarshalDepthRangeToDepthRangef(GLclampd z_near, | 31 void GL_BINDING_CALL MarshalDepthRangeToDepthRangef(GLclampd z_near, |
| 32 GLclampd z_far) { | 32 GLclampd z_far) { |
| 33 glDepthRangef(static_cast<GLclampf>(z_near), static_cast<GLclampf>(z_far)); | 33 glDepthRangef(static_cast<GLclampf>(z_near), static_cast<GLclampf>(z_far)); |
| 34 } | 34 } |
| 35 | 35 |
| 36 // Load a library, printing an error message on failure. | 36 // Load a library, printing an error message on failure. |
| 37 base::NativeLibrary LoadLibrary(const FilePath& filename) { | 37 base::NativeLibrary LoadLibrary(const base::FilePath& filename) { |
| 38 std::string error; | 38 std::string error; |
| 39 base::NativeLibrary library = base::LoadNativeLibrary(filename, | 39 base::NativeLibrary library = base::LoadNativeLibrary(filename, |
| 40 &error); | 40 &error); |
| 41 if (!library) { | 41 if (!library) { |
| 42 DVLOG(1) << "Failed to load " << filename.MaybeAsASCII() << ": " << error; | 42 DVLOG(1) << "Failed to load " << filename.MaybeAsASCII() << ": " << error; |
| 43 return NULL; | 43 return NULL; |
| 44 } | 44 } |
| 45 return library; | 45 return library; |
| 46 } | 46 } |
| 47 | 47 |
| 48 base::NativeLibrary LoadLibrary(const char* filename) { | 48 base::NativeLibrary LoadLibrary(const char* filename) { |
| 49 return LoadLibrary(FilePath(filename)); | 49 return LoadLibrary(base::FilePath(filename)); |
| 50 } | 50 } |
| 51 | 51 |
| 52 } // namespace | 52 } // namespace |
| 53 | 53 |
| 54 void GetAllowedGLImplementations(std::vector<GLImplementation>* impls) { | 54 void GetAllowedGLImplementations(std::vector<GLImplementation>* impls) { |
| 55 impls->push_back(kGLImplementationDesktopGL); | 55 impls->push_back(kGLImplementationDesktopGL); |
| 56 impls->push_back(kGLImplementationEGLGLES2); | 56 impls->push_back(kGLImplementationEGLGLES2); |
| 57 impls->push_back(kGLImplementationOSMesaGL); | 57 impls->push_back(kGLImplementationOSMesaGL); |
| 58 } | 58 } |
| 59 | 59 |
| 60 bool InitializeGLBindings(GLImplementation implementation) { | 60 bool InitializeGLBindings(GLImplementation implementation) { |
| 61 // Prevent reinitialization with a different implementation. Once the gpu | 61 // Prevent reinitialization with a different implementation. Once the gpu |
| 62 // unit tests have initialized with kGLImplementationMock, we don't want to | 62 // unit tests have initialized with kGLImplementationMock, we don't want to |
| 63 // later switch to another GL implementation. | 63 // later switch to another GL implementation. |
| 64 if (GetGLImplementation() != kGLImplementationNone) | 64 if (GetGLImplementation() != kGLImplementationNone) |
| 65 return true; | 65 return true; |
| 66 | 66 |
| 67 // Allow the main thread or another to initialize these bindings | 67 // Allow the main thread or another to initialize these bindings |
| 68 // after instituting restrictions on I/O. Going forward they will | 68 // after instituting restrictions on I/O. Going forward they will |
| 69 // likely be used in the browser process on most platforms. The | 69 // likely be used in the browser process on most platforms. The |
| 70 // one-time initialization cost is small, between 2 and 5 ms. | 70 // one-time initialization cost is small, between 2 and 5 ms. |
| 71 base::ThreadRestrictions::ScopedAllowIO allow_io; | 71 base::ThreadRestrictions::ScopedAllowIO allow_io; |
| 72 | 72 |
| 73 switch (implementation) { | 73 switch (implementation) { |
| 74 case kGLImplementationOSMesaGL: { | 74 case kGLImplementationOSMesaGL: { |
| 75 FilePath module_path; | 75 base::FilePath module_path; |
| 76 if (!PathService::Get(base::DIR_MODULE, &module_path)) { | 76 if (!PathService::Get(base::DIR_MODULE, &module_path)) { |
| 77 LOG(ERROR) << "PathService::Get failed."; | 77 LOG(ERROR) << "PathService::Get failed."; |
| 78 return false; | 78 return false; |
| 79 } | 79 } |
| 80 | 80 |
| 81 base::NativeLibrary library = LoadLibrary( | 81 base::NativeLibrary library = LoadLibrary( |
| 82 module_path.Append("libosmesa.so")); | 82 module_path.Append("libosmesa.so")); |
| 83 if (!library) | 83 if (!library) |
| 84 return false; | 84 return false; |
| 85 | 85 |
| (...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 223 ClearGLBindingsEGL(); | 223 ClearGLBindingsEGL(); |
| 224 ClearGLBindingsGL(); | 224 ClearGLBindingsGL(); |
| 225 ClearGLBindingsGLX(); | 225 ClearGLBindingsGLX(); |
| 226 ClearGLBindingsOSMESA(); | 226 ClearGLBindingsOSMESA(); |
| 227 SetGLImplementation(kGLImplementationNone); | 227 SetGLImplementation(kGLImplementationNone); |
| 228 | 228 |
| 229 UnloadGLNativeLibraries(); | 229 UnloadGLNativeLibraries(); |
| 230 } | 230 } |
| 231 | 231 |
| 232 } // namespace gfx | 232 } // namespace gfx |
| OLD | NEW |