[gtk+/gtk-2-22] tests: Remove gdk_draw_pixbuf() with Cairo equivalent
- From: Benjamin Otte <otte src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+/gtk-2-22] tests: Remove gdk_draw_pixbuf() with Cairo equivalent
- Date: Sat, 7 Aug 2010 13:56:50 +0000 (UTC)
commit 4150ffbbe2c7e64d662dc52904d32feedbc31211
Author: Benjamin Otte <otte redhat com>
Date: Mon Jul 12 15:45:12 2010 +0200
tests: Remove gdk_draw_pixbuf() with Cairo equivalent
tests/testgtk.c | 20 ++++++++++++++------
tests/testrgb.c | 12 +++++++-----
2 files changed, 21 insertions(+), 11 deletions(-)
---
diff --git a/tests/testgtk.c b/tests/testgtk.c
index a8bf9a1..996c0e4 100644
--- a/tests/testgtk.c
+++ b/tests/testgtk.c
@@ -281,6 +281,7 @@ on_alpha_drawing_expose (GtkWidget *widget,
int width = widget->allocation.width;
int height = widget->allocation.height;
GdkPixbuf *pixbuf;
+ cairo_t *cr;
guchar *buffer;
guchar *p;
int i, j;
@@ -308,11 +309,15 @@ on_alpha_drawing_expose (GtkWidget *widget,
pixbuf = gdk_pixbuf_new_from_data (buffer, GDK_COLORSPACE_RGB, TRUE,
8, 64, 64, 4 * 64, NULL, NULL);
+ cr = gdk_cairo_create (widget->window);
- gdk_draw_pixbuf (widget->window, widget->style->black_gc, pixbuf,
- 0, 0, x + width - 18 - 64, y + (height - 64) /2,
- 64, 64, GDK_RGB_DITHER_NORMAL, 0, 0);
+ gdk_cairo_set_source_pixbuf (cr, pixbuf, 0, 0);
+ cairo_rectangle (cr,
+ x + width - 18 - 64, y + (height - 64) /2,
+ 64, 64);
+ cairo_fill (cr);
+ cairo_destroy (cr);
g_object_unref (pixbuf);
g_free (buffer);
@@ -3274,14 +3279,17 @@ on_rotated_text_expose (GtkWidget *widget,
if (tile_pixbuf)
{
GdkPixmap *tile;
+ cairo_t *cr;
gint width = gdk_pixbuf_get_width (tile_pixbuf);
gint height = gdk_pixbuf_get_height (tile_pixbuf);
tile = gdk_pixmap_new (widget->window, width, height, -1);
- gdk_draw_pixbuf (tile, gc, tile_pixbuf,
- 0, 0, 0, 0, width, height,
- GDK_RGB_DITHER_NORMAL, 0, 0);
+
+ cr = gdk_cairo_create (tile);
+ gdk_cairo_set_source_pixbuf (cr, tile_pixbuf, 0, 0);
+ cairo_paint (cr);
+ cairo_destroy (cr);
gdk_gc_set_tile (gc, tile);
gdk_gc_set_fill (gc, GDK_TILED);
diff --git a/tests/testrgb.c b/tests/testrgb.c
index f4fdbc2..b050183 100644
--- a/tests/testrgb.c
+++ b/tests/testrgb.c
@@ -147,15 +147,17 @@ testrgb_rgb_test (GtkWidget *drawing_area)
start_time = g_timer_elapsed (timer, NULL);
for (i = 0; i < NUM_ITERS; i++)
{
+ cairo_t *cr;
+
offset = (rand () % (WIDTH * HEIGHT * 4)) & -4;
pixbuf = gdk_pixbuf_new_from_data (buf + offset, GDK_COLORSPACE_RGB, TRUE,
8, WIDTH, HEIGHT, WIDTH * 4,
NULL, NULL);
- gdk_draw_pixbuf (drawing_area->window, drawing_area->style->black_gc,
- pixbuf,
- 0, 0, 0, 0, WIDTH, HEIGHT,
- GDK_RGB_DITHER_NORMAL,
- 0, 0);
+ cr = gdk_cairo_create (drawing_area->window);
+ gdk_cairo_set_source_pixbuf (cr, pixbuf, 0, 0);
+ cairo_rectangle (cr, 0, 0, WIDTH, HEIGHT);
+ cairo_fill (cr);
+ cairo_destroy (cr);
g_object_unref (pixbuf);
}
gdk_flush ();
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]