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() {
NOTREACHED();
return NULL;
case gfx::kGLImplementationDesktopGL:
case gfx::kGLImplementationAppleGL:
binding = kDesktop_GrGLBinding;
break;
case gfx::kGLImplementationOSMesaGL:
......
......@@ -76,6 +76,7 @@ bool GLContext::LosesAllContextsOnContextLost() {
case kGLImplementationEGLGLES2:
return true;
case kGLImplementationOSMesaGL:
case kGLImplementationAppleGL:
return false;
case kGLImplementationMockGL:
return false;
......
......@@ -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_),
&current_surface,
&face,
&level,
&screen);
if (current_surface != surface->GetHandle())
return false;
}
return true;
}
......
......@@ -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())
......
......@@ -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) {
......
......@@ -23,6 +23,7 @@ enum GLImplementation {
kGLImplementationNone,
kGLImplementationDesktopGL,
kGLImplementationOSMesaGL,
kGLImplementationAppleGL,
kGLImplementationEGLGLES2,
kGLImplementationMockGL
};
......
......@@ -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:
......
......@@ -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;
......
......@@ -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;
......
......@@ -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";
......
......@@ -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[];
......
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