gdiplus: Forward GdipDrawRectangle() to GdipDrawRectangles().

Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
Signed-off-by: Esme Povirk <esme@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Nikolay Sivov 2021-03-23 19:08:13 +03:00 committed by Alexandre Julliard
parent 9b04f1c660
commit 41651d2e16
2 changed files with 64 additions and 17 deletions

View File

@ -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,

View File

@ -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);
}