dia r4035 - in trunk: . lib plug-ins/cairo



Author: hans
Date: Sun May 18 13:46:54 2008
New Revision: 4035
URL: http://svn.gnome.org/viewvc/dia?rev=4035&view=rev

Log:
2008-05-18  Hans Breuer  <hans breuer org>

	* lib/diagdkrenderer.c lib/diarenderer.c
	  plug-ins/cairo/diacairo-renderer.c (*_rounded_rect) : fall back to
	(draw|fill}_rect if the radius is so small (smaller than one device 
	unit) it will only produce artifacts. Fixes bug #446854



Modified:
   trunk/ChangeLog
   trunk/lib/diagdkrenderer.c
   trunk/lib/diarenderer.c
   trunk/plug-ins/cairo/diacairo-renderer.c

Modified: trunk/lib/diagdkrenderer.c
==============================================================================
--- trunk/lib/diagdkrenderer.c	(original)
+++ trunk/lib/diagdkrenderer.c	Sun May 18 13:46:54 2008
@@ -1006,18 +1006,30 @@
   }
 }
 static void 
-draw_rounded_rect (DiaRenderer *renderer, 
+draw_rounded_rect (DiaRenderer *self, 
                    Point *ul_corner, Point *lr_corner,
                    Color *color, real radius) 
 {
-  draw_fill_rounded_rect (renderer, ul_corner, lr_corner, color, radius, FALSE);
+  DiaGdkRenderer *renderer = DIA_GDK_RENDERER (self);
+  gint r = dia_transform_length(renderer->transform, radius);
+
+  if (r > 0)
+    draw_fill_rounded_rect (self, ul_corner, lr_corner, color, radius, FALSE);
+  else
+    draw_rect (self, ul_corner, lr_corner, color);
 }
 static void 
-fill_rounded_rect (DiaRenderer *renderer, 
+fill_rounded_rect (DiaRenderer *self, 
                    Point *ul_corner, Point *lr_corner,
                    Color *color, real radius) 
 {
-  draw_fill_rounded_rect (renderer, ul_corner, lr_corner, color, radius, TRUE);
+  DiaGdkRenderer *renderer = DIA_GDK_RENDERER (self);
+  gint r = dia_transform_length(renderer->transform, radius);
+
+  if (r > 0)
+    draw_fill_rounded_rect (self, ul_corner, lr_corner, color, radius, TRUE);
+  else
+    fill_rect (self, ul_corner, lr_corner, color);
 }
 
 static void

Modified: trunk/lib/diarenderer.c
==============================================================================
--- trunk/lib/diarenderer.c	(original)
+++ trunk/lib/diarenderer.c	Sun May 18 13:46:54 2008
@@ -808,6 +808,12 @@
 
   radius = MIN(radius, (lr_corner->x-ul_corner->x)/2);
   radius = MIN(radius, (lr_corner->y-ul_corner->y)/2);
+  
+  if (radius < 0.00001) {
+    renderer_ops->draw_rect(renderer, ul_corner, lr_corner, color);
+    return;
+  }
+
   start.x = center.x = ul_corner->x+radius;
   end.x = lr_corner->x-radius;
   start.y = end.y = ul_corner->y;
@@ -852,6 +858,12 @@
 
   radius = MIN(radius, (lr_corner->x-ul_corner->x)/2);
   radius = MIN(radius, (lr_corner->y-ul_corner->y)/2);
+
+  if (radius < 0.00001) {
+    renderer_ops->fill_rect(renderer, ul_corner, lr_corner, color);
+    return;
+  }
+
   start.x = center.x = ul_corner->x+radius;
   end.x = lr_corner->x-radius;
   start.y = ul_corner->y;

Modified: trunk/plug-ins/cairo/diacairo-renderer.c
==============================================================================
--- trunk/plug-ins/cairo/diacairo-renderer.c	(original)
+++ trunk/plug-ins/cairo/diacairo-renderer.c	Sun May 18 13:46:54 2008
@@ -799,11 +799,19 @@
                gboolean fill)
 {
   DiaCairoRenderer *renderer = DIA_CAIRO_RENDERER (self);
-  real r2;
+  double rv[2];
 
   radius = MIN(radius, (bottomright->x - topleft->x)/2);
   radius = MIN(radius, (bottomright->y - topleft->y)/2);
-  r2 = radius/2;
+  
+  /* ignore radius if it is smaller than the device unit, avoids anti-aliasing artifacts */
+  rv[0] = radius;
+  rv[1] = 0.0;
+  cairo_user_to_device_distance (renderer->cr, &rv[0], &rv[1]);
+  if (rv[0] < 1.0 && rv[1] < 1.0) {
+    _rect (self, topleft, bottomright, color, fill);
+    return;  
+  }
 
   DIAG_NOTE(g_message("%s_rounded_rect %f,%f -> %f,%f, %f", 
             fill ? "fill" : "draw",



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]