| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "base/basictypes.h" | 5 #include "base/basictypes.h" |
| 6 #include "base/logging.h" | 6 #include "base/logging.h" |
| 7 #include "base/memory/scoped_ptr.h" | 7 #include "base/memory/scoped_ptr.h" |
| 8 #include "third_party/mesa/MesaLib/include/GL/osmesa.h" | 8 #include "third_party/mesa/MesaLib/include/GL/osmesa.h" |
| 9 #include "ui/gfx/gl/gl_bindings.h" | 9 #include "ui/gfx/gl/gl_bindings.h" |
| 10 #include "ui/gfx/gl/gl_context_cgl.h" | 10 #include "ui/gfx/gl/gl_context_cgl.h" |
| 11 #include "ui/gfx/gl/gl_context_osmesa.h" | 11 #include "ui/gfx/gl/gl_context_osmesa.h" |
| 12 #include "ui/gfx/gl/gl_context_stub.h" | 12 #include "ui/gfx/gl/gl_context_stub.h" |
| 13 #include "ui/gfx/gl/gl_implementation.h" | 13 #include "ui/gfx/gl/gl_implementation.h" |
| 14 #include "ui/gfx/gl/gl_surface_cgl.h" | 14 #include "ui/gfx/gl/gl_surface_cgl.h" |
| 15 #include "ui/gfx/gl/gl_surface_osmesa.h" | 15 #include "ui/gfx/gl/gl_surface_osmesa.h" |
| 16 | 16 |
| 17 namespace gfx { | 17 namespace gfx { |
| 18 | 18 |
| 19 GLContext* GLContext::CreateGLContext(GLSurface* compatible_surface, | 19 GLContext* GLContext::CreateGLContext(GLContext* shared_context) { |
| 20 GLContext* shared_context) { | |
| 21 scoped_ptr<GLSurface> surface(compatible_surface); | |
| 22 | |
| 23 switch (GetGLImplementation()) { | 20 switch (GetGLImplementation()) { |
| 24 case kGLImplementationDesktopGL: { | 21 case kGLImplementationDesktopGL: { |
| 25 scoped_ptr<GLContextCGL> context( | 22 scoped_ptr<GLContextCGL> context(new GLContextCGL); |
| 26 new GLContextCGL( | |
| 27 static_cast<GLSurfaceCGL*>(surface.release()))); | |
| 28 if (!context->Initialize(shared_context)) | 23 if (!context->Initialize(shared_context)) |
| 29 return NULL; | 24 return NULL; |
| 30 | 25 |
| 31 return context.release(); | 26 return context.release(); |
| 32 } | 27 } |
| 33 case kGLImplementationOSMesaGL: { | 28 case kGLImplementationOSMesaGL: { |
| 34 scoped_ptr<GLContextOSMesa> context( | 29 scoped_ptr<GLContextOSMesa> context(new GLContextOSMesa); |
| 35 new GLContextOSMesa( | |
| 36 static_cast<GLSurfaceOSMesa*>(surface.release()))); | |
| 37 if (!context->Initialize(OSMESA_RGBA, shared_context)) | 30 if (!context->Initialize(OSMESA_RGBA, shared_context)) |
| 38 return NULL; | 31 return NULL; |
| 39 | 32 |
| 40 return context.release(); | 33 return context.release(); |
| 41 } | 34 } |
| 42 case kGLImplementationMockGL: | 35 case kGLImplementationMockGL: |
| 43 return new GLContextStub; | 36 return new GLContextStub; |
| 44 default: | 37 default: |
| 45 NOTREACHED(); | 38 NOTREACHED(); |
| 46 return NULL; | 39 return NULL; |
| 47 } | 40 } |
| 48 } | 41 } |
| 49 | 42 |
| 50 } // namespace gfx | 43 } // namespace gfx |
| OLD | NEW |