| 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 "base/base_paths.h" | 5 #include "base/base_paths.h" |
| 6 #include "base/command_line.h" | 6 #include "base/command_line.h" |
| 7 #include "base/files/file_path.h" | 7 #include "base/files/file_path.h" |
| 8 #include "base/logging.h" | 8 #include "base/logging.h" |
| 9 #include "base/native_library.h" | 9 #include "base/native_library.h" |
| 10 #include "base/path_service.h" | 10 #include "base/path_service.h" |
| 11 #include "ui/gl/gl_bindings.h" | 11 #include "ui/gl/gl_bindings.h" |
| 12 #include "ui/gl/gl_context_mock_version.h" |
| 12 #include "ui/gl/gl_egl_api_implementation.h" | 13 #include "ui/gl/gl_egl_api_implementation.h" |
| 13 #include "ui/gl/gl_gl_api_implementation.h" | 14 #include "ui/gl/gl_gl_api_implementation.h" |
| 14 #include "ui/gl/gl_implementation.h" | 15 #include "ui/gl/gl_implementation.h" |
| 15 #include "ui/gl/gl_osmesa_api_implementation.h" | 16 #include "ui/gl/gl_osmesa_api_implementation.h" |
| 16 | 17 |
| 17 namespace gfx { | 18 namespace gfx { |
| 18 | 19 |
| 19 namespace { | 20 namespace { |
| 20 | 21 |
| 21 void GL_BINDING_CALL MarshalClearDepthToClearDepthf(GLclampd depth) { | 22 void GL_BINDING_CALL MarshalClearDepthToClearDepthf(GLclampd depth) { |
| (...skipping 18 matching lines...) Expand all Loading... |
| 40 base::NativeLibrary LoadLibrary(const char* filename) { | 41 base::NativeLibrary LoadLibrary(const char* filename) { |
| 41 return LoadLibrary(base::FilePath(filename)); | 42 return LoadLibrary(base::FilePath(filename)); |
| 42 } | 43 } |
| 43 | 44 |
| 44 } // namespace | 45 } // namespace |
| 45 | 46 |
| 46 void GetAllowedGLImplementations(std::vector<GLImplementation>* impls) { | 47 void GetAllowedGLImplementations(std::vector<GLImplementation>* impls) { |
| 47 impls->push_back(kGLImplementationEGLGLES2); | 48 impls->push_back(kGLImplementationEGLGLES2); |
| 48 } | 49 } |
| 49 | 50 |
| 50 bool InitializeGLBindings(GLImplementation implementation) { | 51 bool InitializeStaticGLBindings(GLImplementation implementation) { |
| 51 // Prevent reinitialization with a different implementation. Once the gpu | 52 // Prevent reinitialization with a different implementation. Once the gpu |
| 52 // unit tests have initialized with kGLImplementationMock, we don't want to | 53 // unit tests have initialized with kGLImplementationMock, we don't want to |
| 53 // later switch to another GL implementation. | 54 // later switch to another GL implementation. |
| 54 if (GetGLImplementation() != kGLImplementationNone) | 55 if (GetGLImplementation() != kGLImplementationNone) |
| 55 return true; | 56 return true; |
| 56 | 57 |
| 57 switch (implementation) { | 58 switch (implementation) { |
| 58 case kGLImplementationEGLGLES2: { | 59 case kGLImplementationEGLGLES2: { |
| 59 base::NativeLibrary gles_library = LoadLibrary("libGLESv2.so"); | 60 base::NativeLibrary gles_library = LoadLibrary("libGLESv2.so"); |
| 60 if (!gles_library) | 61 if (!gles_library) |
| (...skipping 13 matching lines...) Expand all Loading... |
| 74 base::UnloadNativeLibrary(egl_library); | 75 base::UnloadNativeLibrary(egl_library); |
| 75 base::UnloadNativeLibrary(gles_library); | 76 base::UnloadNativeLibrary(gles_library); |
| 76 return false; | 77 return false; |
| 77 } | 78 } |
| 78 | 79 |
| 79 SetGLGetProcAddressProc(get_proc_address); | 80 SetGLGetProcAddressProc(get_proc_address); |
| 80 AddGLNativeLibrary(egl_library); | 81 AddGLNativeLibrary(egl_library); |
| 81 AddGLNativeLibrary(gles_library); | 82 AddGLNativeLibrary(gles_library); |
| 82 SetGLImplementation(kGLImplementationEGLGLES2); | 83 SetGLImplementation(kGLImplementationEGLGLES2); |
| 83 | 84 |
| 84 InitializeGLBindingsGL(); | 85 InitializeStaticGLBindingsGL(); |
| 85 InitializeGLBindingsEGL(); | 86 InitializeStaticGLBindingsEGL(); |
| 86 | 87 |
| 87 // These two functions take single precision float rather than double | 88 // These two functions take single precision float rather than double |
| 88 // precision float parameters in GLES. | 89 // precision float parameters in GLES. |
| 89 ::gfx::g_driver_gl.fn.glClearDepthFn = MarshalClearDepthToClearDepthf; | 90 ::gfx::g_driver_gl.fn.glClearDepthFn = MarshalClearDepthToClearDepthf; |
| 90 ::gfx::g_driver_gl.fn.glDepthRangeFn = MarshalDepthRangeToDepthRangef; | 91 ::gfx::g_driver_gl.fn.glDepthRangeFn = MarshalDepthRangeToDepthRangef; |
| 91 break; | 92 break; |
| 92 } | 93 } |
| 93 case kGLImplementationMockGL: { | 94 case kGLImplementationMockGL: { |
| 94 SetGLGetProcAddressProc(GetMockGLProcAddress); | 95 SetGLGetProcAddressProc(GetMockGLProcAddress); |
| 95 SetGLImplementation(kGLImplementationMockGL); | 96 SetGLImplementation(kGLImplementationMockGL); |
| 96 InitializeGLBindingsGL(); | 97 InitializeStaticGLBindingsGL(); |
| 97 break; | 98 break; |
| 98 } | 99 } |
| 99 default: | 100 default: |
| 100 NOTIMPLEMENTED() << "InitializeGLBindings on Android"; | 101 NOTIMPLEMENTED() << "InitializeStaticGLBindings on Android"; |
| 101 return false; | 102 return false; |
| 102 } | 103 } |
| 103 | 104 |
| 104 return true; | 105 return true; |
| 105 } | 106 } |
| 106 | 107 |
| 107 bool InitializeGLExtensionBindings(GLImplementation implementation, | 108 bool InitializeDynamicGLBindings(GLImplementation implementation, |
| 108 GLContext* context) { | 109 GLContext* context) { |
| 109 switch (implementation) { | 110 switch (implementation) { |
| 110 case kGLImplementationEGLGLES2: | 111 case kGLImplementationEGLGLES2: |
| 111 InitializeGLExtensionBindingsGL(context); | 112 InitializeDynamicGLBindingsGL(context); |
| 112 InitializeGLExtensionBindingsEGL(context); | 113 InitializeDynamicGLBindingsEGL(context); |
| 113 break; | 114 break; |
| 114 case kGLImplementationMockGL: | 115 case kGLImplementationMockGL: |
| 115 InitializeGLExtensionBindingsGL(context); | 116 { |
| 117 scoped_refptr<GLContextMockVersion> mock_context( |
| 118 new GLContextMockVersion("opengl es 3.0")); |
| 119 InitializeDynamicGLBindingsGL(mock_context.get()); |
| 120 } |
| 116 break; | 121 break; |
| 117 default: | 122 default: |
| 118 return false; | 123 return false; |
| 119 } | 124 } |
| 120 | 125 |
| 121 return true; | 126 return true; |
| 122 } | 127 } |
| 123 | 128 |
| 124 void InitializeDebugGLBindings() { | 129 void InitializeDebugGLBindings() { |
| 125 } | 130 } |
| (...skipping 10 matching lines...) Expand all Loading... |
| 136 switch (GetGLImplementation()) { | 141 switch (GetGLImplementation()) { |
| 137 case kGLImplementationEGLGLES2: | 142 case kGLImplementationEGLGLES2: |
| 138 return GetGLWindowSystemBindingInfoEGL(info); | 143 return GetGLWindowSystemBindingInfoEGL(info); |
| 139 default: | 144 default: |
| 140 return false; | 145 return false; |
| 141 } | 146 } |
| 142 return false; | 147 return false; |
| 143 } | 148 } |
| 144 | 149 |
| 145 } // namespace gfx | 150 } // namespace gfx |
| OLD | NEW |