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) { | 24 GLSurface* compatible_surface) { |
25 scoped_ptr<GLSurface> surface(compatible_surface); | |
26 | |
27 switch (GetGLImplementation()) { | 25 switch (GetGLImplementation()) { |
28 case kGLImplementationOSMesaGL: { | 26 case kGLImplementationOSMesaGL: { |
29 scoped_ptr<GLContextOSMesa> context( | 27 scoped_ptr<GLContextOSMesa> context(new GLContextOSMesa); |
30 new GLContextOSMesa(static_cast<GLSurfaceOSMesa*>( | 28 if (!context->Initialize(shared_context, compatible_surface)) |
31 surface.release()))); | |
32 if (!context->Initialize(OSMESA_RGBA, shared_context)) | |
33 return NULL; | 29 return NULL; |
34 | 30 |
35 return context.release(); | 31 return context.release(); |
36 } | 32 } |
37 case kGLImplementationEGLGLES2: { | 33 case kGLImplementationEGLGLES2: { |
38 scoped_ptr<GLContextEGL> context( | 34 scoped_ptr<GLContextEGL> context(new GLContextEGL); |
39 new GLContextEGL( | 35 if (!context->Initialize(shared_context, compatible_surface)) |
40 static_cast<GLSurfaceEGL*>(surface.release()))); | |
41 if (!context->Initialize(shared_context)) | |
42 return NULL; | 36 return NULL; |
43 | 37 |
44 return context.release(); | 38 return context.release(); |
45 } | 39 } |
46 case kGLImplementationDesktopGL: { | 40 case kGLImplementationDesktopGL: { |
47 scoped_ptr<GLContextGLX> context( | 41 scoped_ptr<GLContextGLX> context(new GLContextGLX); |
48 new GLContextGLX( | 42 if (!context->Initialize(shared_context, compatible_surface)) |
49 static_cast<GLSurfaceGLX*>(surface.release()))); | |
50 if (!context->Initialize(shared_context)) | |
51 return NULL; | 43 return NULL; |
52 | 44 |
53 return context.release(); | 45 return context.release(); |
54 } | 46 } |
55 case kGLImplementationMockGL: | 47 case kGLImplementationMockGL: |
56 return new GLContextStub; | 48 return new GLContextStub; |
57 default: | 49 default: |
58 NOTREACHED(); | 50 NOTREACHED(); |
59 return NULL; | 51 return NULL; |
60 } | 52 } |
61 } | 53 } |
62 | 54 |
63 } // namespace gfx | 55 } // namespace gfx |
OLD | NEW |