[gtk/image-loading: 47/59] testsuite: Add png and tiff methods




commit 577bf104c0a086e254634c26a1c4fb534dc69f1b
Author: Benjamin Otte <otte redhat com>
Date:   Tue Sep 14 02:37:50 2021 +0200

    testsuite: Add png and tiff methods
    
    We encode the texture to a PNG or TIFF and then decode
    it again, in various ways.

 testsuite/gdk/memorytexture.c | 68 ++++++++++++++++++++++++++++++++++++++++++-
 1 file changed, 67 insertions(+), 1 deletion(-)
---
diff --git a/testsuite/gdk/memorytexture.c b/testsuite/gdk/memorytexture.c
index 021a7ad11b..020d6927e4 100644
--- a/testsuite/gdk/memorytexture.c
+++ b/testsuite/gdk/memorytexture.c
@@ -12,6 +12,10 @@ typedef enum {
   TEXTURE_METHOD_LOCAL,
   TEXTURE_METHOD_GL,
   TEXTURE_METHOD_GL_RELEASED,
+  TEXTURE_METHOD_PNG,
+  TEXTURE_METHOD_PNG_PIXBUF,
+  TEXTURE_METHOD_TIFF,
+  TEXTURE_METHOD_TIFF_PIXBUF,
 
   N_TEXTURE_METHODS
 } TextureMethod;
@@ -448,6 +452,68 @@ create_texture (GdkMemoryFormat  format,
       gdk_gl_texture_release (GDK_GL_TEXTURE (texture));
       break;
 
+    case TEXTURE_METHOD_PNG:
+      {
+        GBytes *bytes = gdk_texture_save_to_png_bytes (texture);
+        g_assert (bytes);
+        g_object_unref (texture);
+        texture = gdk_texture_new_from_bytes (bytes, NULL);
+        g_assert (texture);
+        g_bytes_unref (bytes);
+      }
+      break;
+
+    case TEXTURE_METHOD_PNG_PIXBUF:
+      {
+        GInputStream *stream;
+        GdkPixbuf *pixbuf;
+        GBytes *bytes;
+
+        bytes = gdk_texture_save_to_png_bytes (texture);
+        g_assert (bytes);
+        g_object_unref (texture);
+        stream = g_memory_input_stream_new_from_bytes (bytes);
+        pixbuf = gdk_pixbuf_new_from_stream (stream, NULL, NULL);
+        g_object_unref (stream);
+        g_assert (pixbuf);
+        texture = gdk_texture_new_for_pixbuf (pixbuf);
+        g_assert (texture);
+        g_object_unref (pixbuf);
+        g_bytes_unref (bytes);
+      }
+      break;
+
+    case TEXTURE_METHOD_TIFF:
+      {
+        GBytes *bytes = gdk_texture_save_to_tiff_bytes (texture);
+        g_assert (bytes);
+        g_object_unref (texture);
+        texture = gdk_texture_new_from_bytes (bytes, NULL);
+        g_assert (texture);
+        g_bytes_unref (bytes);
+      }
+      break;
+
+    case TEXTURE_METHOD_TIFF_PIXBUF:
+      {
+        GInputStream *stream;
+        GdkPixbuf *pixbuf;
+        GBytes *bytes;
+
+        bytes = gdk_texture_save_to_png_bytes (texture);
+        g_assert (bytes);
+        g_object_unref (texture);
+        stream = g_memory_input_stream_new_from_bytes (bytes);
+        pixbuf = gdk_pixbuf_new_from_stream (stream, NULL, NULL);
+        g_object_unref (stream);
+        g_assert (pixbuf);
+        texture = gdk_texture_new_for_pixbuf (pixbuf);
+        g_assert (texture);
+        g_object_unref (pixbuf);
+        g_bytes_unref (bytes);
+      }
+      break;
+
     case N_TEXTURE_METHODS:
     default:
       g_assert_not_reached ();
@@ -584,7 +650,7 @@ add_test (const char    *name,
     {
       for (method = 0; method < N_TEXTURE_METHODS; method++)
         {
-          const char *method_names[N_TEXTURE_METHODS] = { "local", "gl", "gl-released" };
+          const char *method_names[N_TEXTURE_METHODS] = { "local", "gl", "gl-released", "png", "png-pixbuf", 
"tiff", "tiff-pixbuf" };
           char *test_name = g_strdup_printf ("%s/%s/%s",
                                              name,
                                              g_enum_get_value (enum_class, format)->value_nick,


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]