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 #if !defined(OS_ANDROID) |
10 #include "third_party/angle/include/EGL/egl.h" | 11 #include "third_party/angle/include/EGL/egl.h" |
11 #include "third_party/angle/include/EGL/eglext.h" | 12 #include "third_party/angle/include/EGL/eglext.h" |
| 13 #endif |
12 #include "ui/gfx/gl/egl_util.h" | 14 #include "ui/gfx/gl/egl_util.h" |
13 | 15 |
| 16 #if defined(OS_ANDROID) |
| 17 #include <EGL/egl.h> |
| 18 #endif |
| 19 |
14 // This header must come after the above third-party include, as | 20 // This header must come after the above third-party include, as |
15 // it brings in #defines that cause conflicts. | 21 // it brings in #defines that cause conflicts. |
16 #include "ui/gfx/gl/gl_bindings.h" | 22 #include "ui/gfx/gl/gl_bindings.h" |
17 | 23 |
18 #if defined(USE_X11) && !defined(USE_WAYLAND) | 24 #if defined(USE_X11) && !defined(USE_WAYLAND) |
19 extern "C" { | 25 extern "C" { |
20 #include <X11/Xlib.h> | 26 #include <X11/Xlib.h> |
21 } | 27 } |
22 #endif | 28 #endif |
23 | 29 |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
103 &g_config, | 109 &g_config, |
104 1, | 110 1, |
105 &num_configs)) { | 111 &num_configs)) { |
106 LOG(ERROR) << "eglChooseConfig failed with error " | 112 LOG(ERROR) << "eglChooseConfig failed with error " |
107 << GetLastEGLErrorString(); | 113 << GetLastEGLErrorString(); |
108 return false; | 114 return false; |
109 } | 115 } |
110 | 116 |
111 initialized = true; | 117 initialized = true; |
112 | 118 |
113 #if defined(USE_X11) | 119 #if defined(USE_X11) || defined(OS_ANDROID) |
114 return true; | 120 return true; |
115 #else | 121 #else |
116 g_software_native_display = EGL_SOFTWARE_DISPLAY_ANGLE; | 122 g_software_native_display = EGL_SOFTWARE_DISPLAY_ANGLE; |
117 #endif | 123 #endif |
118 g_software_display = eglGetDisplay(g_software_native_display); | 124 g_software_display = eglGetDisplay(g_software_native_display); |
119 if (!g_software_display) { | 125 if (!g_software_display) { |
120 return true; | 126 return true; |
121 } | 127 } |
122 | 128 |
123 if (!eglInitialize(g_software_display, NULL, NULL)) { | 129 if (!eglInitialize(g_software_display, NULL, NULL)) { |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
177 supports_post_sub_buffer_(false) | 183 supports_post_sub_buffer_(false) |
178 { | 184 { |
179 software_ = software; | 185 software_ = software; |
180 } | 186 } |
181 | 187 |
182 NativeViewGLSurfaceEGL::~NativeViewGLSurfaceEGL() { | 188 NativeViewGLSurfaceEGL::~NativeViewGLSurfaceEGL() { |
183 Destroy(); | 189 Destroy(); |
184 } | 190 } |
185 | 191 |
186 bool NativeViewGLSurfaceEGL::Initialize() { | 192 bool NativeViewGLSurfaceEGL::Initialize() { |
| 193 #if defined(OS_ANDROID) |
| 194 NOTREACHED(); |
| 195 return false; |
| 196 #else |
187 DCHECK(!surface_); | 197 DCHECK(!surface_); |
188 | 198 |
189 if (!GetDisplay()) { | 199 if (!GetDisplay()) { |
190 LOG(ERROR) << "Trying to create surface with invalid display."; | 200 LOG(ERROR) << "Trying to create surface with invalid display."; |
191 return false; | 201 return false; |
192 } | 202 } |
193 | 203 |
194 static const EGLint egl_window_attributes_sub_buffer[] = { | 204 static const EGLint egl_window_attributes_sub_buffer[] = { |
195 EGL_POST_SUB_BUFFER_SUPPORTED_NV, EGL_TRUE, | 205 EGL_POST_SUB_BUFFER_SUPPORTED_NV, EGL_TRUE, |
196 EGL_NONE | 206 EGL_NONE |
(...skipping 15 matching lines...) Expand all Loading... |
212 } | 222 } |
213 | 223 |
214 EGLint surfaceVal; | 224 EGLint surfaceVal; |
215 EGLBoolean retVal = eglQuerySurface(GetDisplay(), | 225 EGLBoolean retVal = eglQuerySurface(GetDisplay(), |
216 surface_, | 226 surface_, |
217 EGL_POST_SUB_BUFFER_SUPPORTED_NV, | 227 EGL_POST_SUB_BUFFER_SUPPORTED_NV, |
218 &surfaceVal); | 228 &surfaceVal); |
219 supports_post_sub_buffer_ = (surfaceVal && retVal) == EGL_TRUE; | 229 supports_post_sub_buffer_ = (surfaceVal && retVal) == EGL_TRUE; |
220 | 230 |
221 return true; | 231 return true; |
| 232 #endif |
222 } | 233 } |
223 | 234 |
224 void NativeViewGLSurfaceEGL::Destroy() { | 235 void NativeViewGLSurfaceEGL::Destroy() { |
225 if (surface_) { | 236 if (surface_) { |
226 if (!eglDestroySurface(GetDisplay(), surface_)) { | 237 if (!eglDestroySurface(GetDisplay(), surface_)) { |
227 LOG(ERROR) << "eglDestroySurface failed with error " | 238 LOG(ERROR) << "eglDestroySurface failed with error " |
228 << GetLastEGLErrorString(); | 239 << GetLastEGLErrorString(); |
229 } | 240 } |
230 surface_ = NULL; | 241 surface_ = NULL; |
231 } | 242 } |
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
344 Destroy(); | 355 Destroy(); |
345 size_ = size; | 356 size_ = size; |
346 return Initialize(); | 357 return Initialize(); |
347 } | 358 } |
348 | 359 |
349 EGLSurface PbufferGLSurfaceEGL::GetHandle() { | 360 EGLSurface PbufferGLSurfaceEGL::GetHandle() { |
350 return surface_; | 361 return surface_; |
351 } | 362 } |
352 | 363 |
353 void* PbufferGLSurfaceEGL::GetShareHandle() { | 364 void* PbufferGLSurfaceEGL::GetShareHandle() { |
| 365 #if defined(OS_ANDROID) |
| 366 NOTREACHED(); |
| 367 return NULL; |
| 368 #else |
354 const char* extensions = eglQueryString(g_display, EGL_EXTENSIONS); | 369 const char* extensions = eglQueryString(g_display, EGL_EXTENSIONS); |
355 if (!strstr(extensions, "EGL_ANGLE_query_surface_pointer")) | 370 if (!strstr(extensions, "EGL_ANGLE_query_surface_pointer")) |
356 return NULL; | 371 return NULL; |
357 | 372 |
358 void* handle; | 373 void* handle; |
359 if (!eglQuerySurfacePointerANGLE(g_display, | 374 if (!eglQuerySurfacePointerANGLE(g_display, |
360 GetHandle(), | 375 GetHandle(), |
361 EGL_D3D_TEXTURE_2D_SHARE_HANDLE_ANGLE, | 376 EGL_D3D_TEXTURE_2D_SHARE_HANDLE_ANGLE, |
362 &handle)) { | 377 &handle)) { |
363 return NULL; | 378 return NULL; |
364 } | 379 } |
365 | 380 |
366 return handle; | 381 return handle; |
| 382 #endif |
367 } | 383 } |
368 | 384 |
369 } // namespace gfx | 385 } // namespace gfx |
OLD | NEW |