Signed-off-by: Nikolay Sivov nsivov@codeweavers.com --- dlls/gdiplus/gdiplus_private.h | 1 + dlls/gdiplus/graphics.c | 10 ++++++ dlls/gdiplus/metafile.c | 34 ++++++++++++++++++++ dlls/gdiplus/tests/metafile.c | 58 ++++++++++++++++++++++++++++++++++ 4 files changed, 103 insertions(+)
diff --git a/dlls/gdiplus/gdiplus_private.h b/dlls/gdiplus/gdiplus_private.h index 4bca5b13be9..0b6dfb69b07 100644 --- a/dlls/gdiplus/gdiplus_private.h +++ b/dlls/gdiplus/gdiplus_private.h @@ -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; diff --git a/dlls/gdiplus/graphics.c b/dlls/gdiplus/graphics.c index 7b4794e3620..b2d0e6bf59b 100644 --- a/dlls/gdiplus/graphics.c +++ b/dlls/gdiplus/graphics.c @@ -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;
diff --git a/dlls/gdiplus/metafile.c b/dlls/gdiplus/metafile.c index 5ff6b113c3d..3e7853ecd50 100644 --- a/dlls/gdiplus/metafile.c +++ b/dlls/gdiplus/metafile.c @@ -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; diff --git a/dlls/gdiplus/tests/metafile.c b/dlls/gdiplus/tests/metafile.c index 60659bf3119..fede802b675 100644 --- a/dlls/gdiplus/tests/metafile.c +++ b/dlls/gdiplus/tests/metafile.c @@ -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); }
Signed-off-by: Nikolay Sivov nsivov@codeweavers.com --- dlls/gdiplus/gdiplus_private.h | 1 + dlls/gdiplus/graphics.c | 11 +++++++ dlls/gdiplus/metafile.c | 46 +++++++++++++++++++++++++++ dlls/gdiplus/tests/metafile.c | 58 ++++++++++++++++++++++++++++++++++ 4 files changed, 116 insertions(+)
diff --git a/dlls/gdiplus/gdiplus_private.h b/dlls/gdiplus/gdiplus_private.h index 0b6dfb69b07..9b608035909 100644 --- a/dlls/gdiplus/gdiplus_private.h +++ b/dlls/gdiplus/gdiplus_private.h @@ -111,6 +111,7 @@ 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 GpStatus METAFILE_FillEllipse(GpMetafile *metafile, GpBrush *brush, GpRectF *rect) 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 b2d0e6bf59b..97dfc4a75f2 100644 --- a/dlls/gdiplus/graphics.c +++ b/dlls/gdiplus/graphics.c @@ -4258,6 +4258,17 @@ GpStatus WINGDIPAPI GdipFillEllipse(GpGraphics *graphics, GpBrush *brush, REAL x if(graphics->busy) return ObjectBusy;
+ if (graphics->image && graphics->image->type == ImageTypeMetafile) + { + GpRectF rect; + + rect.X = x; + rect.Y = y; + rect.Width = width; + rect.Height = height; + return METAFILE_FillEllipse((GpMetafile *)graphics->image, brush, &rect); + } + stat = GdipCreatePath(FillModeAlternate, &path);
if (stat == Ok) diff --git a/dlls/gdiplus/metafile.c b/dlls/gdiplus/metafile.c index 3e7853ecd50..c285dc58f40 100644 --- a/dlls/gdiplus/metafile.c +++ b/dlls/gdiplus/metafile.c @@ -4850,6 +4850,52 @@ GpStatus METAFILE_FillPath(GpMetafile *metafile, GpBrush *brush, GpPath *path) return Ok; }
+GpStatus METAFILE_FillEllipse(GpMetafile *metafile, GpBrush *brush, GpRectF *rect) +{ + EmfPlusFillEllipse *record; + DWORD brush_id = -1; + BOOL inline_color; + 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; + } + + stat = METAFILE_AllocateRecord(metafile, sizeof(EmfPlusFillEllipse), (void **)&record); + if (stat != Ok) return stat; + record->Header.Type = EmfPlusRecordTypeFillEllipse; + if (inline_color) + { + record->Header.Flags = 0x8000; + record->BrushId = ((GpSolidFill *)brush)->color; + } + else + record->BrushId = brush_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; +} + static GpStatus METAFILE_AddFontObject(GpMetafile *metafile, GDIPCONST GpFont *font, DWORD *id) { EmfPlusObject *object_record; diff --git a/dlls/gdiplus/tests/metafile.c b/dlls/gdiplus/tests/metafile.c index fede802b675..410e9a6ab8c 100644 --- a/dlls/gdiplus/tests/metafile.c +++ b/dlls/gdiplus/tests/metafile.c @@ -3593,6 +3593,63 @@ static void test_drawellipse(void) expect(Ok, stat); }
+static const emfplus_record fill_ellipse_records[] = +{ + { EMR_HEADER }, + { EmfPlusRecordTypeHeader }, + { EmfPlusRecordTypeFillEllipse, 0xc000 }, + { EMR_SAVEDC, 0, 1 }, + { EMR_SETICMMODE, 0, 1 }, + { EMR_BITBLT, 0, 1 }, + { EMR_RESTOREDC, 0, 1 }, + { EmfPlusRecordTypeEndOfFile }, + { EMR_EOF }, + { 0 } +}; + +static void test_fillellipse(void) +{ + static const GpRectF frame = { 0.0f, 0.0f, 100.0f, 100.0f }; + + GpMetafile *metafile; + GpGraphics *graphics; + GpSolidFill *brush; + HENHMETAFILE hemf; + GpStatus stat; + 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 = GdipCreateSolidFill(0xffaabbcc, &brush); + expect(Ok, stat); + + stat = GdipFillEllipse(graphics, (GpBrush *)brush, 0.0f, 0.0f, 10.0f, 20.0f); + expect(Ok, stat); + + stat = GdipDeleteBrush((GpBrush*)brush); + expect(Ok, stat); + + stat = GdipDeleteGraphics(graphics); + expect(Ok, stat); + sync_metafile(&metafile, "fill_ellipse.emf"); + + stat = GdipGetHemfFromMetafile(metafile, &hemf); + expect(Ok, stat); + + check_emfplus(hemf, fill_ellipse_records, "fill ellipse"); + + DeleteEnhMetaFile(hemf); + + stat = GdipDisposeImage((GpImage*)metafile); + expect(Ok, stat); +} + START_TEST(metafile) { struct GdiplusStartupInput gdiplusStartupInput; @@ -3648,6 +3705,7 @@ START_TEST(metafile) test_lineargradient(); test_printer_dc(); test_drawellipse(); + test_fillellipse();
GdiplusShutdown(gdiplusToken); }
Signed-off-by: Esme Povirk esme@codeweavers.com
Signed-off-by: Nikolay Sivov nsivov@codeweavers.com --- dlls/gdiplus/graphics.c | 78 +++++++++++++++++++++++------------------ dlls/gdiplus/image.c | 1 + 2 files changed, 44 insertions(+), 35 deletions(-)
diff --git a/dlls/gdiplus/graphics.c b/dlls/gdiplus/graphics.c index 97dfc4a75f2..c2c116acf94 100644 --- a/dlls/gdiplus/graphics.c +++ b/dlls/gdiplus/graphics.c @@ -114,6 +114,11 @@ static COLORREF get_gdi_brush_color(const GpBrush *brush) return ARGB2COLORREF(argb); }
+static BOOL is_metafile_graphics(const GpGraphics *graphics) +{ + return graphics->image && graphics->image_type == ImageTypeMetafile; +} + static ARGB blend_colors(ARGB start, ARGB end, REAL position);
static void init_hatch_palette(ARGB *hatch_palette, ARGB fore_color, ARGB back_color) @@ -556,7 +561,7 @@ static GpStatus alpha_blend_pixels_hrgn(GpGraphics *graphics, INT dst_x, INT dst
return stat; } - else if (graphics->image && graphics->image->type == ImageTypeMetafile) + else if (is_metafile_graphics(graphics)) { ERR("This should not be used for metafiles; fix caller\n"); return NotImplemented; @@ -2241,7 +2246,7 @@ static GpStatus get_visible_clip_region(GpGraphics *graphics, GpRegion *rgn) GpRegion* tmp;
/* Ignore graphics image bounds for metafiles */ - if (graphics->image && graphics->image_type == ImageTypeMetafile) + if (is_metafile_graphics(graphics)) return GdipCombineRegionRegion(rgn, graphics->clip, CombineModeReplace);
if((stat = get_graphics_bounds(graphics, &rectf)) != Ok) @@ -2550,7 +2555,7 @@ GpStatus WINGDIPAPI GdipDeleteGraphics(GpGraphics *graphics) if(!graphics) return InvalidParameter; if(graphics->busy) return ObjectBusy;
- if (graphics->image && graphics->image_type == ImageTypeMetafile) + if (is_metafile_graphics(graphics)) { stat = METAFILE_GraphicsDeleted((GpMetafile*)graphics->image); if (stat != Ok) @@ -2916,7 +2921,7 @@ GpStatus WINGDIPAPI GdipDrawEllipse(GpGraphics *graphics, GpPen *pen, REAL x, if(graphics->busy) return ObjectBusy;
- if (graphics->image && graphics->image->type == ImageTypeMetafile) + if (is_metafile_graphics(graphics)) { rect.X = x; rect.Y = y; @@ -3069,7 +3074,7 @@ GpStatus WINGDIPAPI GdipDrawImagePointsRect(GpGraphics *graphics, GpImage *image TRACE("%s %s %s\n", debugstr_pointf(&points[0]), debugstr_pointf(&points[1]), debugstr_pointf(&points[2]));
- if (graphics->image && graphics->image->type == ImageTypeMetafile) + if (is_metafile_graphics(graphics)) { return METAFILE_DrawImagePointsRect((GpMetafile*)graphics->image, image, points, count, srcx, srcy, srcwidth, srcheight, @@ -4035,7 +4040,7 @@ GpStatus WINGDIPAPI GdipDrawPath(GpGraphics *graphics, GpPen *pen, GpPath *path) if (path->pathdata.Count == 0) return Ok;
- if (graphics->image && graphics->image->type == ImageTypeMetafile) + if (is_metafile_graphics(graphics)) retval = METAFILE_DrawPath((GpMetafile*)graphics->image, pen, path); else if (!graphics->hdc || graphics->alpha_hdc || !brush_can_fill_path(pen->brush, FALSE)) retval = SOFTWARE_GdipDrawPath(graphics, pen, path); @@ -4258,7 +4263,7 @@ GpStatus WINGDIPAPI GdipFillEllipse(GpGraphics *graphics, GpBrush *brush, REAL x if(graphics->busy) return ObjectBusy;
- if (graphics->image && graphics->image->type == ImageTypeMetafile) + if (is_metafile_graphics(graphics)) { GpRectF rect;
@@ -4371,7 +4376,7 @@ GpStatus WINGDIPAPI GdipFillPath(GpGraphics *graphics, GpBrush *brush, GpPath *p if (!path->pathdata.Count) return Ok;
- if (graphics->image && graphics->image->type == ImageTypeMetafile) + if (is_metafile_graphics(graphics)) return METAFILE_FillPath((GpMetafile*)graphics->image, brush, path);
if (!graphics->image && !graphics->alpha_hdc) @@ -4543,7 +4548,7 @@ GpStatus WINGDIPAPI GdipFillRectangles(GpGraphics *graphics, GpBrush *brush, GDI if(!graphics || !brush || !rects || count <= 0) return InvalidParameter;
- if (graphics->image && graphics->image->type == ImageTypeMetafile) + if (is_metafile_graphics(graphics)) { status = METAFILE_FillRectangles((GpMetafile*)graphics->image, brush, rects, count); /* FIXME: Add gdi32 drawing. */ @@ -4736,7 +4741,7 @@ GpStatus WINGDIPAPI GdipFillRegion(GpGraphics* graphics, GpBrush* brush, if(graphics->busy) return ObjectBusy;
- if (graphics->image && graphics->image->type == ImageTypeMetafile) + if (is_metafile_graphics(graphics)) stat = METAFILE_FillRegion((GpMetafile*)graphics->image, brush, region); else { @@ -5076,7 +5081,7 @@ GpStatus WINGDIPAPI GdipGraphicsClear(GpGraphics *graphics, ARGB color) if(graphics->busy) return ObjectBusy;
- if (graphics->image && graphics->image->type == ImageTypeMetafile) + if (is_metafile_graphics(graphics)) return METAFILE_GraphicsClear((GpMetafile*)graphics->image, color);
if((stat = GdipCreateSolidFill(color, &brush)) != Ok) @@ -5854,7 +5859,8 @@ GpStatus WINGDIPAPI GdipResetWorldTransform(GpGraphics *graphics) if(graphics->busy) return ObjectBusy;
- if (graphics->image && graphics->image->type == ImageTypeMetafile) { + if (is_metafile_graphics(graphics)) + { stat = METAFILE_ResetWorldTransform((GpMetafile*)graphics->image);
if (stat != Ok) @@ -5877,7 +5883,8 @@ GpStatus WINGDIPAPI GdipRotateWorldTransform(GpGraphics *graphics, REAL angle, if(graphics->busy) return ObjectBusy;
- if (graphics->image && graphics->image->type == ImageTypeMetafile) { + if (is_metafile_graphics(graphics)) + { stat = METAFILE_RotateWorldTransform((GpMetafile*)graphics->image, angle, order);
if (stat != Ok) @@ -5903,7 +5910,7 @@ static GpStatus begin_container(GpGraphics *graphics, list_add_head(&graphics->containers, &container->entry); *state = graphics->contid = container->contid;
- if (graphics->image && graphics->image->type == ImageTypeMetafile) { + if (is_metafile_graphics(graphics)) { if (type == BEGIN_CONTAINER) METAFILE_BeginContainerNoParams((GpMetafile*)graphics->image, container->contid); else @@ -5963,9 +5970,8 @@ GpStatus WINGDIPAPI GdipBeginContainer(GpGraphics *graphics, GDIPCONST GpRectF *
GdipMultiplyMatrix(&graphics->worldtrans, &transform, MatrixOrderPrepend);
- if (graphics->image && graphics->image->type == ImageTypeMetafile) { + if (is_metafile_graphics(graphics)) METAFILE_BeginContainer((GpMetafile*)graphics->image, dstrect, srcrect, unit, container->contid); - }
return Ok; } @@ -6031,7 +6037,7 @@ static GpStatus end_container(GpGraphics *graphics, GraphicsContainerType type, list_remove(&container->entry); delete_container(container);
- if (graphics->image && graphics->image->type == ImageTypeMetafile) { + if (is_metafile_graphics(graphics)) { if (type == BEGIN_CONTAINER) METAFILE_EndContainer((GpMetafile*)graphics->image, state); else @@ -6066,7 +6072,7 @@ GpStatus WINGDIPAPI GdipScaleWorldTransform(GpGraphics *graphics, REAL sx, if(graphics->busy) return ObjectBusy;
- if (graphics->image && graphics->image->type == ImageTypeMetafile) { + if (is_metafile_graphics(graphics)) { stat = METAFILE_ScaleWorldTransform((GpMetafile*)graphics->image, sx, sy, order);
if (stat != Ok) @@ -6101,7 +6107,7 @@ GpStatus WINGDIPAPI GdipSetCompositingMode(GpGraphics *graphics, if(graphics->compmode == mode) return Ok;
- if(graphics->image && graphics->image->type == ImageTypeMetafile) + if (is_metafile_graphics(graphics)) { GpStatus stat;
@@ -6130,7 +6136,7 @@ GpStatus WINGDIPAPI GdipSetCompositingQuality(GpGraphics *graphics, if(graphics->compqual == quality) return Ok;
- if(graphics->image && graphics->image->type == ImageTypeMetafile) + if (is_metafile_graphics(graphics)) { GpStatus stat;
@@ -6165,7 +6171,7 @@ GpStatus WINGDIPAPI GdipSetInterpolationMode(GpGraphics *graphics, if (mode == graphics->interpolation) return Ok;
- if (graphics->image && graphics->image->type == ImageTypeMetafile) + if (is_metafile_graphics(graphics)) { GpStatus stat;
@@ -6192,7 +6198,7 @@ GpStatus WINGDIPAPI GdipSetPageScale(GpGraphics *graphics, REAL scale) if(graphics->busy) return ObjectBusy;
- if (graphics->image && graphics->image->type == ImageTypeMetafile) + if (is_metafile_graphics(graphics)) { stat = METAFILE_SetPageTransform((GpMetafile*)graphics->image, graphics->unit, scale); if (stat != Ok) @@ -6219,7 +6225,7 @@ GpStatus WINGDIPAPI GdipSetPageUnit(GpGraphics *graphics, GpUnit unit) if(unit == UnitWorld) return InvalidParameter;
- if (graphics->image && graphics->image->type == ImageTypeMetafile) + if (is_metafile_graphics(graphics)) { stat = METAFILE_SetPageTransform((GpMetafile*)graphics->image, unit, graphics->scale); if (stat != Ok) @@ -6245,7 +6251,7 @@ GpStatus WINGDIPAPI GdipSetPixelOffsetMode(GpGraphics *graphics, PixelOffsetMode if(graphics->pixeloffset == mode) return Ok;
- if(graphics->image && graphics->image->type == ImageTypeMetafile) + if (is_metafile_graphics(graphics)) { GpStatus stat;
@@ -6299,7 +6305,8 @@ GpStatus WINGDIPAPI GdipSetSmoothingMode(GpGraphics *graphics, SmoothingMode mod if(graphics->smoothing == mode) return Ok;
- if(graphics->image && graphics->image->type == ImageTypeMetafile) { + if (is_metafile_graphics(graphics)) + { GpStatus stat; BOOL antialias = (mode != SmoothingModeDefault && mode != SmoothingModeNone && mode != SmoothingModeHighSpeed); @@ -6308,7 +6315,7 @@ GpStatus WINGDIPAPI GdipSetSmoothingMode(GpGraphics *graphics, SmoothingMode mod EmfPlusRecordTypeSetAntiAliasMode, (mode << 1) + antialias); if(stat != Ok) return stat; - } + }
graphics->smoothing = mode;
@@ -6341,7 +6348,7 @@ GpStatus WINGDIPAPI GdipSetTextRenderingHint(GpGraphics *graphics, if(graphics->texthint == hint) return Ok;
- if(graphics->image && graphics->image->type == ImageTypeMetafile) { + if (is_metafile_graphics(graphics)) { GpStatus stat;
stat = METAFILE_AddSimpleProperty((GpMetafile*)graphics->image, @@ -6371,7 +6378,7 @@ GpStatus WINGDIPAPI GdipSetWorldTransform(GpGraphics *graphics, GpMatrix *matrix matrix->matrix[0], matrix->matrix[1], matrix->matrix[2], matrix->matrix[3], matrix->matrix[4], matrix->matrix[5]);
- if (graphics->image && graphics->image->type == ImageTypeMetafile) { + if (is_metafile_graphics(graphics)) { stat = METAFILE_SetWorldTransform((GpMetafile*)graphics->image, matrix);
if (stat != Ok) @@ -6396,7 +6403,7 @@ GpStatus WINGDIPAPI GdipTranslateWorldTransform(GpGraphics *graphics, REAL dx, if(graphics->busy) return ObjectBusy;
- if (graphics->image && graphics->image->type == ImageTypeMetafile) { + if (is_metafile_graphics(graphics)) { stat = METAFILE_TranslateWorldTransform((GpMetafile*)graphics->image, dx, dy, order);
if (stat != Ok) @@ -6486,7 +6493,7 @@ GpStatus WINGDIPAPI GdipSetClipRect(GpGraphics *graphics, REAL x, REAL y, if(graphics->busy) return ObjectBusy;
- if (graphics->image && graphics->image->type == ImageTypeMetafile) + if (is_metafile_graphics(graphics)) { status = METAFILE_SetClipRect((GpMetafile*)graphics->image, x, y, width, height, mode); if (status != Ok) @@ -6544,7 +6551,7 @@ GpStatus WINGDIPAPI GdipSetClipRegion(GpGraphics *graphics, GpRegion *region, if(graphics->busy) return ObjectBusy;
- if (graphics->image && graphics->image->type == ImageTypeMetafile) + if (is_metafile_graphics(graphics)) { status = METAFILE_SetClipRegion((GpMetafile*)graphics->image, region, mode); if (status != Ok) @@ -6661,7 +6668,8 @@ GpStatus WINGDIPAPI GdipMultiplyWorldTransform(GpGraphics *graphics, GDIPCONST G if(graphics->busy) return ObjectBusy;
- if (graphics->image && graphics->image->type == ImageTypeMetafile) { + if (is_metafile_graphics(graphics)) + { ret = METAFILE_MultiplyWorldTransform((GpMetafile*)graphics->image, matrix, order);
if (ret != Ok) @@ -6692,7 +6700,7 @@ GpStatus WINGDIPAPI GdipGetDC(GpGraphics *graphics, HDC *hdc) if(graphics->busy) return ObjectBusy;
- if (graphics->image && graphics->image->type == ImageTypeMetafile) + if (is_metafile_graphics(graphics)) { stat = METAFILE_GetDC((GpMetafile*)graphics->image, hdc); } @@ -6773,7 +6781,7 @@ GpStatus WINGDIPAPI GdipReleaseDC(GpGraphics *graphics, HDC hdc) if(!graphics || !hdc || !graphics->busy) return InvalidParameter;
- if (graphics->image && graphics->image->type == ImageTypeMetafile) + if (is_metafile_graphics(graphics)) { stat = METAFILE_ReleaseDC((GpMetafile*)graphics->image, hdc); } @@ -7489,7 +7497,7 @@ static GpStatus draw_driver_string(GpGraphics *graphics, GDIPCONST UINT16 *text, if (length == -1) length = lstrlenW(text);
- if (graphics->image && graphics->image->type == ImageTypeMetafile) + if (is_metafile_graphics(graphics)) return METAFILE_DrawDriverString((GpMetafile*)graphics->image, text, length, font, format, brush, positions, flags, matrix);
diff --git a/dlls/gdiplus/image.c b/dlls/gdiplus/image.c index 3d527801da9..552dcf83e9a 100644 --- a/dlls/gdiplus/image.c +++ b/dlls/gdiplus/image.c @@ -2239,6 +2239,7 @@ GpStatus WINGDIPAPI GdipGetImageGraphicsContext(GpImage *image, if (stat == Ok) { (*graphics)->image = image; + (*graphics)->image_type = image->type; (*graphics)->xres = image->xres; (*graphics)->yres = image->yres; }
Signed-off-by: Esme Povirk esme@codeweavers.com
Signed-off-by: Nikolay Sivov nsivov@codeweavers.com --- dlls/gdiplus/gdiplus_private.h | 1 + dlls/gdiplus/graphics.c | 3 ++ dlls/gdiplus/metafile.c | 56 ++++++++++++++++++++++++++++++++++ 3 files changed, 60 insertions(+)
diff --git a/dlls/gdiplus/gdiplus_private.h b/dlls/gdiplus/gdiplus_private.h index 9b608035909..a617ca4803e 100644 --- a/dlls/gdiplus/gdiplus_private.h +++ b/dlls/gdiplus/gdiplus_private.h @@ -112,6 +112,7 @@ extern GpStatus METAFILE_FillRegion(GpMetafile* metafile, GpBrush* brush, 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 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 c2c116acf94..2c18ced3e92 100644 --- a/dlls/gdiplus/graphics.c +++ b/dlls/gdiplus/graphics.c @@ -4132,6 +4132,9 @@ GpStatus WINGDIPAPI GdipDrawRectangles(GpGraphics *graphics, GpPen *pen, if(graphics->busy) return ObjectBusy;
+ if (is_metafile_graphics(graphics)) + return METAFILE_DrawRectangles((GpMetafile *)graphics->image, pen, rects, count); + status = GdipCreatePath(FillModeAlternate, &path); if (status != Ok) return status;
diff --git a/dlls/gdiplus/metafile.c b/dlls/gdiplus/metafile.c index c285dc58f40..eafcdaee963 100644 --- a/dlls/gdiplus/metafile.c +++ b/dlls/gdiplus/metafile.c @@ -5102,3 +5102,59 @@ GpStatus METAFILE_FillRegion(GpMetafile* metafile, GpBrush* brush, GpRegion* reg
return Ok; } + +GpStatus METAFILE_DrawRectangles(GpMetafile *metafile, GpPen *pen, const GpRectF *rects, INT count) +{ + EmfPlusDrawRects *record; + GpStatus stat; + BOOL integer_rects = TRUE; + DWORD pen_id; + int i; + + if (metafile->metafile_type == MetafileTypeEmf) + { + FIXME("stub!\n"); + return NotImplemented; + } + + stat = METAFILE_AddPenObject(metafile, pen, &pen_id); + if (stat != Ok) return stat; + + for (i = 0; i < count; i++) + { + if (!is_integer_rect(&rects[i])) + { + integer_rects = FALSE; + break; + } + } + + stat = METAFILE_AllocateRecord(metafile, FIELD_OFFSET(EmfPlusDrawRects, RectData) + + count * (integer_rects ? sizeof(record->RectData.rect) : sizeof(record->RectData.rectF)), + (void **)&record); + if (stat != Ok) + return stat; + + record->Header.Type = EmfPlusRecordTypeDrawRects; + record->Header.Flags = pen_id; + if (integer_rects) + record->Header.Flags |= 0x4000; + record->Count = count; + + if (integer_rects) + { + for (i = 0; i < count; i++) + { + record->RectData.rect[i].X = (SHORT)rects[i].X; + record->RectData.rect[i].Y = (SHORT)rects[i].Y; + record->RectData.rect[i].Width = (SHORT)rects[i].Width; + record->RectData.rect[i].Height = (SHORT)rects[i].Height; + } + } + else + memcpy(record->RectData.rectF, rects, sizeof(*rects) * count); + + METAFILE_WriteRecords(metafile); + + return Ok; +}
Signed-off-by: Esme Povirk esme@codeweavers.com