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" |
(...skipping 27 matching lines...) Expand all Loading... | |
38 } | 38 } |
39 | 39 |
40 base::NativeLibrary LoadLibrary(const char* filename) { | 40 base::NativeLibrary LoadLibrary(const char* filename) { |
41 return LoadLibrary(base::FilePath(filename)); | 41 return LoadLibrary(base::FilePath(filename)); |
42 } | 42 } |
43 | 43 |
44 } // namespace | 44 } // namespace |
45 | 45 |
46 void GetAllowedGLImplementations(std::vector<GLImplementation>* impls) { | 46 void GetAllowedGLImplementations(std::vector<GLImplementation>* impls) { |
47 impls->push_back(kGLImplementationEGLGLES2); | 47 impls->push_back(kGLImplementationEGLGLES2); |
48 impls->push_back(kGLImplementationOSMesaGL); | |
49 } | |
50 | |
51 bool InitializeGLBindingsOSMesaGL() { | |
52 base::FilePath module_path; | |
53 if (!PathService::Get(base::DIR_MODULE, &module_path)) { | |
54 LOG(ERROR) << "PathService::Get failed."; | |
55 return false; | |
56 } | |
57 | |
58 base::NativeLibrary library = LoadLibrary(module_path.Append("libosmesa.so")); | |
59 if (!library) | |
60 return false; | |
61 | |
62 GLGetProcAddressProc get_proc_address = | |
63 reinterpret_cast<GLGetProcAddressProc>( | |
64 base::GetFunctionPointerFromNativeLibrary(library, | |
65 "OSMesaGetProcAddress")); | |
66 if (!get_proc_address) { | |
67 LOG(ERROR) << "OSMesaGetProcAddress not found."; | |
68 base::UnloadNativeLibrary(library); | |
69 return false; | |
70 } | |
71 | |
72 SetGLGetProcAddressProc(get_proc_address); | |
73 AddGLNativeLibrary(library); | |
74 SetGLImplementation(kGLImplementationOSMesaGL); | |
75 | |
76 InitializeGLBindingsGL(); | |
77 InitializeGLBindingsOSMESA(); | |
78 return true; | |
48 } | 79 } |
piman
2013/09/19 19:48:37
nit: since this looks like a copy&paste from gl_im
Peter Beverloo
2013/10/03 19:46:42
Done, except for the problem I pointed out in gl.g
| |
49 | 80 |
50 bool InitializeGLBindings(GLImplementation implementation) { | 81 bool InitializeGLBindings(GLImplementation implementation) { |
51 // Prevent reinitialization with a different implementation. Once the gpu | 82 // Prevent reinitialization with a different implementation. Once the gpu |
52 // unit tests have initialized with kGLImplementationMock, we don't want to | 83 // unit tests have initialized with kGLImplementationMock, we don't want to |
53 // later switch to another GL implementation. | 84 // later switch to another GL implementation. |
54 if (GetGLImplementation() != kGLImplementationNone) | 85 if (GetGLImplementation() != kGLImplementationNone) |
55 return true; | 86 return true; |
56 | 87 |
57 switch (implementation) { | 88 switch (implementation) { |
58 case kGLImplementationEGLGLES2: { | 89 case kGLImplementationEGLGLES2: { |
(...skipping 24 matching lines...) Expand all Loading... | |
83 | 114 |
84 InitializeGLBindingsGL(); | 115 InitializeGLBindingsGL(); |
85 InitializeGLBindingsEGL(); | 116 InitializeGLBindingsEGL(); |
86 | 117 |
87 // These two functions take single precision float rather than double | 118 // These two functions take single precision float rather than double |
88 // precision float parameters in GLES. | 119 // precision float parameters in GLES. |
89 ::gfx::g_driver_gl.fn.glClearDepthFn = MarshalClearDepthToClearDepthf; | 120 ::gfx::g_driver_gl.fn.glClearDepthFn = MarshalClearDepthToClearDepthf; |
90 ::gfx::g_driver_gl.fn.glDepthRangeFn = MarshalDepthRangeToDepthRangef; | 121 ::gfx::g_driver_gl.fn.glDepthRangeFn = MarshalDepthRangeToDepthRangef; |
91 break; | 122 break; |
92 } | 123 } |
124 case kGLImplementationOSMesaGL: | |
125 return InitializeGLBindingsOSMesaGL(); | |
93 case kGLImplementationMockGL: { | 126 case kGLImplementationMockGL: { |
94 SetGLGetProcAddressProc(GetMockGLProcAddress); | 127 SetGLGetProcAddressProc(GetMockGLProcAddress); |
95 SetGLImplementation(kGLImplementationMockGL); | 128 SetGLImplementation(kGLImplementationMockGL); |
96 InitializeGLBindingsGL(); | 129 InitializeGLBindingsGL(); |
97 break; | 130 break; |
98 } | 131 } |
99 default: | 132 default: |
100 NOTIMPLEMENTED() << "InitializeGLBindings on Android"; | 133 NOTIMPLEMENTED() << "InitializeGLBindings on Android"; |
101 return false; | 134 return false; |
102 } | 135 } |
103 | 136 |
104 return true; | 137 return true; |
105 } | 138 } |
106 | 139 |
107 bool InitializeGLExtensionBindings(GLImplementation implementation, | 140 bool InitializeGLExtensionBindings(GLImplementation implementation, |
108 GLContext* context) { | 141 GLContext* context) { |
109 switch (implementation) { | 142 switch (implementation) { |
110 case kGLImplementationEGLGLES2: | 143 case kGLImplementationEGLGLES2: |
111 InitializeGLExtensionBindingsGL(context); | 144 InitializeGLExtensionBindingsGL(context); |
112 InitializeGLExtensionBindingsEGL(context); | 145 InitializeGLExtensionBindingsEGL(context); |
113 break; | 146 break; |
147 case kGLImplementationOSMesaGL: | |
148 InitializeGLExtensionBindingsGL(context); | |
149 InitializeGLExtensionBindingsOSMESA(context); | |
150 break; | |
114 case kGLImplementationMockGL: | 151 case kGLImplementationMockGL: |
115 InitializeGLExtensionBindingsGL(context); | 152 InitializeGLExtensionBindingsGL(context); |
116 break; | 153 break; |
117 default: | 154 default: |
118 return false; | 155 return false; |
119 } | 156 } |
120 | 157 |
121 return true; | 158 return true; |
122 } | 159 } |
123 | 160 |
(...skipping 12 matching lines...) Expand all Loading... | |
136 switch (GetGLImplementation()) { | 173 switch (GetGLImplementation()) { |
137 case kGLImplementationEGLGLES2: | 174 case kGLImplementationEGLGLES2: |
138 return GetGLWindowSystemBindingInfoEGL(info); | 175 return GetGLWindowSystemBindingInfoEGL(info); |
139 default: | 176 default: |
140 return false; | 177 return false; |
141 } | 178 } |
142 return false; | 179 return false; |
143 } | 180 } |
144 | 181 |
145 } // namespace gfx | 182 } // namespace gfx |
OLD | NEW |