summaryrefslogtreecommitdiff
path: root/gdk/mir
diff options
context:
space:
mode:
authorMarco Trevisan (Treviño) <mail@3v1n0.net>2015-02-12 03:03:18 +0100
committerMarco Trevisan (Treviño) <mail@3v1n0.net>2015-02-12 03:03:18 +0100
commitf9503ac18991ed7401c86b3d97fb8b93d18e9016 (patch)
treed8cd929f14b49e96d39061ffd56a626fc13109ef /gdk/mir
parent8a52ace8de5eb1820170950079d904d75f2a5db0 (diff)
downloadgtk+-f9503ac18991ed7401c86b3d97fb8b93d18e9016.tar.gz
mir, GL: Split GL context creation in two phases
Move egl_context initialization in gdk_gl_context_realize • gdk_window_create_gl_context() creates a GdkGLContext • gdk_gl_context_realize() creates the underlying resources https://bugzilla.gnome.org/show_bug.cgi?id=741946
Diffstat (limited to 'gdk/mir')
-rw-r--r--gdk/mir/gdkmirglcontext.c49
-rw-r--r--gdk/mir/gdkmirwindowimpl.c27
2 files changed, 49 insertions, 27 deletions
diff --git a/gdk/mir/gdkmirglcontext.c b/gdk/mir/gdkmirglcontext.c
index 8a7494be48..5cacdb5786 100644
--- a/gdk/mir/gdkmirglcontext.c
+++ b/gdk/mir/gdkmirglcontext.c
@@ -26,6 +26,54 @@
G_DEFINE_TYPE (GdkMirGLContext, gdk_mir_gl_context, GDK_TYPE_GL_CONTEXT)
+static gboolean
+gdk_mir_gl_context_realize (GdkGLContext *context,
+ GError **error)
+{
+ GdkMirGLContext *context_mir = GDK_MIR_GL_CONTEXT (context);
+ GdkDisplay *display = gdk_gl_context_get_display (context);
+ GdkGLContext *share = gdk_gl_context_get_shared_context (context);
+ GdkGLProfile profile = gdk_gl_context_get_profile (context);
+ EGLContext ctx;
+ EGLint context_attribs[3];
+ int i;
+
+ if (!_gdk_mir_display_init_egl_display (display))
+ {
+ g_set_error_literal (error, GDK_GL_ERROR,
+ GDK_GL_ERROR_NOT_AVAILABLE,
+ _("No GL implementation is available"));
+ return FALSE;
+ }
+
+ i = 0;
+ if (profile == GDK_GL_PROFILE_3_2_CORE)
+ {
+ context_attribs[i++] = EGL_CONTEXT_OPENGL_PROFILE_MASK_KHR;
+ context_attribs[i++] = EGL_CONTEXT_OPENGL_CORE_PROFILE_BIT_KHR;
+ }
+ context_attribs[i++] = EGL_NONE;
+
+ ctx = eglCreateContext (_gdk_mir_display_get_egl_display (display),
+ context_mir->egl_config,
+ share != NULL ? GDK_MIR_GL_CONTEXT (share)->egl_context
+ : EGL_NO_CONTEXT,
+ context_attribs);
+ if (ctx == NULL)
+ {
+ g_set_error_literal (error, GDK_GL_ERROR,
+ GDK_GL_ERROR_NOT_AVAILABLE,
+ _("Unable to create a GL context"));
+ return FALSE;
+ }
+
+ GDK_NOTE (OPENGL, g_print ("Created EGL context[%p]\n", ctx));
+
+ context_mir->egl_context = ctx;
+
+ return TRUE;
+}
+
static void
gdk_mir_gl_context_end_frame (GdkGLContext *context,
cairo_region_t *painted,
@@ -96,6 +144,7 @@ gdk_mir_gl_context_class_init (GdkMirGLContextClass *klass)
GdkGLContextClass *context_class = GDK_GL_CONTEXT_CLASS (klass);
GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
+ context_class->realize = gdk_mir_gl_context_realize;
context_class->end_frame = gdk_mir_gl_context_end_frame;
gobject_class->dispose = gdk_mir_gl_context_dispose;
}
diff --git a/gdk/mir/gdkmirwindowimpl.c b/gdk/mir/gdkmirwindowimpl.c
index 1d560483b7..cddb55b68b 100644
--- a/gdk/mir/gdkmirwindowimpl.c
+++ b/gdk/mir/gdkmirwindowimpl.c
@@ -1398,10 +1398,7 @@ gdk_mir_window_impl_create_gl_context (GdkWindow *window,
{
GdkDisplay *display = gdk_window_get_display (window);
GdkMirGLContext *context;
- EGLContext ctx;
EGLConfig config;
- int i;
- EGLint context_attribs[3];
if (!_gdk_mir_display_init_egl_display (display))
{
@@ -1426,29 +1423,6 @@ gdk_mir_window_impl_create_gl_context (GdkWindow *window,
if (!find_eglconfig_for_window (window, &config, error))
return NULL;
- i = 0;
- if (profile == GDK_GL_PROFILE_3_2_CORE)
- {
- context_attribs[i++] = EGL_CONTEXT_OPENGL_PROFILE_MASK_KHR;
- context_attribs[i++] = EGL_CONTEXT_OPENGL_CORE_PROFILE_BIT_KHR;
- }
- context_attribs[i++] = EGL_NONE;
-
- ctx = eglCreateContext (_gdk_mir_display_get_egl_display (display),
- config,
- share ? GDK_MIR_GL_CONTEXT (share)->egl_context : EGL_NO_CONTEXT,
- context_attribs);
- if (ctx == NULL)
- {
- g_set_error_literal (error, GDK_GL_ERROR,
- GDK_GL_ERROR_NOT_AVAILABLE,
- _("Unable to create a GL context"));
- return NULL;
- }
-
- GDK_NOTE (OPENGL,
- g_print ("Created EGL context[%p]\n", ctx));
-
context = g_object_new (GDK_TYPE_MIR_GL_CONTEXT,
"display", display,
"window", window,
@@ -1457,7 +1431,6 @@ gdk_mir_window_impl_create_gl_context (GdkWindow *window,
NULL);
context->egl_config = config;
- context->egl_context = ctx;
context->is_attached = attached;
return GDK_GL_CONTEXT (context);