| 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_surface_egl.h" | 5 #include "ui/gfx/gl/gl_surface_egl.h" |
| 6 | 6 |
| 7 #include "build/build_config.h" | 7 #include "build/build_config.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 "third_party/angle/include/EGL/egl.h" | 10 #include "third_party/angle/include/EGL/egl.h" |
| 11 #include "ui/gfx/gl/egl_util.h" | 11 #include "ui/gfx/gl/egl_util.h" |
| 12 | 12 |
| 13 // This header must come after the above third-party include, as | 13 // This header must come after the above third-party include, as |
| 14 // it brings in #defines that cause conflicts. | 14 // it brings in #defines that cause conflicts. |
| 15 #include "ui/gfx/gl/gl_bindings.h" | 15 #include "ui/gfx/gl/gl_bindings.h" |
| 16 | 16 |
| 17 #if defined(OS_LINUX) | 17 #if defined(USE_X11) |
| 18 extern "C" { | 18 extern "C" { |
| 19 #include <X11/Xlib.h> | 19 #include <X11/Xlib.h> |
| 20 } | 20 } |
| 21 #endif | 21 #endif |
| 22 | 22 |
| 23 namespace gfx { | 23 namespace gfx { |
| 24 | 24 |
| 25 namespace { | 25 namespace { |
| 26 EGLConfig g_config; | 26 EGLConfig g_config; |
| 27 EGLDisplay g_display; | 27 EGLDisplay g_display; |
| 28 } | 28 } |
| 29 | 29 |
| 30 GLSurfaceEGL::GLSurfaceEGL() { | 30 GLSurfaceEGL::GLSurfaceEGL() { |
| 31 } | 31 } |
| 32 | 32 |
| 33 GLSurfaceEGL::~GLSurfaceEGL() { | 33 GLSurfaceEGL::~GLSurfaceEGL() { |
| 34 } | 34 } |
| 35 | 35 |
| 36 bool GLSurfaceEGL::InitializeOneOff() { | 36 bool GLSurfaceEGL::InitializeOneOff() { |
| 37 static bool initialized = false; | 37 static bool initialized = false; |
| 38 if (initialized) | 38 if (initialized) |
| 39 return true; | 39 return true; |
| 40 | 40 |
| 41 #ifdef OS_LINUX | 41 #if defined(USE_X11) |
| 42 EGLNativeDisplayType native_display = XOpenDisplay(NULL); | 42 EGLNativeDisplayType native_display = XOpenDisplay(NULL); |
| 43 #else | 43 #else |
| 44 EGLNativeDisplayType native_display = EGL_DEFAULT_DISPLAY; | 44 EGLNativeDisplayType native_display = EGL_DEFAULT_DISPLAY; |
| 45 #endif | 45 #endif |
| 46 g_display = eglGetDisplay(native_display); | 46 g_display = eglGetDisplay(native_display); |
| 47 if (!g_display) { | 47 if (!g_display) { |
| 48 LOG(ERROR) << "eglGetDisplay failed with error " << GetLastEGLErrorString(); | 48 LOG(ERROR) << "eglGetDisplay failed with error " << GetLastEGLErrorString(); |
| 49 return false; | 49 return false; |
| 50 } | 50 } |
| 51 | 51 |
| (...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 231 | 231 |
| 232 gfx::Size PbufferGLSurfaceEGL::GetSize() { | 232 gfx::Size PbufferGLSurfaceEGL::GetSize() { |
| 233 return size_; | 233 return size_; |
| 234 } | 234 } |
| 235 | 235 |
| 236 EGLSurface PbufferGLSurfaceEGL::GetHandle() { | 236 EGLSurface PbufferGLSurfaceEGL::GetHandle() { |
| 237 return surface_; | 237 return surface_; |
| 238 } | 238 } |
| 239 | 239 |
| 240 } // namespace gfx | 240 } // namespace gfx |
| OLD | NEW |