[gtk+/wip/otte/rendernode: 33/34] cssimage: Port a few more simple ones to snapshots
- From: Benjamin Otte <otte src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+/wip/otte/rendernode: 33/34] cssimage: Port a few more simple ones to snapshots
- Date: Wed, 14 Dec 2016 04:36:23 +0000 (UTC)
commit 253f18f4a62e75c7c54625cd43d02bdc125e1538
Author: Benjamin Otte <otte redhat com>
Date: Wed Dec 14 04:55:24 2016 +0100
cssimage: Port a few more simple ones to snapshots
gtk/gtkcssimageicontheme.c | 36 +++++++++++++++++++++++-------------
gtk/gtkcssimagescaled.c | 12 ++++++------
gtk/gtkcssimageurl.c | 12 ++++++------
3 files changed, 35 insertions(+), 25 deletions(-)
---
diff --git a/gtk/gtkcssimageicontheme.c b/gtk/gtkcssimageicontheme.c
index 4451e19..3037257 100644
--- a/gtk/gtkcssimageicontheme.c
+++ b/gtk/gtkcssimageicontheme.c
@@ -26,6 +26,7 @@
#include "gtkcssiconthemevalueprivate.h"
#include "gtkcssrgbavalueprivate.h"
#include "gtksettingsprivate.h"
+#include "gtksnapshot.h"
#include "gtkstyleproviderprivate.h"
#include "gtkiconthemeprivate.h"
@@ -39,15 +40,17 @@ gtk_css_image_icon_theme_get_aspect_ratio (GtkCssImage *image)
}
static void
-gtk_css_image_icon_theme_draw (GtkCssImage *image,
- cairo_t *cr,
- double width,
- double height)
+gtk_css_image_icon_theme_snapshot (GtkCssImage *image,
+ GtkSnapshot *snapshot,
+ double width,
+ double height)
{
GtkCssImageIconTheme *icon_theme = GTK_CSS_IMAGE_ICON_THEME (image);
GError *error = NULL;
GtkIconInfo *icon_info;
+ GskTexture *texture;
GdkPixbuf *pixbuf;
+ double texture_width, texture_height;
gint size;
size = floor (MIN (width, height));
@@ -79,14 +82,21 @@ gtk_css_image_icon_theme_draw (GtkCssImage *image,
return;
}
- cairo_translate (cr, width / 2.0, height / 2.0);
- cairo_scale (cr, 1.0 / icon_theme->scale, 1.0 / icon_theme->scale);
- gdk_cairo_set_source_pixbuf (cr,
- pixbuf,
- - gdk_pixbuf_get_width (pixbuf) / 2.0,
- - gdk_pixbuf_get_height (pixbuf) / 2.0);
- cairo_paint (cr);
-
+ texture = gsk_texture_new_for_pixbuf (pixbuf);
+ texture_width = (double) gdk_pixbuf_get_width (pixbuf) / icon_theme->scale;
+ texture_height = (double) gdk_pixbuf_get_height (pixbuf) / icon_theme->scale;
+
+ gtk_snapshot_append_texture_node (snapshot,
+ texture,
+ &GRAPHENE_RECT_INIT(
+ (width - texture_width) / 2.0,
+ (height - texture_height) / 2.0,
+ texture_width,
+ texture_height
+ ),
+ "CssImageIconTheme<%s@%d>", icon_theme->name, icon_theme->scale);
+
+ gsk_texture_unref (texture);
g_object_unref (pixbuf);
g_object_unref (icon_info);
}
@@ -175,7 +185,7 @@ _gtk_css_image_icon_theme_class_init (GtkCssImageIconThemeClass *klass)
GObjectClass *object_class = G_OBJECT_CLASS (klass);
image_class->get_aspect_ratio = gtk_css_image_icon_theme_get_aspect_ratio;
- image_class->draw = gtk_css_image_icon_theme_draw;
+ image_class->snapshot = gtk_css_image_icon_theme_snapshot;
image_class->parse = gtk_css_image_icon_theme_parse;
image_class->print = gtk_css_image_icon_theme_print;
image_class->compute = gtk_css_image_icon_theme_compute;
diff --git a/gtk/gtkcssimagescaled.c b/gtk/gtkcssimagescaled.c
index 1169f10..4de2423 100644
--- a/gtk/gtkcssimagescaled.c
+++ b/gtk/gtkcssimagescaled.c
@@ -50,14 +50,14 @@ gtk_css_image_scaled_get_aspect_ratio (GtkCssImage *image)
}
static void
-gtk_css_image_scaled_draw (GtkCssImage *image,
- cairo_t *cr,
- double width,
- double height)
+gtk_css_image_scaled_snapshot (GtkCssImage *image,
+ GtkSnapshot *snapshot,
+ double width,
+ double height)
{
GtkCssImageScaled *scaled = GTK_CSS_IMAGE_SCALED (image);
- _gtk_css_image_draw (scaled->images[scaled->scale - 1], cr, width, height);
+ gtk_css_image_snapshot (scaled->images[scaled->scale - 1], snapshot, width, height);
}
static void
@@ -189,7 +189,7 @@ _gtk_css_image_scaled_class_init (GtkCssImageScaledClass *klass)
image_class->get_width = gtk_css_image_scaled_get_width;
image_class->get_height = gtk_css_image_scaled_get_height;
image_class->get_aspect_ratio = gtk_css_image_scaled_get_aspect_ratio;
- image_class->draw = gtk_css_image_scaled_draw;
+ image_class->snapshot = gtk_css_image_scaled_snapshot;
image_class->parse = gtk_css_image_scaled_parse;
image_class->compute = gtk_css_image_scaled_compute;
image_class->print = gtk_css_image_scaled_print;
diff --git a/gtk/gtkcssimageurl.c b/gtk/gtkcssimageurl.c
index 03e80a0..ffde548 100644
--- a/gtk/gtkcssimageurl.c
+++ b/gtk/gtkcssimageurl.c
@@ -114,14 +114,14 @@ gtk_css_image_url_get_aspect_ratio (GtkCssImage *image)
}
static void
-gtk_css_image_url_draw (GtkCssImage *image,
- cairo_t *cr,
- double width,
- double height)
+gtk_css_image_url_snapshot (GtkCssImage *image,
+ GtkSnapshot *snapshot,
+ double width,
+ double height)
{
GtkCssImageUrl *url = GTK_CSS_IMAGE_URL (image);
- _gtk_css_image_draw (gtk_css_image_url_load_image (url, NULL), cr, width, height);
+ gtk_css_image_snapshot (gtk_css_image_url_load_image (url, NULL), snapshot, width, height);
}
static GtkCssImage *
@@ -189,7 +189,7 @@ _gtk_css_image_url_class_init (GtkCssImageUrlClass *klass)
image_class->get_height = gtk_css_image_url_get_height;
image_class->get_aspect_ratio = gtk_css_image_url_get_aspect_ratio;
image_class->compute = gtk_css_image_url_compute;
- image_class->draw = gtk_css_image_url_draw;
+ image_class->snapshot = gtk_css_image_url_snapshot;
image_class->parse = gtk_css_image_url_parse;
image_class->print = gtk_css_image_url_print;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]