gdiplus/metafile: Implement DrawEllipse() recording.

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-18 15:18:00 +03:00 committed by Alexandre Julliard
parent e2189f588f
commit 4e55ec2b9e
4 changed files with 103 additions and 0 deletions

View File

@ -110,6 +110,7 @@ extern GpStatus METAFILE_DrawDriverString(GpMetafile *metafile, GDIPCONST UINT16
extern GpStatus METAFILE_FillRegion(GpMetafile* metafile, GpBrush* brush,
GpRegion* region) DECLSPEC_HIDDEN;
extern void METAFILE_Free(GpMetafile *metafile) DECLSPEC_HIDDEN;
extern GpStatus METAFILE_DrawEllipse(GpMetafile *metafile, GpPen *pen, GpRectF *rect) DECLSPEC_HIDDEN;
extern void calc_curve_bezier(const GpPointF *pts, REAL tension, REAL *x1,
REAL *y1, REAL *x2, REAL *y2) DECLSPEC_HIDDEN;

View File

@ -2906,6 +2906,7 @@ GpStatus WINGDIPAPI GdipDrawEllipse(GpGraphics *graphics, GpPen *pen, REAL x,
{
GpPath *path;
GpStatus status;
GpRectF rect;
TRACE("(%p, %p, %.2f, %.2f, %.2f, %.2f)\n", graphics, pen, x, y, width, height);
@ -2915,6 +2916,15 @@ GpStatus WINGDIPAPI GdipDrawEllipse(GpGraphics *graphics, GpPen *pen, REAL x,
if(graphics->busy)
return ObjectBusy;
if (graphics->image && graphics->image->type == ImageTypeMetafile)
{
rect.X = x;
rect.Y = y;
rect.Width = width;
rect.Height = height;
return METAFILE_DrawEllipse((GpMetafile *)graphics->image, pen, &rect);
}
status = GdipCreatePath(FillModeAlternate, &path);
if (status != Ok) return status;

View File

@ -4774,6 +4774,40 @@ GpStatus METAFILE_DrawPath(GpMetafile *metafile, GpPen *pen, GpPath *path)
return Ok;
}
GpStatus METAFILE_DrawEllipse(GpMetafile *metafile, GpPen *pen, GpRectF *rect)
{
EmfPlusDrawEllipse *record;
GpStatus stat;
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;
stat = METAFILE_AllocateRecord(metafile, sizeof(EmfPlusDrawEllipse), (void **)&record);
if (stat != Ok) return stat;
record->Header.Type = EmfPlusRecordTypeDrawEllipse;
record->Header.Flags = pen_id;
if (is_integer_rect(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;
}
GpStatus METAFILE_FillPath(GpMetafile *metafile, GpBrush *brush, GpPath *path)
{
EmfPlusFillPath *fill_path_record;

View File

@ -3536,6 +3536,63 @@ static void test_printer_dc(void)
GdipDisposeImage((GpImage *)metafile);
}
static const emfplus_record draw_ellipse_records[] =
{
{ EMR_HEADER },
{ EmfPlusRecordTypeHeader },
{ EmfPlusRecordTypeObject, ObjectTypePen << 8 },
{ EmfPlusRecordTypeDrawEllipse, 0x4000 },
{ EMR_SAVEDC, 0, 1 },
{ EMR_SETICMMODE, 0, 1 },
{ EMR_BITBLT, 0, 1 },
{ EMR_RESTOREDC, 0, 1 },
{ EmfPlusRecordTypeEndOfFile },
{ EMR_EOF },
{ 0 }
};
static void test_drawellipse(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 = GdipDrawEllipse(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_ellipse.emf");
stat = GdipGetHemfFromMetafile(metafile, &hemf);
expect(Ok, stat);
check_emfplus(hemf, draw_ellipse_records, "draw ellipse");
DeleteEnhMetaFile(hemf);
stat = GdipDisposeImage((GpImage*)metafile);
expect(Ok, stat);
}
START_TEST(metafile)
{
struct GdiplusStartupInput gdiplusStartupInput;
@ -3590,6 +3647,7 @@ START_TEST(metafile)
test_fillregion();
test_lineargradient();
test_printer_dc();
test_drawellipse();
GdiplusShutdown(gdiplusToken);
}