[dia] Bug 535871 - Rounded corners have gaps in the rendering
- From: Hans Breuer <hans src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [dia] Bug 535871 - Rounded corners have gaps in the rendering
- Date: Sat, 7 Nov 2009 20:29:06 +0000 (UTC)
commit e026f7651549b92aa6b305a384aa47c5cd41cd56
Author: Hans Breuer <hans breuer org>
Date: Sat Nov 7 21:10:52 2009 +0100
Bug 535871 - Rounded corners have gaps in the rendering
Implement DiaRenderer::draw_rounded_polyline() by combining
all drawing steps in one path.
plug-ins/cairo/diacairo-renderer.c | 34 ++++++++++++++++++++++++++++------
plug-ins/cairo/diacairo.h | 1 +
2 files changed, 29 insertions(+), 6 deletions(-)
---
diff --git a/plug-ins/cairo/diacairo-renderer.c b/plug-ins/cairo/diacairo-renderer.c
index 4110a9b..8cd2b46 100644
--- a/plug-ins/cairo/diacairo-renderer.c
+++ b/plug-ins/cairo/diacairo-renderer.c
@@ -365,7 +365,8 @@ draw_line(DiaRenderer *self,
cairo_set_source_rgba (renderer->cr, color->red, color->green, color->blue, 1.0);
cairo_move_to (renderer->cr, start->x, start->y);
cairo_line_to (renderer->cr, end->x, end->y);
- cairo_stroke (renderer->cr);
+ if (!renderer->stroke_pending)
+ cairo_stroke (renderer->cr);
DIAG_STATE(renderer->cr)
}
@@ -501,10 +502,11 @@ draw_arc(DiaRenderer *self,
cairo_set_source_rgba (renderer->cr, color->red, color->green, color->blue, 1.0);
+ if (!renderer->stroke_pending)
+ cairo_new_path (renderer->cr);
/* Dia and Cairo don't agree on arc definitions, so it needs
* to be converted, i.e. mirrored at the x axis
*/
- cairo_new_path (renderer->cr);
start.x = center->x + (width / 2.0) * cos((M_PI / 180.0) * angle1);
start.y = center->y - (height / 2.0) * sin((M_PI / 180.0) * angle1);
cairo_move_to (renderer->cr, start.x, start.y);
@@ -514,7 +516,8 @@ draw_arc(DiaRenderer *self,
cairo_arc_negative (renderer->cr, center->x, center->y,
width > height ? height / 2.0 : width / 2.0, /* FIXME 2nd radius */
a1, a2);
- cairo_stroke (renderer->cr);
+ if (!renderer->stroke_pending)
+ cairo_stroke (renderer->cr);
DIAG_STATE(renderer->cr)
}
@@ -917,12 +920,31 @@ fill_rounded_rect (DiaRenderer *renderer,
_rounded_rect (renderer, topleft, bottomright, color, radius, TRUE);
}
+static gpointer parent_class = NULL;
+
+static void
+draw_rounded_polyline (DiaRenderer *self,
+ Point *points, int num_points,
+ Color *color, real radius)
+{
+ DiaCairoRenderer *renderer = DIA_CAIRO_RENDERER (self);
+
+ cairo_new_path (renderer->cr);
+ cairo_move_to (renderer->cr, points[0].x, points[0].y);
+ /* use base class implementation */
+ renderer->stroke_pending = TRUE;
+ DIA_RENDERER_CLASS(parent_class)->draw_rounded_polyline (self,
+ points, num_points,
+ color, radius);
+ renderer->stroke_pending = FALSE;
+ cairo_stroke (renderer->cr);
+ DIAG_STATE(renderer->cr)
+}
+
/* gobject boiler plate */
static void cairo_renderer_init (DiaCairoRenderer *r, void *p);
static void cairo_renderer_class_init (DiaCairoRendererClass *klass);
-static gpointer parent_class = NULL;
-
GType
dia_cairo_renderer_get_type (void)
{
@@ -1024,7 +1046,7 @@ cairo_renderer_class_init (DiaCairoRendererClass *klass)
/* highest level functions */
renderer_class->draw_rounded_rect = draw_rounded_rect;
renderer_class->fill_rounded_rect = fill_rounded_rect;
-
+ renderer_class->draw_rounded_polyline = draw_rounded_polyline;
/* other */
renderer_class->is_capable_to = is_capable_to;
}
diff --git a/plug-ins/cairo/diacairo.h b/plug-ins/cairo/diacairo.h
index f1af16b..83422ee 100644
--- a/plug-ins/cairo/diacairo.h
+++ b/plug-ins/cairo/diacairo.h
@@ -60,6 +60,7 @@ struct _DiaCairoRenderer
real scale;
gboolean with_alpha;
gboolean skip_show_page; /**< when using for print avoid the internal show_page */
+ gboolean stroke_pending; /**< to delay call to cairo_stroke */
/** caching the font description from set_font */
PangoLayout *layout;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]