[PATCH 2/4] gdiplus: Forward GdipDrawRectangle() to GdipDrawRectangles().
Nikolay Sivov
nsivov at codeweavers.com
Tue Mar 23 11:08:13 CDT 2021
Signed-off-by: Nikolay Sivov <nsivov at 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);
}
--
2.30.2
More information about the wine-devel
mailing list