diff options
author | apatrick@chromium.org <apatrick@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-05-11 19:41:58 +0000 |
---|---|---|
committer | apatrick@chromium.org <apatrick@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-05-11 19:41:58 +0000 |
commit | 333c5c9ca65425d1796d9d13abda37ecbce2c9fb (patch) | |
tree | 85b92482a6ed18f7be48b153352436be89eb5b3e /ui/gfx/gl/gl_context_mac.cc | |
parent | 374d9094395c15cd3b337de5c36587312fcc8a1e (diff) | |
download | chromium_src-333c5c9ca65425d1796d9d13abda37ecbce2c9fb.zip chromium_src-333c5c9ca65425d1796d9d13abda37ecbce2c9fb.tar.gz chromium_src-333c5c9ca65425d1796d9d13abda37ecbce2c9fb.tar.bz2 |
Revert 85013 - Split GLContext::Create*GLContext into GLSurface::Create*GLSurface plus a surface type independent GLContext::CreateGLContext.
TEST=webgl on windows and mac, trybots
BUG=none
Review URL: http://codereview.chromium.org/6997003
TBR=apatrick@chromium.org
Review URL: http://codereview.chromium.org/7015003
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@85016 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ui/gfx/gl/gl_context_mac.cc')
-rw-r--r-- | ui/gfx/gl/gl_context_mac.cc | 52 |
1 files changed, 45 insertions, 7 deletions
diff --git a/ui/gfx/gl/gl_context_mac.cc b/ui/gfx/gl/gl_context_mac.cc index ba72080..fbb18b0 100644 --- a/ui/gfx/gl/gl_context_mac.cc +++ b/ui/gfx/gl/gl_context_mac.cc @@ -16,28 +16,66 @@ namespace gfx { -GLContext* GLContext::CreateGLContext(GLSurface* compatible_surface, - GLContext* shared_context) { +bool GLContext::InitializeOneOff() { + static bool initialized = false; + if (initialized) + return true; + + static const GLImplementation kAllowedGLImplementations[] = { + kGLImplementationDesktopGL, + kGLImplementationOSMesaGL + }; + + if (!InitializeRequestedGLBindings( + kAllowedGLImplementations, + kAllowedGLImplementations + arraysize(kAllowedGLImplementations), + kGLImplementationDesktopGL)) { + LOG(ERROR) << "InitializeRequestedGLBindings failed."; + return false; + } + + switch (GetGLImplementation()) { + case kGLImplementationDesktopGL: + if (!GLSurfaceCGL::InitializeOneOff()) { + LOG(ERROR) << "GLSurfaceCGL::InitializeOneOff failed."; + return false; + } + break; + default: + break; + } + + initialized = true; + return true; +} + +GLContext* GLContext::CreateOffscreenGLContext(GLContext* shared_context) { switch (GetGLImplementation()) { case kGLImplementationDesktopGL: { - scoped_ptr<GLContextCGL> context( - new GLContextCGL(static_cast<GLSurfaceCGL*>(compatible_surface))); + scoped_ptr<PbufferGLSurfaceCGL> surface(new PbufferGLSurfaceCGL( + gfx::Size(1, 1))); + if (!surface->Initialize()) + return false; + + scoped_ptr<GLContextCGL> context(new GLContextCGL(surface.release())); if (!context->Initialize(shared_context)) return NULL; return context.release(); } case kGLImplementationOSMesaGL: { + scoped_ptr<GLSurfaceOSMesa> surface(new GLSurfaceOSMesa()); + surface->Resize(gfx::Size(1, 1)); + scoped_ptr<GLContextOSMesa> context( - new GLContextOSMesa( - static_cast<GLSurfaceOSMesa*>(compatible_surface))); + new GLContextOSMesa(surface.release())); if (!context->Initialize(OSMESA_RGBA, shared_context)) return NULL; return context.release(); } case kGLImplementationMockGL: - return new GLContextStub; + return new StubGLContext; default: NOTREACHED(); return NULL; |