Merge branch 'wip/otte/for-main' into 'main'

glcontext: Remove leftover function call

Closes #4697

See merge request GNOME/gtk!4483
This commit is contained in:
Benjamin Otte 2022-02-16 03:07:05 +00:00
commit 49b0ee21c1
5 changed files with 91 additions and 5 deletions

View File

@ -2053,6 +2053,7 @@ activate (GApplication *app)
{ "win.open", { "<Control>o", NULL } },
{ "win.record", { "<Control>r", NULL } },
{ "win.lock", { "<Control>l", NULL } },
{ "win.fullscreen", { "F11", NULL } },
};
struct {
const char *action_and_target;

View File

@ -279,11 +279,7 @@ gdk_gl_context_real_realize (GdkGLContext *context,
G_GNUC_UNUSED gint64 start_time = GDK_PROFILER_CURRENT_TIME;
if (share != NULL)
{
gdk_gl_context_get_required_version (share, &major, &minor);
gdk_gl_context_set_allowed_apis (context,
gdk_gl_context_get_allowed_apis (share));
}
else
gdk_gl_context_get_required_version (context, &major, &minor);

View File

@ -83,6 +83,8 @@
*
* A macro that evaluates to the 4.2 version of GDK, in a format
* that can be used by the C pre-processor.
*
* Since: 4.2
*/
#define GDK_VERSION_4_2 (G_ENCODE_VERSION (4, 2))
@ -91,6 +93,8 @@
*
* A macro that evaluates to the 4.4 version of GDK, in a format
* that can be used by the C pre-processor.
*
* Since: 4.4
*/
#define GDK_VERSION_4_4 (G_ENCODE_VERSION (4, 4))
@ -99,6 +103,8 @@
*
* A macro that evaluates to the 4.6 version of GDK, in a format
* that can be used by the C pre-processor.
*
* Since: 4.6
*/
#define GDK_VERSION_4_6 (G_ENCODE_VERSION (4, 6))

82
testsuite/gdk/glcontext.c Normal file
View File

@ -0,0 +1,82 @@
#include <gtk/gtk.h>
#define ALL_APIS (GDK_GL_API_GL | GDK_GL_API_GLES)
static GdkGLAPI
is_unique (GdkGLAPI api)
{
return (api & (api - 1)) == 0;
}
static void
test_allowed_backends (gconstpointer data)
{
GdkGLAPI allowed = GPOINTER_TO_SIZE (data);
GdkGLAPI not_allowed = (~allowed) & ALL_APIS;
GdkGLAPI api, random_apis;
GdkDisplay *display = gdk_display_get_default ();
GdkGLContext *context;
GError *error = NULL;
display = gdk_display_get_default ();
if (!gdk_display_prepare_gl (display, &error))
{
g_test_message ("no GL support: %s", error->message);
g_test_skip ("no GL support");
g_clear_error (&error);
return;
}
context = gdk_display_create_gl_context (display, &error);
g_assert (context);
g_assert_no_error (error);
g_assert_cmpint (gdk_gl_context_get_api (context), ==, 0);
g_assert_cmpint (gdk_gl_context_get_allowed_apis (context), ==, ALL_APIS);
gdk_gl_context_set_allowed_apis (context, allowed);
g_assert_cmpint (gdk_gl_context_get_allowed_apis (context), ==, allowed);
g_assert_cmpint (gdk_gl_context_get_api (context), ==, 0);
if (!gdk_gl_context_realize (context, &error))
{
g_assert_cmpint (gdk_gl_context_get_api (context), ==, 0);
if (not_allowed && g_error_matches (error, GDK_GL_ERROR, GDK_GL_ERROR_NOT_AVAILABLE))
{
g_clear_error (&error);
g_object_unref (context);
return;
}
g_assert_no_error (error);
}
g_assert_no_error (error);
g_assert_cmpint (gdk_gl_context_get_allowed_apis (context), ==, allowed);
api = gdk_gl_context_get_api (context);
g_assert_cmpint (api, !=, 0);
g_assert_true (is_unique (api));
g_assert_cmpint (api & allowed, ==, api);
g_assert_cmpint (api & not_allowed, ==, 0);
random_apis = g_random_int_range (0, ALL_APIS + 1);
gdk_gl_context_set_allowed_apis (context, random_apis);
g_assert_cmpint (gdk_gl_context_get_allowed_apis (context), ==, random_apis);
g_assert_cmpint (gdk_gl_context_get_api (context), ==, api);
g_object_unref (context);
}
int
main (int argc, char *argv[])
{
gtk_test_init (&argc, &argv, NULL);
g_test_add_data_func ("/allowed-apis/none", GSIZE_TO_POINTER (0), test_allowed_backends);
g_test_add_data_func ("/allowed-apis/gl", GSIZE_TO_POINTER (GDK_GL_API_GL), test_allowed_backends);
g_test_add_data_func ("/allowed-apis/gles", GSIZE_TO_POINTER (GDK_GL_API_GLES), test_allowed_backends);
g_test_add_data_func ("/allowed-apis/all", GSIZE_TO_POINTER (GDK_GL_API_GL | GDK_GL_API_GLES), test_allowed_backends);
return g_test_run ();
}

View File

@ -19,6 +19,7 @@ tests = [
{ 'name': 'display' },
{ 'name': 'displaymanager' },
{ 'name': 'encoding' },
{ 'name': 'glcontext' },
{ 'name': 'keysyms' },
{ 'name': 'memorytexture' },
{ 'name': 'pixbuf' },