Index: ui/gl/gl_implementation_ozone.cc |
diff --git a/ui/gl/gl_implementation_android.cc b/ui/gl/gl_implementation_ozone.cc |
similarity index 69% |
copy from ui/gl/gl_implementation_android.cc |
copy to ui/gl/gl_implementation_ozone.cc |
index 1486a6d917764e8e7134182c82b8c40c24dbe629..43b3b047b3018bccc95bc605ea36725f5efa99eb 100644 |
--- a/ui/gl/gl_implementation_android.cc |
+++ b/ui/gl/gl_implementation_ozone.cc |
@@ -2,11 +2,7 @@ |
// Use of this source code is governed by a BSD-style license that can be |
// found in the LICENSE file. |
-#include "base/base_paths.h" |
-#include "base/command_line.h" |
-#include "base/files/file_path.h" |
-#include "base/logging.h" |
-#include "base/native_library.h" |
+#include "base/bind.h" |
#include "ui/gl/gl_bindings.h" |
#include "ui/gl/gl_context_stub_with_extensions.h" |
#include "ui/gl/gl_egl_api_implementation.h" |
@@ -14,6 +10,8 @@ |
#include "ui/gl/gl_implementation.h" |
#include "ui/gl/gl_implementation_osmesa.h" |
#include "ui/gl/gl_osmesa_api_implementation.h" |
+#include "ui/ozone/public/ozone_platform.h" |
+#include "ui/ozone/public/surface_factory_ozone.h" |
namespace gfx { |
@@ -40,35 +38,17 @@ bool InitializeStaticGLBindings(GLImplementation implementation) { |
// unit tests have initialized with kGLImplementationMock, we don't want to |
// later switch to another GL implementation. |
DCHECK_EQ(kGLImplementationNone, GetGLImplementation()); |
+ ui::OzonePlatform::InitializeForGPU(); |
switch (implementation) { |
- case kGLImplementationEGLGLES2: { |
- base::NativeLibrary gles_library = |
- LoadLibraryAndPrintError("libGLESv2.so"); |
- if (!gles_library) |
- return false; |
- base::NativeLibrary egl_library = LoadLibraryAndPrintError("libEGL.so"); |
- if (!egl_library) { |
- base::UnloadNativeLibrary(gles_library); |
- return false; |
- } |
- |
- GLGetProcAddressProc get_proc_address = |
- reinterpret_cast<GLGetProcAddressProc>( |
- base::GetFunctionPointerFromNativeLibrary( |
- egl_library, "eglGetProcAddress")); |
- if (!get_proc_address) { |
- LOG(ERROR) << "eglGetProcAddress not found."; |
- base::UnloadNativeLibrary(egl_library); |
- base::UnloadNativeLibrary(gles_library); |
+ case kGLImplementationOSMesaGL: |
+ return InitializeStaticGLBindingsOSMesaGL(); |
+ case kGLImplementationEGLGLES2: |
+ if (!ui::SurfaceFactoryOzone::GetInstance()->LoadEGLGLES2Bindings( |
+ base::Bind(&AddGLNativeLibrary), |
+ base::Bind(&SetGLGetProcAddressProc))) |
return false; |
- } |
- |
- SetGLGetProcAddressProc(get_proc_address); |
- AddGLNativeLibrary(egl_library); |
- AddGLNativeLibrary(gles_library); |
SetGLImplementation(kGLImplementationEGLGLES2); |
- |
InitializeStaticGLBindingsGL(); |
InitializeStaticGLBindingsEGL(); |
@@ -77,17 +57,14 @@ bool InitializeStaticGLBindings(GLImplementation implementation) { |
::gfx::g_driver_gl.fn.glClearDepthFn = MarshalClearDepthToClearDepthf; |
::gfx::g_driver_gl.fn.glDepthRangeFn = MarshalDepthRangeToDepthRangef; |
break; |
- } |
- case kGLImplementationOSMesaGL: |
- InitializeStaticGLBindingsOSMesaGL(); |
- break; |
case kGLImplementationMockGL: { |
SetGLImplementation(kGLImplementationMockGL); |
InitializeStaticGLBindingsGL(); |
break; |
} |
default: |
- NOTIMPLEMENTED() << "InitializeStaticGLBindings on Android"; |
+ NOTIMPLEMENTED() |
+ << "Unsupported GL type for Ozone surface implementation"; |
return false; |
} |
@@ -97,25 +74,24 @@ bool InitializeStaticGLBindings(GLImplementation implementation) { |
bool InitializeDynamicGLBindings(GLImplementation implementation, |
GLContext* context) { |
switch (implementation) { |
- case kGLImplementationEGLGLES2: |
- InitializeDynamicGLBindingsGL(context); |
- InitializeDynamicGLBindingsEGL(context); |
- break; |
case kGLImplementationOSMesaGL: |
InitializeDynamicGLBindingsGL(context); |
InitializeDynamicGLBindingsOSMESA(context); |
break; |
+ case kGLImplementationEGLGLES2: |
+ InitializeDynamicGLBindingsGL(context); |
+ InitializeDynamicGLBindingsEGL(context); |
+ break; |
case kGLImplementationMockGL: |
if (!context) { |
scoped_refptr<GLContextStubWithExtensions> mock_context( |
new GLContextStubWithExtensions()); |
- mock_context->SetGLVersionString("opengl es 3.0"); |
+ mock_context->SetGLVersionString("3.0"); |
InitializeDynamicGLBindingsGL(mock_context.get()); |
} else |
InitializeDynamicGLBindingsGL(context); |
break; |
default: |
- NOTREACHED() << "InitializeDynamicGLBindings on Android"; |
return false; |
} |
@@ -123,17 +99,12 @@ bool InitializeDynamicGLBindings(GLImplementation implementation, |
} |
void InitializeDebugGLBindings() { |
- InitializeDebugGLBindingsEGL(); |
- InitializeDebugGLBindingsGL(); |
- InitializeDebugGLBindingsOSMESA(); |
} |
void ClearGLBindings() { |
ClearGLBindingsEGL(); |
ClearGLBindingsGL(); |
- ClearGLBindingsOSMESA(); |
SetGLImplementation(kGLImplementationNone); |
- |
UnloadGLNativeLibraries(); |
} |