| Index: ui/gl/gl_implementation_mac.cc
|
| diff --git a/ui/gl/gl_implementation_android.cc b/ui/gl/gl_implementation_mac.cc
|
| similarity index 54%
|
| copy from ui/gl/gl_implementation_android.cc
|
| copy to ui/gl/gl_implementation_mac.cc
|
| index 176cf289a97cc92a82e71f8c8dd9cb3314f226bc..ae26dff2b1741eb46d2c0c70596fd65e204fb738 100644
|
| --- a/ui/gl/gl_implementation_android.cc
|
| +++ b/ui/gl/gl_implementation_mac.cc
|
| @@ -6,32 +6,25 @@
|
| #include "base/command_line.h"
|
| #include "base/files/file_path.h"
|
| #include "base/logging.h"
|
| +#include "base/mac/foundation_util.h"
|
| #include "base/native_library.h"
|
| +#include "base/path_service.h"
|
| +#include "base/threading/thread_restrictions.h"
|
| #include "ui/gl/gl_bindings.h"
|
| #include "ui/gl/gl_context_stub_with_extensions.h"
|
| -#include "ui/gl/gl_egl_api_implementation.h"
|
| #include "ui/gl/gl_gl_api_implementation.h"
|
| #include "ui/gl/gl_implementation.h"
|
| -#include "ui/gl/gl_implementation_osmesa.h"
|
| #include "ui/gl/gl_osmesa_api_implementation.h"
|
|
|
| namespace gfx {
|
| -
|
| namespace {
|
| -
|
| -void GL_BINDING_CALL MarshalClearDepthToClearDepthf(GLclampd depth) {
|
| - glClearDepthf(static_cast<GLclampf>(depth));
|
| -}
|
| -
|
| -void GL_BINDING_CALL MarshalDepthRangeToDepthRangef(GLclampd z_near,
|
| - GLclampd z_far) {
|
| - glDepthRangef(static_cast<GLclampf>(z_near), static_cast<GLclampf>(z_far));
|
| -}
|
| -
|
| +const char kOpenGLFrameworkPath[] =
|
| + "/System/Library/Frameworks/OpenGL.framework/Versions/Current/OpenGL";
|
| } // namespace
|
|
|
| void GetAllowedGLImplementations(std::vector<GLImplementation>* impls) {
|
| - impls->push_back(kGLImplementationEGLGLES2);
|
| + impls->push_back(kGLImplementationDesktopGL);
|
| + impls->push_back(kGLImplementationAppleGL);
|
| impls->push_back(kGLImplementationOSMesaGL);
|
| }
|
|
|
| @@ -42,52 +35,67 @@ bool InitializeStaticGLBindings(GLImplementation implementation) {
|
| DCHECK_EQ(kGLImplementationNone, GetGLImplementation());
|
|
|
| switch (implementation) {
|
| - case kGLImplementationEGLGLES2: {
|
| - base::NativeLibrary gles_library =
|
| - LoadLibraryAndPrintError("libGLESv2.so");
|
| - if (!gles_library)
|
| + case kGLImplementationOSMesaGL: {
|
| + // osmesa.so is located in the build directory. This code path is only
|
| + // valid in a developer build environment.
|
| + base::FilePath exe_path;
|
| + if (!PathService::Get(base::FILE_EXE, &exe_path)) {
|
| + LOG(ERROR) << "PathService::Get failed.";
|
| return false;
|
| - base::NativeLibrary egl_library = LoadLibraryAndPrintError("libEGL.so");
|
| - if (!egl_library) {
|
| - base::UnloadNativeLibrary(gles_library);
|
| + }
|
| + base::FilePath bundle_path = base::mac::GetAppBundlePath(exe_path);
|
| + // Some unit test targets depend on osmesa but aren't built as app
|
| + // bundles. In that case, the .so is next to the executable.
|
| + if (bundle_path.empty())
|
| + bundle_path = exe_path;
|
| + base::FilePath build_dir_path = bundle_path.DirName();
|
| + base::FilePath osmesa_path = build_dir_path.Append("osmesa.so");
|
| +
|
| + // When using OSMesa, just use OSMesaGetProcAddress to find entry points.
|
| + base::NativeLibrary library = base::LoadNativeLibrary(osmesa_path, NULL);
|
| + if (!library) {
|
| + LOG(ERROR) << "osmesa.so not found at " << osmesa_path.value();
|
| return false;
|
| }
|
|
|
| GLGetProcAddressProc get_proc_address =
|
| reinterpret_cast<GLGetProcAddressProc>(
|
| base::GetFunctionPointerFromNativeLibrary(
|
| - egl_library, "eglGetProcAddress"));
|
| + library, "OSMesaGetProcAddress"));
|
| if (!get_proc_address) {
|
| - LOG(ERROR) << "eglGetProcAddress not found.";
|
| - base::UnloadNativeLibrary(egl_library);
|
| - base::UnloadNativeLibrary(gles_library);
|
| + LOG(ERROR) << "OSMesaGetProcAddress not found.";
|
| + base::UnloadNativeLibrary(library);
|
| return false;
|
| }
|
|
|
| SetGLGetProcAddressProc(get_proc_address);
|
| - AddGLNativeLibrary(egl_library);
|
| - AddGLNativeLibrary(gles_library);
|
| - SetGLImplementation(kGLImplementationEGLGLES2);
|
| + AddGLNativeLibrary(library);
|
| + SetGLImplementation(kGLImplementationOSMesaGL);
|
|
|
| InitializeStaticGLBindingsGL();
|
| - InitializeStaticGLBindingsEGL();
|
| -
|
| - // These two functions take single precision float rather than double
|
| - // precision float parameters in GLES.
|
| - ::gfx::g_driver_gl.fn.glClearDepthFn = MarshalClearDepthToClearDepthf;
|
| - ::gfx::g_driver_gl.fn.glDepthRangeFn = MarshalDepthRangeToDepthRangef;
|
| break;
|
| }
|
| - case kGLImplementationOSMesaGL:
|
| - InitializeStaticGLBindingsOSMesaGL();
|
| + case kGLImplementationDesktopGL:
|
| + case kGLImplementationAppleGL: {
|
| + base::NativeLibrary library = base::LoadNativeLibrary(
|
| + base::FilePath(kOpenGLFrameworkPath), NULL);
|
| + if (!library) {
|
| + LOG(ERROR) << "OpenGL framework not found";
|
| + return false;
|
| + }
|
| +
|
| + AddGLNativeLibrary(library);
|
| + SetGLImplementation(implementation);
|
| +
|
| + InitializeStaticGLBindingsGL();
|
| break;
|
| + }
|
| case kGLImplementationMockGL: {
|
| SetGLImplementation(kGLImplementationMockGL);
|
| InitializeStaticGLBindingsGL();
|
| break;
|
| }
|
| default:
|
| - NOTIMPLEMENTED() << "InitializeStaticGLBindings on Android";
|
| return false;
|
| }
|
|
|
| @@ -95,22 +103,23 @@ bool InitializeStaticGLBindings(GLImplementation implementation) {
|
| }
|
|
|
| bool InitializeDynamicGLBindings(GLImplementation implementation,
|
| - GLContext* context) {
|
| + GLContext* context) {
|
| switch (implementation) {
|
| - case kGLImplementationEGLGLES2:
|
| + case kGLImplementationOSMesaGL:
|
| + case kGLImplementationDesktopGL:
|
| + case kGLImplementationAppleGL:
|
| InitializeDynamicGLBindingsGL(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;
|
| }
|
|
|
| @@ -118,27 +127,17 @@ bool InitializeDynamicGLBindings(GLImplementation implementation,
|
| }
|
|
|
| void InitializeDebugGLBindings() {
|
| - InitializeDebugGLBindingsEGL();
|
| InitializeDebugGLBindingsGL();
|
| - InitializeDebugGLBindingsOSMESA();
|
| }
|
|
|
| void ClearGLBindings() {
|
| - ClearGLBindingsEGL();
|
| ClearGLBindingsGL();
|
| - ClearGLBindingsOSMESA();
|
| SetGLImplementation(kGLImplementationNone);
|
|
|
| UnloadGLNativeLibraries();
|
| }
|
|
|
| bool GetGLWindowSystemBindingInfo(GLWindowSystemBindingInfo* info) {
|
| - switch (GetGLImplementation()) {
|
| - case kGLImplementationEGLGLES2:
|
| - return GetGLWindowSystemBindingInfoEGL(info);
|
| - default:
|
| - return false;
|
| - }
|
| return false;
|
| }
|
|
|
|
|