[gtk+/rendering-cleanup: 10/22] tests: Remove gdk_draw_pixbuf() with Cairo equivalent
- From: Benjamin Otte <otte src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+/rendering-cleanup: 10/22] tests: Remove gdk_draw_pixbuf() with Cairo equivalent
- Date: Tue, 13 Jul 2010 00:57:16 +0000 (UTC)
commit 821976d39dd445f4c3fca2f075c72dc1a53ae5d0
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 0a3161b..12fee48 100644
--- a/tests/testgtk.c
+++ b/tests/testgtk.c
@@ -256,6 +256,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;
@@ -283,11 +284,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);
@@ -2741,14 +2746,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]