From 29867e7ae1f24c4e7d1f63e70b78a0de458f83d4 Mon Sep 17 00:00:00 2001 From: Matthias Clasen Date: Tue, 30 May 2023 20:21:13 -0400 Subject: [PATCH 1/6] NEWS: Updates --- NEWS | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/NEWS b/NEWS index 0f54f8a23b..64431d0258 100644 --- a/NEWS +++ b/NEWS @@ -8,6 +8,9 @@ Overview of Changes in 4.11.3, xx-xx-xxxx * GtkListView: - Don't leak the factories +* GtkColumnView: + - Support displaying sections + * GtkNotebook: - Make the pages model implement GtkSelectionModel @@ -20,6 +23,10 @@ Overview of Changes in 4.11.3, xx-xx-xxxx * Css: - Add new binding-friendly css provider apis +* GDK: + - Support grayscale texture and alpha texture formats + for loading and saving to png and tiff, and in GL + * Theme: - Show focus in the shortcuts window @@ -49,6 +56,7 @@ Overview of Changes in 4.11.3, xx-xx-xxxx Basque Catalan Russian + Turkish Overview of Changes in 4.11.2, 09-05-2023 From f29c7e76f5fc2a66fafb3e77597132a2b9a66e9b Mon Sep 17 00:00:00 2001 From: Matthias Clasen Date: Tue, 30 May 2023 22:35:45 -0400 Subject: [PATCH 2/6] gltexture: Use proper alignment for downloads --- gdk/gdkgltexture.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/gdk/gdkgltexture.c b/gdk/gdkgltexture.c index 6e72af5403..d9d62190d9 100644 --- a/gdk/gdkgltexture.c +++ b/gdk/gdkgltexture.c @@ -204,6 +204,7 @@ gdk_gl_texture_do_download (GdkGLTexture *self, gsize stride = texture->width * gdk_memory_format_bytes_per_pixel (format); guchar *pixels = g_malloc_n (stride, texture->height); + glPixelStorei (GL_PACK_ALIGNMENT, 1); glGetTexImage (GL_TEXTURE_2D, 0, gl_format, @@ -271,6 +272,7 @@ gdk_gl_texture_do_download (GdkGLTexture *self, gsize stride = actual_bpp * texture->width; guchar *pixels = g_malloc_n (stride, texture->height); + glPixelStorei (GL_PACK_ALIGNMENT, 1); glReadPixels (0, 0, texture->width, texture->height, gl_read_format, From a79da8b655e2ef3eb15f30a7adad332ff8489acd Mon Sep 17 00:00:00 2001 From: Matthias Clasen Date: Tue, 30 May 2023 22:36:10 -0400 Subject: [PATCH 3/6] Improve test coverage for GdkGLTexture --- testsuite/gdk/gltexture.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/testsuite/gdk/gltexture.c b/testsuite/gdk/gltexture.c index cb00e842ff..e593f4eeb5 100644 --- a/testsuite/gdk/gltexture.c +++ b/testsuite/gdk/gltexture.c @@ -2,6 +2,7 @@ #include #include "gdk/gdktextureprivate.h" #include "gdk/gdkglcontextprivate.h" +#include "gdk/gdkgltextureprivate.h" static cairo_surface_t * make_surface (void) @@ -202,6 +203,11 @@ G_GNUC_END_IGNORE_DEPRECATIONS texture = gdk_gl_texture_builder_build (builder, NULL, NULL); + g_assert_true (gdk_gl_texture_get_context (GDK_GL_TEXTURE (texture)) == context); + g_assert_true (gdk_gl_texture_get_id (GDK_GL_TEXTURE (texture)) == id); + g_assert_false (gdk_gl_texture_has_mipmap (GDK_GL_TEXTURE (texture))); + g_assert_true (gdk_gl_texture_get_sync (GDK_GL_TEXTURE (texture)) == sync); + data = g_malloc0 (64 * 64 * 4); gdk_texture_download (texture, data, 64 * 4); From 8d2047c824dce43b3f658cd01bf835c4b34a4b32 Mon Sep 17 00:00:00 2001 From: Matthias Clasen Date: Tue, 30 May 2023 22:36:41 -0400 Subject: [PATCH 4/6] testsuite: Use proper alignment when uploading to GL --- testsuite/gdk/memorytexture.c | 1 + 1 file changed, 1 insertion(+) diff --git a/testsuite/gdk/memorytexture.c b/testsuite/gdk/memorytexture.c index c98668d3c1..a675fff59d 100644 --- a/testsuite/gdk/memorytexture.c +++ b/testsuite/gdk/memorytexture.c @@ -890,6 +890,7 @@ upload_to_gl_native (GdkTexture *texture) glGenTextures (1, &id); glActiveTexture (GL_TEXTURE0); glBindTexture (GL_TEXTURE_2D, id); + glPixelStorei (GL_UNPACK_ALIGNMENT, 1); glTexImage2D (GL_TEXTURE_2D, 0, formats[i].gl_internalformat, width, height, 0, formats[i].gl_format, formats[i].gl_type, data); glTexParameteriv (GL_TEXTURE_2D, GL_TEXTURE_SWIZZLE_RGBA, formats[i].swizzle); From cc665f29eae796469a3d0e9287cf451d3e9540fb Mon Sep 17 00:00:00 2001 From: Matthias Clasen Date: Tue, 30 May 2023 22:37:03 -0400 Subject: [PATCH 5/6] testsuite: Plug a memory leak --- testsuite/gdk/memorytexture.c | 1 + 1 file changed, 1 insertion(+) diff --git a/testsuite/gdk/memorytexture.c b/testsuite/gdk/memorytexture.c index a675fff59d..6d55ffb252 100644 --- a/testsuite/gdk/memorytexture.c +++ b/testsuite/gdk/memorytexture.c @@ -1064,6 +1064,7 @@ ensure_texture_format (GdkTexture *texture, format, bytes, stride); + g_bytes_unref (bytes); g_object_unref (texture); return result; From 96f6787a3ef852b62ca888f88142e7e79336ce8e Mon Sep 17 00:00:00 2001 From: Matthias Clasen Date: Tue, 30 May 2023 22:37:18 -0400 Subject: [PATCH 6/6] testsuite: Add more download tests Add some odd-sized texture sizes to the download tests, to trigger alignment issues in the various upload code paths. And add a size that is bigger than the max-texture-size we force in one of our test setups. To compensate, reduce the number of runs per size from 20 to 10. --- testsuite/gdk/memorytexture.c | 95 +++++++++++------------------------ 1 file changed, 30 insertions(+), 65 deletions(-) diff --git a/testsuite/gdk/memorytexture.c b/testsuite/gdk/memorytexture.c index 6d55ffb252..62329f61e7 100644 --- a/testsuite/gdk/memorytexture.c +++ b/testsuite/gdk/memorytexture.c @@ -4,7 +4,7 @@ #include -#define N 20 +#define N 10 static GdkGLContext *gl_context = NULL; static GskRenderer *gl_renderer = NULL; @@ -1142,7 +1142,9 @@ should_skip_download_test (GdkMemoryFormat format, } static void -test_download_1x1 (gconstpointer data) +test_download (gconstpointer data, + unsigned int width, + unsigned int height) { GdkMemoryFormat format; TextureMethod method; @@ -1168,8 +1170,8 @@ test_download_1x1 (gconstpointer data) (method == TEXTURE_METHOD_GL || method == TEXTURE_METHOD_GL_RELEASED || method == TEXTURE_METHOD_GL_NATIVE)) color = (GdkRGBA) { 0, 0, 0, 0 }; - expected = create_texture (format, TEXTURE_METHOD_LOCAL, 1, 1, &color); - test = create_texture (format, method, 1, 1, &color); + expected = create_texture (format, TEXTURE_METHOD_LOCAL, width, height, &color); + test = create_texture (format, method, width, height, &color); test = ensure_texture_format (test, format); compare_textures (expected, test, texture_method_is_accurate (method)); @@ -1179,76 +1181,37 @@ test_download_1x1 (gconstpointer data) } } +static void +test_download_1x1 (gconstpointer data) +{ + test_download (data, 1, 1); +} + static void test_download_4x4 (gconstpointer data) { - GdkMemoryFormat format; - TextureMethod method; - GdkTexture *expected, *test; - gsize i; - - if (!decode (data, &format, &method)) - return; - - if (should_skip_download_test (format, method)) - return; - - for (i = 0; i < N; i++) - { - GdkRGBA color; - - create_random_color (&color); - - /* these methods may premultiply during operation */ - if (color.alpha == 0.f && - !gdk_memory_format_is_premultiplied (format) && - gdk_memory_format_has_alpha (format) && - (method == TEXTURE_METHOD_GL || method == TEXTURE_METHOD_GL_RELEASED || method == TEXTURE_METHOD_GL_NATIVE)) - color = (GdkRGBA) { 0, 0, 0, 0 }; - - expected = create_texture (format, TEXTURE_METHOD_LOCAL, 4, 4, &color); - test = create_texture (format, method, 4, 4, &color); - test = ensure_texture_format (test, format); - - compare_textures (expected, test, texture_method_is_accurate (method)); - - g_object_unref (expected); - g_object_unref (test); - } + test_download (data, 4, 4); } -/* larger than what NGL puts into the icon cache */ +/* odd sizes, to trigger alignment issues */ +static void +test_download_17x7 (gconstpointer data) +{ + test_download (data, 17, 7); +} + +/* larger than what GSK puts into the icon cache */ static void test_download_192x192 (gconstpointer data) { - GdkMemoryFormat format; - TextureMethod method; - GdkTexture *expected, *test; - GdkRGBA color; + test_download (data, 192, 192); +} - if (!decode (data, &format, &method)) - return; - - if (should_skip_download_test (format, method)) - return; - - create_random_color (&color); - - /* these methods may premultiply during operation */ - if (color.alpha == 0.f && - !gdk_memory_format_is_premultiplied (format) && - gdk_memory_format_has_alpha (format) && - (method == TEXTURE_METHOD_GL || method == TEXTURE_METHOD_GL_RELEASED || method == TEXTURE_METHOD_GL_NATIVE)) - color = (GdkRGBA) { 0, 0, 0, 0 }; - - expected = create_texture (format, TEXTURE_METHOD_LOCAL, 192, 192, &color); - test = create_texture (format, method, 192, 192, &color); - test = ensure_texture_format (test, format); - - compare_textures (expected, test, texture_method_is_accurate (method)); - - g_object_unref (expected); - g_object_unref (test); +/* larger than the small max-texture-size we test against */ +static void +test_download_1065x17 (gconstpointer data) +{ + test_download (data, 1065, 17); } static void @@ -1384,7 +1347,9 @@ main (int argc, char *argv[]) add_test ("/memorytexture/download_1x1", test_download_1x1); add_test ("/memorytexture/download_4x4", test_download_4x4); + add_test ("/memorytexture/download_17x7", test_download_17x7); add_test ("/memorytexture/download_192x192", test_download_192x192); + add_test ("/memorytexture/download_1065x17", test_download_1065x17); add_conversion_test ("/memorytexture/conversion_1x1", test_conversion_1x1); add_conversion_test ("/memorytexture/conversion_4x4", test_conversion_4x4);