| 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/gfx/x/x11_types.h" |
| 13 #include "ui/gl/gl_bindings.h" | 14 #include "ui/gl/gl_bindings.h" |
| 14 #include "ui/gl/gl_implementation.h" | 15 #include "ui/gl/gl_implementation.h" |
| 15 #include "ui/gl/gl_surface_egl.h" | 16 #include "ui/gl/gl_surface_egl.h" |
| 16 #include "ui/gl/gl_surface_glx.h" | 17 #include "ui/gl/gl_surface_glx.h" |
| 17 #include "ui/gl/gl_surface_osmesa.h" | 18 #include "ui/gl/gl_surface_osmesa.h" |
| 18 #include "ui/gl/gl_surface_stub.h" | 19 #include "ui/gl/gl_surface_stub.h" |
| 19 | 20 |
| 20 namespace gfx { | 21 namespace gfx { |
| 21 | 22 |
| 22 // This OSMesa GL surface can use XLib to swap the contents of the buffer to a | 23 // This OSMesa GL surface can use XLib to swap the contents of the buffer to a |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 72 default: | 73 default: |
| 73 break; | 74 break; |
| 74 } | 75 } |
| 75 | 76 |
| 76 return true; | 77 return true; |
| 77 } | 78 } |
| 78 | 79 |
| 79 NativeViewGLSurfaceOSMesa::NativeViewGLSurfaceOSMesa( | 80 NativeViewGLSurfaceOSMesa::NativeViewGLSurfaceOSMesa( |
| 80 gfx::AcceleratedWidget window) | 81 gfx::AcceleratedWidget window) |
| 81 : GLSurfaceOSMesa(OSMESA_BGRA, gfx::Size(1, 1)), | 82 : GLSurfaceOSMesa(OSMESA_BGRA, gfx::Size(1, 1)), |
| 82 xdisplay_(base::MessagePumpForUI::GetDefaultXDisplay()), | 83 xdisplay_(gfx::GetXDisplay()), |
| 83 window_graphics_context_(0), | 84 window_graphics_context_(0), |
| 84 window_(window), | 85 window_(window), |
| 85 pixmap_graphics_context_(0), | 86 pixmap_graphics_context_(0), |
| 86 pixmap_(0) { | 87 pixmap_(0) { |
| 87 DCHECK(xdisplay_); | 88 DCHECK(xdisplay_); |
| 88 DCHECK(window_); | 89 DCHECK(window_); |
| 89 } | 90 } |
| 90 | 91 |
| 91 // static | 92 // static |
| 92 bool NativeViewGLSurfaceOSMesa::InitializeOneOff() { | 93 bool NativeViewGLSurfaceOSMesa::InitializeOneOff() { |
| 93 static bool initialized = false; | 94 static bool initialized = false; |
| 94 if (initialized) | 95 if (initialized) |
| 95 return true; | 96 return true; |
| 96 | 97 |
| 97 if (!base::MessagePumpForUI::GetDefaultXDisplay()) { | 98 if (!gfx::GetXDisplay()) { |
| 98 LOG(ERROR) << "XOpenDisplay failed."; | 99 LOG(ERROR) << "XOpenDisplay failed."; |
| 99 return false; | 100 return false; |
| 100 } | 101 } |
| 101 | 102 |
| 102 initialized = true; | 103 initialized = true; |
| 103 return true; | 104 return true; |
| 104 } | 105 } |
| 105 | 106 |
| 106 bool NativeViewGLSurfaceOSMesa::Initialize() { | 107 bool NativeViewGLSurfaceOSMesa::Initialize() { |
| 107 if (!GLSurfaceOSMesa::Initialize()) | 108 if (!GLSurfaceOSMesa::Initialize()) |
| (...skipping 226 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 334 } | 335 } |
| 335 case kGLImplementationMockGL: | 336 case kGLImplementationMockGL: |
| 336 return new GLSurfaceStub; | 337 return new GLSurfaceStub; |
| 337 default: | 338 default: |
| 338 NOTREACHED(); | 339 NOTREACHED(); |
| 339 return NULL; | 340 return NULL; |
| 340 } | 341 } |
| 341 } | 342 } |
| 342 | 343 |
| 343 EGLNativeDisplayType GetPlatformDefaultEGLNativeDisplay() { | 344 EGLNativeDisplayType GetPlatformDefaultEGLNativeDisplay() { |
| 344 return base::MessagePumpForUI::GetDefaultXDisplay(); | 345 return gfx::GetXDisplay(); |
| 345 } | 346 } |
| 346 | 347 |
| 347 } // namespace gfx | 348 } // namespace gfx |
| OLD | NEW |