[sapwood] rewrite the mask compositing to use cairo
- From: Sven Herzberg <herzi src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [sapwood] rewrite the mask compositing to use cairo
- Date: Fri, 6 Aug 2010 12:06:28 +0000 (UTC)
commit fe48037bd7bd9372483ebb6f29cab37ea9ee583d
Author: Sven Herzberg <herzi gnome-de org>
Date: Thu Aug 5 15:25:24 2010 +0200
rewrite the mask compositing to use cairo
* engine/sapwood-pixmap.c: rewrite the mask compositing in cairo, this
will make several things a lot easier
engine/sapwood-pixmap.c | 40 ++++++++++++++++++++++++++++------------
1 files changed, 28 insertions(+), 12 deletions(-)
---
diff --git a/engine/sapwood-pixmap.c b/engine/sapwood-pixmap.c
index 90a3d5e..5dc49ef 100644
--- a/engine/sapwood-pixmap.c
+++ b/engine/sapwood-pixmap.c
@@ -258,6 +258,22 @@ sapwood_pixmap_get_pixmap (SapwoodPixmap *self,
*pixmask = self->pixmask[y][x];
}
+/*
+ * sapwood_pixmap_render_rects_internal:
+ * @self: a #SapwoodPixmap
+ * @drawable: the #GdkDrawable to draw to
+ * @draw_x: the horizontal offset on @drawable in pixels
+ * @draw_y: the vertical offset on @drawable in pixels
+ * @mask: a #GdkBitmap mask to paint @self's bitmask to and to use when the 1-bit transparency should be honored
+ * @mask_x: the horizontal offset on @mask in pixels
+ * @mask_y: the vertical offset on @mask in pixels
+ * @mask_required: FIXME
+ * @clip_rect: the clipping area of the rendering
+ * @n_rect: the number of rectangles in @rect
+ * @rect: an array of rectangles to render
+ *
+ * Render the areas of @self specified by @rect to @drawable.
+ */
static void
sapwood_pixmap_render_rects_internal (SapwoodPixmap *self,
GdkDrawable *draw,
@@ -271,7 +287,6 @@ sapwood_pixmap_render_rects_internal (SapwoodPixmap *self,
gint n_rect,
SapwoodRect *rect)
{
- static GdkGC *mask_gc = NULL;
static GdkGC *draw_gc = NULL;
GdkGCValues values;
gint xofs;
@@ -282,13 +297,13 @@ sapwood_pixmap_render_rects_internal (SapwoodPixmap *self,
xofs = draw_x - mask_x;
yofs = draw_y - mask_y;
+ /* FIXME: try to rewrite this to use one loop only */
+
if (mask)
{
- if (!mask_gc)
- {
- values.fill = GDK_TILED;
- mask_gc = gdk_gc_new_with_values (mask, &values, GDK_GC_FILL);
- }
+ cairo_t* cr = gdk_cairo_create (mask);
+ cairo_set_operator (cr, CAIRO_OPERATOR_SOURCE);
+ cairo_translate (cr, mask_x, mask_y);
for (n = 0; n < n_rect; n++)
{
@@ -305,16 +320,15 @@ sapwood_pixmap_render_rects_internal (SapwoodPixmap *self,
if (rect[n].pixmap && rect[n].pixmask)
{
- values.tile = rect[n].pixmask;
- values.ts_x_origin = dest->x - xofs;
- values.ts_y_origin = dest->y - yofs;
- gdk_gc_set_values (mask_gc, &values, GDK_GC_TILE|GDK_GC_TS_X_ORIGIN|GDK_GC_TS_Y_ORIGIN);
-
- gdk_draw_rectangle (mask, mask_gc, TRUE, area.x - xofs, area.y - yofs, area.width, area.height);
+ gdk_cairo_set_source_pixmap (cr, rect[n].pixmask, area.x, area.y);
+ cairo_pattern_set_extend (cairo_get_source (cr), CAIRO_EXTEND_REPEAT);
+ gdk_cairo_rectangle (cr, &area);
+ cairo_fill (cr);
have_mask = TRUE;
}
}
+ cairo_destroy (cr);
}
if (!draw_gc)
@@ -601,3 +615,5 @@ sapwood_pixmap_render_rects (SapwoodPixmap* self,
cairo_destroy (tmp_cr);
g_object_unref (tmp);
}
+
+/* vim:set et sw=2 cino=t0,f0,(0,{s,>2s,n-1s,^-1s,e2s: */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]