Author: spouliot
Date: 2007-05-28 16:30:54 -0400 (Mon, 28 May 2007)
New Revision: 78089
Modified:
trunk/libgdiplus/src/ChangeLog
trunk/libgdiplus/src/graphics-cairo-private.h
trunk/libgdiplus/src/graphics-cairo.c
Log:
2007-05-28 Sebastien Pouliot <[EMAIL PROTECTED]>
* graphics-cairo.c: Adjust the x,y position (-1,-1) when the pen's
length is a multiple of 2. This makes the rectangle drawing match MS
implementation. Also fix cairo_DrawRectanglesI to use anti-aliasing
(like all drawing functions should do).
* graphics-cairo-private.h: Add macro to check if a coordinate
correction is required for the specified pen's width.
Modified: trunk/libgdiplus/src/ChangeLog
===================================================================
--- trunk/libgdiplus/src/ChangeLog 2007-05-28 19:33:29 UTC (rev 78088)
+++ trunk/libgdiplus/src/ChangeLog 2007-05-28 20:30:54 UTC (rev 78089)
@@ -1,3 +1,12 @@
+2007-05-28 Sebastien Pouliot <[EMAIL PROTECTED]>
+
+ * graphics-cairo.c: Adjust the x,y position (-1,-1) when the pen's
+ length is a multiple of 2. This makes the rectangle drawing match MS
+ implementation. Also fix cairo_DrawRectanglesI to use anti-aliasing
+ (like all drawing functions should do).
+ * graphics-cairo-private.h: Add macro to check if a coordinate
+ correction is required for the specified pen's width.
+
2007-05-25 Sebastien Pouliot <[EMAIL PROTECTED]>
* general-private.h: Don't optimize convertions when printing.
Modified: trunk/libgdiplus/src/graphics-cairo-private.h
===================================================================
--- trunk/libgdiplus/src/graphics-cairo-private.h 2007-05-28 19:33:29 UTC
(rev 78088)
+++ trunk/libgdiplus/src/graphics-cairo-private.h 2007-05-28 20:30:54 UTC
(rev 78089)
@@ -39,6 +39,10 @@
#define cairo_DrawRectangleI cairo_DrawRectangle
#define cairo_FillRectangleI cairo_FillRectangle
+/*
+ * Handling of pens with a width greater than 1 is not identical between GDI+
and Cairo
+ */
+#define gdip_cairo_pen_width_needs_adjustment(pen) (((int)(pen->width) &
1) == 0)
GpStatus cairo_DrawArc (GpGraphics *graphics, GpPen *pen, float x, float y,
float width, float height, float startAngle,
float sweepAngle) GDIP_INTERNAL;
Modified: trunk/libgdiplus/src/graphics-cairo.c
===================================================================
--- trunk/libgdiplus/src/graphics-cairo.c 2007-05-28 19:33:29 UTC (rev
78088)
+++ trunk/libgdiplus/src/graphics-cairo.c 2007-05-28 20:30:54 UTC (rev
78089)
@@ -736,6 +736,11 @@
GpStatus
cairo_DrawRectangle (GpGraphics *graphics, GpPen *pen, float x, float y, float
width, float height)
{
+ /* wide pen position can be different between cairo and gdi+ */
+ if (gdip_cairo_pen_width_needs_adjustment (pen)) {
+ x -= 1.0f;
+ y -= 1.0f;
+ }
gdip_cairo_rectangle (graphics, x, y, width, height, TRUE);
return stroke_graphics_with_pen (graphics, pen);
}
@@ -751,14 +756,26 @@
cairo_DrawRectangles (GpGraphics *graphics, GpPen *pen, GDIPCONST GpRectF
*rects, int count)
{
BOOL draw = FALSE;
+ BOOL adjust = gdip_cairo_pen_width_needs_adjustment (pen);
int i;
for (i = 0; i < count; i++) {
+ float x = rects [i].X;
+ float y = rects [i].Y;
+ float w = rects [i].Width;
+ float h = rects [i].Height;
+
/* don't draw/fill rectangles with negative width/height (bug
#77129) */
- if ((rects [i].Width < 0) || (rects [i].Height < 0))
+ if ((w < 0) || (h < 0))
continue;
- gdip_cairo_rectangle (graphics, rects [i].X, rects [i].Y, rects
[i].Width, rects [i].Height, TRUE);
+ /* wide pen position can be different between cairo and gdi+ */
+ if (adjust) {
+ x -= 1.0f;
+ y -= 1.0f;
+ }
+
+ gdip_cairo_rectangle (graphics, x, y, w, h, TRUE);
draw = TRUE;
}
@@ -772,14 +789,26 @@
cairo_DrawRectanglesI (GpGraphics *graphics, GpPen *pen, GDIPCONST GpRect
*rects, int count)
{
BOOL draw = FALSE;
+ BOOL adjust = gdip_cairo_pen_width_needs_adjustment (pen);
int i;
for (i = 0; i < count; i++) {
+ int x = rects [i].X;
+ int y = rects [i].Y;
+ int w = rects [i].Width;
+ int h = rects [i].Height;
+
/* don't draw/fill rectangles with negative width/height (bug
#77129) */
- if ((rects [i].Width < 0) || (rects [i].Height < 0))
+ if ((w < 0) || (h < 0))
continue;
- gdip_cairo_rectangle (graphics, rects [i].X, rects [i].Y, rects
[i].Width, rects [i].Height, FALSE);
+ /* wide pen position can be different between cairo and gdi+ */
+ if (adjust) {
+ x -= 1;
+ y -= 1;
+ }
+
+ gdip_cairo_rectangle (graphics, x, y, w, h, TRUE);
draw = TRUE;
}
_______________________________________________
Mono-patches maillist - [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches