[sapwood] refactor the cropping code
- From: Sven Herzberg <herzi src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [sapwood] refactor the cropping code
- Date: Fri, 13 Aug 2010 11:40:06 +0000 (UTC)
commit 77a81447d038f61b3c42b22b4c4a66b116cb8955
Author: Sven Herzberg <herzi gnome-de org>
Date: Wed Aug 11 13:23:48 2010 +0200
refactor the cropping code
* engine/sapwood-pixmap.c: we now use a cairo_surface_t instead of a
GdkPixmap
engine/sapwood-pixmap.c | 45 +++++++++++++++++++++++----------------------
1 files changed, 23 insertions(+), 22 deletions(-)
---
diff --git a/engine/sapwood-pixmap.c b/engine/sapwood-pixmap.c
index 9347bdd..b383375 100644
--- a/engine/sapwood-pixmap.c
+++ b/engine/sapwood-pixmap.c
@@ -385,15 +385,14 @@ sapwood_pixmap_render_rects_internal (SapwoodPixmap* self,
}
static void
-sapwood_crop_pixmap (GdkPixmap *pixmap,
- GdkBitmap *mask,
- int requested_width,
- int requested_height,
- int original_width,
- int original_height)
+sapwood_crop_pixmap (cairo_surface_t* surface,
+ GdkBitmap * mask,
+ int requested_width,
+ int requested_height,
+ int original_width,
+ int original_height)
{
- cairo_t * cr = gdk_cairo_create (pixmap);
- cairo_surface_t* surface = cairo_get_target (cr);
+ cairo_t* cr = cairo_create (surface);
cairo_set_operator (cr, CAIRO_OPERATOR_SOURCE);
@@ -530,15 +529,17 @@ sapwood_pixmap_render_rects (SapwoodPixmap* self,
gint n_rect,
SapwoodRect *rect)
{
- gint tmp_width;
- gint tmp_height;
- GdkPixmap *tmp;
- gboolean need_tmp_mask = FALSE;
- GdkPixmap *tmp_mask = NULL;
- cairo_t *mask_cr = NULL;
- cairo_t *tmp_cr;
- cairo_t *cr;
- gint n;
+ cairo_surface_t* tmp;
+ gboolean need_tmp_mask = FALSE;
+ GdkPixmap * tmp_mask = NULL;
+ cairo_t * mask_cr = NULL;
+ cairo_t * tmp_cr;
+ cairo_t * cr;
+ gint n;
+ gint tmp_width;
+ gint tmp_height;
+
+ cr = gdk_cairo_create (draw);
/* Don't even try to scale down shape masks (should never be useful, and
* implementing would add some complexity.) Areas larger than the pixmap
@@ -546,7 +547,6 @@ sapwood_pixmap_render_rects (SapwoodPixmap* self,
*/
if (mask_required || (width >= self->width && height >= self->height))
{
- cr = gdk_cairo_create (draw);
sapwood_pixmap_render_rects_internal (self, cr, draw_x, draw_y, mask, mask_x, mask_y, mask_required, clip_rect, n_rect, rect);
cairo_destroy (cr);
return;
@@ -566,7 +566,9 @@ sapwood_pixmap_render_rects (SapwoodPixmap* self,
tmp_width = MAX(width, self->width);
tmp_height = MAX(height, self->height);
- tmp = gdk_pixmap_new (draw, tmp_width, tmp_height, -1);
+ tmp = cairo_surface_create_similar (cairo_get_target (cr),
+ cairo_surface_get_content (cairo_get_target (cr)),
+ tmp_width, tmp_height);
if (need_tmp_mask)
{
@@ -577,11 +579,10 @@ sapwood_pixmap_render_rects (SapwoodPixmap* self,
cairo_paint (mask_cr);
}
- tmp_cr = gdk_cairo_create (tmp);
+ tmp_cr = cairo_create (tmp);
sapwood_pixmap_render_rects_internal (self, tmp_cr, 0, 0, tmp_mask, 0, 0, mask_required, NULL, n_rect, rect);
/* finally, render downscaled at draw_x,draw_y */
- cr = gdk_cairo_create (draw);
if (clip_rect)
{
gdk_cairo_rectangle (cr, clip_rect);
@@ -633,7 +634,7 @@ sapwood_pixmap_render_rects (SapwoodPixmap* self,
if (tmp_mask)
g_object_unref (tmp_mask);
cairo_destroy (tmp_cr);
- g_object_unref (tmp);
+ cairo_surface_destroy (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]