diff options
author | senorblanco@chromium.org <senorblanco@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-12-07 19:15:42 +0000 |
---|---|---|
committer | senorblanco@chromium.org <senorblanco@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-12-07 19:15:42 +0000 |
commit | 020d047e85ccb8e634bc4f6d3356c8d64a2d7f97 (patch) | |
tree | b84a5afc223a809b018c1b390c0361070ca59dd1 /ui/gfx/gl | |
parent | fbbcbaf43b973f38cfd00cedf048f0cb3655a5e7 (diff) | |
download | chromium_src-020d047e85ccb8e634bc4f6d3356c8d64a2d7f97.zip chromium_src-020d047e85ccb8e634bc4f6d3356c8d64a2d7f97.tar.gz chromium_src-020d047e85ccb8e634bc4f6d3356c8d64a2d7f97.tar.bz2 |
This change adds the apple software renderer as an option on Chrome/Mac. It's enabled by passing --use-gl=apple on the command line. It also removes the default pbuffer creation on Mac since it's not required to create GL contexts and is incompatible with the generic float renderer.
BUG=106584
TEST=--use-gl=apple on chrome/mac cmdline
Review URL: http://codereview.chromium.org/8698008
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@113436 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ui/gfx/gl')
-rw-r--r-- | ui/gfx/gl/gl_bindings_skia_in_process.cc | 1 | ||||
-rw-r--r-- | ui/gfx/gl/gl_context.cc | 1 | ||||
-rw-r--r-- | ui/gfx/gl/gl_context_cgl.cc | 31 | ||||
-rw-r--r-- | ui/gfx/gl/gl_context_mac.mm | 3 | ||||
-rw-r--r-- | ui/gfx/gl/gl_implementation.cc | 7 | ||||
-rw-r--r-- | ui/gfx/gl/gl_implementation.h | 1 | ||||
-rw-r--r-- | ui/gfx/gl/gl_implementation_mac.cc | 7 | ||||
-rw-r--r-- | ui/gfx/gl/gl_surface_cgl.cc | 8 | ||||
-rw-r--r-- | ui/gfx/gl/gl_surface_mac.cc | 7 | ||||
-rw-r--r-- | ui/gfx/gl/gl_switches.cc | 1 | ||||
-rw-r--r-- | ui/gfx/gl/gl_switches.h | 1 |
11 files changed, 37 insertions, 31 deletions
diff --git a/ui/gfx/gl/gl_bindings_skia_in_process.cc b/ui/gfx/gl/gl_bindings_skia_in_process.cc index 5059bfe..2b84006 100644 --- a/ui/gfx/gl/gl_bindings_skia_in_process.cc +++ b/ui/gfx/gl/gl_bindings_skia_in_process.cc @@ -528,6 +528,7 @@ GrGLInterface* CreateInProcessSkiaGLBinding() { NOTREACHED(); return NULL; case gfx::kGLImplementationDesktopGL: + case gfx::kGLImplementationAppleGL: binding = kDesktop_GrGLBinding; break; case gfx::kGLImplementationOSMesaGL: diff --git a/ui/gfx/gl/gl_context.cc b/ui/gfx/gl/gl_context.cc index e3b9612..199ee7d 100644 --- a/ui/gfx/gl/gl_context.cc +++ b/ui/gfx/gl/gl_context.cc @@ -76,6 +76,7 @@ bool GLContext::LosesAllContextsOnContextLost() { case kGLImplementationEGLGLES2: return true; case kGLImplementationOSMesaGL: + case kGLImplementationAppleGL: return false; case kGLImplementationMockGL: return false; diff --git a/ui/gfx/gl/gl_context_cgl.cc b/ui/gfx/gl/gl_context_cgl.cc index 8790602..b95f7ff 100644 --- a/ui/gfx/gl/gl_context_cgl.cc +++ b/ui/gfx/gl/gl_context_cgl.cc @@ -4,10 +4,12 @@ #include "ui/gfx/gl/gl_context_cgl.h" +#include <OpenGL/CGLRenderers.h> #include <vector> #include "base/logging.h" #include "ui/gfx/gl/gl_bindings.h" +#include "ui/gfx/gl/gl_implementation.h" #include "ui/gfx/gl/gl_surface_cgl.h" namespace gfx { @@ -42,6 +44,10 @@ bool GLContextCGL::Initialize( if (using_offline_renderer) { attribs.push_back(kCGLPFAAllowOfflineRenderers); } + if (GetGLImplementation() == kGLImplementationAppleGL) { + attribs.push_back(kCGLPFARendererID); + attribs.push_back((CGLPixelFormatAttribute) kCGLRendererGenericFloatID); + } attribs.push_back((CGLPixelFormatAttribute) 0); CGLPixelFormatObj format; @@ -86,16 +92,6 @@ bool GLContextCGL::MakeCurrent(GLSurface* surface) { if (IsCurrent(surface)) return true; - if (CGLSetPBuffer(static_cast<CGLContextObj>(context_), - static_cast<CGLPBufferObj>(surface->GetHandle()), - 0, - 0, - 0) != kCGLNoError) { - LOG(ERROR) << "Error attaching pbuffer to context."; - Destroy(); - return false; - } - if (CGLSetCurrentContext( static_cast<CGLContextObj>(context_)) != kCGLNoError) { LOG(ERROR) << "Unable to make gl context current."; @@ -122,7 +118,6 @@ void GLContextCGL::ReleaseCurrent(GLSurface* surface) { SetCurrent(NULL, NULL); CGLSetCurrentContext(NULL); - CGLSetPBuffer(static_cast<CGLContextObj>(context_), NULL, 0, 0, 0); } bool GLContextCGL::IsCurrent(GLSurface* surface) { @@ -136,20 +131,6 @@ bool GLContextCGL::IsCurrent(GLSurface* surface) { if (!native_context_is_current) return false; - if (surface) { - CGLPBufferObj current_surface = NULL; - GLenum face; - GLint level; - GLint screen; - CGLGetPBuffer(static_cast<CGLContextObj>(context_), - ¤t_surface, - &face, - &level, - &screen); - if (current_surface != surface->GetHandle()) - return false; - } - return true; } diff --git a/ui/gfx/gl/gl_context_mac.mm b/ui/gfx/gl/gl_context_mac.mm index 2fcd085..6e68ccf 100644 --- a/ui/gfx/gl/gl_context_mac.mm +++ b/ui/gfx/gl/gl_context_mac.mm @@ -40,7 +40,8 @@ scoped_refptr<GLContext> GLContext::CreateGLContext( GLSurface* compatible_surface, GpuPreference gpu_preference) { switch (GetGLImplementation()) { - case kGLImplementationDesktopGL: { + case kGLImplementationDesktopGL: + case kGLImplementationAppleGL: { scoped_refptr<GLContext> context; #if defined(USE_AURA) if (compatible_surface->IsOffscreen()) diff --git a/ui/gfx/gl/gl_implementation.cc b/ui/gfx/gl/gl_implementation.cc index 0f5df21..d225d57 100644 --- a/ui/gfx/gl/gl_implementation.cc +++ b/ui/gfx/gl/gl_implementation.cc @@ -21,6 +21,9 @@ const struct { } kGLImplementationNamePairs[] = { { kGLImplementationDesktopName, kGLImplementationDesktopGL }, { kGLImplementationOSMesaName, kGLImplementationOSMesaGL }, +#if defined(OS_MACOSX) + { kGLImplementationAppleName, kGLImplementationAppleGL }, +#endif { kGLImplementationEGLName, kGLImplementationEGLGLES2 }, { kGLImplementationMockName, kGLImplementationMockGL } }; @@ -46,6 +49,7 @@ bool ExportsCoreFunctionsFromGetProcAddress(GLImplementation implementation) { switch (GetGLImplementation()) { case kGLImplementationDesktopGL: case kGLImplementationOSMesaGL: + case kGLImplementationAppleGL: case kGLImplementationMockGL: return true; case kGLImplementationEGLGLES2: @@ -86,7 +90,8 @@ GLImplementation GetGLImplementation() { bool HasDesktopGLFeatures() { return kGLImplementationDesktopGL == g_gl_implementation || - kGLImplementationOSMesaGL == g_gl_implementation; + kGLImplementationOSMesaGL == g_gl_implementation || + kGLImplementationAppleGL == g_gl_implementation; } void AddGLNativeLibrary(base::NativeLibrary library) { diff --git a/ui/gfx/gl/gl_implementation.h b/ui/gfx/gl/gl_implementation.h index cfbb33a..cd27dff 100644 --- a/ui/gfx/gl/gl_implementation.h +++ b/ui/gfx/gl/gl_implementation.h @@ -23,6 +23,7 @@ enum GLImplementation { kGLImplementationNone, kGLImplementationDesktopGL, kGLImplementationOSMesaGL, + kGLImplementationAppleGL, kGLImplementationEGLGLES2, kGLImplementationMockGL }; diff --git a/ui/gfx/gl/gl_implementation_mac.cc b/ui/gfx/gl/gl_implementation_mac.cc index a3574fa..c2ba2e2 100644 --- a/ui/gfx/gl/gl_implementation_mac.cc +++ b/ui/gfx/gl/gl_implementation_mac.cc @@ -20,6 +20,7 @@ const char kOpenGLFrameworkPath[] = void GetAllowedGLImplementations(std::vector<GLImplementation>* impls) { impls->push_back(kGLImplementationDesktopGL); + impls->push_back(kGLImplementationAppleGL); impls->push_back(kGLImplementationOSMesaGL); } @@ -74,7 +75,8 @@ bool InitializeGLBindings(GLImplementation implementation) { InitializeGLBindingsOSMESA(); break; } - case kGLImplementationDesktopGL: { + case kGLImplementationDesktopGL: + case kGLImplementationAppleGL: { base::NativeLibrary library = base::LoadNativeLibrary( FilePath(kOpenGLFrameworkPath), NULL); if (!library) { @@ -83,7 +85,7 @@ bool InitializeGLBindings(GLImplementation implementation) { } AddGLNativeLibrary(library); - SetGLImplementation(kGLImplementationDesktopGL); + SetGLImplementation(implementation); InitializeGLBindingsGL(); break; @@ -109,6 +111,7 @@ bool InitializeGLExtensionBindings(GLImplementation implementation, InitializeGLExtensionBindingsOSMESA(context); break; case kGLImplementationDesktopGL: + case kGLImplementationAppleGL: InitializeGLExtensionBindingsGL(context); break; case kGLImplementationMockGL: diff --git a/ui/gfx/gl/gl_surface_cgl.cc b/ui/gfx/gl/gl_surface_cgl.cc index 695d744..5f3ec58 100644 --- a/ui/gfx/gl/gl_surface_cgl.cc +++ b/ui/gfx/gl/gl_surface_cgl.cc @@ -4,11 +4,14 @@ #include "ui/gfx/gl/gl_surface_cgl.h" +#include <OpenGL/CGLRenderers.h> + #include "base/basictypes.h" #include "base/logging.h" #include "base/mac/mac_util.h" #include "ui/gfx/gl/gl_bindings.h" #include "ui/gfx/gl/gl_context.h" +#include "ui/gfx/gl/gl_implementation.h" namespace gfx { @@ -36,6 +39,11 @@ bool GLSurfaceCGL::InitializeOneOff() { // format selection. attribs.push_back(kCGLPFAAllowOfflineRenderers); } + if (GetGLImplementation() == kGLImplementationAppleGL) { + attribs.push_back(kCGLPFARendererID); + attribs.push_back(static_cast<CGLPixelFormatAttribute>( + kCGLRendererGenericFloatID)); + } attribs.push_back(static_cast<CGLPixelFormatAttribute>(0)); CGLPixelFormatObj format; diff --git a/ui/gfx/gl/gl_surface_mac.cc b/ui/gfx/gl/gl_surface_mac.cc index ebe3cc3..40b7f03 100644 --- a/ui/gfx/gl/gl_surface_mac.cc +++ b/ui/gfx/gl/gl_surface_mac.cc @@ -22,6 +22,7 @@ namespace gfx { bool GLSurface::InitializeOneOffInternal() { switch (GetGLImplementation()) { case kGLImplementationDesktopGL: + case kGLImplementationAppleGL: if (!GLSurfaceCGL::InitializeOneOff()) { LOG(ERROR) << "GLSurfaceCGL::InitializeOneOff failed."; return false; @@ -41,7 +42,8 @@ scoped_refptr<GLSurface> GLSurface::CreateViewGLSurface( return NULL; switch (GetGLImplementation()) { - case kGLImplementationDesktopGL: { + case kGLImplementationDesktopGL: + case kGLImplementationAppleGL: { scoped_refptr<GLSurface> surface(new GLSurfaceNSView(window)); if (!surface->Initialize()) return NULL; @@ -74,7 +76,8 @@ scoped_refptr<GLSurface> GLSurface::CreateOffscreenGLSurface( return surface; } - case kGLImplementationDesktopGL: { + case kGLImplementationDesktopGL: + case kGLImplementationAppleGL: { scoped_refptr<GLSurface> surface(new PbufferGLSurfaceCGL(size)); if (!surface->Initialize()) return NULL; diff --git a/ui/gfx/gl/gl_switches.cc b/ui/gfx/gl/gl_switches.cc index c79397f..2fed5ee 100644 --- a/ui/gfx/gl/gl_switches.cc +++ b/ui/gfx/gl/gl_switches.cc @@ -8,6 +8,7 @@ namespace gfx { const char kGLImplementationDesktopName[] = "desktop"; const char kGLImplementationOSMesaName[] = "osmesa"; +const char kGLImplementationAppleName[] = "apple"; const char kGLImplementationEGLName[] = "egl"; const char kGLImplementationSwiftShaderName[] = "swiftshader"; const char kGLImplementationMockName[] = "mock"; diff --git a/ui/gfx/gl/gl_switches.h b/ui/gfx/gl/gl_switches.h index 75ec7ea..745eb65 100644 --- a/ui/gfx/gl/gl_switches.h +++ b/ui/gfx/gl/gl_switches.h @@ -15,6 +15,7 @@ namespace gfx { // The GL implementation names that can be passed to --use-gl. GL_EXPORT extern const char kGLImplementationDesktopName[]; GL_EXPORT extern const char kGLImplementationOSMesaName[]; +GL_EXPORT extern const char kGLImplementationAppleName[]; GL_EXPORT extern const char kGLImplementationEGLName[]; extern const char kGLImplementationMockName[]; |