Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(56)

Side by Side Diff: ui/gl/gl_implementation_android.cc

Issue 23868030: Make it possible to use OSMesa on Android (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« ui/gl/gl.gyp ('K') | « ui/gl/gl_context_android.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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_egl_api_implementation.h" 12 #include "ui/gl/gl_egl_api_implementation.h"
13 #include "ui/gl/gl_gl_api_implementation.h" 13 #include "ui/gl/gl_gl_api_implementation.h"
14 #include "ui/gl/gl_implementation.h" 14 #include "ui/gl/gl_implementation.h"
15 #include "ui/gl/gl_implementation_linux.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) {
22 glClearDepthf(static_cast<GLclampf>(depth)); 23 glClearDepthf(static_cast<GLclampf>(depth));
23 } 24 }
24 25
25 void GL_BINDING_CALL MarshalDepthRangeToDepthRangef(GLclampd z_near, 26 void GL_BINDING_CALL MarshalDepthRangeToDepthRangef(GLclampd z_near,
26 GLclampd z_far) { 27 GLclampd z_far) {
27 glDepthRangef(static_cast<GLclampf>(z_near), static_cast<GLclampf>(z_far)); 28 glDepthRangef(static_cast<GLclampf>(z_near), static_cast<GLclampf>(z_far));
28 } 29 }
29 30
30 base::NativeLibrary LoadLibrary(const base::FilePath& filename) {
31 std::string error;
32 base::NativeLibrary library = base::LoadNativeLibrary(filename, &error);
33 if (!library) {
34 DVLOG(1) << "Failed to load " << filename.MaybeAsASCII() << ": " << error;
35 return NULL;
36 }
37 return library;
38 }
39
40 base::NativeLibrary LoadLibrary(const char* filename) {
41 return LoadLibrary(base::FilePath(filename));
42 }
43
44 } // namespace 31 } // namespace
45 32
46 void GetAllowedGLImplementations(std::vector<GLImplementation>* impls) { 33 void GetAllowedGLImplementations(std::vector<GLImplementation>* impls) {
47 impls->push_back(kGLImplementationEGLGLES2); 34 impls->push_back(kGLImplementationEGLGLES2);
35 impls->push_back(kGLImplementationOSMesaGL);
48 } 36 }
49 37
50 bool InitializeGLBindings(GLImplementation implementation) { 38 bool InitializeGLBindings(GLImplementation implementation) {
51 // Prevent reinitialization with a different implementation. Once the gpu 39 // Prevent reinitialization with a different implementation. Once the gpu
52 // unit tests have initialized with kGLImplementationMock, we don't want to 40 // unit tests have initialized with kGLImplementationMock, we don't want to
53 // later switch to another GL implementation. 41 // later switch to another GL implementation.
54 if (GetGLImplementation() != kGLImplementationNone) 42 if (GetGLImplementation() != kGLImplementationNone)
55 return true; 43 return true;
56 44
57 switch (implementation) { 45 switch (implementation) {
(...skipping 25 matching lines...) Expand all
83 71
84 InitializeGLBindingsGL(); 72 InitializeGLBindingsGL();
85 InitializeGLBindingsEGL(); 73 InitializeGLBindingsEGL();
86 74
87 // These two functions take single precision float rather than double 75 // These two functions take single precision float rather than double
88 // precision float parameters in GLES. 76 // precision float parameters in GLES.
89 ::gfx::g_driver_gl.fn.glClearDepthFn = MarshalClearDepthToClearDepthf; 77 ::gfx::g_driver_gl.fn.glClearDepthFn = MarshalClearDepthToClearDepthf;
90 ::gfx::g_driver_gl.fn.glDepthRangeFn = MarshalDepthRangeToDepthRangef; 78 ::gfx::g_driver_gl.fn.glDepthRangeFn = MarshalDepthRangeToDepthRangef;
91 break; 79 break;
92 } 80 }
81 case kGLImplementationOSMesaGL:
82 return InitializeGLBindingsOSMesaGL();
93 case kGLImplementationMockGL: { 83 case kGLImplementationMockGL: {
94 SetGLGetProcAddressProc(GetMockGLProcAddress); 84 SetGLGetProcAddressProc(GetMockGLProcAddress);
95 SetGLImplementation(kGLImplementationMockGL); 85 SetGLImplementation(kGLImplementationMockGL);
96 InitializeGLBindingsGL(); 86 InitializeGLBindingsGL();
97 break; 87 break;
98 } 88 }
99 default: 89 default:
100 NOTIMPLEMENTED() << "InitializeGLBindings on Android"; 90 NOTIMPLEMENTED() << "InitializeGLBindings on Android";
101 return false; 91 return false;
102 } 92 }
103 93
104 return true; 94 return true;
105 } 95 }
106 96
107 bool InitializeGLExtensionBindings(GLImplementation implementation, 97 bool InitializeGLExtensionBindings(GLImplementation implementation,
108 GLContext* context) { 98 GLContext* context) {
109 switch (implementation) { 99 switch (implementation) {
110 case kGLImplementationEGLGLES2: 100 case kGLImplementationEGLGLES2:
111 InitializeGLExtensionBindingsGL(context); 101 InitializeGLExtensionBindingsGL(context);
112 InitializeGLExtensionBindingsEGL(context); 102 InitializeGLExtensionBindingsEGL(context);
113 break; 103 break;
104 case kGLImplementationOSMesaGL:
105 InitializeGLExtensionBindingsGL(context);
106 InitializeGLExtensionBindingsOSMESA(context);
107 break;
114 case kGLImplementationMockGL: 108 case kGLImplementationMockGL:
115 InitializeGLExtensionBindingsGL(context); 109 InitializeGLExtensionBindingsGL(context);
116 break; 110 break;
117 default: 111 default:
118 return false; 112 return false;
119 } 113 }
120 114
121 return true; 115 return true;
122 } 116 }
123 117
(...skipping 12 matching lines...) Expand all
136 switch (GetGLImplementation()) { 130 switch (GetGLImplementation()) {
137 case kGLImplementationEGLGLES2: 131 case kGLImplementationEGLGLES2:
138 return GetGLWindowSystemBindingInfoEGL(info); 132 return GetGLWindowSystemBindingInfoEGL(info);
139 default: 133 default:
140 return false; 134 return false;
141 } 135 }
142 return false; 136 return false;
143 } 137 }
144 138
145 } // namespace gfx 139 } // namespace gfx
OLDNEW
« ui/gl/gl.gyp ('K') | « ui/gl/gl_context_android.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698