| 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 #if defined(OS_ANDROID) | 7 #if defined(OS_ANDROID) |
| 8 #include <android/native_window_jni.h> | 8 #include <android/native_window_jni.h> |
| 9 #endif | 9 #endif |
| 10 | 10 |
| (...skipping 11 matching lines...) Expand all Loading... |
| 22 #include "ui/gl/gl_switches.h" | 22 #include "ui/gl/gl_switches.h" |
| 23 #include "ui/gl/scoped_make_current.h" | 23 #include "ui/gl/scoped_make_current.h" |
| 24 #include "ui/gl/sync_control_vsync_provider.h" | 24 #include "ui/gl/sync_control_vsync_provider.h" |
| 25 | 25 |
| 26 #if defined(USE_X11) | 26 #if defined(USE_X11) |
| 27 extern "C" { | 27 extern "C" { |
| 28 #include <X11/Xlib.h> | 28 #include <X11/Xlib.h> |
| 29 } | 29 } |
| 30 #endif | 30 #endif |
| 31 | 31 |
| 32 #if defined (USE_OZONE) | |
| 33 #include "ui/ozone/public/surface_factory_ozone.h" | |
| 34 #endif | |
| 35 | |
| 36 #if !defined(EGL_FIXED_SIZE_ANGLE) | 32 #if !defined(EGL_FIXED_SIZE_ANGLE) |
| 37 #define EGL_FIXED_SIZE_ANGLE 0x3201 | 33 #define EGL_FIXED_SIZE_ANGLE 0x3201 |
| 38 #endif | 34 #endif |
| 39 | 35 |
| 40 #if defined(OS_WIN) | 36 #if defined(OS_WIN) |
| 41 // From ANGLE's egl/eglext.h. | 37 // From ANGLE's egl/eglext.h. |
| 42 #if !defined(EGL_PLATFORM_ANGLE_ANGLE) | 38 #if !defined(EGL_PLATFORM_ANGLE_ANGLE) |
| 43 #define EGL_PLATFORM_ANGLE_ANGLE 0x3201 | 39 #define EGL_PLATFORM_ANGLE_ANGLE 0x3201 |
| 44 #endif | 40 #endif |
| 45 #if !defined(EGL_PLATFORM_ANGLE_TYPE_ANGLE) | 41 #if !defined(EGL_PLATFORM_ANGLE_TYPE_ANGLE) |
| (...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 160 EGL_BUFFER_SIZE, 32, | 156 EGL_BUFFER_SIZE, 32, |
| 161 EGL_ALPHA_SIZE, 8, | 157 EGL_ALPHA_SIZE, 8, |
| 162 EGL_BLUE_SIZE, 8, | 158 EGL_BLUE_SIZE, 8, |
| 163 EGL_GREEN_SIZE, 8, | 159 EGL_GREEN_SIZE, 8, |
| 164 EGL_RED_SIZE, 8, | 160 EGL_RED_SIZE, 8, |
| 165 EGL_RENDERABLE_TYPE, EGL_OPENGL_ES2_BIT, | 161 EGL_RENDERABLE_TYPE, EGL_OPENGL_ES2_BIT, |
| 166 EGL_SURFACE_TYPE, EGL_WINDOW_BIT | EGL_PBUFFER_BIT, | 162 EGL_SURFACE_TYPE, EGL_WINDOW_BIT | EGL_PBUFFER_BIT, |
| 167 EGL_NONE | 163 EGL_NONE |
| 168 }; | 164 }; |
| 169 | 165 |
| 170 #if defined(USE_OZONE) | |
| 171 const EGLint* config_attribs = | |
| 172 ui::SurfaceFactoryOzone::GetInstance()->GetEGLSurfaceProperties( | |
| 173 kConfigAttribs); | |
| 174 #else | |
| 175 const EGLint* config_attribs = kConfigAttribs; | |
| 176 #endif | |
| 177 | |
| 178 EGLint num_configs; | 166 EGLint num_configs; |
| 179 if (!eglChooseConfig(g_display, | 167 if (!eglChooseConfig(g_display, kConfigAttribs, NULL, 0, &num_configs)) { |
| 180 config_attribs, | |
| 181 NULL, | |
| 182 0, | |
| 183 &num_configs)) { | |
| 184 LOG(ERROR) << "eglChooseConfig failed with error " | 168 LOG(ERROR) << "eglChooseConfig failed with error " |
| 185 << GetLastEGLErrorString(); | 169 << GetLastEGLErrorString(); |
| 186 return false; | 170 return false; |
| 187 } | 171 } |
| 188 | 172 |
| 189 if (num_configs == 0) { | 173 if (num_configs == 0) { |
| 190 LOG(ERROR) << "No suitable EGL configs found."; | 174 LOG(ERROR) << "No suitable EGL configs found."; |
| 191 return false; | 175 return false; |
| 192 } | 176 } |
| 193 | 177 |
| 194 if (!eglChooseConfig(g_display, | 178 if (!eglChooseConfig(g_display, kConfigAttribs, &g_config, 1, &num_configs)) { |
| 195 config_attribs, | |
| 196 &g_config, | |
| 197 1, | |
| 198 &num_configs)) { | |
| 199 LOG(ERROR) << "eglChooseConfig failed with error " | 179 LOG(ERROR) << "eglChooseConfig failed with error " |
| 200 << GetLastEGLErrorString(); | 180 << GetLastEGLErrorString(); |
| 201 return false; | 181 return false; |
| 202 } | 182 } |
| 203 | 183 |
| 204 g_egl_extensions = eglQueryString(g_display, EGL_EXTENSIONS); | 184 g_egl_extensions = eglQueryString(g_display, EGL_EXTENSIONS); |
| 205 g_egl_create_context_robustness_supported = | 185 g_egl_create_context_robustness_supported = |
| 206 HasEGLExtension("EGL_EXT_create_context_robustness"); | 186 HasEGLExtension("EGL_EXT_create_context_robustness"); |
| 207 g_egl_sync_control_supported = | 187 g_egl_sync_control_supported = |
| 208 HasEGLExtension("EGL_CHROMIUM_sync_control"); | 188 HasEGLExtension("EGL_CHROMIUM_sync_control"); |
| (...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 331 return eglGetPlatformDisplayEXT(EGL_PLATFORM_ANGLE_ANGLE, native_display, | 311 return eglGetPlatformDisplayEXT(EGL_PLATFORM_ANGLE_ANGLE, native_display, |
| 332 kDisplayAttribsWarp); | 312 kDisplayAttribsWarp); |
| 333 } | 313 } |
| 334 | 314 |
| 335 return eglGetDisplay(native_display); | 315 return eglGetDisplay(native_display); |
| 336 } | 316 } |
| 337 #endif | 317 #endif |
| 338 | 318 |
| 339 NativeViewGLSurfaceEGL::NativeViewGLSurfaceEGL(EGLNativeWindowType window) | 319 NativeViewGLSurfaceEGL::NativeViewGLSurfaceEGL(EGLNativeWindowType window) |
| 340 : window_(window), | 320 : window_(window), |
| 321 config_(NULL), |
| 341 surface_(NULL), | 322 surface_(NULL), |
| 342 supports_post_sub_buffer_(false), | 323 supports_post_sub_buffer_(false), |
| 343 config_(NULL), | |
| 344 size_(1, 1) { | 324 size_(1, 1) { |
| 345 #if defined(OS_ANDROID) | 325 #if defined(OS_ANDROID) |
| 346 if (window) | 326 if (window) |
| 347 ANativeWindow_acquire(window); | 327 ANativeWindow_acquire(window); |
| 348 #endif | 328 #endif |
| 349 | 329 |
| 350 #if defined(OS_WIN) | 330 #if defined(OS_WIN) |
| 351 RECT windowRect; | 331 RECT windowRect; |
| 352 if (GetClientRect(window_, &windowRect)) | 332 if (GetClientRect(window_, &windowRect)) |
| 353 size_ = gfx::Rect(windowRect).size(); | 333 size_ = gfx::Rect(windowRect).size(); |
| (...skipping 406 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 760 } | 740 } |
| 761 | 741 |
| 762 void* SurfacelessEGL::GetShareHandle() { | 742 void* SurfacelessEGL::GetShareHandle() { |
| 763 return NULL; | 743 return NULL; |
| 764 } | 744 } |
| 765 | 745 |
| 766 SurfacelessEGL::~SurfacelessEGL() { | 746 SurfacelessEGL::~SurfacelessEGL() { |
| 767 } | 747 } |
| 768 | 748 |
| 769 } // namespace gfx | 749 } // namespace gfx |
| OLD | NEW |