| 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 256 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 267 } | 267 } |
| 268 if (*num_configs == 0) { | 268 if (*num_configs == 0) { |
| 269 return false; | 269 return false; |
| 270 } | 270 } |
| 271 return true; | 271 return true; |
| 272 } | 272 } |
| 273 | 273 |
| 274 EGLConfig ChooseConfig(GLSurfaceFormat format) { | 274 EGLConfig ChooseConfig(GLSurfaceFormat format) { |
| 275 // Choose an EGL configuration. | 275 // Choose an EGL configuration. |
| 276 // On X this is only used for PBuffer surfaces. | 276 // On X this is only used for PBuffer surfaces. |
| 277 |
| 277 std::vector<EGLint> renderable_types; | 278 std::vector<EGLint> renderable_types; |
| 278 if (!base::CommandLine::ForCurrentProcess()->HasSwitch( | 279 if (!base::CommandLine::ForCurrentProcess()->HasSwitch( |
| 279 switches::kDisableES3GLContext)) { | 280 switches::kDisableES3GLContext)) { |
| 280 renderable_types.push_back(EGL_OPENGL_ES3_BIT); | 281 renderable_types.push_back(EGL_OPENGL_ES3_BIT); |
| 281 } | 282 } |
| 282 renderable_types.push_back(EGL_OPENGL_ES2_BIT); | 283 renderable_types.push_back(EGL_OPENGL_ES2_BIT); |
| 283 | 284 |
| 284 EGLint buffer_size = format.GetBufferSize(); | 285 EGLint buffer_size = format.GetBufferSize(); |
| 285 EGLint alpha_size = 8; | 286 EGLint alpha_size = 8; |
| 286 bool want_rgb565 = buffer_size == 16; | 287 bool want_rgb565 = buffer_size == 16; |
| 288 EGLint depth_size = format.GetDepthBits(); |
| 289 EGLint stencil_size = format.GetStencilBits(); |
| 290 EGLint samples = format.GetSamples(); |
| 287 | 291 |
| 288 #if defined(USE_X11) && !defined(OS_CHROMEOS) | 292 #if defined(USE_X11) && !defined(OS_CHROMEOS) |
| 289 // If we're using ANGLE_NULL, we may not have a display, in which case we | 293 // If we're using ANGLE_NULL, we may not have a display, in which case we |
| 290 // can't use XVisualManager. | 294 // can't use XVisualManager. |
| 291 if (g_native_display) { | 295 if (g_native_display) { |
| 292 ui::XVisualManager::GetInstance()->ChooseVisualForWindow( | 296 ui::XVisualManager::GetInstance()->ChooseVisualForWindow( |
| 293 true, nullptr, &buffer_size, nullptr, nullptr); | 297 true, nullptr, &buffer_size, nullptr, nullptr); |
| 294 alpha_size = buffer_size == 32 ? 8 : 0; | 298 alpha_size = buffer_size == 32 ? 8 : 0; |
| 295 } | 299 } |
| 296 #endif | 300 #endif |
| 297 | 301 |
| 298 EGLint surface_type = (format.IsSurfaceless() | 302 EGLint surface_type = (format.IsSurfaceless() |
| 299 ? EGL_DONT_CARE | 303 ? EGL_DONT_CARE |
| 300 : EGL_WINDOW_BIT | EGL_PBUFFER_BIT); | 304 : EGL_WINDOW_BIT | EGL_PBUFFER_BIT); |
| 301 | 305 |
| 302 for (auto renderable_type : renderable_types) { | 306 for (auto renderable_type : renderable_types) { |
| 303 EGLint config_attribs_8888[] = {EGL_BUFFER_SIZE, | 307 EGLint config_attribs_8888[] = {EGL_BUFFER_SIZE, |
| 304 buffer_size, | 308 buffer_size, |
| 305 EGL_ALPHA_SIZE, | 309 EGL_ALPHA_SIZE, |
| 306 alpha_size, | 310 alpha_size, |
| 307 EGL_BLUE_SIZE, | 311 EGL_BLUE_SIZE, |
| 308 8, | 312 8, |
| 309 EGL_GREEN_SIZE, | 313 EGL_GREEN_SIZE, |
| 310 8, | 314 8, |
| 311 EGL_RED_SIZE, | 315 EGL_RED_SIZE, |
| 312 8, | 316 8, |
| 317 EGL_SAMPLES, |
| 318 samples, |
| 319 EGL_DEPTH_SIZE, |
| 320 depth_size, |
| 321 EGL_STENCIL_SIZE, |
| 322 stencil_size, |
| 313 EGL_RENDERABLE_TYPE, | 323 EGL_RENDERABLE_TYPE, |
| 314 renderable_type, | 324 renderable_type, |
| 315 EGL_SURFACE_TYPE, | 325 EGL_SURFACE_TYPE, |
| 316 surface_type, | 326 surface_type, |
| 317 EGL_NONE}; | 327 EGL_NONE}; |
| 318 | 328 |
| 319 EGLint config_attribs_565[] = {EGL_BUFFER_SIZE, | 329 EGLint config_attribs_565[] = {EGL_BUFFER_SIZE, |
| 320 16, | 330 16, |
| 321 EGL_BLUE_SIZE, | 331 EGL_BLUE_SIZE, |
| 322 5, | 332 5, |
| 323 EGL_GREEN_SIZE, | 333 EGL_GREEN_SIZE, |
| 324 6, | 334 6, |
| 325 EGL_RED_SIZE, | 335 EGL_RED_SIZE, |
| 326 5, | 336 5, |
| 337 EGL_SAMPLES, |
| 338 samples, |
| 339 EGL_DEPTH_SIZE, |
| 340 depth_size, |
| 341 EGL_STENCIL_SIZE, |
| 342 stencil_size, |
| 327 EGL_RENDERABLE_TYPE, | 343 EGL_RENDERABLE_TYPE, |
| 328 renderable_type, | 344 renderable_type, |
| 329 EGL_SURFACE_TYPE, | 345 EGL_SURFACE_TYPE, |
| 330 surface_type, | 346 surface_type, |
| 331 EGL_NONE}; | 347 EGL_NONE}; |
| 332 | 348 |
| 333 EGLint* choose_attributes = config_attribs_8888; | 349 EGLint* choose_attributes = config_attribs_8888; |
| 334 if (want_rgb565) { | 350 if (want_rgb565) { |
| 335 choose_attributes = config_attribs_565; | 351 choose_attributes = config_attribs_565; |
| 336 } | 352 } |
| (...skipping 892 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1229 } | 1245 } |
| 1230 | 1246 |
| 1231 void* SurfacelessEGL::GetShareHandle() { | 1247 void* SurfacelessEGL::GetShareHandle() { |
| 1232 return NULL; | 1248 return NULL; |
| 1233 } | 1249 } |
| 1234 | 1250 |
| 1235 SurfacelessEGL::~SurfacelessEGL() { | 1251 SurfacelessEGL::~SurfacelessEGL() { |
| 1236 } | 1252 } |
| 1237 | 1253 |
| 1238 } // namespace gl | 1254 } // namespace gl |
| OLD | NEW |