Module: wine Branch: master Commit: 9d5d4dba288c642521ecf73a33ec38567149f374 URL: https://gitlab.winehq.org/wine/wine/-/commit/9d5d4dba288c642521ecf73a33ec385...
Author: Bartosz Kosiorek gang65@poczta.onet.pl Date: Sat Oct 29 14:39:20 2022 +0200
gdiplus: Add GdipSetPenCompoundArray implementation.
Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=52196
---
dlls/gdiplus/gdiplus_private.h | 2 ++ dlls/gdiplus/graphicspath.c | 3 +++ dlls/gdiplus/pen.c | 26 ++++++++++++++++++++++---- dlls/gdiplus/tests/pen.c | 12 +++++++++++- 4 files changed, 38 insertions(+), 5 deletions(-)
diff --git a/dlls/gdiplus/gdiplus_private.h b/dlls/gdiplus/gdiplus_private.h index 03bfa5513cb..0c55af6614a 100644 --- a/dlls/gdiplus/gdiplus_private.h +++ b/dlls/gdiplus/gdiplus_private.h @@ -235,6 +235,8 @@ struct GpPen{ GpBrush *brush; GpPenAlignment align; GpMatrix transform; + REAL *compound_array; + INT compound_array_size; };
struct GpGraphics{ diff --git a/dlls/gdiplus/graphicspath.c b/dlls/gdiplus/graphicspath.c index ce2666eedab..d98a5ae4bf6 100644 --- a/dlls/gdiplus/graphicspath.c +++ b/dlls/gdiplus/graphicspath.c @@ -2356,6 +2356,9 @@ GpStatus WINGDIPAPI GdipWidenPath(GpPath *path, GpPen *pen, GpMatrix *matrix, if (pen->align != PenAlignmentCenter) FIXME("unimplemented pen alignment %d\n", pen->align);
+ if (pen->compound_array_size != 0) + FIXME("unimplemented pen compoundline. Solid line will be drawn instead: %d\n", pen->compound_array_size); + for (i=0; i < flat_path->pathdata.Count; i++) { if ((types[i]&PathPointTypePathTypeMask) == PathPointTypeStart) diff --git a/dlls/gdiplus/pen.c b/dlls/gdiplus/pen.c index 32579adc484..083406eedef 100644 --- a/dlls/gdiplus/pen.c +++ b/dlls/gdiplus/pen.c @@ -171,6 +171,8 @@ GpStatus WINGDIPAPI GdipCreatePen2(GpBrush *brush, REAL width, GpUnit unit, gp_pen->offset = 0.0; gp_pen->customstart = NULL; gp_pen->customend = NULL; + gp_pen->compound_array = NULL; + gp_pen->compound_array_size = 0; GdipSetMatrixElements(&gp_pen->transform, 1.0, 0.0, 0.0, 1.0, 0.0, 0.0);
if(!((gp_pen->unit == UnitWorld) || (gp_pen->unit == UnitPixel))) { @@ -198,6 +200,7 @@ GpStatus WINGDIPAPI GdipDeletePen(GpPen *pen) GdipDeleteBrush(pen->brush); GdipDeleteCustomLineCap(pen->customstart); GdipDeleteCustomLineCap(pen->customend); + heap_free(pen->compound_array); heap_free(pen->dashes); heap_free(pen);
@@ -533,15 +536,30 @@ GpStatus WINGDIPAPI GdipGetPenCompoundCount(GpPen *pen, INT *count) return NotImplemented; }
-GpStatus WINGDIPAPI GdipSetPenCompoundArray(GpPen *pen, GDIPCONST REAL *dash, +GpStatus WINGDIPAPI GdipSetPenCompoundArray(GpPen *pen, GDIPCONST REAL *compoundarray, INT count) { - FIXME("(%p, %p, %i): stub\n", pen, dash, count); + INT i; + REAL *tmp; + TRACE("(%p, %p, %i)\n", pen, compoundarray, count);
- if (!pen || !dash || count < 2 || count%2 == 1) + if(!pen || !compoundarray || count < 2 || count%2 == 1 || *compoundarray < 0.0 || *compoundarray > 1.0) return InvalidParameter;
- return NotImplemented; + for(i = 1; i<count; i++) + { + if((compoundarray[i] < compoundarray[i - 1]) || (compoundarray[i] > 1.0)) + return InvalidParameter; + } + + tmp = heap_alloc_zero(count * sizeof(REAL)); + if(!tmp) + return OutOfMemory; + heap_free(pen->compound_array); + pen->compound_array = tmp; + memcpy(pen->compound_array, compoundarray, count * sizeof(REAL)); + pen->compound_array_size = count; + return Ok; }
GpStatus WINGDIPAPI GdipSetPenCustomEndCap(GpPen *pen, GpCustomLineCap* customCap) diff --git a/dlls/gdiplus/tests/pen.c b/dlls/gdiplus/tests/pen.c index cd3e45f9b41..d1d19312878 100644 --- a/dlls/gdiplus/tests/pen.c +++ b/dlls/gdiplus/tests/pen.c @@ -351,6 +351,9 @@ static void test_compoundarray(void) GpStatus status; GpPen *pen; static const REAL testvalues[] = {0.2, 0.4, 0.6, 0.8}; + static const REAL notSortedValues[] = {0.2, 0.6, 0.4, 0.8}; + static const REAL negativeValues[] = {-1.2, 0.4, 0.6, 0.8}; + static const REAL tooLargeValues[] = {0.2, 0.4, 0.6, 2.8}; INT count;
status = GdipSetPenCompoundArray(NULL, testvalues, 4); @@ -382,8 +385,15 @@ todo_wine { status = GdipSetPenCompoundArray(pen, testvalues, -2); expect(InvalidParameter, status);
+ status = GdipSetPenCompoundArray(pen, notSortedValues, 4); + expect(InvalidParameter, status); + status = GdipSetPenCompoundArray(pen, negativeValues, 4); + expect(InvalidParameter, status); + status = GdipSetPenCompoundArray(pen, tooLargeValues, 4); + expect(InvalidParameter, status); + status = GdipSetPenCompoundArray(pen, testvalues, 4); - todo_wine expect(Ok, status); + expect(Ok, status); status = GdipSetPenCompoundArray(pen, NULL, 0); expect(InvalidParameter, status);