From 150abb0844ea8172c5c16f84dcfb0ca7470e7760 Mon Sep 17 00:00:00 2001 From: Dmitry Chapyshev Date: Sun, 1 Jun 2008 13:14:02 +0000 Subject: [PATCH] - Sync with Wine HEAD svn path=/trunk/; revision=33804 --- reactos/dll/win32/gdiplus/font.c | 2 +- reactos/dll/win32/gdiplus/gdiplus.spec | 24 ++++---- reactos/dll/win32/gdiplus/gdiplus_private.h | 1 + reactos/dll/win32/gdiplus/graphics.c | 45 +++++++++----- reactos/dll/win32/gdiplus/graphicspath.c | 50 +++++++++++++++ reactos/dll/win32/gdiplus/image.c | 18 ++++++ reactos/dll/win32/gdiplus/matrix.c | 10 ++- reactos/dll/win32/gdiplus/pen.c | 3 + reactos/dll/win32/gdiplus/region.c | 67 +++++++++++++++++++++ 9 files changed, 189 insertions(+), 31 deletions(-) diff --git a/reactos/dll/win32/gdiplus/font.c b/reactos/dll/win32/gdiplus/font.c index a05ef7530c3..82523cea4c6 100644 --- a/reactos/dll/win32/gdiplus/font.c +++ b/reactos/dll/win32/gdiplus/font.c @@ -68,7 +68,7 @@ GpStatus WINGDIPAPI GdipCreateFontFromLogfontA(HDC hdc, if(!lfa || !font) return InvalidParameter; - memcpy(&lfw, lfa, sizeof(LOGFONTA)); + memcpy(&lfw, lfa, FIELD_OFFSET(LOGFONTA,lfFaceName) ); if(!MultiByteToWideChar(CP_ACP, 0, lfa->lfFaceName, -1, lfw.lfFaceName, LF_FACESIZE)) return GenericError; diff --git a/reactos/dll/win32/gdiplus/gdiplus.spec b/reactos/dll/win32/gdiplus/gdiplus.spec index ec3897aede3..f2eb2b3a451 100644 --- a/reactos/dll/win32/gdiplus/gdiplus.spec +++ b/reactos/dll/win32/gdiplus/gdiplus.spec @@ -25,8 +25,8 @@ @ stub GdipAddPathPieI @ stub GdipAddPathPolygon @ stub GdipAddPathPolygonI -@ stub GdipAddPathRectangle -@ stub GdipAddPathRectangleI +@ stdcall GdipAddPathRectangle(ptr long long long long) +@ stdcall GdipAddPathRectangleI(ptr long long long long) @ stub GdipAddPathRectangles @ stub GdipAddPathRectanglesI @ stub GdipAddPathString @@ -92,7 +92,7 @@ @ stdcall GdipCreateFromHDC2(long long ptr) @ stdcall GdipCreateFromHDC(long ptr) @ stdcall GdipCreateFromHWND(long ptr) -@ stub GdipCreateFromHWNDICM +@ stdcall GdipCreateFromHWNDICM(long ptr) @ stdcall GdipCreateHBITMAPFromBitmap(ptr ptr long) @ stub GdipCreateHICONFromBitmap @ stub GdipCreateHalftonePalette @@ -122,9 +122,9 @@ @ stdcall GdipCreatePathIter(ptr ptr) @ stdcall GdipCreatePen1(long long long ptr) @ stdcall GdipCreatePen2(ptr long long ptr) -@ stub GdipCreateRegion +@ stdcall GdipCreateRegion(ptr) @ stub GdipCreateRegionHrgn -@ stub GdipCreateRegionPath +@ stdcall GdipCreateRegionPath(ptr ptr) @ stub GdipCreateRegionRect @ stub GdipCreateRegionRectI @ stub GdipCreateRegionRgnData @@ -148,7 +148,7 @@ @ stdcall GdipDeletePathIter(ptr) @ stdcall GdipDeletePen(ptr) @ stub GdipDeletePrivateFontCollection -@ stub GdipDeleteRegion +@ stdcall GdipDeleteRegion(ptr) @ stdcall GdipDeleteStringFormat(ptr) @ stdcall GdipDisposeImage(ptr) @ stdcall GdipDisposeImageAttributes(ptr) @@ -244,7 +244,7 @@ @ stdcall GdipGetBrushType(ptr ptr) @ stub GdipGetCellAscent @ stub GdipGetCellDescent -@ stub GdipGetClip +@ stdcall GdipGetClip(ptr ptr) @ stub GdipGetClipBounds @ stub GdipGetClipBoundsI @ stdcall GdipGetCompositingMode(ptr ptr) @@ -255,7 +255,7 @@ @ stub GdipGetCustomLineCapStrokeJoin @ stub GdipGetCustomLineCapType @ stub GdipGetCustomLineCapWidthScale -@ stub GdipGetDC +@ stdcall GdipGetDC(ptr ptr) @ stdcall GdipGetDpiX(ptr ptr) @ stdcall GdipGetDpiY(ptr ptr) @ stub GdipGetEffectParameterSize @@ -286,7 +286,7 @@ @ stdcall GdipGetImageDimension(ptr ptr ptr) @ stdcall GdipGetImageEncoders(long long ptr) @ stdcall GdipGetImageEncodersSize(ptr ptr) -@ stub GdipGetImageFlags +@ stdcall GdipGetImageFlags(ptr ptr) @ stdcall GdipGetImageGraphicsContext(ptr ptr) @ stdcall GdipGetImageHeight(ptr ptr) @ stdcall GdipGetImageHorizontalResolution(ptr ptr) @@ -379,7 +379,7 @@ @ stub GdipGetRegionBoundsI @ stub GdipGetRegionData @ stub GdipGetRegionDataSize -@ stub GdipGetRegionHRgn +@ stdcall GdipGetRegionHRgn(ptr ptr ptr) @ stub GdipGetRegionScans @ stub GdipGetRegionScansCount @ stub GdipGetRegionScansI @@ -436,7 +436,7 @@ @ stub GdipIsVisibleRegionRect @ stub GdipIsVisibleRegionRectI @ stdcall GdipLoadImageFromFile(wstr ptr) -@ stub GdipLoadImageFromFileICM +@ stdcall GdipLoadImageFromFileICM(wstr ptr) @ stdcall GdipLoadImageFromStream(ptr ptr) @ stdcall GdipLoadImageFromStreamICM(ptr ptr) @ stub GdipMeasureCharacterRanges @@ -472,7 +472,7 @@ @ stub GdipRecordMetafileI @ stub GdipRecordMetafileStream @ stub GdipRecordMetafileStreamI -@ stub GdipReleaseDC +@ stdcall GdipReleaseDC(ptr ptr) @ stdcall GdipRemovePropertyItem(ptr long) @ stub GdipResetClip @ stub GdipResetImageAttributes diff --git a/reactos/dll/win32/gdiplus/gdiplus_private.h b/reactos/dll/win32/gdiplus/gdiplus_private.h index 149d54019dd..d2d0373656b 100644 --- a/reactos/dll/win32/gdiplus/gdiplus_private.h +++ b/reactos/dll/win32/gdiplus/gdiplus_private.h @@ -149,6 +149,7 @@ struct GpCustomLineCap{ struct GpImage{ IPicture* picture; ImageType type; + UINT flags; }; struct GpMetafile{ diff --git a/reactos/dll/win32/gdiplus/graphics.c b/reactos/dll/win32/gdiplus/graphics.c index 37280f85580..347543f5e8e 100644 --- a/reactos/dll/win32/gdiplus/graphics.c +++ b/reactos/dll/win32/gdiplus/graphics.c @@ -797,6 +797,12 @@ GpStatus WINGDIPAPI GdipCreateFromHWND(HWND hwnd, GpGraphics **graphics) return Ok; } +/* FIXME: no icm handling */ +GpStatus WINGDIPAPI GdipCreateFromHWNDICM(HWND hwnd, GpGraphics **graphics) +{ + return GdipCreateFromHWND(hwnd, graphics); +} + GpStatus WINGDIPAPI GdipCreateMetafileFromEmf(HENHMETAFILE hemf, BOOL delete, GpMetafile **metafile) { @@ -932,22 +938,7 @@ GpStatus WINGDIPAPI GdipDrawArc(GpGraphics *graphics, GpPen *pen, REAL x, GpStatus WINGDIPAPI GdipDrawArcI(GpGraphics *graphics, GpPen *pen, INT x, INT y, INT width, INT height, REAL startAngle, REAL sweepAngle) { - INT save_state, num_pts; - GpPointF points[MAX_ARC_PTS]; - GpStatus retval; - - if(!graphics || !pen || width <= 0 || height <= 0) - return InvalidParameter; - - num_pts = arc2polybezier(points, x, y, width, height, startAngle, sweepAngle); - - save_state = prepare_dc(graphics, pen); - - retval = draw_polybezier(graphics, pen, points, num_pts, TRUE); - - restore_dc(graphics, save_state); - - return retval; + return GdipDrawArc(graphics,pen,(REAL)x,(REAL)y,(REAL)width,(REAL)height,startAngle,sweepAngle); } GpStatus WINGDIPAPI GdipDrawBezier(GpGraphics *graphics, GpPen *pen, REAL x1, @@ -2436,3 +2427,25 @@ GpStatus WINGDIPAPI GdipMultiplyWorldTransform(GpGraphics *graphics, GDIPCONST G return ret; } + +GpStatus WINGDIPAPI GdipGetDC(GpGraphics *graphics, HDC *hdc) +{ + FIXME("(%p, %p): stub\n", graphics, hdc); + + *hdc = NULL; + return NotImplemented; +} + +GpStatus WINGDIPAPI GdipReleaseDC(GpGraphics *graphics, HDC hdc) +{ + FIXME("(%p, %p): stub\n", graphics, hdc); + + return NotImplemented; +} + +GpStatus WINGDIPAPI GdipGetClip(GpGraphics *graphics, GpRegion *region) +{ + FIXME("(%p, %p): stub\n", graphics, region); + + return NotImplemented; +} diff --git a/reactos/dll/win32/gdiplus/graphicspath.c b/reactos/dll/win32/gdiplus/graphicspath.c index 84446aaed55..3b09e04f37e 100644 --- a/reactos/dll/win32/gdiplus/graphicspath.c +++ b/reactos/dll/win32/gdiplus/graphicspath.c @@ -708,3 +708,53 @@ GpStatus WINGDIPAPI GdipTransformPath(GpPath *path, GpMatrix *matrix) return GdipTransformMatrixPoints(matrix, path->pathdata.Points, path->pathdata.Count); } + +GpStatus WINGDIPAPI GdipAddPathRectangle(GpPath *path, REAL x, REAL y, + REAL width, REAL height) +{ + GpPath *backup; + GpPointF ptf[2]; + GpStatus retstat; + BOOL old_new; + + if(!path || width < 0.0 || height < 0.0) + return InvalidParameter; + + /* make a backup copy of path data */ + if((retstat = GdipClonePath(path, &backup)) != Ok) + return retstat; + + /* rectangle should start as new path */ + old_new = path->newfigure; + path->newfigure = TRUE; + if((retstat = GdipAddPathLine(path,x,y,x+width,y)) != Ok){ + path->newfigure = old_new; + goto fail; + } + + ptf[0].X = x+width; + ptf[0].Y = y+height; + ptf[1].X = x; + ptf[1].Y = y+height; + + if((retstat = GdipAddPathLine2(path,(GDIPCONST GpPointF*)&ptf,2)) != Ok) goto fail; + path->pathdata.Types[path->pathdata.Count-1] |= PathPointTypeCloseSubpath; + + /* free backup */ + GdipDeletePath(backup); + return Ok; + +fail: + /* reverting */ + GdipDeletePath(path); + GdipClonePath(backup, &path); + GdipDeletePath(backup); + + return retstat; +} + +GpStatus WINGDIPAPI GdipAddPathRectangleI(GpPath *path, INT x, INT y, + INT width, INT height) +{ + return GdipAddPathRectangle(path,(REAL)x,(REAL)y,(REAL)width,(REAL)height); +} diff --git a/reactos/dll/win32/gdiplus/image.c b/reactos/dll/win32/gdiplus/image.c index a89b6ea0b7d..72bf7f509bf 100644 --- a/reactos/dll/win32/gdiplus/image.c +++ b/reactos/dll/win32/gdiplus/image.c @@ -384,6 +384,7 @@ GpStatus WINGDIPAPI GdipCreateBitmapFromScan0(INT width, INT height, INT stride, } (*bitmap)->image.type = ImageTypeBitmap; + (*bitmap)->image.flags = ImageFlagsNone; (*bitmap)->width = width; (*bitmap)->height = height; (*bitmap)->format = format; @@ -726,6 +727,12 @@ GpStatus WINGDIPAPI GdipLoadImageFromFile(GDIPCONST WCHAR* filename, return stat; } +/* FIXME: no icm handling */ +GpStatus WINGDIPAPI GdipLoadImageFromFileICM(GDIPCONST WCHAR* filename,GpImage **image) +{ + return GdipLoadImageFromFile(filename, image); +} + GpStatus WINGDIPAPI GdipLoadImageFromStream(IStream* stream, GpImage **image) { IPicture *pic; @@ -789,6 +796,7 @@ GpStatus WINGDIPAPI GdipLoadImageFromStream(IStream* stream, GpImage **image) } (*image)->picture = pic; + (*image)->flags = ImageFlagsNone; return Ok; } @@ -1108,3 +1116,13 @@ GpStatus WINGDIPAPI GdipSetEffectParameters(CGpEffect *effect, return NotImplemented; } + +GpStatus WINGDIPAPI GdipGetImageFlags(GpImage *image, UINT *flags) +{ + if(!image || !flags) + return InvalidParameter; + + *flags = image->flags; + + return Ok; +} diff --git a/reactos/dll/win32/gdiplus/matrix.c b/reactos/dll/win32/gdiplus/matrix.c index a8617db85a2..eb8388454f0 100644 --- a/reactos/dll/win32/gdiplus/matrix.c +++ b/reactos/dll/win32/gdiplus/matrix.c @@ -244,7 +244,7 @@ GpStatus WINGDIPAPI GdipTransformMatrixPoints(GpMatrix *matrix, GpPointF *pts, REAL x, y; INT i; - if(!matrix || !pts) + if(!matrix || !pts || count <= 0) return InvalidParameter; for(i = 0; i < count; i++) @@ -265,6 +265,9 @@ GpStatus WINGDIPAPI GdipTransformMatrixPointsI(GpMatrix *matrix, GpPoint *pts, I GpStatus ret; INT i; + if(count <= 0) + return InvalidParameter; + ptsF = GdipAlloc(sizeof(GpPointF) * count); if(!ptsF) return OutOfMemory; @@ -314,7 +317,7 @@ GpStatus WINGDIPAPI GdipVectorTransformMatrixPoints(GpMatrix *matrix, GpPointF * REAL x, y; INT i; - if(!matrix || !pts) + if(!matrix || !pts || count <= 0) return InvalidParameter; for(i = 0; i < count; i++) @@ -335,6 +338,9 @@ GpStatus WINGDIPAPI GdipVectorTransformMatrixPointsI(GpMatrix *matrix, GpPoint * GpStatus ret; INT i; + if(count <= 0) + return InvalidParameter; + ptsF = GdipAlloc(sizeof(GpPointF) * count); if(!ptsF) return OutOfMemory; diff --git a/reactos/dll/win32/gdiplus/pen.c b/reactos/dll/win32/gdiplus/pen.c index 7a692e3f607..9ef14827cbf 100644 --- a/reactos/dll/win32/gdiplus/pen.c +++ b/reactos/dll/win32/gdiplus/pen.c @@ -251,6 +251,9 @@ GpStatus WINGDIPAPI GdipSetPenDashArray(GpPen *pen, GDIPCONST REAL *dash, if(!pen || !dash) return InvalidParameter; + if(count <= 0) + return OutOfMemory; + for(i = 0; i < count; i++){ sum += dash[i]; if(dash[i] < 0.0) diff --git a/reactos/dll/win32/gdiplus/region.c b/reactos/dll/win32/gdiplus/region.c index 92da5809a8d..46e99194a5f 100644 --- a/reactos/dll/win32/gdiplus/region.c +++ b/reactos/dll/win32/gdiplus/region.c @@ -30,6 +30,73 @@ WINE_DEFAULT_DEBUG_CHANNEL(gdiplus); +/********************************************************** + * + * Data returned by GdipGetRegionData (for rectangle based regions) + * looks something like this: + * + * struct region_data_header + * { + * DWORD size; size in bytes of the data - 8. + * DWORD magic1; probably a checksum. + * DWORD magic2; always seems to be 0xdbc01001 - version? + * DWORD num_ops; number of combining ops * 2 + * }; + * + * Then follows a sequence of combining ops and RECTFs. + * + * Combining ops are just stored as their CombineMode value. + * + * Each RECTF is preceded by the DWORD 0x10000000. An empty rect is + * stored as 0x10000002 (with no following RECTF) and an infinite rect + * is stored as 0x10000003 (again with no following RECTF). + * + * The combining ops are stored in the reverse order to the RECTFs and in the + * reverse order to which the region was constructed. + * + * When two or more complex regions (ie those with more than one rect) + * are combined, the combining op for the two regions comes first, + * then the combining ops for the rects in region 1, followed by the + * rects for region 1, then follows the combining ops for region 2 and + * finally region 2's rects. Presumably you're supposed to use the + * 0x10000000 rect header to find the end of the op list (the count of + * the rects in each region is not stored). + * + * When a simple region (1 rect) is combined, it's treated as if a single rect + * is being combined. + * + */ + +GpStatus WINGDIPAPI GdipCreateRegion(GpRegion **region) +{ + FIXME("(%p): stub\n", region); + + *region = NULL; + return NotImplemented; +} + +GpStatus WINGDIPAPI GdipCreateRegionPath(GpPath *path, GpRegion **region) +{ + FIXME("(%p, %p): stub\n", path, region); + + *region = NULL; + return NotImplemented; +} + +GpStatus WINGDIPAPI GdipDeleteRegion(GpRegion *region) +{ + FIXME("(%p): stub\n", region); + return NotImplemented; +} + +GpStatus WINGDIPAPI GdipGetRegionHRgn(GpRegion *region, GpGraphics *graphics, HRGN *hrgn) +{ + FIXME("(%p, %p, %p): stub\n", region, graphics, hrgn); + + *hrgn = NULL; + return NotImplemented; +} + GpStatus WINGDIPAPI GdipSetEmpty(GpRegion *region) { static int calls;