cssimageurl: Just create a texture directly
We don't need to use the pixbufutils api here.
This commit is contained in:
committed by
Benjamin Otte
parent
dcd873a6d8
commit
729ad8e64a
@@ -26,10 +26,9 @@
|
|||||||
#include "gtkcssimageinvalidprivate.h"
|
#include "gtkcssimageinvalidprivate.h"
|
||||||
#include "gtkcssimagepaintableprivate.h"
|
#include "gtkcssimagepaintableprivate.h"
|
||||||
#include "gtkstyleproviderprivate.h"
|
#include "gtkstyleproviderprivate.h"
|
||||||
#include "gdkpixbufutilsprivate.h"
|
|
||||||
|
|
||||||
#include "gtk/css/gtkcssdataurlprivate.h"
|
#include "gtk/css/gtkcssdataurlprivate.h"
|
||||||
|
|
||||||
|
|
||||||
G_DEFINE_TYPE (GtkCssImageUrl, _gtk_css_image_url, GTK_TYPE_CSS_IMAGE)
|
G_DEFINE_TYPE (GtkCssImageUrl, _gtk_css_image_url, GTK_TYPE_CSS_IMAGE)
|
||||||
|
|
||||||
static GtkCssImage *
|
static GtkCssImage *
|
||||||
@@ -181,28 +180,28 @@ gtk_css_image_url_parse (GtkCssImage *image,
|
|||||||
if (scheme && g_ascii_strcasecmp (scheme, "data") == 0)
|
if (scheme && g_ascii_strcasecmp (scheme, "data") == 0)
|
||||||
{
|
{
|
||||||
GBytes *bytes;
|
GBytes *bytes;
|
||||||
GdkPaintable *paintable;
|
|
||||||
GError *error = NULL;
|
GError *error = NULL;
|
||||||
|
|
||||||
bytes = gtk_css_data_url_parse (url, NULL, &error);
|
bytes = gtk_css_data_url_parse (url, NULL, &error);
|
||||||
if (bytes)
|
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);
|
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_emit_error (parser,
|
||||||
gtk_css_parser_get_start_location (parser),
|
gtk_css_parser_get_start_location (parser),
|
||||||
gtk_css_parser_get_end_location (parser),
|
gtk_css_parser_get_end_location (parser),
|
||||||
error);
|
error);
|
||||||
g_clear_error (&error);
|
g_clear_error (&error);
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
|
||||||
self->loaded_image = gtk_css_image_paintable_new (paintable, paintable);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user