| 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 19 matching lines...) Expand all Loading... |
| 30 #endif | 30 #endif |
| 31 | 31 |
| 32 #if defined (USE_OZONE) | 32 #if defined (USE_OZONE) |
| 33 #include "ui/ozone/public/surface_factory_ozone.h" | 33 #include "ui/ozone/public/surface_factory_ozone.h" |
| 34 #endif | 34 #endif |
| 35 | 35 |
| 36 #if !defined(EGL_FIXED_SIZE_ANGLE) | 36 #if !defined(EGL_FIXED_SIZE_ANGLE) |
| 37 #define EGL_FIXED_SIZE_ANGLE 0x3201 | 37 #define EGL_FIXED_SIZE_ANGLE 0x3201 |
| 38 #endif | 38 #endif |
| 39 | 39 |
| 40 #if !defined(EGL_OPENGL_ES3_BIT) |
| 41 #define EGL_OPENGL_ES3_BIT 0x00000040 |
| 42 #endif |
| 43 |
| 40 #if defined(OS_WIN) | 44 #if defined(OS_WIN) |
| 41 // From ANGLE's egl/eglext.h. | 45 // From ANGLE's egl/eglext.h. |
| 42 | 46 |
| 43 #ifndef EGL_ANGLE_platform_angle | 47 #ifndef EGL_ANGLE_platform_angle |
| 44 #define EGL_ANGLE_platform_angle 1 | 48 #define EGL_ANGLE_platform_angle 1 |
| 45 #define EGL_PLATFORM_ANGLE_ANGLE 0x3202 | 49 #define EGL_PLATFORM_ANGLE_ANGLE 0x3202 |
| 46 #define EGL_PLATFORM_ANGLE_TYPE_ANGLE 0x3203 | 50 #define EGL_PLATFORM_ANGLE_TYPE_ANGLE 0x3203 |
| 47 #define EGL_PLATFORM_ANGLE_MAX_VERSION_MAJOR_ANGLE 0x3204 | 51 #define EGL_PLATFORM_ANGLE_MAX_VERSION_MAJOR_ANGLE 0x3204 |
| 48 #define EGL_PLATFORM_ANGLE_MAX_VERSION_MINOR_ANGLE 0x3205 | 52 #define EGL_PLATFORM_ANGLE_MAX_VERSION_MINOR_ANGLE 0x3205 |
| 49 #define EGL_PLATFORM_ANGLE_TYPE_DEFAULT_ANGLE 0x3206 | 53 #define EGL_PLATFORM_ANGLE_TYPE_DEFAULT_ANGLE 0x3206 |
| (...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 165 return false; | 169 return false; |
| 166 } | 170 } |
| 167 | 171 |
| 168 if (!eglInitialize(g_display, NULL, NULL)) { | 172 if (!eglInitialize(g_display, NULL, NULL)) { |
| 169 LOG(ERROR) << "eglInitialize failed with error " << GetLastEGLErrorString(); | 173 LOG(ERROR) << "eglInitialize failed with error " << GetLastEGLErrorString(); |
| 170 return false; | 174 return false; |
| 171 } | 175 } |
| 172 | 176 |
| 173 // Choose an EGL configuration. | 177 // Choose an EGL configuration. |
| 174 // On X this is only used for PBuffer surfaces. | 178 // On X this is only used for PBuffer surfaces. |
| 175 static const EGLint kConfigAttribs[] = { | 179 EGLint renderable_type = EGL_OPENGL_ES2_BIT; |
| 180 if (base::CommandLine::ForCurrentProcess()->HasSwitch( |
| 181 switches::kEnableUnsafeES3APIs)) { |
| 182 renderable_type = EGL_OPENGL_ES3_BIT; |
| 183 } |
| 184 const EGLint kConfigAttribs[] = { |
| 176 EGL_BUFFER_SIZE, 32, | 185 EGL_BUFFER_SIZE, 32, |
| 177 EGL_ALPHA_SIZE, 8, | 186 EGL_ALPHA_SIZE, 8, |
| 178 EGL_BLUE_SIZE, 8, | 187 EGL_BLUE_SIZE, 8, |
| 179 EGL_GREEN_SIZE, 8, | 188 EGL_GREEN_SIZE, 8, |
| 180 EGL_RED_SIZE, 8, | 189 EGL_RED_SIZE, 8, |
| 181 EGL_RENDERABLE_TYPE, EGL_OPENGL_ES2_BIT, | 190 EGL_RENDERABLE_TYPE, renderable_type, |
| 182 EGL_SURFACE_TYPE, EGL_WINDOW_BIT | EGL_PBUFFER_BIT, | 191 EGL_SURFACE_TYPE, EGL_WINDOW_BIT | EGL_PBUFFER_BIT, |
| 183 EGL_NONE | 192 EGL_NONE |
| 184 }; | 193 }; |
| 185 | 194 |
| 186 #if defined(USE_OZONE) | 195 #if defined(USE_OZONE) |
| 187 const EGLint* config_attribs = | 196 const EGLint* config_attribs = |
| 188 ui::SurfaceFactoryOzone::GetInstance()->GetEGLSurfaceProperties( | 197 ui::SurfaceFactoryOzone::GetInstance()->GetEGLSurfaceProperties( |
| 189 kConfigAttribs); | 198 kConfigAttribs); |
| 190 #else | 199 #else |
| 191 const EGLint* config_attribs = kConfigAttribs; | 200 const EGLint* config_attribs = kConfigAttribs; |
| (...skipping 630 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 822 } | 831 } |
| 823 | 832 |
| 824 void* SurfacelessEGL::GetShareHandle() { | 833 void* SurfacelessEGL::GetShareHandle() { |
| 825 return NULL; | 834 return NULL; |
| 826 } | 835 } |
| 827 | 836 |
| 828 SurfacelessEGL::~SurfacelessEGL() { | 837 SurfacelessEGL::~SurfacelessEGL() { |
| 829 } | 838 } |
| 830 | 839 |
| 831 } // namespace gfx | 840 } // namespace gfx |
| OLD | NEW |