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 224 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
235 } | 235 } |
236 if (*num_configs == 0) { | 236 if (*num_configs == 0) { |
237 return false; | 237 return false; |
238 } | 238 } |
239 return true; | 239 return true; |
240 } | 240 } |
241 | 241 |
242 EGLConfig ChooseConfig(GLSurfaceFormat format) { | 242 EGLConfig ChooseConfig(GLSurfaceFormat format) { |
243 // Choose an EGL configuration. | 243 // Choose an EGL configuration. |
244 // On X this is only used for PBuffer surfaces. | 244 // On X this is only used for PBuffer surfaces. |
| 245 |
245 std::vector<EGLint> renderable_types; | 246 std::vector<EGLint> renderable_types; |
246 if (!base::CommandLine::ForCurrentProcess()->HasSwitch( | 247 if (!base::CommandLine::ForCurrentProcess()->HasSwitch( |
247 switches::kDisableES3GLContext)) { | 248 switches::kDisableES3GLContext)) { |
248 renderable_types.push_back(EGL_OPENGL_ES3_BIT); | 249 renderable_types.push_back(EGL_OPENGL_ES3_BIT); |
249 } | 250 } |
250 renderable_types.push_back(EGL_OPENGL_ES2_BIT); | 251 renderable_types.push_back(EGL_OPENGL_ES2_BIT); |
251 | 252 |
252 EGLint buffer_size = format.GetBufferSize(); | 253 EGLint buffer_size = format.GetBufferSize(); |
253 EGLint alpha_size = 8; | 254 EGLint alpha_size = 8; |
254 bool want_rgb565 = buffer_size == 16; | 255 bool want_rgb565 = buffer_size == 16; |
| 256 EGLint depth_size = format.GetDepthBits(); |
| 257 EGLint stencil_size = format.GetStencilBits(); |
| 258 EGLint samples = format.GetSamples(); |
255 | 259 |
256 #if defined(USE_X11) && !defined(OS_CHROMEOS) | 260 #if defined(USE_X11) && !defined(OS_CHROMEOS) |
257 // If we're using ANGLE_NULL, we may not have a display, in which case we | 261 // If we're using ANGLE_NULL, we may not have a display, in which case we |
258 // can't use XVisualManager. | 262 // can't use XVisualManager. |
259 if (g_native_display) { | 263 if (g_native_display) { |
260 ui::XVisualManager::GetInstance()->ChooseVisualForWindow( | 264 ui::XVisualManager::GetInstance()->ChooseVisualForWindow( |
261 true, nullptr, &buffer_size, nullptr, nullptr); | 265 true, nullptr, &buffer_size, nullptr, nullptr); |
262 alpha_size = buffer_size == 32 ? 8 : 0; | 266 alpha_size = buffer_size == 32 ? 8 : 0; |
263 } | 267 } |
264 #endif | 268 #endif |
265 | 269 |
266 EGLint surface_type = (format.IsSurfaceless() | 270 EGLint surface_type = (format.IsSurfaceless() |
267 ? EGL_DONT_CARE | 271 ? EGL_DONT_CARE |
268 : EGL_WINDOW_BIT | EGL_PBUFFER_BIT); | 272 : EGL_WINDOW_BIT | EGL_PBUFFER_BIT); |
269 | 273 |
270 for (auto renderable_type : renderable_types) { | 274 for (auto renderable_type : renderable_types) { |
271 EGLint config_attribs_8888[] = {EGL_BUFFER_SIZE, | 275 EGLint config_attribs_8888[] = {EGL_BUFFER_SIZE, |
272 buffer_size, | 276 buffer_size, |
273 EGL_ALPHA_SIZE, | 277 EGL_ALPHA_SIZE, |
274 alpha_size, | 278 alpha_size, |
275 EGL_BLUE_SIZE, | 279 EGL_BLUE_SIZE, |
276 8, | 280 8, |
277 EGL_GREEN_SIZE, | 281 EGL_GREEN_SIZE, |
278 8, | 282 8, |
279 EGL_RED_SIZE, | 283 EGL_RED_SIZE, |
280 8, | 284 8, |
| 285 EGL_SAMPLES, |
| 286 samples, |
| 287 EGL_DEPTH_SIZE, |
| 288 depth_size, |
| 289 EGL_STENCIL_SIZE, |
| 290 stencil_size, |
281 EGL_RENDERABLE_TYPE, | 291 EGL_RENDERABLE_TYPE, |
282 renderable_type, | 292 renderable_type, |
283 EGL_SURFACE_TYPE, | 293 EGL_SURFACE_TYPE, |
284 surface_type, | 294 surface_type, |
285 EGL_NONE}; | 295 EGL_NONE}; |
286 | 296 |
287 EGLint config_attribs_565[] = {EGL_BUFFER_SIZE, | 297 EGLint config_attribs_565[] = {EGL_BUFFER_SIZE, |
288 16, | 298 16, |
289 EGL_BLUE_SIZE, | 299 EGL_BLUE_SIZE, |
290 5, | 300 5, |
291 EGL_GREEN_SIZE, | 301 EGL_GREEN_SIZE, |
292 6, | 302 6, |
293 EGL_RED_SIZE, | 303 EGL_RED_SIZE, |
294 5, | 304 5, |
| 305 EGL_SAMPLES, |
| 306 samples, |
| 307 EGL_DEPTH_SIZE, |
| 308 depth_size, |
| 309 EGL_STENCIL_SIZE, |
| 310 stencil_size, |
295 EGL_RENDERABLE_TYPE, | 311 EGL_RENDERABLE_TYPE, |
296 renderable_type, | 312 renderable_type, |
297 EGL_SURFACE_TYPE, | 313 EGL_SURFACE_TYPE, |
298 surface_type, | 314 surface_type, |
299 EGL_NONE}; | 315 EGL_NONE}; |
300 | 316 |
301 EGLint* choose_attributes = config_attribs_8888; | 317 EGLint* choose_attributes = config_attribs_8888; |
302 if (want_rgb565) { | 318 if (want_rgb565) { |
303 choose_attributes = config_attribs_565; | 319 choose_attributes = config_attribs_565; |
304 } | 320 } |
(...skipping 923 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1228 } | 1244 } |
1229 | 1245 |
1230 void* SurfacelessEGL::GetShareHandle() { | 1246 void* SurfacelessEGL::GetShareHandle() { |
1231 return NULL; | 1247 return NULL; |
1232 } | 1248 } |
1233 | 1249 |
1234 SurfacelessEGL::~SurfacelessEGL() { | 1250 SurfacelessEGL::~SurfacelessEGL() { |
1235 } | 1251 } |
1236 | 1252 |
1237 } // namespace gl | 1253 } // namespace gl |
OLD | NEW |