Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(599)

Unified Diff: ui/gl/gl_context_egl.cc

Issue 2480373002: Refactor context creation parameters into a struct. (Closed)
Patch Set: Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: ui/gl/gl_context_egl.cc
diff --git a/ui/gl/gl_context_egl.cc b/ui/gl/gl_context_egl.cc
index b1ea4e6a77040716cc441e2287edb1267613fd76..eabc455e3f54c6c845c53abbc5bbb9b213904c22 100644
--- a/ui/gl/gl_context_egl.cc
+++ b/ui/gl/gl_context_egl.cc
@@ -22,6 +22,16 @@ extern "C" {
}
#endif
+#ifndef EGL_CHROMIUM_create_context_bind_generates_resource
+#define EGL_CHROMIUM_create_context_bind_generates_resource 1
+#define EGL_CONTEXT_BIND_GENERATES_RESOURCE_CHROMIUM 0x3AAD
+#endif /* EGL_CHROMIUM_create_context_bind_generates_resource */
+
+#ifndef EGL_ANGLE_create_context_webgl_compatibility
+#define EGL_ANGLE_create_context_webgl_compatibility 1
+#define EGL_CONTEXT_WEBGL_COMPATIBILITY_ANGLE 0x3AAC
+#endif /* EGL_ANGLE_create_context_webgl_compatibility */
+
using ui::GetLastEGLErrorString;
namespace gl {
@@ -35,8 +45,8 @@ GLContextEGL::GLContextEGL(GLShareGroup* share_group)
swap_interval_(1) {
}
-bool GLContextEGL::Initialize(
- GLSurface* compatible_surface, GpuPreference gpu_preference) {
+bool GLContextEGL::Initialize(GLSurface* compatible_surface,
+ const GLContextAttribs& attribs) {
DCHECK(compatible_surface);
DCHECK(!context_);
@@ -58,26 +68,19 @@ bool GLContextEGL::Initialize(
context_client_version = 3;
}
- const EGLint kContextAttributes[] = {
- EGL_CONTEXT_CLIENT_VERSION, context_client_version,
- EGL_NONE
- };
- const EGLint kContextRobustnessAttributes[] = {
- EGL_CONTEXT_CLIENT_VERSION, context_client_version,
- EGL_CONTEXT_OPENGL_RESET_NOTIFICATION_STRATEGY_EXT,
- EGL_LOSE_CONTEXT_ON_RESET_EXT,
- EGL_NONE
- };
-
- const EGLint* context_attributes = nullptr;
+ std::vector<EGLint> context_attributes;
+ context_attributes.push_back(EGL_CONTEXT_CLIENT_VERSION);
+ context_attributes.push_back(context_client_version);
+
if (GLSurfaceEGL::IsCreateContextRobustnessSupported()) {
DVLOG(1) << "EGL_EXT_create_context_robustness supported.";
- context_attributes = kContextRobustnessAttributes;
} else {
// At some point we should require the presence of the robustness
// extension and remove this code path.
DVLOG(1) << "EGL_EXT_create_context_robustness NOT supported.";
- context_attributes = kContextAttributes;
+ context_attributes.push_back(
+ EGL_CONTEXT_OPENGL_RESET_NOTIFICATION_STRATEGY_EXT);
+ context_attributes.push_back(EGL_LOSE_CONTEXT_ON_RESET_EXT);
}
if (!eglBindAPI(EGL_OPENGL_ES_API)) {
@@ -86,11 +89,25 @@ bool GLContextEGL::Initialize(
return false;
}
+ if (GLSurfaceEGL::IsCreateContextBindGeneratesResourceSupported()) {
+ context_attributes.push_back(EGL_CONTEXT_BIND_GENERATES_RESOURCE_CHROMIUM);
+ context_attributes.push_back(attribs.bind_generates_resource ? EGL_TRUE
+ : EGL_FALSE);
+ }
+
+ if (GLSurfaceEGL::IsCreateContextWebGLCompatabilitySupported()) {
+ context_attributes.push_back(EGL_CONTEXT_WEBGL_COMPATIBILITY_ANGLE);
+ context_attributes.push_back(
+ attribs.webgl_compatibility_context ? EGL_TRUE : EGL_FALSE);
+ }
+
+ // Append final EGL_NONE to signal the context attributes are finished
+ context_attributes.push_back(EGL_NONE);
+ context_attributes.push_back(EGL_NONE);
+
context_ = eglCreateContext(
- display_,
- config_,
- share_group() ? share_group()->GetHandle() : nullptr,
- context_attributes);
+ display_, config_, share_group() ? share_group()->GetHandle() : nullptr,
+ context_attributes.data());
if (!context_) {
LOG(ERROR) << "eglCreateContext failed with error "
« ui/gl/gl_context_cgl.cc ('K') | « ui/gl/gl_context_egl.h ('k') | ui/gl/gl_context_glx.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698