Module: wine Branch: master Commit: a65718a3e7b95443a82dafd5d2c9cded961404a6 URL: http://source.winehq.org/git/wine.git/?a=commit;h=a65718a3e7b95443a82dafd5d2...
Author: Vincent Povirk vincent@codeweavers.com Date: Wed Aug 3 16:19:38 2016 -0500
gdiplus: Implement ResetWorldTransform metafile playback/recording.
Signed-off-by: Vincent Povirk vincent@codeweavers.com Signed-off-by: Alexandre Julliard julliard@winehq.org
---
dlls/gdiplus/gdiplus_private.h | 1 + dlls/gdiplus/graphics.c | 9 +++++++++ dlls/gdiplus/metafile.c | 28 ++++++++++++++++++++++++++++ dlls/gdiplus/tests/metafile.c | 26 ++++++++++++++++++++++++++ 4 files changed, 64 insertions(+)
diff --git a/dlls/gdiplus/gdiplus_private.h b/dlls/gdiplus/gdiplus_private.h index e4056b4..3eebaed 100644 --- a/dlls/gdiplus/gdiplus_private.h +++ b/dlls/gdiplus/gdiplus_private.h @@ -91,6 +91,7 @@ extern GpStatus METAFILE_FillRectangles(GpMetafile* metafile, GpBrush* brush, GDIPCONST GpRectF* rects, INT count) DECLSPEC_HIDDEN; extern GpStatus METAFILE_SetPageTransform(GpMetafile* metafile, GpUnit unit, REAL scale) DECLSPEC_HIDDEN; extern GpStatus METAFILE_ScaleWorldTransform(GpMetafile* metafile, REAL sx, REAL sy, MatrixOrder order) DECLSPEC_HIDDEN; +extern GpStatus METAFILE_ResetWorldTransform(GpMetafile* metafile) DECLSPEC_HIDDEN; extern GpStatus METAFILE_GraphicsDeleted(GpMetafile* metafile) DECLSPEC_HIDDEN;
extern void calc_curve_bezier(const GpPointF *pts, REAL tension, REAL *x1, diff --git a/dlls/gdiplus/graphics.c b/dlls/gdiplus/graphics.c index febb60d..6003a19 100644 --- a/dlls/gdiplus/graphics.c +++ b/dlls/gdiplus/graphics.c @@ -5128,6 +5128,8 @@ GpStatus WINGDIPAPI GdipResetClip(GpGraphics *graphics)
GpStatus WINGDIPAPI GdipResetWorldTransform(GpGraphics *graphics) { + GpStatus stat; + TRACE("(%p)\n", graphics);
if(!graphics) @@ -5136,6 +5138,13 @@ GpStatus WINGDIPAPI GdipResetWorldTransform(GpGraphics *graphics) if(graphics->busy) return ObjectBusy;
+ if (graphics->image && graphics->image->type == ImageTypeMetafile) { + stat = METAFILE_ResetWorldTransform((GpMetafile*)graphics->image); + + if (stat != Ok) + return stat; + } + return GdipSetMatrixElements(&graphics->worldtrans, 1.0, 0.0, 0.0, 1.0, 0.0, 0.0); }
diff --git a/dlls/gdiplus/metafile.c b/dlls/gdiplus/metafile.c index 09ecd39..f0c0bd1 100644 --- a/dlls/gdiplus/metafile.c +++ b/dlls/gdiplus/metafile.c @@ -586,6 +586,28 @@ GpStatus METAFILE_ScaleWorldTransform(GpMetafile* metafile, REAL sx, REAL sy, Ma return Ok; }
+GpStatus METAFILE_ResetWorldTransform(GpMetafile* metafile) +{ + if (metafile->metafile_type == MetafileTypeEmfPlusOnly || metafile->metafile_type == MetafileTypeEmfPlusDual) + { + EmfPlusRecordHeader *record; + GpStatus stat; + + stat = METAFILE_AllocateRecord(metafile, + sizeof(EmfPlusRecordHeader), + (void**)&record); + if (stat != Ok) + return stat; + + record->Type = EmfPlusRecordTypeResetWorldTransform; + record->Flags = 0; + + METAFILE_WriteRecords(metafile); + } + + return Ok; +} + GpStatus METAFILE_ReleaseDC(GpMetafile* metafile, HDC hdc) { if (hdc != metafile->record_dc) @@ -935,6 +957,12 @@ GpStatus WINGDIPAPI GdipPlayMetafileRecord(GDIPCONST GpMetafile *metafile,
return METAFILE_PlaybackUpdateWorldTransform(real_metafile); } + case EmfPlusRecordTypeResetWorldTransform: + { + GdipSetMatrixElements(real_metafile->world_transform, 1.0, 0.0, 0.0, 1.0, 0.0, 0.0); + + return METAFILE_PlaybackUpdateWorldTransform(real_metafile); + } default: FIXME("Not implemented for record type %x\n", recordType); return NotImplemented; diff --git a/dlls/gdiplus/tests/metafile.c b/dlls/gdiplus/tests/metafile.c index 354e880..e514eb5 100644 --- a/dlls/gdiplus/tests/metafile.c +++ b/dlls/gdiplus/tests/metafile.c @@ -1273,6 +1273,8 @@ static const emfplus_record worldtransform_records[] = { {0, EmfPlusRecordTypeFillRects}, {0, EmfPlusRecordTypeScaleWorldTransform}, {0, EmfPlusRecordTypeFillRects}, + {0, EmfPlusRecordTypeResetWorldTransform}, + {0, EmfPlusRecordTypeFillRects}, {0, EmfPlusRecordTypeEndOfFile}, {0, EMR_EOF}, {0} @@ -1352,6 +1354,26 @@ static void test_worldtransform(void) stat = GdipDeleteBrush(brush); expect(Ok, stat);
+ /* reset transform */ + stat = GdipResetWorldTransform(graphics); + expect(Ok, stat); + + stat = GdipGetWorldTransform(graphics, transform); + expect(Ok, stat); + + stat = GdipIsMatrixIdentity(transform, &identity); + expect(Ok, stat); + expect(TRUE, identity); + + stat = GdipCreateSolidFill((ARGB)0xff00ffff, (GpSolidFill**)&brush); + expect(Ok, stat); + + stat = GdipFillRectangle(graphics, brush, 1.0, 0.0, 1.0, 1.0); + expect(Ok, stat); + + stat = GdipDeleteBrush(brush); + expect(Ok, stat); + stat = GdipDeleteMatrix(transform); expect(Ok, stat);
@@ -1382,6 +1404,10 @@ static void test_worldtransform(void) expect(Ok, stat); expect(0xff00ff00, color);
+ stat = GdipBitmapGetPixel(bitmap, 30, 10, &color); + expect(Ok, stat); + expect(0xff00ffff, color); + stat = GdipDeleteGraphics(graphics); expect(Ok, stat);