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

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 6 years, 10 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
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_context_stub_with_extensions.h" 12 #include "ui/gl/gl_context_stub_with_extensions.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.h" 15 #include "ui/gl/gl_implementation.h"
16 #include "ui/gl/gl_implementation_osmesa.h"
16 #include "ui/gl/gl_osmesa_api_implementation.h" 17 #include "ui/gl/gl_osmesa_api_implementation.h"
17 18
18 namespace gfx { 19 namespace gfx {
19 20
20 namespace { 21 namespace {
21 22
22 void GL_BINDING_CALL MarshalClearDepthToClearDepthf(GLclampd depth) { 23 void GL_BINDING_CALL MarshalClearDepthToClearDepthf(GLclampd depth) {
23 glClearDepthf(static_cast<GLclampf>(depth)); 24 glClearDepthf(static_cast<GLclampf>(depth));
24 } 25 }
25 26
26 void GL_BINDING_CALL MarshalDepthRangeToDepthRangef(GLclampd z_near, 27 void GL_BINDING_CALL MarshalDepthRangeToDepthRangef(GLclampd z_near,
27 GLclampd z_far) { 28 GLclampd z_far) {
28 glDepthRangef(static_cast<GLclampf>(z_near), static_cast<GLclampf>(z_far)); 29 glDepthRangef(static_cast<GLclampf>(z_near), static_cast<GLclampf>(z_far));
29 } 30 }
30 31
31 base::NativeLibrary LoadLibrary(const base::FilePath& filename) {
32 std::string error;
33 base::NativeLibrary library = base::LoadNativeLibrary(filename, &error);
34 if (!library) {
35 DVLOG(1) << "Failed to load " << filename.MaybeAsASCII() << ": " << error;
36 return NULL;
37 }
38 return library;
39 }
40
41 base::NativeLibrary LoadLibrary(const char* filename) {
42 return LoadLibrary(base::FilePath(filename));
43 }
44
45 } // namespace 32 } // namespace
46 33
47 void GetAllowedGLImplementations(std::vector<GLImplementation>* impls) { 34 void GetAllowedGLImplementations(std::vector<GLImplementation>* impls) {
48 impls->push_back(kGLImplementationEGLGLES2); 35 impls->push_back(kGLImplementationEGLGLES2);
36 impls->push_back(kGLImplementationOSMesaGL);
49 } 37 }
50 38
51 bool InitializeStaticGLBindings(GLImplementation implementation) { 39 bool InitializeStaticGLBindings(GLImplementation implementation) {
52 // Prevent reinitialization with a different implementation. Once the gpu 40 // Prevent reinitialization with a different implementation. Once the gpu
53 // unit tests have initialized with kGLImplementationMock, we don't want to 41 // unit tests have initialized with kGLImplementationMock, we don't want to
54 // later switch to another GL implementation. 42 // later switch to another GL implementation.
55 DCHECK_EQ(kGLImplementationNone, GetGLImplementation()); 43 DCHECK_EQ(kGLImplementationNone, GetGLImplementation());
56 44
57 switch (implementation) { 45 switch (implementation) {
58 case kGLImplementationEGLGLES2: { 46 case kGLImplementationEGLGLES2: {
(...skipping 27 matching lines...) Expand all
86 74
87 InitializeStaticGLBindingsGL(); 75 InitializeStaticGLBindingsGL();
88 InitializeStaticGLBindingsEGL(); 76 InitializeStaticGLBindingsEGL();
89 77
90 // These two functions take single precision float rather than double 78 // These two functions take single precision float rather than double
91 // precision float parameters in GLES. 79 // precision float parameters in GLES.
92 ::gfx::g_driver_gl.fn.glClearDepthFn = MarshalClearDepthToClearDepthf; 80 ::gfx::g_driver_gl.fn.glClearDepthFn = MarshalClearDepthToClearDepthf;
93 ::gfx::g_driver_gl.fn.glDepthRangeFn = MarshalDepthRangeToDepthRangef; 81 ::gfx::g_driver_gl.fn.glDepthRangeFn = MarshalDepthRangeToDepthRangef;
94 break; 82 break;
95 } 83 }
84 case kGLImplementationOSMesaGL:
85 return InitializeStaticGLBindingsOSMesaGL();
Sami 2014/02/19 18:42:43 nit: To make this a tiny bit more consistent, inst
96 case kGLImplementationMockGL: { 86 case kGLImplementationMockGL: {
97 SetGLImplementation(kGLImplementationMockGL); 87 SetGLImplementation(kGLImplementationMockGL);
98 InitializeStaticGLBindingsGL(); 88 InitializeStaticGLBindingsGL();
99 break; 89 break;
100 } 90 }
101 default: 91 default:
102 NOTIMPLEMENTED() << "InitializeStaticGLBindings on Android"; 92 NOTIMPLEMENTED() << "InitializeStaticGLBindings on Android";
103 return false; 93 return false;
104 } 94 }
105 95
106 return true; 96 return true;
107 } 97 }
108 98
109 bool InitializeDynamicGLBindings(GLImplementation implementation, 99 bool InitializeDynamicGLBindings(GLImplementation implementation,
110 GLContext* context) { 100 GLContext* context) {
111 switch (implementation) { 101 switch (implementation) {
112 case kGLImplementationEGLGLES2: 102 case kGLImplementationEGLGLES2:
113 InitializeDynamicGLBindingsGL(context); 103 InitializeDynamicGLBindingsGL(context);
114 InitializeDynamicGLBindingsEGL(context); 104 InitializeDynamicGLBindingsEGL(context);
115 break; 105 break;
106 case kGLImplementationOSMesaGL:
107 InitializeDynamicGLBindingsGL(context);
108 InitializeDynamicGLBindingsOSMESA(context);
109 break;
116 case kGLImplementationMockGL: 110 case kGLImplementationMockGL:
117 if (!context) { 111 if (!context) {
118 scoped_refptr<GLContextStubWithExtensions> mock_context( 112 scoped_refptr<GLContextStubWithExtensions> mock_context(
119 new GLContextStubWithExtensions()); 113 new GLContextStubWithExtensions());
120 mock_context->SetGLVersionString("opengl es 3.0"); 114 mock_context->SetGLVersionString("opengl es 3.0");
121 InitializeDynamicGLBindingsGL(mock_context.get()); 115 InitializeDynamicGLBindingsGL(mock_context.get());
122 } else 116 } else
123 InitializeDynamicGLBindingsGL(context); 117 InitializeDynamicGLBindingsGL(context);
124 break; 118 break;
125 default: 119 default:
126 NOTREACHED() << "InitializeDynamicGLBindings on Android"; 120 NOTREACHED() << "InitializeDynamicGLBindings on Android";
127 return false; 121 return false;
128 } 122 }
129 123
130 return true; 124 return true;
131 } 125 }
132 126
133 void InitializeDebugGLBindings() { 127 void InitializeDebugGLBindings() {
134 InitializeDebugGLBindingsEGL(); 128 InitializeDebugGLBindingsEGL();
135 InitializeDebugGLBindingsGL(); 129 InitializeDebugGLBindingsGL();
130 InitializeDebugGLBindingsOSMESA();
136 } 131 }
137 132
138 void ClearGLBindings() { 133 void ClearGLBindings() {
139 ClearGLBindingsEGL(); 134 ClearGLBindingsEGL();
140 ClearGLBindingsGL(); 135 ClearGLBindingsGL();
136 ClearGLBindingsOSMESA();
141 SetGLImplementation(kGLImplementationNone); 137 SetGLImplementation(kGLImplementationNone);
142 138
143 UnloadGLNativeLibraries(); 139 UnloadGLNativeLibraries();
144 } 140 }
145 141
146 bool GetGLWindowSystemBindingInfo(GLWindowSystemBindingInfo* info) { 142 bool GetGLWindowSystemBindingInfo(GLWindowSystemBindingInfo* info) {
147 switch (GetGLImplementation()) { 143 switch (GetGLImplementation()) {
148 case kGLImplementationEGLGLES2: 144 case kGLImplementationEGLGLES2:
149 return GetGLWindowSystemBindingInfoEGL(info); 145 return GetGLWindowSystemBindingInfoEGL(info);
150 default: 146 default:
151 return false; 147 return false;
152 } 148 }
153 return false; 149 return false;
154 } 150 }
155 151
156 } // namespace gfx 152 } // namespace gfx
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698