| 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 253 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 264 LOG(ERROR) << "eglChooseConfig failed with error " | 264 LOG(ERROR) << "eglChooseConfig failed with error " |
| 265 << GetLastEGLErrorString(); | 265 << GetLastEGLErrorString(); |
| 266 return false; | 266 return false; |
| 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, bool surfaceless) { |
| 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 |
| 278 std::vector<EGLint> renderable_types; | 278 std::vector<EGLint> renderable_types; |
| 279 if (!base::CommandLine::ForCurrentProcess()->HasSwitch( | 279 if (!base::CommandLine::ForCurrentProcess()->HasSwitch( |
| 280 switches::kDisableES3GLContext)) { | 280 switches::kDisableES3GLContext)) { |
| 281 renderable_types.push_back(EGL_OPENGL_ES3_BIT); | 281 renderable_types.push_back(EGL_OPENGL_ES3_BIT); |
| 282 } | 282 } |
| 283 renderable_types.push_back(EGL_OPENGL_ES2_BIT); | 283 renderable_types.push_back(EGL_OPENGL_ES2_BIT); |
| 284 | 284 |
| 285 EGLint buffer_size = format.GetBufferSize(); | 285 EGLint buffer_size = format.GetBufferSize(); |
| 286 EGLint alpha_size = 8; | 286 EGLint alpha_size = 8; |
| 287 bool want_rgb565 = buffer_size == 16; | 287 bool want_rgb565 = buffer_size == 16; |
| 288 EGLint depth_size = format.GetDepthBits(); | 288 EGLint depth_size = format.GetDepthBits(); |
| 289 EGLint stencil_size = format.GetStencilBits(); | 289 EGLint stencil_size = format.GetStencilBits(); |
| 290 EGLint samples = format.GetSamples(); | 290 EGLint samples = format.GetSamples(); |
| 291 | 291 |
| 292 #if defined(USE_X11) && !defined(OS_CHROMEOS) | 292 #if defined(USE_X11) && !defined(OS_CHROMEOS) |
| 293 // 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 |
| 294 // can't use XVisualManager. | 294 // can't use XVisualManager. |
| 295 if (g_native_display) { | 295 if (g_native_display) { |
| 296 ui::XVisualManager::GetInstance()->ChooseVisualForWindow( | 296 ui::XVisualManager::GetInstance()->ChooseVisualForWindow( |
| 297 true, nullptr, &buffer_size, nullptr, nullptr); | 297 true, nullptr, &buffer_size, nullptr, nullptr); |
| 298 alpha_size = buffer_size == 32 ? 8 : 0; | 298 alpha_size = buffer_size == 32 ? 8 : 0; |
| 299 } | 299 } |
| 300 #endif | 300 #endif |
| 301 | 301 |
| 302 EGLint surface_type = (format.IsSurfaceless() | 302 EGLint surface_type = |
| 303 ? EGL_DONT_CARE | 303 (surfaceless ? EGL_DONT_CARE : EGL_WINDOW_BIT | EGL_PBUFFER_BIT); |
| 304 : EGL_WINDOW_BIT | EGL_PBUFFER_BIT); | |
| 305 | 304 |
| 306 for (auto renderable_type : renderable_types) { | 305 for (auto renderable_type : renderable_types) { |
| 307 EGLint config_attribs_8888[] = {EGL_BUFFER_SIZE, | 306 EGLint config_attribs_8888[] = {EGL_BUFFER_SIZE, |
| 308 buffer_size, | 307 buffer_size, |
| 309 EGL_ALPHA_SIZE, | 308 EGL_ALPHA_SIZE, |
| 310 alpha_size, | 309 alpha_size, |
| 311 EGL_BLUE_SIZE, | 310 EGL_BLUE_SIZE, |
| 312 8, | 311 8, |
| 313 EGL_GREEN_SIZE, | 312 EGL_GREEN_SIZE, |
| 314 8, | 313 8, |
| (...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 488 GLSurfaceFormat GLSurfaceEGL::GetFormat() { | 487 GLSurfaceFormat GLSurfaceEGL::GetFormat() { |
| 489 return format_; | 488 return format_; |
| 490 } | 489 } |
| 491 | 490 |
| 492 EGLDisplay GLSurfaceEGL::GetDisplay() { | 491 EGLDisplay GLSurfaceEGL::GetDisplay() { |
| 493 return g_display; | 492 return g_display; |
| 494 } | 493 } |
| 495 | 494 |
| 496 EGLConfig GLSurfaceEGL::GetConfig() { | 495 EGLConfig GLSurfaceEGL::GetConfig() { |
| 497 if (!config_) { | 496 if (!config_) { |
| 498 config_ = ChooseConfig(format_); | 497 config_ = ChooseConfig(format_, IsSurfaceless()); |
| 499 } | 498 } |
| 500 return config_; | 499 return config_; |
| 501 } | 500 } |
| 502 | 501 |
| 503 // static | 502 // static |
| 504 bool GLSurfaceEGL::InitializeOneOff(EGLNativeDisplayType native_display) { | 503 bool GLSurfaceEGL::InitializeOneOff(EGLNativeDisplayType native_display) { |
| 505 if (initialized_) | 504 if (initialized_) |
| 506 return true; | 505 return true; |
| 507 | 506 |
| 508 // Must be called before InitializeDisplay(). | 507 // Must be called before InitializeDisplay(). |
| (...skipping 685 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1194 } | 1193 } |
| 1195 | 1194 |
| 1196 return handle; | 1195 return handle; |
| 1197 #endif | 1196 #endif |
| 1198 } | 1197 } |
| 1199 | 1198 |
| 1200 PbufferGLSurfaceEGL::~PbufferGLSurfaceEGL() { | 1199 PbufferGLSurfaceEGL::~PbufferGLSurfaceEGL() { |
| 1201 Destroy(); | 1200 Destroy(); |
| 1202 } | 1201 } |
| 1203 | 1202 |
| 1204 SurfacelessEGL::SurfacelessEGL(const gfx::Size& size) | 1203 SurfacelessEGL::SurfacelessEGL(const gfx::Size& size) : size_(size) {} |
| 1205 : size_(size) { | |
| 1206 format_ = GLSurfaceFormat(); | |
| 1207 format_.SetIsSurfaceless(); | |
| 1208 } | |
| 1209 | 1204 |
| 1210 bool SurfacelessEGL::Initialize(GLSurfaceFormat format) { | 1205 bool SurfacelessEGL::Initialize(GLSurfaceFormat format) { |
| 1211 format.SetIsSurfaceless(); | |
| 1212 format_ = format; | 1206 format_ = format; |
| 1213 return true; | 1207 return true; |
| 1214 } | 1208 } |
| 1215 | 1209 |
| 1216 void SurfacelessEGL::Destroy() { | 1210 void SurfacelessEGL::Destroy() { |
| 1217 } | 1211 } |
| 1218 | 1212 |
| 1219 bool SurfacelessEGL::IsOffscreen() { | 1213 bool SurfacelessEGL::IsOffscreen() { |
| 1220 return true; | 1214 return true; |
| 1221 } | 1215 } |
| (...skipping 23 matching lines...) Expand all Loading... |
| 1245 } | 1239 } |
| 1246 | 1240 |
| 1247 void* SurfacelessEGL::GetShareHandle() { | 1241 void* SurfacelessEGL::GetShareHandle() { |
| 1248 return NULL; | 1242 return NULL; |
| 1249 } | 1243 } |
| 1250 | 1244 |
| 1251 SurfacelessEGL::~SurfacelessEGL() { | 1245 SurfacelessEGL::~SurfacelessEGL() { |
| 1252 } | 1246 } |
| 1253 | 1247 |
| 1254 } // namespace gl | 1248 } // namespace gl |
| OLD | NEW |