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_egl.h" | 5 #include "ui/gl/gl_surface_egl.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 "base/message_loop.h" | 9 #include "base/message_loop.h" |
10 #include "build/build_config.h" | 10 #include "build/build_config.h" |
11 #include "third_party/angle/include/EGL/egl.h" | 11 #include "third_party/angle/include/EGL/egl.h" |
12 #include "third_party/angle/include/EGL/eglext.h" | 12 #include "third_party/angle/include/EGL/eglext.h" |
13 #include "ui/gl/egl_util.h" | 13 #include "ui/gl/egl_util.h" |
14 #include "ui/gl/gl_context.h" | 14 #include "ui/gl/gl_context.h" |
15 | 15 |
16 // This header must come after the above third-party include, as | 16 // This header must come after the above third-party include, as |
17 // it brings in #defines that cause conflicts. | 17 // it brings in #defines that cause conflicts. |
18 #include "ui/gl/gl_bindings.h" | 18 #include "ui/gl/gl_bindings.h" |
19 | 19 |
20 #if defined(USE_X11) | 20 #if defined(USE_X11) |
21 extern "C" { | 21 extern "C" { |
22 #include <X11/Xlib.h> | 22 #include <X11/Xlib.h> |
23 } | 23 } |
24 #endif | 24 #endif |
25 | 25 |
26 namespace gfx { | 26 namespace gfx { |
27 | 27 |
28 namespace { | 28 namespace { |
| 29 |
29 EGLConfig g_config; | 30 EGLConfig g_config; |
30 EGLDisplay g_display; | 31 EGLDisplay g_display; |
31 EGLNativeDisplayType g_native_display; | 32 EGLNativeDisplayType g_native_display; |
32 EGLConfig g_software_config; | 33 EGLConfig g_software_config; |
33 EGLDisplay g_software_display; | 34 EGLDisplay g_software_display; |
34 EGLNativeDisplayType g_software_native_display; | 35 EGLNativeDisplayType g_software_native_display; |
| 36 |
| 37 const char* g_egl_extensions = NULL; |
| 38 bool g_egl_create_context_robustness_supported = false; |
| 39 |
35 } | 40 } |
36 | 41 |
37 GLSurfaceEGL::GLSurfaceEGL() : software_(false) {} | 42 GLSurfaceEGL::GLSurfaceEGL() : software_(false) {} |
38 | 43 |
39 bool GLSurfaceEGL::InitializeOneOff() { | 44 bool GLSurfaceEGL::InitializeOneOff() { |
40 static bool initialized = false; | 45 static bool initialized = false; |
41 if (initialized) | 46 if (initialized) |
42 return true; | 47 return true; |
43 | 48 |
44 #if defined(USE_X11) | 49 #if defined(USE_X11) |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
89 if (!eglChooseConfig(g_display, | 94 if (!eglChooseConfig(g_display, |
90 kConfigAttribs, | 95 kConfigAttribs, |
91 &g_config, | 96 &g_config, |
92 1, | 97 1, |
93 &num_configs)) { | 98 &num_configs)) { |
94 LOG(ERROR) << "eglChooseConfig failed with error " | 99 LOG(ERROR) << "eglChooseConfig failed with error " |
95 << GetLastEGLErrorString(); | 100 << GetLastEGLErrorString(); |
96 return false; | 101 return false; |
97 } | 102 } |
98 | 103 |
| 104 g_egl_extensions = eglQueryString(g_display, EGL_EXTENSIONS); |
| 105 g_egl_create_context_robustness_supported = |
| 106 HasEGLExtension("EGL_EXT_create_context_robustness"); |
| 107 |
99 initialized = true; | 108 initialized = true; |
100 | 109 |
101 #if defined(USE_X11) || defined(OS_ANDROID) | 110 #if defined(USE_X11) || defined(OS_ANDROID) |
102 return true; | 111 return true; |
103 #else | 112 #else |
104 g_software_native_display = EGL_SOFTWARE_DISPLAY_ANGLE; | 113 g_software_native_display = EGL_SOFTWARE_DISPLAY_ANGLE; |
105 #endif | 114 #endif |
106 g_software_display = eglGetDisplay(g_software_native_display); | 115 g_software_display = eglGetDisplay(g_software_native_display); |
107 if (!g_software_display) { | 116 if (!g_software_display) { |
108 return true; | 117 return true; |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
147 } | 156 } |
148 | 157 |
149 EGLDisplay GLSurfaceEGL::GetSoftwareDisplay() { | 158 EGLDisplay GLSurfaceEGL::GetSoftwareDisplay() { |
150 return g_software_display; | 159 return g_software_display; |
151 } | 160 } |
152 | 161 |
153 EGLNativeDisplayType GLSurfaceEGL::GetNativeDisplay() { | 162 EGLNativeDisplayType GLSurfaceEGL::GetNativeDisplay() { |
154 return g_native_display; | 163 return g_native_display; |
155 } | 164 } |
156 | 165 |
| 166 const char* GLSurfaceEGL::GetEGLExtensions() { |
| 167 return g_egl_extensions; |
| 168 } |
| 169 |
| 170 bool GLSurfaceEGL::HasEGLExtension(const char* name) { |
| 171 return ExtensionsContain(GetEGLExtensions(), name); |
| 172 } |
| 173 |
| 174 bool GLSurfaceEGL::IsCreateContextRobustnessSupported() { |
| 175 return g_egl_create_context_robustness_supported; |
| 176 } |
| 177 |
157 GLSurfaceEGL::~GLSurfaceEGL() {} | 178 GLSurfaceEGL::~GLSurfaceEGL() {} |
158 | 179 |
159 NativeViewGLSurfaceEGL::NativeViewGLSurfaceEGL(bool software, | 180 NativeViewGLSurfaceEGL::NativeViewGLSurfaceEGL(bool software, |
160 gfx::AcceleratedWidget window) | 181 gfx::AcceleratedWidget window) |
161 : window_(window), | 182 : window_(window), |
162 surface_(NULL), | 183 surface_(NULL), |
163 supports_post_sub_buffer_(false), | 184 supports_post_sub_buffer_(false), |
164 config_(NULL) { | 185 config_(NULL) { |
165 software_ = software; | 186 software_ = software; |
166 } | 187 } |
(...skipping 299 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
466 | 487 |
467 return handle; | 488 return handle; |
468 #endif | 489 #endif |
469 } | 490 } |
470 | 491 |
471 PbufferGLSurfaceEGL::~PbufferGLSurfaceEGL() { | 492 PbufferGLSurfaceEGL::~PbufferGLSurfaceEGL() { |
472 Destroy(); | 493 Destroy(); |
473 } | 494 } |
474 | 495 |
475 } // namespace gfx | 496 } // namespace gfx |
OLD | NEW |