Signed-off-by: Nikolay Sivov nsivov@codeweavers.com --- dlls/gdiplus/gdiplus_private.h | 2 ++ dlls/gdiplus/graphics.c | 10 +++++++ dlls/gdiplus/metafile.c | 53 ++++++++++++++++++++++++++++++++++ 3 files changed, 65 insertions(+)
diff --git a/dlls/gdiplus/gdiplus_private.h b/dlls/gdiplus/gdiplus_private.h index a617ca4803e..b0e4d967894 100644 --- a/dlls/gdiplus/gdiplus_private.h +++ b/dlls/gdiplus/gdiplus_private.h @@ -113,6 +113,8 @@ extern void METAFILE_Free(GpMetafile *metafile) DECLSPEC_HIDDEN; extern GpStatus METAFILE_DrawEllipse(GpMetafile *metafile, GpPen *pen, GpRectF *rect) DECLSPEC_HIDDEN; extern GpStatus METAFILE_FillEllipse(GpMetafile *metafile, GpBrush *brush, GpRectF *rect) DECLSPEC_HIDDEN; extern GpStatus METAFILE_DrawRectangles(GpMetafile *metafile, GpPen *pen, const GpRectF *rects, INT count) DECLSPEC_HIDDEN; +extern GpStatus METAFILE_FillPie(GpMetafile *metafile, GpBrush *brush, const GpRectF *rect, + REAL startAngle, REAL sweepAngle) DECLSPEC_HIDDEN;
extern void calc_curve_bezier(const GpPointF *pts, REAL tension, REAL *x1, REAL *y1, REAL *x2, REAL *y2) DECLSPEC_HIDDEN; diff --git a/dlls/gdiplus/graphics.c b/dlls/gdiplus/graphics.c index 2c18ced3e92..922c6591c87 100644 --- a/dlls/gdiplus/graphics.c +++ b/dlls/gdiplus/graphics.c @@ -4402,6 +4402,7 @@ GpStatus WINGDIPAPI GdipFillPie(GpGraphics *graphics, GpBrush *brush, REAL x, { GpStatus stat; GpPath *path; + GpRectF rect;
TRACE("(%p, %p, %.2f, %.2f, %.2f, %.2f, %.2f, %.2f)\n", graphics, brush, x, y, width, height, startAngle, sweepAngle); @@ -4412,6 +4413,15 @@ GpStatus WINGDIPAPI GdipFillPie(GpGraphics *graphics, GpBrush *brush, REAL x, if(graphics->busy) return ObjectBusy;
+ if (is_metafile_graphics(graphics)) + { + rect.X = x; + rect.Y = y; + rect.Width = width; + rect.Height = height; + return METAFILE_FillPie((GpMetafile *)graphics->image, brush, &rect, startAngle, sweepAngle); + } + stat = GdipCreatePath(FillModeAlternate, &path);
if (stat == Ok) diff --git a/dlls/gdiplus/metafile.c b/dlls/gdiplus/metafile.c index eafcdaee963..a483b3a5e6d 100644 --- a/dlls/gdiplus/metafile.c +++ b/dlls/gdiplus/metafile.c @@ -4896,6 +4896,59 @@ GpStatus METAFILE_FillEllipse(GpMetafile *metafile, GpBrush *brush, GpRectF *rec return Ok; }
+GpStatus METAFILE_FillPie(GpMetafile *metafile, GpBrush *brush, const GpRectF *rect, + REAL startAngle, REAL sweepAngle) +{ + BOOL is_int_rect, inline_color; + EmfPlusFillPie *record; + DWORD brush_id = -1; + GpStatus stat; + + if (metafile->metafile_type == MetafileTypeEmf) + { + FIXME("stub!\n"); + return NotImplemented; + } + + inline_color = brush->bt == BrushTypeSolidColor; + if (!inline_color) + { + stat = METAFILE_AddBrushObject(metafile, brush, &brush_id); + if (stat != Ok) return stat; + } + + is_int_rect = is_integer_rect(rect); + + stat = METAFILE_AllocateRecord(metafile, FIELD_OFFSET(EmfPlusFillPie, RectData) + + is_int_rect ? sizeof(EmfPlusRect) : sizeof(EmfPlusRectF), (void **)&record); + if (stat != Ok) return stat; + record->Header.Type = EmfPlusRecordTypeFillPie; + if (inline_color) + { + record->Header.Flags = 0x8000; + record->BrushId = ((GpSolidFill *)brush)->color; + } + else + record->BrushId = brush_id; + + record->StartAngle = startAngle; + record->SweepAngle = sweepAngle; + + if (is_int_rect) + { + record->Header.Flags |= 0x4000; + record->RectData.rect.X = (SHORT)rect->X; + record->RectData.rect.Y = (SHORT)rect->Y; + record->RectData.rect.Width = (SHORT)rect->Width; + record->RectData.rect.Height = (SHORT)rect->Height; + } + else + memcpy(&record->RectData.rectF, rect, sizeof(*rect)); + + METAFILE_WriteRecords(metafile); + return Ok; +} + static GpStatus METAFILE_AddFontObject(GpMetafile *metafile, GDIPCONST GpFont *font, DWORD *id) { EmfPlusObject *object_record;
Signed-off-by: Nikolay Sivov nsivov@codeweavers.com --- dlls/gdiplus/graphics.c | 23 ++++---------- dlls/gdiplus/tests/metafile.c | 58 +++++++++++++++++++++++++++++++++++ 2 files changed, 64 insertions(+), 17 deletions(-)
diff --git a/dlls/gdiplus/graphics.c b/dlls/gdiplus/graphics.c index 922c6591c87..4ee0430051f 100644 --- a/dlls/gdiplus/graphics.c +++ b/dlls/gdiplus/graphics.c @@ -4088,26 +4088,15 @@ GpStatus WINGDIPAPI GdipDrawPieI(GpGraphics *graphics, GpPen *pen, INT x, GpStatus WINGDIPAPI GdipDrawRectangle(GpGraphics *graphics, GpPen *pen, REAL x, REAL y, REAL width, REAL height) { - GpStatus status; - GpPath *path; + GpRectF rect;
TRACE("(%p, %p, %.2f, %.2f, %.2f, %.2f)\n", graphics, pen, x, y, width, height);
- if(!pen || !graphics) - return InvalidParameter; - - if(graphics->busy) - return ObjectBusy; - - status = GdipCreatePath(FillModeAlternate, &path); - if (status != Ok) return status; - - status = GdipAddPathRectangle(path, x, y, width, height); - if (status == Ok) - status = GdipDrawPath(graphics, pen, path); - - GdipDeletePath(path); - return status; + rect.X = x; + rect.Y = y, + rect.Width = width; + rect.Height = height; + return GdipDrawRectangles(graphics, pen, &rect, 1); }
GpStatus WINGDIPAPI GdipDrawRectangleI(GpGraphics *graphics, GpPen *pen, INT x, diff --git a/dlls/gdiplus/tests/metafile.c b/dlls/gdiplus/tests/metafile.c index 410e9a6ab8c..92c738f5116 100644 --- a/dlls/gdiplus/tests/metafile.c +++ b/dlls/gdiplus/tests/metafile.c @@ -3650,6 +3650,63 @@ static void test_fillellipse(void) expect(Ok, stat); }
+static const emfplus_record draw_rectangle_records[] = +{ + { EMR_HEADER }, + { EmfPlusRecordTypeHeader }, + { EmfPlusRecordTypeObject, ObjectTypePen << 8 }, + { EmfPlusRecordTypeDrawRects, 0x4000 }, + { EMR_SAVEDC, 0, 1 }, + { EMR_SETICMMODE, 0, 1 }, + { EMR_BITBLT, 0, 1 }, + { EMR_RESTOREDC, 0, 1 }, + { EmfPlusRecordTypeEndOfFile }, + { EMR_EOF }, + { 0 } +}; + +static void test_drawrectangle(void) +{ + static const GpRectF frame = { 0.0f, 0.0f, 100.0f, 100.0f }; + + GpMetafile *metafile; + GpGraphics *graphics; + HENHMETAFILE hemf; + GpStatus stat; + GpPen *pen; + HDC hdc; + + hdc = CreateCompatibleDC(0); + stat = GdipRecordMetafile(hdc, EmfTypeEmfPlusOnly, &frame, MetafileFrameUnitPixel, description, &metafile); + expect(Ok, stat); + DeleteDC(hdc); + + stat = GdipGetImageGraphicsContext((GpImage *)metafile, &graphics); + expect(Ok, stat); + + stat = GdipCreatePen1((ARGB)0xffff00ff, 10.0f, UnitPixel, &pen); + expect(Ok, stat); + + stat = GdipDrawRectangle(graphics, pen, 1.0f, 1.0f, 16.0f, 32.0f); + expect(Ok, stat); + + stat = GdipDeletePen(pen); + expect(Ok, stat); + + stat = GdipDeleteGraphics(graphics); + expect(Ok, stat); + sync_metafile(&metafile, "draw_rectangle.emf"); + + stat = GdipGetHemfFromMetafile(metafile, &hemf); + expect(Ok, stat); + + check_emfplus(hemf, draw_rectangle_records, "draw rectangle"); + DeleteEnhMetaFile(hemf); + + stat = GdipDisposeImage((GpImage*)metafile); + expect(Ok, stat); +} + START_TEST(metafile) { struct GdiplusStartupInput gdiplusStartupInput; @@ -3706,6 +3763,7 @@ START_TEST(metafile) test_printer_dc(); test_drawellipse(); test_fillellipse(); + test_drawrectangle();
GdiplusShutdown(gdiplusToken); }
Signed-off-by: Esme Povirk esme@codeweavers.com
Signed-off-by: Nikolay Sivov nsivov@codeweavers.com --- dlls/gdiplus/brush.c | 6 +-- dlls/gdiplus/gdiplus_private.h | 8 ++++ dlls/gdiplus/graphics.c | 74 +++++++--------------------------- dlls/gdiplus/graphicspath.c | 29 +++++-------- dlls/gdiplus/matrix.c | 5 +-- dlls/gdiplus/metafile.c | 10 +---- dlls/gdiplus/region.c | 12 +----- 7 files changed, 40 insertions(+), 104 deletions(-)
diff --git a/dlls/gdiplus/brush.c b/dlls/gdiplus/brush.c index d0da60df3a8..dc8ac7f7349 100644 --- a/dlls/gdiplus/brush.c +++ b/dlls/gdiplus/brush.c @@ -471,11 +471,7 @@ GpStatus WINGDIPAPI GdipCreateLineBrushFromRectI(GDIPCONST GpRect* rect, TRACE("(%p, %x, %x, %d, %d, %p)\n", rect, startcolor, endcolor, mode, wrap, line);
- rectF.X = (REAL) rect->X; - rectF.Y = (REAL) rect->Y; - rectF.Width = (REAL) rect->Width; - rectF.Height = (REAL) rect->Height; - + set_rect(&rectF, rect->X, rect->Y, rect->Width, rect->Height); return GdipCreateLineBrushFromRect(&rectF, startcolor, endcolor, mode, wrap, line); }
diff --git a/dlls/gdiplus/gdiplus_private.h b/dlls/gdiplus/gdiplus_private.h index b0e4d967894..f777595e810 100644 --- a/dlls/gdiplus/gdiplus_private.h +++ b/dlls/gdiplus/gdiplus_private.h @@ -618,4 +618,12 @@ static inline void image_unlock(GpImage *image, BOOL unlock) if (unlock) image->busy = 0; }
+static inline void set_rect(GpRectF *rect, REAL x, REAL y, REAL width, REAL height) +{ + rect->X = x; + rect->Y = y; + rect->Width = width; + rect->Height = height; +} + #endif diff --git a/dlls/gdiplus/graphics.c b/dlls/gdiplus/graphics.c index 4ee0430051f..9d16d7c3cdb 100644 --- a/dlls/gdiplus/graphics.c +++ b/dlls/gdiplus/graphics.c @@ -2923,10 +2923,7 @@ GpStatus WINGDIPAPI GdipDrawEllipse(GpGraphics *graphics, GpPen *pen, REAL x,
if (is_metafile_graphics(graphics)) { - rect.X = x; - rect.Y = y; - rect.Width = width; - rect.Height = height; + set_rect(&rect, x, y, width, height); return METAFILE_DrawEllipse((GpMetafile *)graphics->image, pen, &rect); }
@@ -3411,11 +3408,7 @@ GpStatus WINGDIPAPI GdipDrawImagePointsRect(GpGraphics *graphics, GpImage *image { GpRectF rc;
- rc.X = srcx; - rc.Y = srcy; - rc.Width = srcwidth; - rc.Height = srcheight; - + set_rect(&rc, srcx, srcy, srcwidth, srcheight); return GdipEnumerateMetafileSrcRectDestPoints(graphics, (GpMetafile*)image, points, count, &rc, srcUnit, play_metafile_proc, image, imageAttributes); } @@ -4092,10 +4085,7 @@ GpStatus WINGDIPAPI GdipDrawRectangle(GpGraphics *graphics, GpPen *pen, REAL x,
TRACE("(%p, %p, %.2f, %.2f, %.2f, %.2f)\n", graphics, pen, x, y, width, height);
- rect.X = x; - rect.Y = y, - rect.Width = width; - rect.Height = height; + set_rect(&rect, x, y, width, height); return GdipDrawRectangles(graphics, pen, &rect, 1); }
@@ -4151,12 +4141,8 @@ GpStatus WINGDIPAPI GdipDrawRectanglesI(GpGraphics *graphics, GpPen *pen, if(!rectsF) return OutOfMemory;
- for(i = 0;i < count;i++){ - rectsF[i].X = (REAL)rects[i].X; - rectsF[i].Y = (REAL)rects[i].Y; - rectsF[i].Width = (REAL)rects[i].Width; - rectsF[i].Height = (REAL)rects[i].Height; - } + for(i = 0;i < count;i++) + set_rect(&rectsF[i], rects[i].X, rects[i].Y, rects[i].Width, rects[i].Height);
ret = GdipDrawRectangles(graphics, pen, rectsF, count); heap_free(rectsF); @@ -4246,6 +4232,7 @@ GpStatus WINGDIPAPI GdipFillEllipse(GpGraphics *graphics, GpBrush *brush, REAL x { GpStatus stat; GpPath *path; + GpRectF rect;
TRACE("(%p, %p, %.2f, %.2f, %.2f, %.2f)\n", graphics, brush, x, y, width, height);
@@ -4257,12 +4244,7 @@ GpStatus WINGDIPAPI GdipFillEllipse(GpGraphics *graphics, GpBrush *brush, REAL x
if (is_metafile_graphics(graphics)) { - GpRectF rect; - - rect.X = x; - rect.Y = y; - rect.Width = width; - rect.Height = height; + set_rect(&rect, x, y, width, height); return METAFILE_FillEllipse((GpMetafile *)graphics->image, brush, &rect); }
@@ -4404,10 +4386,7 @@ GpStatus WINGDIPAPI GdipFillPie(GpGraphics *graphics, GpBrush *brush, REAL x,
if (is_metafile_graphics(graphics)) { - rect.X = x; - rect.Y = y; - rect.Width = width; - rect.Height = height; + set_rect(&rect, x, y, width, height); return METAFILE_FillPie((GpMetafile *)graphics->image, brush, &rect, startAngle, sweepAngle); }
@@ -4516,11 +4495,7 @@ GpStatus WINGDIPAPI GdipFillRectangle(GpGraphics *graphics, GpBrush *brush,
TRACE("(%p, %p, %.2f, %.2f, %.2f, %.2f)\n", graphics, brush, x, y, width, height);
- rect.X = x; - rect.Y = y; - rect.Width = width; - rect.Height = height; - + set_rect(&rect, x, y, width, height); return GdipFillRectangles(graphics, brush, &rect, 1); }
@@ -4531,11 +4506,7 @@ GpStatus WINGDIPAPI GdipFillRectangleI(GpGraphics *graphics, GpBrush *brush,
TRACE("(%p, %p, %d, %d, %d, %d)\n", graphics, brush, x, y, width, height);
- rect.X = (REAL)x; - rect.Y = (REAL)y; - rect.Width = (REAL)width; - rect.Height = (REAL)height; - + set_rect(&rect, x, y, width, height); return GdipFillRectangles(graphics, brush, &rect, 1); }
@@ -4584,12 +4555,8 @@ GpStatus WINGDIPAPI GdipFillRectanglesI(GpGraphics *graphics, GpBrush *brush, GD if(!rectsF) return OutOfMemory;
- for(i = 0; i < count; i++){ - rectsF[i].X = (REAL)rects[i].X; - rectsF[i].Y = (REAL)rects[i].Y; - rectsF[i].Width = (REAL)rects[i].Width; - rectsF[i].Height = (REAL)rects[i].Height; - } + for(i = 0; i < count; i++) + set_rect(&rectsF[i], rects[i].X, rects[i].Y, rects[i].Width, rects[i].Height);
ret = GdipFillRectangles(graphics,brush,rectsF,count); heap_free(rectsF); @@ -5620,10 +5587,7 @@ GpStatus WINGDIPAPI GdipMeasureString(GpGraphics *graphics, get_font_hfont(graphics, font, format, &gdifont, NULL, NULL); oldfont = SelectObject(hdc, gdifont);
- bounds->X = rect->X; - bounds->Y = rect->Y; - bounds->Width = 0.0; - bounds->Height = 0.0; + set_rect(bounds, rect->X, rect->Y, 0.0f, 0.0f);
args.bounds = bounds; args.codepointsfitted = &glyphs; @@ -6502,10 +6466,7 @@ GpStatus WINGDIPAPI GdipSetClipRect(GpGraphics *graphics, REAL x, REAL y, return status; }
- rect.X = x; - rect.Y = y; - rect.Width = width; - rect.Height = height; + set_rect(&rect, x, y, width, height); status = GdipCreateRegionRect(&rect, ®ion); if (status == Ok) { @@ -7098,12 +7059,7 @@ GpStatus WINGDIPAPI GdipMeasureDriverString(GpGraphics *graphics, GDIPCONST UINT length = lstrlenW(text);
if (length == 0) - { - boundingBox->X = 0.0; - boundingBox->Y = 0.0; - boundingBox->Width = 0.0; - boundingBox->Height = 0.0; - } + set_rect(boundingBox, 0.0f, 0.0f, 0.0f, 0.0f);
if (flags & unsupported_flags) FIXME("Ignoring flags %x\n", flags & unsupported_flags); diff --git a/dlls/gdiplus/graphicspath.c b/dlls/gdiplus/graphicspath.c index 79e231bf1b2..ce2666eedab 100644 --- a/dlls/gdiplus/graphicspath.c +++ b/dlls/gdiplus/graphicspath.c @@ -1080,19 +1080,16 @@ GpStatus WINGDIPAPI GdipAddPathString(GpPath* path, GDIPCONST WCHAR* string, INT return status; }
-GpStatus WINGDIPAPI GdipAddPathStringI(GpPath* path, GDIPCONST WCHAR* string, INT length, GDIPCONST GpFontFamily* family, INT style, REAL emSize, GDIPCONST Rect* layoutRect, GDIPCONST GpStringFormat* format) +GpStatus WINGDIPAPI GdipAddPathStringI(GpPath* path, GDIPCONST WCHAR* string, INT length, GDIPCONST GpFontFamily* family, + INT style, REAL emSize, GDIPCONST Rect* layoutRect, GDIPCONST GpStringFormat* format) { - if (layoutRect) - { - RectF layoutRectF = { - (REAL)layoutRect->X, - (REAL)layoutRect->Y, - (REAL)layoutRect->Width, - (REAL)layoutRect->Height - }; - return GdipAddPathString(path, string, length, family, style, emSize, &layoutRectF, format); - } - return InvalidParameter; + RectF rect; + + if (!layoutRect) + return InvalidParameter; + + set_rect(&rect, layoutRect->X, layoutRect->Y, layoutRect->Width, layoutRect->Height); + return GdipAddPathString(path, string, length, family, style, emSize, &rect, format); }
/************************************************************************* @@ -2547,12 +2544,8 @@ GpStatus WINGDIPAPI GdipAddPathRectanglesI(GpPath *path, GDIPCONST GpRect *rects
rectsF = heap_alloc_zero(sizeof(GpRectF)*count);
- for(i = 0;i < count;i++){ - rectsF[i].X = (REAL)rects[i].X; - rectsF[i].Y = (REAL)rects[i].Y; - rectsF[i].Width = (REAL)rects[i].Width; - rectsF[i].Height = (REAL)rects[i].Height; - } + for(i = 0;i < count;i++) + set_rect(&rectsF[i], rects[i].X, rects[i].Y, rects[i].Width, rects[i].Height);
retstat = GdipAddPathRectangles(path, rectsF, count); heap_free(rectsF); diff --git a/dlls/gdiplus/matrix.c b/dlls/gdiplus/matrix.c index 5d8cf890079..40abbc93e21 100644 --- a/dlls/gdiplus/matrix.c +++ b/dlls/gdiplus/matrix.c @@ -111,10 +111,7 @@ GpStatus WINGDIPAPI GdipCreateMatrix3I(GDIPCONST GpRect *rect, GDIPCONST GpPoint
TRACE("(%p, %p, %p)\n", rect, pt, matrix);
- rectF.X = (REAL)rect->X; - rectF.Y = (REAL)rect->Y; - rectF.Width = (REAL)rect->Width; - rectF.Height = (REAL)rect->Height; + set_rect(&rectF, rect->X, rect->Y, rect->Width, rect->Height);
for (i = 0; i < 3; i++) { ptF[i].X = (REAL)pt[i].X; diff --git a/dlls/gdiplus/metafile.c b/dlls/gdiplus/metafile.c index a483b3a5e6d..06d1a9ccbf4 100644 --- a/dlls/gdiplus/metafile.c +++ b/dlls/gdiplus/metafile.c @@ -777,10 +777,7 @@ GpStatus WINGDIPAPI GdipRecordMetafileI(HDC hdc, EmfType type, GDIPCONST GpRect
if (frameRect) { - frameRectF.X = frameRect->X; - frameRectF.Y = frameRect->Y; - frameRectF.Width = frameRect->Width; - frameRectF.Height = frameRect->Height; + set_rect(&frameRectF, frameRect->X, frameRect->Y, frameRect->Width, frameRect->Height); pFrameRectF = &frameRectF; } else @@ -798,10 +795,7 @@ GpStatus WINGDIPAPI GdipRecordMetafileStreamI(IStream *stream, HDC hdc, EmfType
if (frameRect) { - frameRectF.X = frameRect->X; - frameRectF.Y = frameRect->Y; - frameRectF.Width = frameRect->Width; - frameRectF.Height = frameRect->Height; + set_rect(&frameRectF, frameRect->X, frameRect->Y, frameRect->Width, frameRect->Height); pFrameRectF = &frameRectF; } else diff --git a/dlls/gdiplus/region.c b/dlls/gdiplus/region.c index dcc40002836..0f14e8aae32 100644 --- a/dlls/gdiplus/region.c +++ b/dlls/gdiplus/region.c @@ -332,11 +332,7 @@ GpStatus WINGDIPAPI GdipCombineRegionRectI(GpRegion *region, if (!rect) return InvalidParameter;
- rectf.X = (REAL)rect->X; - rectf.Y = (REAL)rect->Y; - rectf.Height = (REAL)rect->Height; - rectf.Width = (REAL)rect->Width; - + set_rect(&rectf, rect->X, rect->Y, rect->Width, rect->Height); return GdipCombineRegionRect(region, &rectf, mode); }
@@ -492,11 +488,7 @@ GpStatus WINGDIPAPI GdipCreateRegionRectI(GDIPCONST GpRect *rect,
TRACE("%p, %p\n", rect, region);
- rectf.X = (REAL)rect->X; - rectf.Y = (REAL)rect->Y; - rectf.Width = (REAL)rect->Width; - rectf.Height = (REAL)rect->Height; - + set_rect(&rectf, rect->X, rect->Y, rect->Width, rect->Height); return GdipCreateRegionRect(&rectf, region); }
Signed-off-by: Esme Povirk esme@codeweavers.com
Signed-off-by: Nikolay Sivov nsivov@codeweavers.com --- dlls/gdiplus/gdiplus_private.h | 2 ++ dlls/gdiplus/graphics.c | 7 ++++++ dlls/gdiplus/metafile.c | 46 ++++++++++++++++++++++++++++++++++ 3 files changed, 55 insertions(+)
diff --git a/dlls/gdiplus/gdiplus_private.h b/dlls/gdiplus/gdiplus_private.h index f777595e810..25672530313 100644 --- a/dlls/gdiplus/gdiplus_private.h +++ b/dlls/gdiplus/gdiplus_private.h @@ -115,6 +115,8 @@ extern GpStatus METAFILE_FillEllipse(GpMetafile *metafile, GpBrush *brush, GpRec extern GpStatus METAFILE_DrawRectangles(GpMetafile *metafile, GpPen *pen, const GpRectF *rects, INT count) DECLSPEC_HIDDEN; extern GpStatus METAFILE_FillPie(GpMetafile *metafile, GpBrush *brush, const GpRectF *rect, REAL startAngle, REAL sweepAngle) DECLSPEC_HIDDEN; +extern GpStatus METAFILE_DrawArc(GpMetafile *metafile, GpPen *pen, const GpRectF *rect, + REAL startAngle, REAL sweepAngle) DECLSPEC_HIDDEN;
extern void calc_curve_bezier(const GpPointF *pts, REAL tension, REAL *x1, REAL *y1, REAL *x2, REAL *y2) DECLSPEC_HIDDEN; diff --git a/dlls/gdiplus/graphics.c b/dlls/gdiplus/graphics.c index 9d16d7c3cdb..e292afdfb2c 100644 --- a/dlls/gdiplus/graphics.c +++ b/dlls/gdiplus/graphics.c @@ -2595,6 +2595,7 @@ GpStatus WINGDIPAPI GdipDrawArc(GpGraphics *graphics, GpPen *pen, REAL x, { GpStatus status; GpPath *path; + GpRectF rect;
TRACE("(%p, %p, %.2f, %.2f, %.2f, %.2f, %.2f, %.2f)\n", graphics, pen, x, y, width, height, startAngle, sweepAngle); @@ -2605,6 +2606,12 @@ GpStatus WINGDIPAPI GdipDrawArc(GpGraphics *graphics, GpPen *pen, REAL x, if(graphics->busy) return ObjectBusy;
+ if (is_metafile_graphics(graphics)) + { + set_rect(&rect, x, y, width, height); + return METAFILE_DrawArc((GpMetafile *)graphics->image, pen, &rect, startAngle, sweepAngle); + } + status = GdipCreatePath(FillModeAlternate, &path); if (status != Ok) return status;
diff --git a/dlls/gdiplus/metafile.c b/dlls/gdiplus/metafile.c index 06d1a9ccbf4..41950eb31c7 100644 --- a/dlls/gdiplus/metafile.c +++ b/dlls/gdiplus/metafile.c @@ -5205,3 +5205,49 @@ GpStatus METAFILE_DrawRectangles(GpMetafile *metafile, GpPen *pen, const GpRectF
return Ok; } + +GpStatus METAFILE_DrawArc(GpMetafile *metafile, GpPen *pen, const GpRectF *rect, REAL startAngle, REAL sweepAngle) +{ + EmfPlusDrawArc *record; + GpStatus stat; + BOOL integer_rect; + DWORD pen_id; + + if (metafile->metafile_type == MetafileTypeEmf) + { + FIXME("stub!\n"); + return NotImplemented; + } + + stat = METAFILE_AddPenObject(metafile, pen, &pen_id); + if (stat != Ok) return stat; + + integer_rect = is_integer_rect(rect); + + stat = METAFILE_AllocateRecord(metafile, FIELD_OFFSET(EmfPlusDrawArc, RectData) + + integer_rect ? sizeof(record->RectData.rect) : sizeof(record->RectData.rectF), + (void **)&record); + if (stat != Ok) + return stat; + + record->Header.Type = EmfPlusRecordTypeDrawArc; + record->Header.Flags = pen_id; + if (integer_rect) + record->Header.Flags |= 0x4000; + record->StartAngle = startAngle; + record->SweepAngle = sweepAngle; + + if (integer_rect) + { + record->RectData.rect.X = (SHORT)rect->X; + record->RectData.rect.Y = (SHORT)rect->Y; + record->RectData.rect.Width = (SHORT)rect->Width; + record->RectData.rect.Height = (SHORT)rect->Height; + } + else + memcpy(&record->RectData.rectF, rect, sizeof(*rect)); + + METAFILE_WriteRecords(metafile); + + return Ok; +}
Signed-off-by: Esme Povirk esme@codeweavers.com