OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/gl/gl_surface.h" | 5 #include "ui/gl/gl_surface.h" |
6 | 6 |
7 #include "base/debug/trace_event.h" | 7 #include "base/debug/trace_event.h" |
8 #include "base/logging.h" | 8 #include "base/logging.h" |
9 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
10 #include "base/message_loop/message_loop.h" | 10 #include "base/message_loop/message_loop.h" |
11 #include "third_party/mesa/src/include/GL/osmesa.h" | 11 #include "third_party/mesa/src/include/GL/osmesa.h" |
12 #include "ui/gfx/native_widget_types.h" | 12 #include "ui/gfx/native_widget_types.h" |
13 #include "ui/gl/gl_bindings.h" | 13 #include "ui/gl/gl_bindings.h" |
14 #include "ui/gl/gl_implementation.h" | 14 #include "ui/gl/gl_implementation.h" |
15 #include "ui/gl/gl_surface_egl.h" | 15 #include "ui/gl/gl_surface_egl.h" |
16 #include "ui/gl/gl_surface_glx.h" | 16 #include "ui/gl/gl_surface_glx.h" |
17 #include "ui/gl/gl_surface_osmesa.h" | 17 #include "ui/gl/gl_surface_osmesa.h" |
18 #include "ui/gl/gl_surface_stub.h" | 18 #include "ui/gl/gl_surface_stub.h" |
19 | 19 |
20 namespace gfx { | 20 namespace gfx { |
21 | 21 |
| 22 namespace { |
| 23 |
| 24 EGLNativeDisplayType GetEGLDisplay() { |
| 25 return base::MessagePumpForUI::GetDefaultXDisplay(); |
| 26 } |
| 27 |
| 28 } // namesapce |
| 29 |
22 // This OSMesa GL surface can use XLib to swap the contents of the buffer to a | 30 // This OSMesa GL surface can use XLib to swap the contents of the buffer to a |
23 // view. | 31 // view. |
24 class NativeViewGLSurfaceOSMesa : public GLSurfaceOSMesa { | 32 class NativeViewGLSurfaceOSMesa : public GLSurfaceOSMesa { |
25 public: | 33 public: |
26 explicit NativeViewGLSurfaceOSMesa(gfx::AcceleratedWidget window); | 34 explicit NativeViewGLSurfaceOSMesa(gfx::AcceleratedWidget window); |
27 | 35 |
28 static bool InitializeOneOff(); | 36 static bool InitializeOneOff(); |
29 | 37 |
30 // Implement a subset of GLSurface. | 38 // Implement a subset of GLSurface. |
31 virtual bool Initialize() OVERRIDE; | 39 virtual bool Initialize() OVERRIDE; |
(...skipping 25 matching lines...) Expand all Loading... |
57 return false; | 65 return false; |
58 } | 66 } |
59 break; | 67 break; |
60 case kGLImplementationOSMesaGL: | 68 case kGLImplementationOSMesaGL: |
61 if (!NativeViewGLSurfaceOSMesa::InitializeOneOff()) { | 69 if (!NativeViewGLSurfaceOSMesa::InitializeOneOff()) { |
62 LOG(ERROR) << "NativeViewGLSurfaceOSMesa::InitializeOneOff failed."; | 70 LOG(ERROR) << "NativeViewGLSurfaceOSMesa::InitializeOneOff failed."; |
63 return false; | 71 return false; |
64 } | 72 } |
65 break; | 73 break; |
66 case kGLImplementationEGLGLES2: | 74 case kGLImplementationEGLGLES2: |
67 if (!GLSurfaceEGL::InitializeOneOff()) { | 75 if (!GLSurfaceEGL::InitializeOneOff(GetEGLDisplay())) { |
68 LOG(ERROR) << "GLSurfaceEGL::InitializeOneOff failed."; | 76 LOG(ERROR) << "GLSurfaceEGL::InitializeOneOff failed."; |
69 return false; | 77 return false; |
70 } | 78 } |
71 break; | 79 break; |
72 default: | 80 default: |
73 break; | 81 break; |
74 } | 82 } |
75 | 83 |
76 return true; | 84 return true; |
77 } | 85 } |
(...skipping 259 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
337 } | 345 } |
338 case kGLImplementationMockGL: | 346 case kGLImplementationMockGL: |
339 return new GLSurfaceStub; | 347 return new GLSurfaceStub; |
340 default: | 348 default: |
341 NOTREACHED(); | 349 NOTREACHED(); |
342 return NULL; | 350 return NULL; |
343 } | 351 } |
344 } | 352 } |
345 | 353 |
346 } // namespace gfx | 354 } // namespace gfx |
OLD | NEW |