| 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_context_egl.h" | 5 #include "ui/gl/gl_context_egl.h" |
| 6 | 6 |
| 7 #include <memory> | 7 #include <memory> |
| 8 | 8 |
| 9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| (...skipping 14 matching lines...) Expand all Loading... |
| 25 #ifndef EGL_CHROMIUM_create_context_bind_generates_resource | 25 #ifndef EGL_CHROMIUM_create_context_bind_generates_resource |
| 26 #define EGL_CHROMIUM_create_context_bind_generates_resource 1 | 26 #define EGL_CHROMIUM_create_context_bind_generates_resource 1 |
| 27 #define EGL_CONTEXT_BIND_GENERATES_RESOURCE_CHROMIUM 0x3AAD | 27 #define EGL_CONTEXT_BIND_GENERATES_RESOURCE_CHROMIUM 0x3AAD |
| 28 #endif /* EGL_CHROMIUM_create_context_bind_generates_resource */ | 28 #endif /* EGL_CHROMIUM_create_context_bind_generates_resource */ |
| 29 | 29 |
| 30 #ifndef EGL_ANGLE_create_context_webgl_compatibility | 30 #ifndef EGL_ANGLE_create_context_webgl_compatibility |
| 31 #define EGL_ANGLE_create_context_webgl_compatibility 1 | 31 #define EGL_ANGLE_create_context_webgl_compatibility 1 |
| 32 #define EGL_CONTEXT_WEBGL_COMPATIBILITY_ANGLE 0x3AAC | 32 #define EGL_CONTEXT_WEBGL_COMPATIBILITY_ANGLE 0x3AAC |
| 33 #endif /* EGL_ANGLE_create_context_webgl_compatibility */ | 33 #endif /* EGL_ANGLE_create_context_webgl_compatibility */ |
| 34 | 34 |
| 35 #ifndef EGL_ANGLE_create_context_client_arrays |
| 36 #define EGL_ANGLE_create_context_client_arrays 1 |
| 37 #define EGL_CONTEXT_CLIENT_ARRAYS_ENABLED_ANGLE 0x3452 |
| 38 #endif /* EGL_ANGLE_create_context_client_arrays */ |
| 39 |
| 35 using ui::GetLastEGLErrorString; | 40 using ui::GetLastEGLErrorString; |
| 36 | 41 |
| 37 namespace gl { | 42 namespace gl { |
| 38 | 43 |
| 39 GLContextEGL::GLContextEGL(GLShareGroup* share_group) | 44 GLContextEGL::GLContextEGL(GLShareGroup* share_group) |
| 40 : GLContextReal(share_group), | 45 : GLContextReal(share_group), |
| 41 context_(nullptr), | 46 context_(nullptr), |
| 42 display_(nullptr), | 47 display_(nullptr), |
| 43 config_(nullptr), | 48 config_(nullptr), |
| 44 unbind_fbo_on_makecurrent_(false), | 49 unbind_fbo_on_makecurrent_(false), |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 98 } | 103 } |
| 99 | 104 |
| 100 if (GLSurfaceEGL::IsCreateContextWebGLCompatabilitySupported()) { | 105 if (GLSurfaceEGL::IsCreateContextWebGLCompatabilitySupported()) { |
| 101 context_attributes.push_back(EGL_CONTEXT_WEBGL_COMPATIBILITY_ANGLE); | 106 context_attributes.push_back(EGL_CONTEXT_WEBGL_COMPATIBILITY_ANGLE); |
| 102 context_attributes.push_back( | 107 context_attributes.push_back( |
| 103 attribs.webgl_compatibility_context ? EGL_TRUE : EGL_FALSE); | 108 attribs.webgl_compatibility_context ? EGL_TRUE : EGL_FALSE); |
| 104 } else { | 109 } else { |
| 105 DCHECK(!attribs.webgl_compatibility_context); | 110 DCHECK(!attribs.webgl_compatibility_context); |
| 106 } | 111 } |
| 107 | 112 |
| 113 if (GLSurfaceEGL::HasEGLExtension("EGL_ANGLE_create_context_client_arrays")) { |
| 114 // Disable client arrays if the context supports it |
| 115 context_attributes.push_back(EGL_CONTEXT_CLIENT_ARRAYS_ENABLED_ANGLE); |
| 116 context_attributes.push_back(EGL_FALSE); |
| 117 } |
| 118 |
| 108 // Append final EGL_NONE to signal the context attributes are finished | 119 // Append final EGL_NONE to signal the context attributes are finished |
| 109 context_attributes.push_back(EGL_NONE); | 120 context_attributes.push_back(EGL_NONE); |
| 110 context_attributes.push_back(EGL_NONE); | 121 context_attributes.push_back(EGL_NONE); |
| 111 | 122 |
| 112 context_ = eglCreateContext( | 123 context_ = eglCreateContext( |
| 113 display_, config_, share_group() ? share_group()->GetHandle() : nullptr, | 124 display_, config_, share_group() ? share_group()->GetHandle() : nullptr, |
| 114 context_attributes.data()); | 125 context_attributes.data()); |
| 115 | 126 |
| 116 if (!context_) { | 127 if (!context_) { |
| 117 LOG(ERROR) << "eglCreateContext failed with error " | 128 LOG(ERROR) << "eglCreateContext failed with error " |
| (...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 244 | 255 |
| 245 bool GLContextEGL::WasAllocatedUsingRobustnessExtension() { | 256 bool GLContextEGL::WasAllocatedUsingRobustnessExtension() { |
| 246 return GLSurfaceEGL::IsCreateContextRobustnessSupported(); | 257 return GLSurfaceEGL::IsCreateContextRobustnessSupported(); |
| 247 } | 258 } |
| 248 | 259 |
| 249 GLContextEGL::~GLContextEGL() { | 260 GLContextEGL::~GLContextEGL() { |
| 250 Destroy(); | 261 Destroy(); |
| 251 } | 262 } |
| 252 | 263 |
| 253 } // namespace gl | 264 } // namespace gl |
| OLD | NEW |