[gtk/image-loading: 10/14] Use our tiff loader for content (de)serialization




commit 4b700ea2646f6aa3ba1521310950ee7738f3665a
Author: Matthias Clasen <mclasen redhat com>
Date:   Thu Sep 9 23:05:01 2021 -0400

    Use our tiff loader for content (de)serialization
    
    We still fall back to gdk-pixbuf for handling all
    the other image formats.

 gdk/gdkcontentdeserializer.c | 14 ++++++++++++--
 gdk/gdkcontentserializer.c   | 13 +++++++++++--
 2 files changed, 23 insertions(+), 4 deletions(-)
---
diff --git a/gdk/gdkcontentdeserializer.c b/gdk/gdkcontentdeserializer.c
index a52638a8cb..e32c154ca8 100644
--- a/gdk/gdkcontentdeserializer.c
+++ b/gdk/gdkcontentdeserializer.c
@@ -26,6 +26,7 @@
 #include "gdktexture.h"
 #include "gdkrgbaprivate.h"
 #include "loaders/gdkpngprivate.h"
+#include "loaders/gdktiffprivate.h"
 
 #include <gdk-pixbuf/gdk-pixbuf.h>
 
@@ -721,6 +722,8 @@ deserialize_texture_in_thread (GTask        *task,
 
   if (strcmp (gdk_content_deserializer_get_mime_type (deserializer), "image/png") == 0)
     texture = gdk_load_png (bytes, &error);
+  else if (strcmp (gdk_content_deserializer_get_mime_type (deserializer), "image/tiff") == 0)
+    texture = gdk_load_tiff (bytes, &error);
   else
     g_assert_not_reached ();
 
@@ -959,6 +962,12 @@ init (void)
                                      NULL,
                                      NULL);
 
+  gdk_content_register_deserializer ("image/tiff",
+                                     GDK_TYPE_TEXTURE,
+                                     texture_deserializer,
+                                     NULL,
+                                     NULL);
+
   formats = gdk_pixbuf_get_formats ();
 
   /* Make sure png comes first */
@@ -990,8 +999,9 @@ init (void)
       mimes = gdk_pixbuf_format_get_mime_types (fmt);
       for (m = mimes; *m; m++)
         {
-          /* Turning pngs into textures is handled above */
-          if (!g_str_equal (name, "png"))
+          /* Turning pngs and tiffs into textures is handled above */
+          if (!g_str_equal (name, "png") &&
+              !g_str_equal (name, "tiff"))
             gdk_content_register_deserializer (*m,
                                                GDK_TYPE_TEXTURE,
                                                pixbuf_deserializer,
diff --git a/gdk/gdkcontentserializer.c b/gdk/gdkcontentserializer.c
index 4c73588270..b06c1c2e96 100644
--- a/gdk/gdkcontentserializer.c
+++ b/gdk/gdkcontentserializer.c
@@ -27,6 +27,7 @@
 #include "gdktextureprivate.h"
 #include "gdkrgba.h"
 #include "loaders/gdkpngprivate.h"
+#include "loaders/gdktiffprivate.h"
 #include "gdkmemorytextureprivate.h"
 
 #include <gdk-pixbuf/gdk-pixbuf.h>
@@ -693,6 +694,8 @@ serialize_texture_in_thread (GTask        *task,
 
   if (strcmp (gdk_content_serializer_get_mime_type (serializer), "image/png") == 0)
     bytes = gdk_save_png (texture);
+  else if (strcmp (gdk_content_serializer_get_mime_type (serializer), "image/tiff") == 0)
+    bytes = gdk_save_tiff (texture);
   else
     g_assert_not_reached ();
 
@@ -959,6 +962,11 @@ init (void)
                                    texture_serializer,
                                    NULL, NULL);
 
+  gdk_content_register_serializer (GDK_TYPE_TEXTURE,
+                                   "image/tiff",
+                                   texture_serializer,
+                                   NULL, NULL);
+
   formats = gdk_pixbuf_get_formats ();
 
   /* Make sure png comes first */
@@ -993,8 +1001,9 @@ init (void)
       mimes = gdk_pixbuf_format_get_mime_types (fmt);
       for (m = mimes; *m; m++)
         {
-          /* Turning textures into pngs is handled above */
-          if (!g_str_equal (name, "png"))
+          /* Turning textures into pngs or tiffs is handled above */
+          if (!g_str_equal (name, "png") &&
+              !g_str_equal (name, "tiff"))
             gdk_content_register_serializer (GDK_TYPE_TEXTURE,
                                              *m,
                                              pixbuf_serializer,


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