| 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 "ui/gfx/gl/gl_context.h" | 5 #include "ui/gfx/gl/gl_context.h" |
| 6 | 6 |
| 7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "base/memory/scoped_ptr.h" | 8 #include "base/memory/scoped_ptr.h" |
| 9 #include "third_party/mesa/MesaLib/include/GL/osmesa.h" | 9 #include "third_party/mesa/MesaLib/include/GL/osmesa.h" |
| 10 #include "ui/gfx/gl/gl_bindings.h" | 10 #include "ui/gfx/gl/gl_bindings.h" |
| 11 #include "ui/gfx/gl/gl_context_egl.h" | 11 #include "ui/gfx/gl/gl_context_egl.h" |
| 12 #include "ui/gfx/gl/gl_context_glx.h" | 12 #include "ui/gfx/gl/gl_context_glx.h" |
| 13 #include "ui/gfx/gl/gl_context_osmesa.h" | 13 #include "ui/gfx/gl/gl_context_osmesa.h" |
| 14 #include "ui/gfx/gl/gl_context_stub.h" | 14 #include "ui/gfx/gl/gl_context_stub.h" |
| 15 #include "ui/gfx/gl/gl_implementation.h" | 15 #include "ui/gfx/gl/gl_implementation.h" |
| 16 #include "ui/gfx/gl/gl_surface_egl.h" | 16 #include "ui/gfx/gl/gl_surface_egl.h" |
| 17 #include "ui/gfx/gl/gl_surface_glx.h" | 17 #include "ui/gfx/gl/gl_surface_glx.h" |
| 18 #include "ui/gfx/gl/gl_surface_stub.h" | 18 #include "ui/gfx/gl/gl_surface_stub.h" |
| 19 #include "ui/gfx/gl/gl_surface_osmesa.h" | 19 #include "ui/gfx/gl/gl_surface_osmesa.h" |
| 20 | 20 |
| 21 namespace gfx { | 21 namespace gfx { |
| 22 | 22 |
| 23 GLContext* GLContext::CreateGLContext(GLSurface* compatible_surface, | 23 GLContext* GLContext::CreateGLContext(GLContext* shared_context) { |
| 24 GLContext* shared_context) { | |
| 25 scoped_ptr<GLSurface> surface(compatible_surface); | |
| 26 | |
| 27 switch (GetGLImplementation()) { | 24 switch (GetGLImplementation()) { |
| 28 case kGLImplementationOSMesaGL: { | 25 case kGLImplementationOSMesaGL: { |
| 29 scoped_ptr<GLContextOSMesa> context( | 26 scoped_ptr<GLContextOSMesa> context(new GLContextOSMesa); |
| 30 new GLContextOSMesa(static_cast<GLSurfaceOSMesa*>( | |
| 31 surface.release()))); | |
| 32 if (!context->Initialize(OSMESA_RGBA, shared_context)) | 27 if (!context->Initialize(OSMESA_RGBA, shared_context)) |
| 33 return NULL; | 28 return NULL; |
| 34 | 29 |
| 35 return context.release(); | 30 return context.release(); |
| 36 } | 31 } |
| 37 case kGLImplementationEGLGLES2: { | 32 case kGLImplementationEGLGLES2: { |
| 38 scoped_ptr<GLContextEGL> context( | 33 scoped_ptr<GLContextEGL> context(new GLContextEGL); |
| 39 new GLContextEGL( | |
| 40 static_cast<GLSurfaceEGL*>(surface.release()))); | |
| 41 if (!context->Initialize(shared_context)) | 34 if (!context->Initialize(shared_context)) |
| 42 return NULL; | 35 return NULL; |
| 43 | 36 |
| 44 return context.release(); | 37 return context.release(); |
| 45 } | 38 } |
| 46 case kGLImplementationDesktopGL: { | 39 case kGLImplementationDesktopGL: { |
| 47 scoped_ptr<GLContextGLX> context( | 40 scoped_ptr<GLContextGLX> context(new GLContextGLX); |
| 48 new GLContextGLX( | |
| 49 static_cast<GLSurfaceGLX*>(surface.release()))); | |
| 50 if (!context->Initialize(shared_context)) | 41 if (!context->Initialize(shared_context)) |
| 51 return NULL; | 42 return NULL; |
| 52 | 43 |
| 53 return context.release(); | 44 return context.release(); |
| 54 } | 45 } |
| 55 case kGLImplementationMockGL: | 46 case kGLImplementationMockGL: |
| 56 return new GLContextStub; | 47 return new GLContextStub; |
| 57 default: | 48 default: |
| 58 NOTREACHED(); | 49 NOTREACHED(); |
| 59 return NULL; | 50 return NULL; |
| 60 } | 51 } |
| 61 } | 52 } |
| 62 | 53 |
| 63 } // namespace gfx | 54 } // namespace gfx |
| OLD | NEW |