This change adds the apple software renderer as an option on Chrome/Mac. It's...

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
parent fbbcbaf4
...@@ -528,6 +528,7 @@ GrGLInterface* CreateInProcessSkiaGLBinding() { ...@@ -528,6 +528,7 @@ GrGLInterface* CreateInProcessSkiaGLBinding() {
NOTREACHED(); NOTREACHED();
return NULL; return NULL;
case gfx::kGLImplementationDesktopGL: case gfx::kGLImplementationDesktopGL:
case gfx::kGLImplementationAppleGL:
binding = kDesktop_GrGLBinding; binding = kDesktop_GrGLBinding;
break; break;
case gfx::kGLImplementationOSMesaGL: case gfx::kGLImplementationOSMesaGL:
......
...@@ -76,6 +76,7 @@ bool GLContext::LosesAllContextsOnContextLost() { ...@@ -76,6 +76,7 @@ bool GLContext::LosesAllContextsOnContextLost() {
case kGLImplementationEGLGLES2: case kGLImplementationEGLGLES2:
return true; return true;
case kGLImplementationOSMesaGL: case kGLImplementationOSMesaGL:
case kGLImplementationAppleGL:
return false; return false;
case kGLImplementationMockGL: case kGLImplementationMockGL:
return false; return false;
......
...@@ -4,10 +4,12 @@ ...@@ -4,10 +4,12 @@
#include "ui/gfx/gl/gl_context_cgl.h" #include "ui/gfx/gl/gl_context_cgl.h"
#include <OpenGL/CGLRenderers.h>
#include <vector> #include <vector>
#include "base/logging.h" #include "base/logging.h"
#include "ui/gfx/gl/gl_bindings.h" #include "ui/gfx/gl/gl_bindings.h"
#include "ui/gfx/gl/gl_implementation.h"
#include "ui/gfx/gl/gl_surface_cgl.h" #include "ui/gfx/gl/gl_surface_cgl.h"
namespace gfx { namespace gfx {
...@@ -42,6 +44,10 @@ bool GLContextCGL::Initialize( ...@@ -42,6 +44,10 @@ bool GLContextCGL::Initialize(
if (using_offline_renderer) { if (using_offline_renderer) {
attribs.push_back(kCGLPFAAllowOfflineRenderers); attribs.push_back(kCGLPFAAllowOfflineRenderers);
} }
if (GetGLImplementation() == kGLImplementationAppleGL) {
attribs.push_back(kCGLPFARendererID);
attribs.push_back((CGLPixelFormatAttribute) kCGLRendererGenericFloatID);
}
attribs.push_back((CGLPixelFormatAttribute) 0); attribs.push_back((CGLPixelFormatAttribute) 0);
CGLPixelFormatObj format; CGLPixelFormatObj format;
...@@ -86,16 +92,6 @@ bool GLContextCGL::MakeCurrent(GLSurface* surface) { ...@@ -86,16 +92,6 @@ bool GLContextCGL::MakeCurrent(GLSurface* surface) {
if (IsCurrent(surface)) if (IsCurrent(surface))
return true; 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( if (CGLSetCurrentContext(
static_cast<CGLContextObj>(context_)) != kCGLNoError) { static_cast<CGLContextObj>(context_)) != kCGLNoError) {
LOG(ERROR) << "Unable to make gl context current."; LOG(ERROR) << "Unable to make gl context current.";
...@@ -122,7 +118,6 @@ void GLContextCGL::ReleaseCurrent(GLSurface* surface) { ...@@ -122,7 +118,6 @@ void GLContextCGL::ReleaseCurrent(GLSurface* surface) {
SetCurrent(NULL, NULL); SetCurrent(NULL, NULL);
CGLSetCurrentContext(NULL); CGLSetCurrentContext(NULL);
CGLSetPBuffer(static_cast<CGLContextObj>(context_), NULL, 0, 0, 0);
} }
bool GLContextCGL::IsCurrent(GLSurface* surface) { bool GLContextCGL::IsCurrent(GLSurface* surface) {
...@@ -136,20 +131,6 @@ bool GLContextCGL::IsCurrent(GLSurface* surface) { ...@@ -136,20 +131,6 @@ bool GLContextCGL::IsCurrent(GLSurface* surface) {
if (!native_context_is_current) if (!native_context_is_current)
return false; return false;
if (surface) {
CGLPBufferObj current_surface = NULL;
GLenum face;
GLint level;
GLint screen;
CGLGetPBuffer(static_cast<CGLContextObj>(context_),
&current_surface,
&face,
&level,
&screen);
if (current_surface != surface->GetHandle())
return false;
}
return true; return true;
} }
......
...@@ -40,7 +40,8 @@ scoped_refptr<GLContext> GLContext::CreateGLContext( ...@@ -40,7 +40,8 @@ scoped_refptr<GLContext> GLContext::CreateGLContext(
GLSurface* compatible_surface, GLSurface* compatible_surface,
GpuPreference gpu_preference) { GpuPreference gpu_preference) {
switch (GetGLImplementation()) { switch (GetGLImplementation()) {
case kGLImplementationDesktopGL: { case kGLImplementationDesktopGL:
case kGLImplementationAppleGL: {
scoped_refptr<GLContext> context; scoped_refptr<GLContext> context;
#if defined(USE_AURA) #if defined(USE_AURA)
if (compatible_surface->IsOffscreen()) if (compatible_surface->IsOffscreen())
......
...@@ -21,6 +21,9 @@ const struct { ...@@ -21,6 +21,9 @@ const struct {
} kGLImplementationNamePairs[] = { } kGLImplementationNamePairs[] = {
{ kGLImplementationDesktopName, kGLImplementationDesktopGL }, { kGLImplementationDesktopName, kGLImplementationDesktopGL },
{ kGLImplementationOSMesaName, kGLImplementationOSMesaGL }, { kGLImplementationOSMesaName, kGLImplementationOSMesaGL },
#if defined(OS_MACOSX)
{ kGLImplementationAppleName, kGLImplementationAppleGL },
#endif
{ kGLImplementationEGLName, kGLImplementationEGLGLES2 }, { kGLImplementationEGLName, kGLImplementationEGLGLES2 },
{ kGLImplementationMockName, kGLImplementationMockGL } { kGLImplementationMockName, kGLImplementationMockGL }
}; };
...@@ -46,6 +49,7 @@ bool ExportsCoreFunctionsFromGetProcAddress(GLImplementation implementation) { ...@@ -46,6 +49,7 @@ bool ExportsCoreFunctionsFromGetProcAddress(GLImplementation implementation) {
switch (GetGLImplementation()) { switch (GetGLImplementation()) {
case kGLImplementationDesktopGL: case kGLImplementationDesktopGL:
case kGLImplementationOSMesaGL: case kGLImplementationOSMesaGL:
case kGLImplementationAppleGL:
case kGLImplementationMockGL: case kGLImplementationMockGL:
return true; return true;
case kGLImplementationEGLGLES2: case kGLImplementationEGLGLES2:
...@@ -86,7 +90,8 @@ GLImplementation GetGLImplementation() { ...@@ -86,7 +90,8 @@ GLImplementation GetGLImplementation() {
bool HasDesktopGLFeatures() { bool HasDesktopGLFeatures() {
return kGLImplementationDesktopGL == g_gl_implementation || return kGLImplementationDesktopGL == g_gl_implementation ||
kGLImplementationOSMesaGL == g_gl_implementation; kGLImplementationOSMesaGL == g_gl_implementation ||
kGLImplementationAppleGL == g_gl_implementation;
} }
void AddGLNativeLibrary(base::NativeLibrary library) { void AddGLNativeLibrary(base::NativeLibrary library) {
......
...@@ -23,6 +23,7 @@ enum GLImplementation { ...@@ -23,6 +23,7 @@ enum GLImplementation {
kGLImplementationNone, kGLImplementationNone,
kGLImplementationDesktopGL, kGLImplementationDesktopGL,
kGLImplementationOSMesaGL, kGLImplementationOSMesaGL,
kGLImplementationAppleGL,
kGLImplementationEGLGLES2, kGLImplementationEGLGLES2,
kGLImplementationMockGL kGLImplementationMockGL
}; };
......
...@@ -20,6 +20,7 @@ const char kOpenGLFrameworkPath[] = ...@@ -20,6 +20,7 @@ const char kOpenGLFrameworkPath[] =
void GetAllowedGLImplementations(std::vector<GLImplementation>* impls) { void GetAllowedGLImplementations(std::vector<GLImplementation>* impls) {
impls->push_back(kGLImplementationDesktopGL); impls->push_back(kGLImplementationDesktopGL);
impls->push_back(kGLImplementationAppleGL);
impls->push_back(kGLImplementationOSMesaGL); impls->push_back(kGLImplementationOSMesaGL);
} }
...@@ -74,7 +75,8 @@ bool InitializeGLBindings(GLImplementation implementation) { ...@@ -74,7 +75,8 @@ bool InitializeGLBindings(GLImplementation implementation) {
InitializeGLBindingsOSMESA(); InitializeGLBindingsOSMESA();
break; break;
} }
case kGLImplementationDesktopGL: { case kGLImplementationDesktopGL:
case kGLImplementationAppleGL: {
base::NativeLibrary library = base::LoadNativeLibrary( base::NativeLibrary library = base::LoadNativeLibrary(
FilePath(kOpenGLFrameworkPath), NULL); FilePath(kOpenGLFrameworkPath), NULL);
if (!library) { if (!library) {
...@@ -83,7 +85,7 @@ bool InitializeGLBindings(GLImplementation implementation) { ...@@ -83,7 +85,7 @@ bool InitializeGLBindings(GLImplementation implementation) {
} }
AddGLNativeLibrary(library); AddGLNativeLibrary(library);
SetGLImplementation(kGLImplementationDesktopGL); SetGLImplementation(implementation);
InitializeGLBindingsGL(); InitializeGLBindingsGL();
break; break;
...@@ -109,6 +111,7 @@ bool InitializeGLExtensionBindings(GLImplementation implementation, ...@@ -109,6 +111,7 @@ bool InitializeGLExtensionBindings(GLImplementation implementation,
InitializeGLExtensionBindingsOSMESA(context); InitializeGLExtensionBindingsOSMESA(context);
break; break;
case kGLImplementationDesktopGL: case kGLImplementationDesktopGL:
case kGLImplementationAppleGL:
InitializeGLExtensionBindingsGL(context); InitializeGLExtensionBindingsGL(context);
break; break;
case kGLImplementationMockGL: case kGLImplementationMockGL:
......
...@@ -4,11 +4,14 @@ ...@@ -4,11 +4,14 @@
#include "ui/gfx/gl/gl_surface_cgl.h" #include "ui/gfx/gl/gl_surface_cgl.h"
#include <OpenGL/CGLRenderers.h>
#include "base/basictypes.h" #include "base/basictypes.h"
#include "base/logging.h" #include "base/logging.h"
#include "base/mac/mac_util.h" #include "base/mac/mac_util.h"
#include "ui/gfx/gl/gl_bindings.h" #include "ui/gfx/gl/gl_bindings.h"
#include "ui/gfx/gl/gl_context.h" #include "ui/gfx/gl/gl_context.h"
#include "ui/gfx/gl/gl_implementation.h"
namespace gfx { namespace gfx {
...@@ -36,6 +39,11 @@ bool GLSurfaceCGL::InitializeOneOff() { ...@@ -36,6 +39,11 @@ bool GLSurfaceCGL::InitializeOneOff() {
// format selection. // format selection.
attribs.push_back(kCGLPFAAllowOfflineRenderers); 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)); attribs.push_back(static_cast<CGLPixelFormatAttribute>(0));
CGLPixelFormatObj format; CGLPixelFormatObj format;
......
...@@ -22,6 +22,7 @@ namespace gfx { ...@@ -22,6 +22,7 @@ namespace gfx {
bool GLSurface::InitializeOneOffInternal() { bool GLSurface::InitializeOneOffInternal() {
switch (GetGLImplementation()) { switch (GetGLImplementation()) {
case kGLImplementationDesktopGL: case kGLImplementationDesktopGL:
case kGLImplementationAppleGL:
if (!GLSurfaceCGL::InitializeOneOff()) { if (!GLSurfaceCGL::InitializeOneOff()) {
LOG(ERROR) << "GLSurfaceCGL::InitializeOneOff failed."; LOG(ERROR) << "GLSurfaceCGL::InitializeOneOff failed.";
return false; return false;
...@@ -41,7 +42,8 @@ scoped_refptr<GLSurface> GLSurface::CreateViewGLSurface( ...@@ -41,7 +42,8 @@ scoped_refptr<GLSurface> GLSurface::CreateViewGLSurface(
return NULL; return NULL;
switch (GetGLImplementation()) { switch (GetGLImplementation()) {
case kGLImplementationDesktopGL: { case kGLImplementationDesktopGL:
case kGLImplementationAppleGL: {
scoped_refptr<GLSurface> surface(new GLSurfaceNSView(window)); scoped_refptr<GLSurface> surface(new GLSurfaceNSView(window));
if (!surface->Initialize()) if (!surface->Initialize())
return NULL; return NULL;
...@@ -74,7 +76,8 @@ scoped_refptr<GLSurface> GLSurface::CreateOffscreenGLSurface( ...@@ -74,7 +76,8 @@ scoped_refptr<GLSurface> GLSurface::CreateOffscreenGLSurface(
return surface; return surface;
} }
case kGLImplementationDesktopGL: { case kGLImplementationDesktopGL:
case kGLImplementationAppleGL: {
scoped_refptr<GLSurface> surface(new PbufferGLSurfaceCGL(size)); scoped_refptr<GLSurface> surface(new PbufferGLSurfaceCGL(size));
if (!surface->Initialize()) if (!surface->Initialize())
return NULL; return NULL;
......
...@@ -8,6 +8,7 @@ namespace gfx { ...@@ -8,6 +8,7 @@ namespace gfx {
const char kGLImplementationDesktopName[] = "desktop"; const char kGLImplementationDesktopName[] = "desktop";
const char kGLImplementationOSMesaName[] = "osmesa"; const char kGLImplementationOSMesaName[] = "osmesa";
const char kGLImplementationAppleName[] = "apple";
const char kGLImplementationEGLName[] = "egl"; const char kGLImplementationEGLName[] = "egl";
const char kGLImplementationSwiftShaderName[] = "swiftshader"; const char kGLImplementationSwiftShaderName[] = "swiftshader";
const char kGLImplementationMockName[] = "mock"; const char kGLImplementationMockName[] = "mock";
......
...@@ -15,6 +15,7 @@ namespace gfx { ...@@ -15,6 +15,7 @@ namespace gfx {
// The GL implementation names that can be passed to --use-gl. // The GL implementation names that can be passed to --use-gl.
GL_EXPORT extern const char kGLImplementationDesktopName[]; GL_EXPORT extern const char kGLImplementationDesktopName[];
GL_EXPORT extern const char kGLImplementationOSMesaName[]; GL_EXPORT extern const char kGLImplementationOSMesaName[];
GL_EXPORT extern const char kGLImplementationAppleName[];
GL_EXPORT extern const char kGLImplementationEGLName[]; GL_EXPORT extern const char kGLImplementationEGLName[];
extern const char kGLImplementationMockName[]; extern const char kGLImplementationMockName[];
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment