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 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
147 | 147 |
148 display_attribs.push_back(EGL_PLATFORM_ANGLE_TYPE_ANGLE); | 148 display_attribs.push_back(EGL_PLATFORM_ANGLE_TYPE_ANGLE); |
149 display_attribs.push_back(platform_type); | 149 display_attribs.push_back(platform_type); |
150 | 150 |
151 if (warpDevice) { | 151 if (warpDevice) { |
152 display_attribs.push_back(EGL_PLATFORM_ANGLE_DEVICE_TYPE_ANGLE); | 152 display_attribs.push_back(EGL_PLATFORM_ANGLE_DEVICE_TYPE_ANGLE); |
153 display_attribs.push_back(EGL_PLATFORM_ANGLE_DEVICE_TYPE_WARP_ANGLE); | 153 display_attribs.push_back(EGL_PLATFORM_ANGLE_DEVICE_TYPE_WARP_ANGLE); |
154 } | 154 } |
155 | 155 |
156 #if defined(USE_X11) && !defined(OS_CHROMEOS) | 156 #if defined(USE_X11) && !defined(OS_CHROMEOS) |
157 Visual* visual; | 157 // ANGLE_NULL doesn't use the visual, and may run without X11 where we can't |
158 ui::XVisualManager::GetInstance()->ChooseVisualForWindow( | 158 // get it anyway. |
159 true, &visual, nullptr, nullptr, nullptr); | 159 if (platform_type != EGL_PLATFORM_ANGLE_TYPE_NULL_ANGLE) { |
160 display_attribs.push_back(EGL_X11_VISUAL_ID_ANGLE); | 160 Visual* visual; |
161 display_attribs.push_back(static_cast<EGLint>(XVisualIDFromVisual(visual))); | 161 ui::XVisualManager::GetInstance()->ChooseVisualForWindow( |
| 162 true, &visual, nullptr, nullptr, nullptr); |
| 163 display_attribs.push_back(EGL_X11_VISUAL_ID_ANGLE); |
| 164 display_attribs.push_back(static_cast<EGLint>(XVisualIDFromVisual(visual))); |
| 165 } |
162 #endif | 166 #endif |
163 | 167 |
164 display_attribs.push_back(EGL_NONE); | 168 display_attribs.push_back(EGL_NONE); |
165 | 169 |
166 return eglGetPlatformDisplayEXT(EGL_PLATFORM_ANGLE_ANGLE, | 170 return eglGetPlatformDisplayEXT(EGL_PLATFORM_ANGLE_ANGLE, |
167 reinterpret_cast<void*>(native_display), | 171 reinterpret_cast<void*>(native_display), |
168 &display_attribs[0]); | 172 &display_attribs[0]); |
169 } | 173 } |
170 | 174 |
171 EGLDisplay GetDisplayFromType(DisplayType display_type, | 175 EGLDisplay GetDisplayFromType(DisplayType display_type, |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
242 if (!base::CommandLine::ForCurrentProcess()->HasSwitch( | 246 if (!base::CommandLine::ForCurrentProcess()->HasSwitch( |
243 switches::kDisableES3GLContext)) { | 247 switches::kDisableES3GLContext)) { |
244 renderable_types.push_back(EGL_OPENGL_ES3_BIT); | 248 renderable_types.push_back(EGL_OPENGL_ES3_BIT); |
245 } | 249 } |
246 renderable_types.push_back(EGL_OPENGL_ES2_BIT); | 250 renderable_types.push_back(EGL_OPENGL_ES2_BIT); |
247 | 251 |
248 EGLint buffer_size = 32; | 252 EGLint buffer_size = 32; |
249 EGLint alpha_size = 8; | 253 EGLint alpha_size = 8; |
250 | 254 |
251 #if defined(USE_X11) && !defined(OS_CHROMEOS) | 255 #if defined(USE_X11) && !defined(OS_CHROMEOS) |
252 ui::XVisualManager::GetInstance()->ChooseVisualForWindow( | 256 // If we're using ANGLE_NULL, we may not have a display, in which case we |
253 true, nullptr, &buffer_size, nullptr, nullptr); | 257 // can't use XVisualManager. |
254 alpha_size = buffer_size == 32 ? 8 : 0; | 258 if (g_native_display) { |
| 259 ui::XVisualManager::GetInstance()->ChooseVisualForWindow( |
| 260 true, nullptr, &buffer_size, nullptr, nullptr); |
| 261 alpha_size = buffer_size == 32 ? 8 : 0; |
| 262 } |
255 #endif | 263 #endif |
256 | 264 |
257 EGLint surface_type = (format == GLSurface::SURFACE_SURFACELESS) | 265 EGLint surface_type = (format == GLSurface::SURFACE_SURFACELESS) |
258 ? EGL_DONT_CARE | 266 ? EGL_DONT_CARE |
259 : EGL_WINDOW_BIT | EGL_PBUFFER_BIT; | 267 : EGL_WINDOW_BIT | EGL_PBUFFER_BIT; |
260 | 268 |
261 for (auto renderable_type : renderable_types) { | 269 for (auto renderable_type : renderable_types) { |
262 EGLint config_attribs_8888[] = {EGL_BUFFER_SIZE, | 270 EGLint config_attribs_8888[] = {EGL_BUFFER_SIZE, |
263 buffer_size, | 271 buffer_size, |
264 EGL_ALPHA_SIZE, | 272 EGL_ALPHA_SIZE, |
(...skipping 972 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1237 } | 1245 } |
1238 | 1246 |
1239 void* SurfacelessEGL::GetShareHandle() { | 1247 void* SurfacelessEGL::GetShareHandle() { |
1240 return NULL; | 1248 return NULL; |
1241 } | 1249 } |
1242 | 1250 |
1243 SurfacelessEGL::~SurfacelessEGL() { | 1251 SurfacelessEGL::~SurfacelessEGL() { |
1244 } | 1252 } |
1245 | 1253 |
1246 } // namespace gl | 1254 } // namespace gl |
OLD | NEW |