| 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_CONTEXT_PRIORITY_LEVEL_IMG | |
| 36 #define EGL_CONTEXT_PRIORITY_LEVEL_IMG 0x3100 | |
| 37 #define EGL_CONTEXT_PRIORITY_LOW_IMG 0x3103 | |
| 38 #endif /* EGL_CONTEXT_PRIORITY_LEVEL */ | |
| 39 | |
| 40 | |
| 41 using ui::GetLastEGLErrorString; | 35 using ui::GetLastEGLErrorString; |
| 42 | 36 |
| 43 namespace gl { | 37 namespace gl { |
| 44 | 38 |
| 45 GLContextEGL::GLContextEGL(GLShareGroup* share_group) | 39 GLContextEGL::GLContextEGL(GLShareGroup* share_group) |
| 46 : GLContextReal(share_group), | 40 : GLContextReal(share_group), |
| 47 context_(nullptr), | 41 context_(nullptr), |
| 48 display_(nullptr), | 42 display_(nullptr), |
| 49 config_(nullptr), | 43 config_(nullptr), |
| 50 unbind_fbo_on_makecurrent_(false), | 44 unbind_fbo_on_makecurrent_(false), |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 104 } | 98 } |
| 105 | 99 |
| 106 if (GLSurfaceEGL::IsCreateContextWebGLCompatabilitySupported()) { | 100 if (GLSurfaceEGL::IsCreateContextWebGLCompatabilitySupported()) { |
| 107 context_attributes.push_back(EGL_CONTEXT_WEBGL_COMPATIBILITY_ANGLE); | 101 context_attributes.push_back(EGL_CONTEXT_WEBGL_COMPATIBILITY_ANGLE); |
| 108 context_attributes.push_back( | 102 context_attributes.push_back( |
| 109 attribs.webgl_compatibility_context ? EGL_TRUE : EGL_FALSE); | 103 attribs.webgl_compatibility_context ? EGL_TRUE : EGL_FALSE); |
| 110 } else { | 104 } else { |
| 111 DCHECK(!attribs.webgl_compatibility_context); | 105 DCHECK(!attribs.webgl_compatibility_context); |
| 112 } | 106 } |
| 113 | 107 |
| 114 if (GLSurfaceEGL::IsEGLContextPrioritySupported() && attribs.low_priority) { | |
| 115 DVLOG(1) << __FUNCTION__ << ": setting low priority"; | |
| 116 context_attributes.push_back(EGL_CONTEXT_PRIORITY_LEVEL_IMG); | |
| 117 context_attributes.push_back(EGL_CONTEXT_PRIORITY_LOW_IMG); | |
| 118 } | |
| 119 | |
| 120 // Append final EGL_NONE to signal the context attributes are finished | 108 // Append final EGL_NONE to signal the context attributes are finished |
| 121 context_attributes.push_back(EGL_NONE); | 109 context_attributes.push_back(EGL_NONE); |
| 122 context_attributes.push_back(EGL_NONE); | 110 context_attributes.push_back(EGL_NONE); |
| 123 | 111 |
| 124 context_ = eglCreateContext( | 112 context_ = eglCreateContext( |
| 125 display_, config_, share_group() ? share_group()->GetHandle() : nullptr, | 113 display_, config_, share_group() ? share_group()->GetHandle() : nullptr, |
| 126 context_attributes.data()); | 114 context_attributes.data()); |
| 127 | 115 |
| 128 if (!context_) { | 116 if (!context_) { |
| 129 LOG(ERROR) << "eglCreateContext failed with error " | 117 LOG(ERROR) << "eglCreateContext failed with error " |
| (...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 256 | 244 |
| 257 bool GLContextEGL::WasAllocatedUsingRobustnessExtension() { | 245 bool GLContextEGL::WasAllocatedUsingRobustnessExtension() { |
| 258 return GLSurfaceEGL::IsCreateContextRobustnessSupported(); | 246 return GLSurfaceEGL::IsCreateContextRobustnessSupported(); |
| 259 } | 247 } |
| 260 | 248 |
| 261 GLContextEGL::~GLContextEGL() { | 249 GLContextEGL::~GLContextEGL() { |
| 262 Destroy(); | 250 Destroy(); |
| 263 } | 251 } |
| 264 | 252 |
| 265 } // namespace gl | 253 } // namespace gl |
| OLD | NEW |