cssimageurl: Just create a texture directly
authorMatthias Clasen <mclasen@redhat.com>
Tue, 14 Sep 2021 19:12:39 +0000 (15:12 -0400)
committerBenjamin Otte <otte@redhat.com>
Fri, 17 Sep 2021 00:02:51 +0000 (02:02 +0200)
We don't need to use the pixbufutils api here.

gtk/gtkcssimageurl.c

index d7271eda188c6d71282413ebb9010e37a94ff63c..15d56ac21e91c96d9fcb5f9efd5008a7c0b6e150 100644 (file)
 #include "gtkcssimageinvalidprivate.h"
 #include "gtkcssimagepaintableprivate.h"
 #include "gtkstyleproviderprivate.h"
-#include "gdkpixbufutilsprivate.h"
-
 #include "gtk/css/gtkcssdataurlprivate.h"
 
+
 G_DEFINE_TYPE (GtkCssImageUrl, _gtk_css_image_url, GTK_TYPE_CSS_IMAGE)
 
 static GtkCssImage *
@@ -181,28 +180,28 @@ gtk_css_image_url_parse (GtkCssImage  *image,
   if (scheme && g_ascii_strcasecmp (scheme, "data") == 0)
     {
       GBytes *bytes;
-      GdkPaintable *paintable;
       GError *error = NULL;
 
       bytes = gtk_css_data_url_parse (url, NULL, &error);
       if (bytes)
         {
-          paintable = gdk_paintable_new_from_bytes_scaled (bytes, 1);
+          GdkTexture *texture;
+
+          texture = gdk_texture_new_from_bytes (bytes, &error);
           g_bytes_unref (bytes);
-          if (paintable == NULL)
+          if (texture)
+            {
+              GdkPaintable *paintable = GDK_PAINTABLE (texture);
+              self->loaded_image = gtk_css_image_paintable_new (paintable, paintable);
+            }
+          else
             {
-              error = g_error_new (G_IO_ERROR, G_IO_ERROR_FAILED,
-                                   "Failed to load image from '%s'", url);
               gtk_css_parser_emit_error (parser,
                                          gtk_css_parser_get_start_location (parser),
                                          gtk_css_parser_get_end_location (parser),
                                          error);
               g_clear_error (&error);
             }
-          else
-            {
-              self->loaded_image = gtk_css_image_paintable_new (paintable, paintable);
-            }
         }
       else
         {