Author: spouliot
Date: 2006-05-17 16:02:20 -0400 (Wed, 17 May 2006)
New Revision: 60803
Modified:
trunk/libgdiplus/src/ChangeLog
trunk/libgdiplus/src/gdip.h
trunk/libgdiplus/src/pen.c
Log:
2006-05-17 Sebastien Pouliot <[EMAIL PROTECTED]>
* gdip.h: Added GpDashCap dash_cap to GpPen. It's not used (visually)
but this way we can keep track of it (unit tests).
* pen.c: Multiple fixes to match new unit tests:
- fix DashStyleCustom style to use the current DashPattern (no reset);
- don't accept non-invertible matrices in GdipMultiplyPenTransform and
GdipSetPenTransform;
- set the minimum miter limit to 1.0 in GdipSetPenMiterLimit (whatever
the value supplied);
- fix some error conditions to return the correct error code and also
track some unimplemented stuff (rather than throwing);
Modified: trunk/libgdiplus/src/ChangeLog
===================================================================
--- trunk/libgdiplus/src/ChangeLog 2006-05-17 19:57:07 UTC (rev 60802)
+++ trunk/libgdiplus/src/ChangeLog 2006-05-17 20:02:20 UTC (rev 60803)
@@ -1,3 +1,16 @@
+2006-05-17 Sebastien Pouliot <[EMAIL PROTECTED]>
+
+ * gdip.h: Added GpDashCap dash_cap to GpPen. It's not used (visually)
+ but this way we can keep track of it (unit tests).
+ * pen.c: Multiple fixes to match new unit tests:
+ - fix DashStyleCustom style to use the current DashPattern (no reset);
+ - don't accept non-invertible matrices in GdipMultiplyPenTransform and
+ GdipSetPenTransform;
+ - set the minimum miter limit to 1.0 in GdipSetPenMiterLimit (whatever
+ the value supplied);
+ - fix some error conditions to return the correct error code and also
+ track some unimplemented stuff (rather than throwing);
+
2006-05-17 Gonzalo Paniagua Javier <[EMAIL PROTECTED]>
* bmpcodec.c: 24bpp bitmaps are no longer stored as 32bpp.
Modified: trunk/libgdiplus/src/gdip.h
===================================================================
--- trunk/libgdiplus/src/gdip.h 2006-05-17 19:57:07 UTC (rev 60802)
+++ trunk/libgdiplus/src/gdip.h 2006-05-17 20:02:20 UTC (rev 60803)
@@ -671,6 +671,7 @@
GpDashStyle dash_style;
GpLineCap line_cap; /* Cairo supports only same kind of end caps for
both the ends. */
GpLineCap end_cap;
+ GpDashCap dash_cap; /* not supported */
int compound_count;
float *compound_array;
GpPenAlignment mode;
Modified: trunk/libgdiplus/src/pen.c
===================================================================
--- trunk/libgdiplus/src/pen.c 2006-05-17 19:57:07 UTC (rev 60802)
+++ trunk/libgdiplus/src/pen.c 2006-05-17 20:02:20 UTC (rev 60803)
@@ -40,6 +40,8 @@
pen->line_join = LineJoinMiter;
pen->dash_style = DashStyleSolid;
pen->line_cap = LineCapFlat;
+ pen->end_cap = LineCapFlat; /* ignored, Cairo only support
a single start/end line cap */
+ pen->dash_cap = DashCapFlat; /* ignored */
pen->mode = PenAlignmentCenter;
pen->dash_offset = 0;
pen->dash_count = 0;
@@ -322,6 +324,7 @@
result->line_join = pen->line_join;
result->dash_style = pen->dash_style;
result->line_cap = pen->line_cap;
+ result->end_cap = pen->end_cap;
result->mode = pen->mode;
result->dash_offset = pen->dash_offset;
result->dash_count = pen->dash_count;
@@ -436,7 +439,7 @@
g_return_val_if_fail (type != NULL, InvalidParameter);
if (pen->brush != NULL)
- return GdipGetBrushType (pen->brush, (GpBrushType *) type);
+ return GdipGetBrushType (pen->brush, (GpBrushType *) type);
*type = PenTypeSolidColor;
@@ -448,9 +451,8 @@
{
g_return_val_if_fail (pen != NULL, InvalidParameter);
+ pen->changed = (pen->color != argb);
pen->color = argb;
- pen->changed = TRUE;
-
return Ok;
}
@@ -469,8 +471,11 @@
{
g_return_val_if_fail (pen != NULL, InvalidParameter);
+ if (miterLimit < 1.0f)
+ miterLimit = 1.0f;
+
+ pen->changed = (pen->miter_limit != miterLimit);
pen->miter_limit = miterLimit;
- pen->changed = TRUE;
return Ok;
}
@@ -489,8 +494,8 @@
{
g_return_val_if_fail (pen != NULL, InvalidParameter);
+ pen->changed = (pen->line_join != lineJoin);
pen->line_join = lineJoin;
- pen->changed = TRUE;
return Ok;
}
@@ -514,7 +519,15 @@
* Use end cap and dash cap when Cairo supports different caps for the
* line ends and dashcap.
*/
+
pen->line_cap = startCap;
+ pen->end_cap = endCap;
+ /* any invalid value is changed to DashCapFlat */
+ if ((dashCap == DashCapRound) || (dashCap == DashCapTriangle))
+ pen->dash_cap = dashCap;
+ else
+ pen->dash_cap = DashCapFlat; /* default */
+
pen->changed = TRUE;
return Ok;
}
@@ -522,11 +535,12 @@
GpStatus
GdipSetPenMode (GpPen *pen, GpPenAlignment penMode)
{
- g_return_val_if_fail (pen != NULL, InvalidParameter);
+ if (!pen)
+ return InvalidParameter;
- pen->mode = penMode;
- pen->changed = TRUE;
- return Ok;
+ pen->changed = (penMode != pen->mode);
+ pen->mode = penMode;
+ return Ok;
}
GpStatus
@@ -562,11 +576,18 @@
GpStatus
GdipSetPenTransform (GpPen *pen, GDIPCONST GpMatrix *matrix)
{
+ GpStatus status;
+ BOOL invertible;
+
g_return_val_if_fail (pen != NULL, InvalidParameter);
g_return_val_if_fail (matrix != NULL, InvalidParameter);
+ /* the matrix MUST be invertible to be used */
+ status = GdipIsMatrixInvertible ((GpMatrix*) matrix, &invertible);
+ if (!invertible || (status != Ok))
+ return InvalidParameter;
- gdip_cairo_matrix_copy(&pen->matrix, matrix);
+ gdip_cairo_matrix_copy (&pen->matrix, matrix);
pen->changed = TRUE;
return Ok;
}
@@ -597,11 +618,21 @@
GdipMultiplyPenTransform (GpPen *pen, GpMatrix *matrix, GpMatrixOrder order)
{
GpStatus status;
+ BOOL invertible;
+
g_return_val_if_fail (pen != NULL, InvalidParameter);
g_return_val_if_fail (matrix != NULL, InvalidParameter);
+ /* the matrix MUST be invertible to be used */
+ status = GdipIsMatrixInvertible ((GpMatrix*) matrix, &invertible);
+ if (!invertible || (status != Ok))
+ return InvalidParameter;
+
+ /* invalid GpMatrixOrder values are computed as MatrixOrderAppend (i.e.
no error) */
+ if (order != MatrixOrderPrepend)
+ order = MatrixOrderAppend;
+
status = GdipMultiplyMatrix (&pen->matrix, matrix, order);
-
if (status == Ok)
pen->changed = TRUE;
@@ -661,7 +692,7 @@
}
static float Custom [] = { 1.0 };
-static float Dot [] = { 1.0 };
+static float Dot [] = { 1.0, 1.0 };
static float Dash [] = { 3.0, 1.0 };
static float DashDot [] = { 3.0, 1.0, 1.0, 1.0 };
static float DashDotDot [] = { 3.0, 1.0, 1.0, 1.0, 1.0, 1.0 };
@@ -689,7 +720,7 @@
case DashStyleDot:
pen->dash_array = Dot;
- pen->dash_count = 1;
+ pen->dash_count = 2;
break;
case DashStyleDash:
@@ -698,8 +729,11 @@
break;
case DashStyleCustom:
- pen->dash_array = Custom;
- pen->dash_count = 1;
+ /* in most case we keep the current assigned value when
switching to Custom */
+ if (pen->dash_count == 0) {
+ pen->dash_array = Custom;
+ pen->dash_count = 1;
+ }
break;
default:
@@ -855,6 +889,7 @@
return Ok;
}
+/* MonoTODO - ignored (always same as start cap) */
GpStatus
GdipSetPenEndCap (GpPen *pen, GpLineCap endCap)
{
@@ -870,6 +905,7 @@
return Ok;
}
+/* MonoTODO - ignored (always same as start cap) */
GpStatus
GdipGetPenEndCap (GpPen *pen, GpLineCap *endCap)
{
@@ -881,38 +917,71 @@
return Ok;
}
+/* MonoTODO - ignored */
GpStatus
GdipSetPenDashCap197819 (GpPen *pen, GpDashCap dashCap)
{
- return NotImplemented;
+ g_return_val_if_fail (pen != NULL, InvalidParameter);
+
+ pen->dash_cap = dashCap;
+ return Ok;
}
+/* MonoTODO - ignored */
GpStatus
GdipGetPenDashCap197819 (GpPen *pen, GpDashCap *dashCap)
{
- return NotImplemented;
+ g_return_val_if_fail (pen != NULL, InvalidParameter);
+ g_return_val_if_fail (dashCap != NULL, InvalidParameter);
+
+ *dashCap = pen->dash_cap;
+ return Ok;
}
+/* MonoTODO - not implemented */
GpStatus
GdipSetPenCustomStartCap (GpPen *pen, GpCustomLineCap *customCap)
{
- return NotImplemented;
+ static bool called = FALSE;
+ if (!called) {
+ g_warning ("GdipSetPenCustomStartCap isn't implemented");
+ called = TRUE;
+ }
+ return Ok;
}
+/* MonoTODO - not implemented */
GpStatus
GdipGetPenCustomStartCap (GpPen *pen, GpCustomLineCap **customCap)
{
- return NotImplemented;
+ static bool called = FALSE;
+ if (!called) {
+ g_warning ("GdipGetPenCustomStartCap isn't implemented");
+ called = TRUE;
+ }
+ return Ok;
}
+/* MonoTODO - not implemented */
GpStatus
GdipSetPenCustomEndCap (GpPen *pen, GpCustomLineCap *customCap)
{
- return NotImplemented;
+ static bool called = FALSE;
+ if (!called) {
+ g_warning ("GdipSetPenCustomEndCap isn't implemented");
+ called = TRUE;
+ }
+ return Ok;
}
+/* MonoTODO - not implemented */
GpStatus
GdipGetPenCustomEndCap (GpPen *pen, GpCustomLineCap **customCap)
{
- return NotImplemented;
+ static bool called = FALSE;
+ if (!called) {
+ g_warning ("GdipGetPenCustomEndCap isn't implemented");
+ called = TRUE;
+ }
+ return Ok;
}
_______________________________________________
Mono-patches maillist - [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches