[gtk/image-loading] cssimageurl: Just create a texture directly



commit 06132c06f386c3619466da520e94b26c064ac172
Author: Matthias Clasen <mclasen redhat com>
Date:   Tue Sep 14 15:12:39 2021 -0400

    cssimageurl: Just create a texture directly
    
    We don't need to use the pixbufutils api here.

 gtk/gtkcssimageurl.c | 21 ++++++++++-----------
 1 file changed, 10 insertions(+), 11 deletions(-)
---
diff --git a/gtk/gtkcssimageurl.c b/gtk/gtkcssimageurl.c
index d7271eda18..15d56ac21e 100644
--- a/gtk/gtkcssimageurl.c
+++ b/gtk/gtkcssimageurl.c
@@ -26,10 +26,9 @@
 #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
         {


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