| 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 #if !defined(OS_ANDROID) | |
| 12 #include "third_party/angle/include/EGL/egl.h" | 11 #include "third_party/angle/include/EGL/egl.h" |
| 13 #include "third_party/angle/include/EGL/eglext.h" | 12 #include "third_party/angle/include/EGL/eglext.h" |
| 14 #endif | |
| 15 #include "ui/gl/egl_util.h" | 13 #include "ui/gl/egl_util.h" |
| 16 #include "ui/gl/gl_context.h" | 14 #include "ui/gl/gl_context.h" |
| 17 | 15 |
| 18 #if defined(OS_ANDROID) | |
| 19 #include <EGL/egl.h> | |
| 20 #endif | |
| 21 | |
| 22 // This header must come after the above third-party include, as | 16 // This header must come after the above third-party include, as |
| 23 // it brings in #defines that cause conflicts. | 17 // it brings in #defines that cause conflicts. |
| 24 #include "ui/gl/gl_bindings.h" | 18 #include "ui/gl/gl_bindings.h" |
| 25 | 19 |
| 26 #if defined(USE_X11) | 20 #if defined(USE_X11) |
| 27 extern "C" { | 21 extern "C" { |
| 28 #include <X11/Xlib.h> | 22 #include <X11/Xlib.h> |
| 29 } | 23 } |
| 30 #endif | 24 #endif |
| 31 | 25 |
| (...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 165 NativeViewGLSurfaceEGL::NativeViewGLSurfaceEGL(bool software, | 159 NativeViewGLSurfaceEGL::NativeViewGLSurfaceEGL(bool software, |
| 166 gfx::AcceleratedWidget window) | 160 gfx::AcceleratedWidget window) |
| 167 : window_(window), | 161 : window_(window), |
| 168 surface_(NULL), | 162 surface_(NULL), |
| 169 supports_post_sub_buffer_(false), | 163 supports_post_sub_buffer_(false), |
| 170 config_(NULL) { | 164 config_(NULL) { |
| 171 software_ = software; | 165 software_ = software; |
| 172 } | 166 } |
| 173 | 167 |
| 174 bool NativeViewGLSurfaceEGL::Initialize() { | 168 bool NativeViewGLSurfaceEGL::Initialize() { |
| 175 #if defined(OS_ANDROID) | |
| 176 NOTREACHED(); | |
| 177 return false; | |
| 178 #else | |
| 179 DCHECK(!surface_); | 169 DCHECK(!surface_); |
| 180 | 170 |
| 181 if (!GetDisplay()) { | 171 if (!GetDisplay()) { |
| 182 LOG(ERROR) << "Trying to create surface with invalid display."; | 172 LOG(ERROR) << "Trying to create surface with invalid display."; |
| 183 return false; | 173 return false; |
| 184 } | 174 } |
| 185 | 175 |
| 186 static const EGLint egl_window_attributes_sub_buffer[] = { | 176 static const EGLint egl_window_attributes_sub_buffer[] = { |
| 187 EGL_POST_SUB_BUFFER_SUPPORTED_NV, EGL_TRUE, | 177 EGL_POST_SUB_BUFFER_SUPPORTED_NV, EGL_TRUE, |
| 188 EGL_NONE | 178 EGL_NONE |
| (...skipping 15 matching lines...) Expand all Loading... |
| 204 } | 194 } |
| 205 | 195 |
| 206 EGLint surfaceVal; | 196 EGLint surfaceVal; |
| 207 EGLBoolean retVal = eglQuerySurface(GetDisplay(), | 197 EGLBoolean retVal = eglQuerySurface(GetDisplay(), |
| 208 surface_, | 198 surface_, |
| 209 EGL_POST_SUB_BUFFER_SUPPORTED_NV, | 199 EGL_POST_SUB_BUFFER_SUPPORTED_NV, |
| 210 &surfaceVal); | 200 &surfaceVal); |
| 211 supports_post_sub_buffer_ = (surfaceVal && retVal) == EGL_TRUE; | 201 supports_post_sub_buffer_ = (surfaceVal && retVal) == EGL_TRUE; |
| 212 | 202 |
| 213 return true; | 203 return true; |
| 214 #endif | |
| 215 } | 204 } |
| 216 | 205 |
| 217 void NativeViewGLSurfaceEGL::Destroy() { | 206 void NativeViewGLSurfaceEGL::Destroy() { |
| 218 if (surface_) { | 207 if (surface_) { |
| 219 if (!eglDestroySurface(GetDisplay(), surface_)) { | 208 if (!eglDestroySurface(GetDisplay(), surface_)) { |
| 220 LOG(ERROR) << "eglDestroySurface failed with error " | 209 LOG(ERROR) << "eglDestroySurface failed with error " |
| 221 << GetLastEGLErrorString(); | 210 << GetLastEGLErrorString(); |
| 222 } | 211 } |
| 223 surface_ = NULL; | 212 surface_ = NULL; |
| 224 } | 213 } |
| (...skipping 252 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 477 | 466 |
| 478 return handle; | 467 return handle; |
| 479 #endif | 468 #endif |
| 480 } | 469 } |
| 481 | 470 |
| 482 PbufferGLSurfaceEGL::~PbufferGLSurfaceEGL() { | 471 PbufferGLSurfaceEGL::~PbufferGLSurfaceEGL() { |
| 483 Destroy(); | 472 Destroy(); |
| 484 } | 473 } |
| 485 | 474 |
| 486 } // namespace gfx | 475 } // namespace gfx |
| OLD | NEW |