Chromium Code Reviews| 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 <stddef.h> | 7 #include <stddef.h> |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include <map> | 10 #include <map> |
| (...skipping 18 matching lines...) Expand all Loading... | |
| 29 #include "ui/gl/gl_surface_stub.h" | 29 #include "ui/gl/gl_surface_stub.h" |
| 30 #include "ui/gl/gl_switches.h" | 30 #include "ui/gl/gl_switches.h" |
| 31 #include "ui/gl/scoped_make_current.h" | 31 #include "ui/gl/scoped_make_current.h" |
| 32 #include "ui/gl/sync_control_vsync_provider.h" | 32 #include "ui/gl/sync_control_vsync_provider.h" |
| 33 | 33 |
| 34 #if defined(OS_ANDROID) | 34 #if defined(OS_ANDROID) |
| 35 #include <android/native_window_jni.h> | 35 #include <android/native_window_jni.h> |
| 36 #endif | 36 #endif |
| 37 | 37 |
| 38 #if defined(USE_X11) && !defined(OS_CHROMEOS) | 38 #if defined(USE_X11) && !defined(OS_CHROMEOS) |
| 39 extern "C" { | 39 #include "ui/gl/gl_visual_picker_glx.h" |
|
piman
2016/09/22 21:24:55
When we're using EGL, we are not using GLX, so I d
Tom (Use chromium acct)
2016/09/23 20:00:37
Done. I opted to use XVisualManager instead. Unf
piman
2016/09/26 21:13:29
I think this is ok.
| |
| 40 #include <X11/Xlib.h> | |
| 41 #define Status int | |
| 42 } | |
| 43 #include "ui/gfx/x/x11_switches.h" // nogncheck | |
| 44 #endif | 40 #endif |
| 45 | 41 |
| 46 #if !defined(EGL_FIXED_SIZE_ANGLE) | 42 #if !defined(EGL_FIXED_SIZE_ANGLE) |
| 47 #define EGL_FIXED_SIZE_ANGLE 0x3201 | 43 #define EGL_FIXED_SIZE_ANGLE 0x3201 |
| 48 #endif | 44 #endif |
| 49 | 45 |
| 50 #if !defined(EGL_OPENGL_ES3_BIT) | 46 #if !defined(EGL_OPENGL_ES3_BIT) |
| 51 #define EGL_OPENGL_ES3_BIT 0x00000040 | 47 #define EGL_OPENGL_ES3_BIT 0x00000040 |
| 52 #endif | 48 #endif |
| 53 | 49 |
| (...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 168 | 164 |
| 169 display_attribs.push_back(EGL_PLATFORM_ANGLE_TYPE_ANGLE); | 165 display_attribs.push_back(EGL_PLATFORM_ANGLE_TYPE_ANGLE); |
| 170 display_attribs.push_back(platform_type); | 166 display_attribs.push_back(platform_type); |
| 171 | 167 |
| 172 if (warpDevice) { | 168 if (warpDevice) { |
| 173 display_attribs.push_back(EGL_PLATFORM_ANGLE_DEVICE_TYPE_ANGLE); | 169 display_attribs.push_back(EGL_PLATFORM_ANGLE_DEVICE_TYPE_ANGLE); |
| 174 display_attribs.push_back(EGL_PLATFORM_ANGLE_DEVICE_TYPE_WARP_ANGLE); | 170 display_attribs.push_back(EGL_PLATFORM_ANGLE_DEVICE_TYPE_WARP_ANGLE); |
| 175 } | 171 } |
| 176 | 172 |
| 177 #if defined(USE_X11) && !defined(OS_CHROMEOS) | 173 #if defined(USE_X11) && !defined(OS_CHROMEOS) |
| 178 std::string visualid_str = | |
| 179 base::CommandLine::ForCurrentProcess()->GetSwitchValueASCII( | |
| 180 switches::kX11VisualID); | |
| 181 unsigned int visualid = 0; | |
| 182 bool succeed = base::StringToUint(visualid_str, &visualid); | |
| 183 DCHECK(succeed); | |
| 184 display_attribs.push_back(EGL_X11_VISUAL_ID_ANGLE); | 174 display_attribs.push_back(EGL_X11_VISUAL_ID_ANGLE); |
| 185 display_attribs.push_back((EGLint)visualid); | 175 display_attribs.push_back( |
| 176 (EGLint)gl::GLVisualPickerGLX::GetInstance()->rgba_visual().visualid); | |
|
piman
2016/09/22 21:24:55
nit: static_cast instead of c-style casts.
Tom (Use chromium acct)
2016/09/23 20:00:37
Done.
| |
| 186 #endif | 177 #endif |
| 187 | 178 |
| 188 display_attribs.push_back(EGL_NONE); | 179 display_attribs.push_back(EGL_NONE); |
| 189 | 180 |
| 190 return eglGetPlatformDisplayEXT(EGL_PLATFORM_ANGLE_ANGLE, | 181 return eglGetPlatformDisplayEXT(EGL_PLATFORM_ANGLE_ANGLE, |
| 191 reinterpret_cast<void*>(native_display), | 182 reinterpret_cast<void*>(native_display), |
| 192 &display_attribs[0]); | 183 &display_attribs[0]); |
| 193 } | 184 } |
| 194 | 185 |
| 195 EGLDisplay GetDisplayFromType(DisplayType display_type, | 186 EGLDisplay GetDisplayFromType(DisplayType display_type, |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 267 if (base::CommandLine::ForCurrentProcess()->HasSwitch( | 258 if (base::CommandLine::ForCurrentProcess()->HasSwitch( |
| 268 switches::kEnableUnsafeES3APIs)) { | 259 switches::kEnableUnsafeES3APIs)) { |
| 269 renderable_types.push_back(EGL_OPENGL_ES3_BIT); | 260 renderable_types.push_back(EGL_OPENGL_ES3_BIT); |
| 270 } | 261 } |
| 271 renderable_types.push_back(EGL_OPENGL_ES2_BIT); | 262 renderable_types.push_back(EGL_OPENGL_ES2_BIT); |
| 272 | 263 |
| 273 EGLint buffer_size = 32; | 264 EGLint buffer_size = 32; |
| 274 EGLint alpha_size = 8; | 265 EGLint alpha_size = 8; |
| 275 | 266 |
| 276 #if defined(USE_X11) && !defined(OS_CHROMEOS) | 267 #if defined(USE_X11) && !defined(OS_CHROMEOS) |
| 277 if (base::CommandLine::ForCurrentProcess()->HasSwitch( | 268 buffer_size = gl::GLVisualPickerGLX::GetInstance()->rgba_visual().depth; |
| 278 switches::kWindowDepth)) { | 269 alpha_size = buffer_size == 32 ? 8 : 0; |
| 279 std::string depth = | |
| 280 base::CommandLine::ForCurrentProcess()->GetSwitchValueASCII( | |
| 281 switches::kWindowDepth); | |
| 282 | |
| 283 bool succeed = base::StringToInt(depth, &buffer_size); | |
| 284 DCHECK(succeed); | |
| 285 | |
| 286 alpha_size = buffer_size == 32 ? 8 : 0; | |
| 287 } | |
| 288 #endif | 270 #endif |
| 289 | 271 |
| 290 EGLint surface_type = (format == GLSurface::SURFACE_SURFACELESS) | 272 EGLint surface_type = (format == GLSurface::SURFACE_SURFACELESS) |
| 291 ? EGL_DONT_CARE | 273 ? EGL_DONT_CARE |
| 292 : EGL_WINDOW_BIT | EGL_PBUFFER_BIT; | 274 : EGL_WINDOW_BIT | EGL_PBUFFER_BIT; |
| 293 | 275 |
| 294 for (auto renderable_type : renderable_types) { | 276 for (auto renderable_type : renderable_types) { |
| 295 EGLint config_attribs_8888[] = {EGL_BUFFER_SIZE, | 277 EGLint config_attribs_8888[] = {EGL_BUFFER_SIZE, |
| 296 buffer_size, | 278 buffer_size, |
| 297 EGL_ALPHA_SIZE, | 279 EGL_ALPHA_SIZE, |
| (...skipping 893 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1191 } | 1173 } |
| 1192 | 1174 |
| 1193 void* SurfacelessEGL::GetShareHandle() { | 1175 void* SurfacelessEGL::GetShareHandle() { |
| 1194 return NULL; | 1176 return NULL; |
| 1195 } | 1177 } |
| 1196 | 1178 |
| 1197 SurfacelessEGL::~SurfacelessEGL() { | 1179 SurfacelessEGL::~SurfacelessEGL() { |
| 1198 } | 1180 } |
| 1199 | 1181 |
| 1200 } // namespace gl | 1182 } // namespace gl |
| OLD | NEW |