diff options
author | Emmanuele Bassi <ebassi@gnome.org> | 2015-02-12 12:34:28 +0000 |
---|---|---|
committer | Emmanuele Bassi <ebassi@gnome.org> | 2015-02-12 12:34:28 +0000 |
commit | 022724aa69bbf1c65768b87d0f3e319257284b40 (patch) | |
tree | 70a133c4ed74584e3a875b173a6fa7bdd383ef51 | |
parent | 015bf99816969cff366e201169e6c54fd8b3cf3d (diff) | |
download | gtk+-022724aa69bbf1c65768b87d0f3e319257284b40.tar.gz |
gl: Drop profile for gdk_window_create_gl_context()
Now that we have a two-stages GL context creation sequence, we can move
the profile to a pre-realize option, like the debug and forward
compatibility bits, or the GL version to use.
-rw-r--r-- | gdk/gdkglcontext.c | 34 | ||||
-rw-r--r-- | gdk/gdkglcontext.h | 8 | ||||
-rw-r--r-- | gdk/gdkwindow.c | 6 | ||||
-rw-r--r-- | gdk/gdkwindow.h | 1 | ||||
-rw-r--r-- | gdk/gdkwindowimpl.h | 1 | ||||
-rw-r--r-- | gdk/mir/gdkmirglcontext.c | 4 | ||||
-rw-r--r-- | gdk/mir/gdkmirwindowimpl.c | 8 | ||||
-rw-r--r-- | gdk/wayland/gdkglcontext-wayland.c | 12 | ||||
-rw-r--r-- | gdk/wayland/gdkglcontext-wayland.h | 1 | ||||
-rw-r--r-- | gdk/win32/gdkglcontext-win32.c | 7 | ||||
-rw-r--r-- | gdk/win32/gdkglcontext-win32.h | 1 | ||||
-rw-r--r-- | gdk/x11/gdkglcontext-x11.c | 17 | ||||
-rw-r--r-- | gdk/x11/gdkglcontext-x11.h | 1 | ||||
-rw-r--r-- | gtk/gtkglarea.c | 4 |
14 files changed, 58 insertions, 47 deletions
diff --git a/gdk/gdkglcontext.c b/gdk/gdkglcontext.c index 5001c71b1e..ec6c0a53f9 100644 --- a/gdk/gdkglcontext.c +++ b/gdk/gdkglcontext.c @@ -201,7 +201,7 @@ gdk_gl_context_set_property (GObject *gobject, break; case PROP_PROFILE: - priv->profile = g_value_get_enum (value); + gdk_gl_context_set_profile (GDK_GL_CONTEXT (gobject), g_value_get_enum (value)); break; default: @@ -307,7 +307,6 @@ gdk_gl_context_class_init (GdkGLContextClass *klass) GDK_TYPE_GL_PROFILE, GDK_GL_PROFILE_DEFAULT, G_PARAM_READWRITE | - G_PARAM_CONSTRUCT_ONLY | G_PARAM_STATIC_STRINGS); /** @@ -731,10 +730,39 @@ gdk_gl_context_get_window (GdkGLContext *context) } /** + * gdk_gl_context_set_profile: + * @context: a #GdkGLContext + * @profile: the profile for the context + * + * Sets the profile used when realizing the context. + * + * The #GdkGLContext must not be realized or made current prior to calling + * this function. + * + * Since: 3.16 + */ +void +gdk_gl_context_set_profile (GdkGLContext *context, + GdkGLProfile profile) +{ + GdkGLContextPrivate *priv = gdk_gl_context_get_instance_private (context); + + g_return_if_fail (GDK_IS_GL_CONTEXT (context)); + g_return_if_fail (!priv->realized); + + if (priv->profile != profile) + { + priv->profile = profile; + + g_object_notify_by_pspec (G_OBJECT (context), obj_pspecs[PROP_PROFILE]); + } +} + +/** * gdk_gl_context_get_profile: * @context: a #GdkGLContext * - * Retrieves the #GdkGLProfile that @context was created for. + * Retrieves the #GdkGLProfile set using gdk_gl_context_set_profile(). * * Returns: a #GdkGLProfile * diff --git a/gdk/gdkglcontext.h b/gdk/gdkglcontext.h index dda70682ac..d6d5f39333 100644 --- a/gdk/gdkglcontext.h +++ b/gdk/gdkglcontext.h @@ -47,8 +47,6 @@ GdkDisplay * gdk_gl_context_get_display (GdkGLContext * GDK_AVAILABLE_IN_3_16 GdkWindow * gdk_gl_context_get_window (GdkGLContext *context); GDK_AVAILABLE_IN_3_16 -GdkGLProfile gdk_gl_context_get_profile (GdkGLContext *context); -GDK_AVAILABLE_IN_3_16 GdkGLContext * gdk_gl_context_get_shared_context (GdkGLContext *context); GDK_AVAILABLE_IN_3_16 @@ -69,11 +67,15 @@ void gdk_gl_context_set_forward_compatible (GdkGLContext * gboolean compatible); GDK_AVAILABLE_IN_3_16 gboolean gdk_gl_context_get_forward_compatible (GdkGLContext *context); +GDK_AVAILABLE_IN_3_16 +void gdk_gl_context_set_profile (GdkGLContext *context, + GdkGLProfile profile); +GDK_AVAILABLE_IN_3_16 +GdkGLProfile gdk_gl_context_get_profile (GdkGLContext *context); GDK_AVAILABLE_IN_3_16 gboolean gdk_gl_context_realize (GdkGLContext *context, GError **error); - GDK_AVAILABLE_IN_3_16 void gdk_gl_context_make_current (GdkGLContext *context); GDK_AVAILABLE_IN_3_16 diff --git a/gdk/gdkwindow.c b/gdk/gdkwindow.c index 94a09c78d0..2de1fa31cc 100644 --- a/gdk/gdkwindow.c +++ b/gdk/gdkwindow.c @@ -2742,7 +2742,6 @@ gdk_window_get_paint_gl_context (GdkWindow *window, window->impl_window->gl_paint_context = GDK_WINDOW_IMPL_GET_CLASS (window->impl)->create_gl_context (window->impl_window, TRUE, - GDK_GL_PROFILE_DEFAULT, NULL, &internal_error); } @@ -2768,7 +2767,6 @@ gdk_window_get_paint_gl_context (GdkWindow *window, /** * gdk_window_create_gl_context: * @window: a #GdkWindow - * @profile: the GL profile the context should target * @error: return location for an error * * Creates a new #GdkGLContext matching the @@ -2778,7 +2776,7 @@ gdk_window_get_paint_gl_context (GdkWindow *window, * If the creation of the #GdkGLContext failed, @error will be set. * * Before using the returned #GdkGLContext, you will need to - * call gdk_gl_context_make_current(). + * call gdk_gl_context_make_current() or gdk_gl_context_realize(). * * Returns: (transfer full): the newly created #GdkGLContext, or * %NULL on error @@ -2787,7 +2785,6 @@ gdk_window_get_paint_gl_context (GdkWindow *window, **/ GdkGLContext * gdk_window_create_gl_context (GdkWindow *window, - GdkGLProfile profile, GError **error) { GdkGLContext *paint_context; @@ -2801,7 +2798,6 @@ gdk_window_create_gl_context (GdkWindow *window, return GDK_WINDOW_IMPL_GET_CLASS (window->impl)->create_gl_context (window->impl_window, FALSE, - profile, paint_context, error); } diff --git a/gdk/gdkwindow.h b/gdk/gdkwindow.h index 85a8567dc6..ad5e88cc14 100644 --- a/gdk/gdkwindow.h +++ b/gdk/gdkwindow.h @@ -1113,7 +1113,6 @@ gboolean gdk_window_show_window_menu (GdkWindow *window, GDK_AVAILABLE_IN_3_16 GdkGLContext * gdk_window_create_gl_context (GdkWindow *window, - GdkGLProfile profile, GError **error); G_END_DECLS diff --git a/gdk/gdkwindowimpl.h b/gdk/gdkwindowimpl.h index 1ac327ff9a..73a819a8f2 100644 --- a/gdk/gdkwindowimpl.h +++ b/gdk/gdkwindowimpl.h @@ -293,7 +293,6 @@ struct _GdkWindowImplClass GdkEvent *event); GdkGLContext *(*create_gl_context) (GdkWindow *window, gboolean attached, - GdkGLProfile profile, GdkGLContext *share, GError **error); gboolean (* realize_gl_context) (GdkWindow *window, diff --git a/gdk/mir/gdkmirglcontext.c b/gdk/mir/gdkmirglcontext.c index b5b23c6487..e792577836 100644 --- a/gdk/mir/gdkmirglcontext.c +++ b/gdk/mir/gdkmirglcontext.c @@ -50,6 +50,10 @@ gdk_mir_gl_context_realize (GdkGLContext *context, return FALSE; } + /* "default profile" means 3.2 core profile */ + if (profile == GDK_GL_PROFILE_DEFAULT) + profile = GDK_GL_PROFILE_3_2_CORE; + if (profile != GDK_GL_PROFILE_3_2_CORE) { g_set_error_literal (error, GDK_GL_ERROR, diff --git a/gdk/mir/gdkmirwindowimpl.c b/gdk/mir/gdkmirwindowimpl.c index 2132219975..666a1d06cf 100644 --- a/gdk/mir/gdkmirwindowimpl.c +++ b/gdk/mir/gdkmirwindowimpl.c @@ -1392,7 +1392,6 @@ find_eglconfig_for_window (GdkWindow *window, static GdkGLContext * gdk_mir_window_impl_create_gl_context (GdkWindow *window, gboolean attached, - GdkGLProfile profile, GdkGLContext *share, GError **error) { @@ -1408,11 +1407,7 @@ gdk_mir_window_impl_create_gl_context (GdkWindow *window, return NULL; } - if (profile == GDK_GL_PROFILE_DEFAULT) - profile = GDK_GL_PROFILE_3_2_CORE; - - if (profile == GDK_GL_PROFILE_3_2_CORE && - !_gdk_mir_display_have_egl_khr_create_context (display)) + if (!_gdk_mir_display_have_egl_khr_create_context (display)) { g_set_error_literal (error, GDK_GL_ERROR, GDK_GL_ERROR_UNSUPPORTED_PROFILE, @@ -1426,7 +1421,6 @@ gdk_mir_window_impl_create_gl_context (GdkWindow *window, context = g_object_new (GDK_TYPE_MIR_GL_CONTEXT, "display", display, "window", window, - "profile", profile, "shared-context", share, NULL); diff --git a/gdk/wayland/gdkglcontext-wayland.c b/gdk/wayland/gdkglcontext-wayland.c index 5f3ddfb654..45bca0ed04 100644 --- a/gdk/wayland/gdkglcontext-wayland.c +++ b/gdk/wayland/gdkglcontext-wayland.c @@ -117,6 +117,10 @@ gdk_wayland_gl_context_realize (GdkGLContext *context, gboolean debug_bit, forward_bit; int i = 0; + /* default profile means 3.2 core profile */ + if (profile == GDK_GL_PROFILE_DEFAULT) + profile = GDK_GL_PROFILE_3_2_CORE; + if (profile != GDK_GL_PROFILE_3_2_CORE) { g_set_error_literal (error, GDK_GL_ERROR, @@ -362,7 +366,6 @@ find_eglconfig_for_window (GdkWindow *window, GdkGLContext * gdk_wayland_window_create_gl_context (GdkWindow *window, gboolean attached, - GdkGLProfile profile, GdkGLContext *share, GError **error) { @@ -379,11 +382,7 @@ gdk_wayland_window_create_gl_context (GdkWindow *window, return NULL; } - if (profile == GDK_GL_PROFILE_DEFAULT) - profile = GDK_GL_PROFILE_3_2_CORE; - - if (profile == GDK_GL_PROFILE_3_2_CORE && - !display_wayland->have_egl_khr_create_context) + if (!display_wayland->have_egl_khr_create_context) { g_set_error_literal (error, GDK_GL_ERROR, GDK_GL_ERROR_UNSUPPORTED_PROFILE, @@ -397,7 +396,6 @@ gdk_wayland_window_create_gl_context (GdkWindow *window, context = g_object_new (GDK_TYPE_WAYLAND_GL_CONTEXT, "display", display, "window", window, - "profile", profile, "shared-context", share, NULL); diff --git a/gdk/wayland/gdkglcontext-wayland.h b/gdk/wayland/gdkglcontext-wayland.h index a140f5ca15..bd2bb88457 100644 --- a/gdk/wayland/gdkglcontext-wayland.h +++ b/gdk/wayland/gdkglcontext-wayland.h @@ -50,7 +50,6 @@ struct _GdkWaylandGLContextClass gboolean gdk_wayland_display_init_gl (GdkDisplay *display); GdkGLContext * gdk_wayland_window_create_gl_context (GdkWindow *window, gboolean attach, - GdkGLProfile profile, GdkGLContext *share, GError **error); void gdk_wayland_window_invalidate_for_new_frame (GdkWindow *window, diff --git a/gdk/win32/gdkglcontext-win32.c b/gdk/win32/gdkglcontext-win32.c index 4e36c99afb..55932b865c 100644 --- a/gdk/win32/gdkglcontext-win32.c +++ b/gdk/win32/gdkglcontext-win32.c @@ -461,7 +461,6 @@ _gdk_win32_gl_context_realize (GdkGLContext *context, { GdkGLContext *share = gdk_gl_context_get_shared_context (context); GdkGLProfile profile = gdk_gl_context_get_profile (context); - GdkWin32GLContext *context_win32 = GDK_WIN32_GL_CONTEXT (context); /* These are the real WGL context items that we will want to use later */ @@ -543,7 +542,6 @@ _gdk_win32_gl_context_realize (GdkGLContext *context, GdkGLContext * _gdk_win32_window_create_gl_context (GdkWindow *window, gboolean attached, - GdkGLProfile profile, GdkGLContext *share, GError **error) { @@ -572,9 +570,7 @@ _gdk_win32_window_create_gl_context (GdkWindow *window, } /* We first check whether we have WGL_ARB_create_context... */ - - if (profile == GDK_GL_PROFILE_3_2_CORE && - !display_win32->hasWglARBCreateContext) + if (!display_win32->hasWglARBCreateContext) { g_set_error_literal (error, GDK_GL_ERROR, GDK_GL_ERROR_UNSUPPORTED_PROFILE, @@ -593,7 +589,6 @@ _gdk_win32_window_create_gl_context (GdkWindow *window, context = g_object_new (GDK_TYPE_WIN32_GL_CONTEXT, "display", display, "window", window, - "profile", profile, "shared-context", share, NULL); diff --git a/gdk/win32/gdkglcontext-win32.h b/gdk/win32/gdkglcontext-win32.h index b057411e20..b42cb9e220 100644 --- a/gdk/win32/gdkglcontext-win32.h +++ b/gdk/win32/gdkglcontext-win32.h @@ -56,7 +56,6 @@ struct _GdkWin32GLContextClass GdkGLContext * _gdk_win32_window_create_gl_context (GdkWindow *window, gboolean attached, - GdkGLProfile profile, GdkGLContext *share, GError **error); diff --git a/gdk/x11/gdkglcontext-x11.c b/gdk/x11/gdkglcontext-x11.c index 2251d154aa..654fdafc6c 100644 --- a/gdk/x11/gdkglcontext-x11.c +++ b/gdk/x11/gdkglcontext-x11.c @@ -592,8 +592,13 @@ gdk_x11_gl_context_realize (GdkGLContext *context, profile = gdk_gl_context_get_profile (context); share = gdk_gl_context_get_shared_context (context); + /* default means 3.2 core profile */ + if (profile == GDK_GL_PROFILE_DEFAULT) + profile = GDK_GL_PROFILE_3_2_CORE; + /* we check for the presence of the GLX_ARB_create_context_profile - * extension before checking for a GLXFBConfig. + * extension before checking for a GLXFBConfig when creating the + * GdkX11GLContext instance in gdk_x11_window_create_gl_context(). */ if (profile == GDK_GL_PROFILE_3_2_CORE) { @@ -1163,7 +1168,6 @@ _gdk_x11_screen_update_visuals_for_gl (GdkScreen *screen) GdkGLContext * gdk_x11_window_create_gl_context (GdkWindow *window, gboolean attached, - GdkGLProfile profile, GdkGLContext *share, GError **error) { @@ -1174,10 +1178,6 @@ gdk_x11_window_create_gl_context (GdkWindow *window, display = gdk_window_get_display (window); - /* GDK_GL_PROFILE_DEFAULT is currently equivalent to the 3_2_CORE profile */ - if (profile == GDK_GL_PROFILE_DEFAULT) - profile = GDK_GL_PROFILE_3_2_CORE; - if (!gdk_x11_screen_init_gl (gdk_window_get_screen (window))) { g_set_error_literal (error, GDK_GL_ERROR, @@ -1186,8 +1186,7 @@ gdk_x11_window_create_gl_context (GdkWindow *window, return NULL; } - if (profile == GDK_GL_PROFILE_3_2_CORE && - !GDK_X11_DISPLAY (display)->has_glx_create_context) + if (!GDK_X11_DISPLAY (display)->has_glx_create_context) { g_set_error_literal (error, GDK_GL_ERROR, GDK_GL_ERROR_UNSUPPORTED_PROFILE, @@ -1204,11 +1203,9 @@ gdk_x11_window_create_gl_context (GdkWindow *window, context = g_object_new (GDK_TYPE_X11_GL_CONTEXT, "display", display, "window", window, - "profile", profile, "shared-context", share, NULL); - context->profile = profile; context->glx_config = config; context->is_attached = attached; diff --git a/gdk/x11/gdkglcontext-x11.h b/gdk/x11/gdkglcontext-x11.h index 957125044d..7e90801572 100644 --- a/gdk/x11/gdkglcontext-x11.h +++ b/gdk/x11/gdkglcontext-x11.h @@ -60,7 +60,6 @@ struct _GdkX11GLContextClass gboolean gdk_x11_screen_init_gl (GdkScreen *screen); GdkGLContext * gdk_x11_window_create_gl_context (GdkWindow *window, gboolean attached, - GdkGLProfile profile, GdkGLContext *share, GError **error); void gdk_x11_window_invalidate_for_new_frame (GdkWindow *window, diff --git a/gtk/gtkglarea.c b/gtk/gtkglarea.c index e6f4236e6b..7de3182fd5 100644 --- a/gtk/gtkglarea.c +++ b/gtk/gtkglarea.c @@ -322,7 +322,7 @@ gtk_gl_area_real_create_context (GtkGLArea *area) GError *error = NULL; GdkGLContext *context; - context = gdk_window_create_gl_context (gtk_widget_get_window (widget), priv->profile, &error); + context = gdk_window_create_gl_context (gtk_widget_get_window (widget), &error); if (priv->error != NULL) { gtk_gl_area_set_error (area, error); @@ -330,6 +330,8 @@ gtk_gl_area_real_create_context (GtkGLArea *area) return NULL; } + gdk_gl_context_set_profile (context, priv->profile); + gdk_gl_context_realize (context, &error); if (priv->error != NULL) { |