winehq.org
Sign In
Sign Up
Sign In
Sign Up
Manage this list
×
Keyboard Shortcuts
Thread View
j
: Next unread message
k
: Previous unread message
j a
: Jump to all threads
j l
: Jump to MailingList overview
2025
February
January
2024
December
November
October
September
August
July
June
May
April
March
February
January
2023
December
November
October
September
August
July
June
May
April
March
February
January
2022
December
November
October
September
August
July
June
May
April
March
February
January
2021
December
November
October
September
August
July
June
May
April
March
February
January
2020
December
November
October
September
August
July
June
May
April
March
February
January
2019
December
November
October
September
August
July
June
May
April
March
February
January
2018
December
November
October
September
August
July
June
May
April
March
February
January
2017
December
November
October
September
August
July
June
May
April
March
February
January
2016
December
November
October
September
August
July
June
May
April
March
February
January
2015
December
November
October
September
August
July
June
May
April
March
February
January
2014
December
November
October
September
August
July
June
May
April
March
February
January
2013
December
November
October
September
August
July
June
May
April
March
February
January
2012
December
November
October
September
August
July
June
May
April
March
February
January
2011
December
November
October
September
August
July
June
May
April
March
February
January
2010
December
November
October
September
August
July
June
May
April
March
February
January
2009
December
November
October
September
August
July
June
May
April
March
February
January
2008
December
November
October
September
August
July
June
May
April
March
February
January
2007
December
November
October
September
August
July
June
May
April
March
February
January
2006
December
November
October
September
August
July
June
May
April
March
February
January
2005
December
November
October
September
August
July
June
May
April
March
February
January
2004
December
November
October
September
August
July
June
May
April
March
February
January
2003
December
November
October
September
August
July
June
May
April
March
February
January
2002
December
November
October
September
August
July
June
May
April
March
February
January
2001
December
November
October
September
August
July
June
May
April
March
February
List overview
wine-commits
July 2007
----- 2025 -----
February 2025
January 2025
----- 2024 -----
December 2024
November 2024
October 2024
September 2024
August 2024
July 2024
June 2024
May 2024
April 2024
March 2024
February 2024
January 2024
----- 2023 -----
December 2023
November 2023
October 2023
September 2023
August 2023
July 2023
June 2023
May 2023
April 2023
March 2023
February 2023
January 2023
----- 2022 -----
December 2022
November 2022
October 2022
September 2022
August 2022
July 2022
June 2022
May 2022
April 2022
March 2022
February 2022
January 2022
----- 2021 -----
December 2021
November 2021
October 2021
September 2021
August 2021
July 2021
June 2021
May 2021
April 2021
March 2021
February 2021
January 2021
----- 2020 -----
December 2020
November 2020
October 2020
September 2020
August 2020
July 2020
June 2020
May 2020
April 2020
March 2020
February 2020
January 2020
----- 2019 -----
December 2019
November 2019
October 2019
September 2019
August 2019
July 2019
June 2019
May 2019
April 2019
March 2019
February 2019
January 2019
----- 2018 -----
December 2018
November 2018
October 2018
September 2018
August 2018
July 2018
June 2018
May 2018
April 2018
March 2018
February 2018
January 2018
----- 2017 -----
December 2017
November 2017
October 2017
September 2017
August 2017
July 2017
June 2017
May 2017
April 2017
March 2017
February 2017
January 2017
----- 2016 -----
December 2016
November 2016
October 2016
September 2016
August 2016
July 2016
June 2016
May 2016
April 2016
March 2016
February 2016
January 2016
----- 2015 -----
December 2015
November 2015
October 2015
September 2015
August 2015
July 2015
June 2015
May 2015
April 2015
March 2015
February 2015
January 2015
----- 2014 -----
December 2014
November 2014
October 2014
September 2014
August 2014
July 2014
June 2014
May 2014
April 2014
March 2014
February 2014
January 2014
----- 2013 -----
December 2013
November 2013
October 2013
September 2013
August 2013
July 2013
June 2013
May 2013
April 2013
March 2013
February 2013
January 2013
----- 2012 -----
December 2012
November 2012
October 2012
September 2012
August 2012
July 2012
June 2012
May 2012
April 2012
March 2012
February 2012
January 2012
----- 2011 -----
December 2011
November 2011
October 2011
September 2011
August 2011
July 2011
June 2011
May 2011
April 2011
March 2011
February 2011
January 2011
----- 2010 -----
December 2010
November 2010
October 2010
September 2010
August 2010
July 2010
June 2010
May 2010
April 2010
March 2010
February 2010
January 2010
----- 2009 -----
December 2009
November 2009
October 2009
September 2009
August 2009
July 2009
June 2009
May 2009
April 2009
March 2009
February 2009
January 2009
----- 2008 -----
December 2008
November 2008
October 2008
September 2008
August 2008
July 2008
June 2008
May 2008
April 2008
March 2008
February 2008
January 2008
----- 2007 -----
December 2007
November 2007
October 2007
September 2007
August 2007
July 2007
June 2007
May 2007
April 2007
March 2007
February 2007
January 2007
----- 2006 -----
December 2006
November 2006
October 2006
September 2006
August 2006
July 2006
June 2006
May 2006
April 2006
March 2006
February 2006
January 2006
----- 2005 -----
December 2005
November 2005
October 2005
September 2005
August 2005
July 2005
June 2005
May 2005
April 2005
March 2005
February 2005
January 2005
----- 2004 -----
December 2004
November 2004
October 2004
September 2004
August 2004
July 2004
June 2004
May 2004
April 2004
March 2004
February 2004
January 2004
----- 2003 -----
December 2003
November 2003
October 2003
September 2003
August 2003
July 2003
June 2003
May 2003
April 2003
March 2003
February 2003
January 2003
----- 2002 -----
December 2002
November 2002
October 2002
September 2002
August 2002
July 2002
June 2002
May 2002
April 2002
March 2002
February 2002
January 2002
----- 2001 -----
December 2001
November 2001
October 2001
September 2001
August 2001
July 2001
June 2001
May 2001
April 2001
March 2001
February 2001
wine-commits@winehq.org
3 participants
957 discussions
Start a n
N
ew thread
Evan Stade : gdiplus: Added GdipClosePathFigure.
by Alexandre Julliard
09 Jul '07
09 Jul '07
Module: wine Branch: master Commit: 8c1291974450850de52f07f66f56a5597929955e URL:
http://source.winehq.org/git/wine.git/?a=commit;h=8c1291974450850de52f07f66…
Author: Evan Stade <estade(a)gmail.com> Date: Fri Jul 6 16:14:17 2007 -0700 gdiplus: Added GdipClosePathFigure. --- dlls/gdiplus/gdiplus.spec | 2 +- dlls/gdiplus/graphicspath.c | 13 +++++++++++++ include/gdiplusflat.h | 1 + 3 files changed, 15 insertions(+), 1 deletions(-) diff --git a/dlls/gdiplus/gdiplus.spec b/dlls/gdiplus/gdiplus.spec index 4ab38ba..8b665fc 100644 --- a/dlls/gdiplus/gdiplus.spec +++ b/dlls/gdiplus/gdiplus.spec @@ -54,7 +54,7 @@ @ stub GdipClonePen @ stub GdipCloneRegion @ stub GdipCloneStringFormat -@ stub GdipClosePathFigure +@ stdcall GdipClosePathFigure(ptr) @ stub GdipClosePathFigures @ stub GdipCombineRegionPath @ stub GdipCombineRegionRect diff --git a/dlls/gdiplus/graphicspath.c b/dlls/gdiplus/graphicspath.c index f8d2d49..c06576c 100644 --- a/dlls/gdiplus/graphicspath.c +++ b/dlls/gdiplus/graphicspath.c @@ -90,6 +90,19 @@ GpStatus WINGDIPAPI GdipAddPathLine2(GpPath *path, GDIPCONST GpPointF *points, return Ok; } +GpStatus WINGDIPAPI GdipClosePathFigure(GpPath* path) +{ + if(!path) + return InvalidParameter; + + if(path->pathdata.Count > 0){ + path->pathdata.Types[path->pathdata.Count - 1] |= PathPointTypeCloseSubpath; + path->newfigure = TRUE; + } + + return Ok; +} + GpStatus WINGDIPAPI GdipCreatePath(GpFillMode fill, GpPath **path) { if(!path) diff --git a/include/gdiplusflat.h b/include/gdiplusflat.h index 42a60b9..3546883 100644 --- a/include/gdiplusflat.h +++ b/include/gdiplusflat.h @@ -49,6 +49,7 @@ GpStatus WINGDIPAPI GdipGetBrushType(GpBrush*,GpBrushType*); GpStatus WINGDIPAPI GdipDeleteBrush(GpBrush*); GpStatus WINGDIPAPI GdipAddPathLine2(GpPath*,GDIPCONST GpPointF*,INT); +GpStatus WINGDIPAPI GdipClosePathFigure(GpPath*); GpStatus WINGDIPAPI GdipCreatePath(GpFillMode,GpPath**); GpStatus WINGDIPAPI GdipDeletePath(GpPath*);
1
0
0
0
Evan Stade : gdiplus: Added GdipAddPathLine2.
by Alexandre Julliard
09 Jul '07
09 Jul '07
Module: wine Branch: master Commit: e4118c1847e750ccfcd8059c6ff009f43233ea7e URL:
http://source.winehq.org/git/wine.git/?a=commit;h=e4118c1847e750ccfcd8059c6…
Author: Evan Stade <estade(a)gmail.com> Date: Fri Jul 6 16:14:07 2007 -0700 gdiplus: Added GdipAddPathLine2. --- dlls/gdiplus/gdiplus.spec | 2 +- dlls/gdiplus/gdiplus_private.h | 2 +- dlls/gdiplus/graphicspath.c | 77 ++++++++++++++++++++++++++++++++-------- include/gdiplusenums.h | 12 ++++++ include/gdiplusflat.h | 1 + 5 files changed, 77 insertions(+), 17 deletions(-) diff --git a/dlls/gdiplus/gdiplus.spec b/dlls/gdiplus/gdiplus.spec index f3ebc6b..4ab38ba 100644 --- a/dlls/gdiplus/gdiplus.spec +++ b/dlls/gdiplus/gdiplus.spec @@ -16,7 +16,7 @@ @ stub GdipAddPathCurveI @ stub GdipAddPathEllipse @ stub GdipAddPathEllipseI -@ stub GdipAddPathLine2 +@ stdcall GdipAddPathLine2(ptr ptr long) @ stub GdipAddPathLine2I @ stub GdipAddPathLine @ stub GdipAddPathLineI diff --git a/dlls/gdiplus/gdiplus_private.h b/dlls/gdiplus/gdiplus_private.h index b023c31..7c5195a 100644 --- a/dlls/gdiplus/gdiplus_private.h +++ b/dlls/gdiplus/gdiplus_private.h @@ -52,9 +52,9 @@ struct GpSolidFill{ struct GpPath{ GpFillMode fill; - GpGraphics* graphics; GpPathData pathdata; BOOL newfigure; /* whether the next drawing action starts a new figure */ + INT datalen; /* size of the arrays in pathdata */ }; #endif diff --git a/dlls/gdiplus/graphicspath.c b/dlls/gdiplus/graphicspath.c index cce60c6..f8d2d49 100644 --- a/dlls/gdiplus/graphicspath.c +++ b/dlls/gdiplus/graphicspath.c @@ -30,11 +30,68 @@ WINE_DEFAULT_DEBUG_CHANNEL(gdiplus); -GpStatus WINGDIPAPI GdipCreatePath(GpFillMode fill, GpPath **path) +/* make sure path has enough space for len more points */ +static BOOL lengthen_path(GpPath *path, INT len) { - HDC hdc; - GpStatus ret; + /* initial allocation */ + if(path->datalen == 0){ + path->datalen = len * 2; + + path->pathdata.Points = GdipAlloc(path->datalen * sizeof(PointF)); + if(!path->pathdata.Points) return FALSE; + + path->pathdata.Types = GdipAlloc(path->datalen); + if(!path->pathdata.Types){ + GdipFree(path->pathdata.Points); + return FALSE; + } + } + /* reallocation, double size of arrays */ + else if(path->datalen - path->pathdata.Count < len){ + while(path->datalen - path->pathdata.Count < len) + path->datalen *= 2; + path->pathdata.Points = HeapReAlloc(GetProcessHeap(), 0, + path->pathdata.Points, path->datalen * sizeof(PointF)); + if(!path->pathdata.Points) return FALSE; + + path->pathdata.Types = HeapReAlloc(GetProcessHeap(), 0, + path->pathdata.Types, path->datalen); + if(!path->pathdata.Types) return FALSE; + } + + return TRUE; +} + +GpStatus WINGDIPAPI GdipAddPathLine2(GpPath *path, GDIPCONST GpPointF *points, + INT count) +{ + INT i, old_count = path->pathdata.Count; + + if(!path || !points) + return InvalidParameter; + + if(!lengthen_path(path, count + (path->newfigure ? 1 : 0))) + return OutOfMemory; + + for(i = 0; i < count; i++){ + path->pathdata.Points[old_count + i].X = points[i].X; + path->pathdata.Points[old_count + i].Y = points[i].Y; + path->pathdata.Types[old_count + i] = PathPointTypeLine; + } + + if(path->newfigure){ + path->pathdata.Types[old_count] = PathPointTypeStart; + path->newfigure = FALSE; + } + + path->pathdata.Count += count; + + return Ok; +} + +GpStatus WINGDIPAPI GdipCreatePath(GpFillMode fill, GpPath **path) +{ if(!path) return InvalidParameter; @@ -44,24 +101,14 @@ GpStatus WINGDIPAPI GdipCreatePath(GpFillMode fill, GpPath **path) (*path)->fill = fill; (*path)->newfigure = TRUE; - hdc = GetDC(0); - ret = GdipCreateFromHDC(hdc, &((*path)->graphics)); - - if(ret != Ok){ - ReleaseDC(0, hdc); - GdipFree(*path); - } - - return ret; + return Ok; } GpStatus WINGDIPAPI GdipDeletePath(GpPath *path) { - if(!path || !(path->graphics)) + if(!path) return InvalidParameter; - ReleaseDC(0, path->graphics->hdc); - GdipDeleteGraphics(path->graphics); GdipFree(path); return Ok; diff --git a/include/gdiplusenums.h b/include/gdiplusenums.h index 16ded0d..1d00188 100644 --- a/include/gdiplusenums.h +++ b/include/gdiplusenums.h @@ -62,12 +62,24 @@ enum LineCap LineCapAnchorMask = 0xf0 }; +enum PathPointType{ + PathPointTypeStart = 0, /* start of a figure */ + PathPointTypeLine = 1, + PathPointTypeBezier = 3, + PathPointTypePathTypeMask = 7, + PathPointTypePathDashMode = 16, /* not used */ + PathPointTypePathMarker = 32, + PathPointTypeCloseSubpath = 128, /* end of a closed figure */ + PathPointTypeBezier3 = 3 +}; + #ifndef __cplusplus typedef enum Unit Unit; typedef enum BrushType BrushType; typedef enum FillMode FillMode; typedef enum LineCap LineCap; +typedef enum PathPointType PathPointType; #endif /* end of c typedefs */ diff --git a/include/gdiplusflat.h b/include/gdiplusflat.h index d308c2a..42a60b9 100644 --- a/include/gdiplusflat.h +++ b/include/gdiplusflat.h @@ -48,6 +48,7 @@ GpStatus WINGDIPAPI GdipCreateSolidFill(ARGB,GpSolidFill**); GpStatus WINGDIPAPI GdipGetBrushType(GpBrush*,GpBrushType*); GpStatus WINGDIPAPI GdipDeleteBrush(GpBrush*); +GpStatus WINGDIPAPI GdipAddPathLine2(GpPath*,GDIPCONST GpPointF*,INT); GpStatus WINGDIPAPI GdipCreatePath(GpFillMode,GpPath**); GpStatus WINGDIPAPI GdipDeletePath(GpPath*);
1
0
0
0
Evan Stade : gdiplus: Public declaration of GdipSetPenEndCap.
by Alexandre Julliard
09 Jul '07
09 Jul '07
Module: wine Branch: master Commit: 5dc8dee76d21957b72d89ff6299b84f34d96b56c URL:
http://source.winehq.org/git/wine.git/?a=commit;h=5dc8dee76d21957b72d89ff62…
Author: Evan Stade <estade(a)gmail.com> Date: Fri Jul 6 16:13:57 2007 -0700 gdiplus: Public declaration of GdipSetPenEndCap. --- include/gdiplusflat.h | 1 + 1 files changed, 1 insertions(+), 0 deletions(-) diff --git a/include/gdiplusflat.h b/include/gdiplusflat.h index 78db330..d308c2a 100644 --- a/include/gdiplusflat.h +++ b/include/gdiplusflat.h @@ -29,6 +29,7 @@ extern "C" { GpStatus WINGDIPAPI GdipCreatePen1(ARGB,REAL,GpUnit,GpPen**); GpStatus WINGDIPAPI GdipDeletePen(GpPen*); +GpStatus WINGDIPAPI GdipSetPenEndCap(GpPen*,GpLineCap); GpStatus WINGDIPAPI GdipCreateFromHDC(HDC,GpGraphics**); GpStatus WINGDIPAPI GdipCreateFromHWND(HWND,GpGraphics**);
1
0
0
0
Evan Stade : gdiplus: Added linecap rendering for GdipDrawBezier.
by Alexandre Julliard
09 Jul '07
09 Jul '07
Module: wine Branch: master Commit: 69a807c6a9a5729c1c8458f92a7ac39754287572 URL:
http://source.winehq.org/git/wine.git/?a=commit;h=69a807c6a9a5729c1c8458f92…
Author: Evan Stade <estade(a)gmail.com> Date: Fri Jul 6 16:13:49 2007 -0700 gdiplus: Added linecap rendering for GdipDrawBezier. --- dlls/gdiplus/graphics.c | 89 +++++++++++++++++++++++++++++++++++++++++++--- 1 files changed, 83 insertions(+), 6 deletions(-) diff --git a/dlls/gdiplus/graphics.c b/dlls/gdiplus/graphics.c index 012cf2d..5f730ab 100644 --- a/dlls/gdiplus/graphics.c +++ b/dlls/gdiplus/graphics.c @@ -32,6 +32,7 @@ WINE_DEFAULT_DEBUG_CHANNEL(gdiplus); /* looks-right constants */ #define TENSION_CONST (0.3) #define ANCHOR_WIDTH (2.0) +#define MAX_ITERS (50) static inline INT roundr(REAL x) { @@ -317,6 +318,72 @@ static void draw_polyline(HDC hdc, GpPen *pen, GDIPCONST GpPointF * pt, GdipFree(pti); } +/* Conducts a linear search to find the bezier points that will back off + * the endpoint of the curve by a distance of amt. Linear search works + * better than binary in this case because there are multiple solutions, + * and binary searches often find a bad one. I don't think this is what + * Windows does but short of rendering the bezier without GDI's help it's + * the best we can do. */ +static void shorten_bezier_amt(GpPointF * pt, REAL amt) +{ + GpPointF origpt[4]; + REAL percent = 0.00, dx, dy, origx = pt[3].X, origy = pt[3].Y, diff = -1.0; + INT i; + + memcpy(origpt, pt, sizeof(GpPointF) * 4); + + for(i = 0; (i < MAX_ITERS) && (diff < amt); i++){ + /* reset bezier points to original values */ + memcpy(pt, origpt, sizeof(GpPointF) * 4); + /* Perform magic on bezier points. Order is important here.*/ + shorten_line_percent(pt[2].X, pt[2].Y, &pt[3].X, &pt[3].Y, percent); + shorten_line_percent(pt[1].X, pt[1].Y, &pt[2].X, &pt[2].Y, percent); + shorten_line_percent(pt[2].X, pt[2].Y, &pt[3].X, &pt[3].Y, percent); + shorten_line_percent(pt[0].X, pt[0].Y, &pt[1].X, &pt[1].Y, percent); + shorten_line_percent(pt[1].X, pt[1].Y, &pt[2].X, &pt[2].Y, percent); + shorten_line_percent(pt[2].X, pt[2].Y, &pt[3].X, &pt[3].Y, percent); + + dx = pt[3].X - origx; + dy = pt[3].Y - origy; + + diff = sqrt(dx * dx + dy * dy); + percent += 0.0005 * amt; + } +} + +/* Draws bezier curves between given points, and if caps is true then draws an + * endcap at the end of the last line. FIXME: Startcaps not implemented. */ +static void draw_polybezier(HDC hdc, GpPen *pen, GDIPCONST GpPointF * pt, + INT count, BOOL caps) +{ + POINT *pti = GdipAlloc(count * sizeof(POINT)); + GpPointF *ptf = GdipAlloc(4 * sizeof(GpPointF)); + INT i; + + memcpy(ptf, &pt[count-4], 4 * sizeof(GpPointF)); + + if(caps){ + if(pen->endcap == LineCapArrowAnchor) + shorten_bezier_amt(ptf, pen->width); + + draw_cap(hdc, pen->color, pen->endcap, pen->width, ptf[3].X, + ptf[3].Y, pt[count - 1].X, pt[count - 1].Y); + } + + for(i = 0; i < count - 4; i ++){ + pti[i].x = roundr(pt[i].X); + pti[i].y = roundr(pt[i].Y); + } + for(i = 0; i < 4; i ++){ + pti[i].x = roundr(ptf[i].X); + pti[i].y = roundr(ptf[i].Y); + } + + PolyBezier(hdc, pti, count); + GdipFree(pti); + GdipFree(ptf); +} + GpStatus WINGDIPAPI GdipCreateFromHDC(HDC hdc, GpGraphics **graphics) { if(hdc == NULL) @@ -385,18 +452,28 @@ GpStatus WINGDIPAPI GdipDrawArc(GpGraphics *graphics, GpPen *pen, REAL x, GpStatus WINGDIPAPI GdipDrawBezier(GpGraphics *graphics, GpPen *pen, REAL x1, REAL y1, REAL x2, REAL y2, REAL x3, REAL y3, REAL x4, REAL y4) { - HGDIOBJ old_pen; - POINT pt[4] = {{roundr(x1), roundr(y1)}, {roundr(x2), roundr(y2)}, - {roundr(x3), roundr(y3)}, {roundr(x4), roundr(y4)}}; + INT save_state; + GpPointF pt[4]; if(!graphics || !pen) return InvalidParameter; - old_pen = SelectObject(graphics->hdc, pen->gdipen); + pt[0].X = x1; + pt[0].Y = y1; + pt[1].X = x2; + pt[1].Y = y2; + pt[2].X = x3; + pt[2].Y = y3; + pt[3].X = x4; + pt[3].Y = y4; - PolyBezier(graphics->hdc, pt, 4); + save_state = SaveDC(graphics->hdc); + EndPath(graphics->hdc); + SelectObject(graphics->hdc, pen->gdipen); - SelectObject(graphics->hdc, old_pen); + draw_polybezier(graphics->hdc, pen, pt, 4, TRUE); + + RestoreDC(graphics->hdc, save_state); return Ok; }
1
0
0
0
Evan Stade : gdiplus: Rendering of linecaps.
by Alexandre Julliard
09 Jul '07
09 Jul '07
Module: wine Branch: master Commit: 5128e5dc58c7e2d0f6c8550a06a38337604661b6 URL:
http://source.winehq.org/git/wine.git/?a=commit;h=5128e5dc58c7e2d0f6c8550a0…
Author: Evan Stade <estade(a)gmail.com> Date: Sat Jul 7 13:20:41 2007 -0700 gdiplus: Rendering of linecaps. --- dlls/gdiplus/graphics.c | 220 ++++++++++++++++++++++++++++++++++++++++++++++- dlls/gdiplus/pen.c | 5 - 2 files changed, 217 insertions(+), 8 deletions(-) diff --git a/dlls/gdiplus/graphics.c b/dlls/gdiplus/graphics.c index 4765e33..012cf2d 100644 --- a/dlls/gdiplus/graphics.c +++ b/dlls/gdiplus/graphics.c @@ -27,8 +27,11 @@ #include "gdiplus_private.h" #include "wine/debug.h" -/* looks-right constant */ +WINE_DEFAULT_DEBUG_CHANNEL(gdiplus); + +/* looks-right constants */ #define TENSION_CONST (0.3) +#define ANCHOR_WIDTH (2.0) static inline INT roundr(REAL x) { @@ -108,6 +111,212 @@ static void calc_curve_bezier_endp(REAL xend, REAL yend, REAL xadj, REAL yadj, *y = roundr(tension * (yadj - yend) + yend); } +/* Draws the linecap the specified color and size on the hdc. The linecap is in + * direction of the line from x1, y1 to x2, y2 and is anchored on x2, y2. */ +static void draw_cap(HDC hdc, COLORREF color, GpLineCap cap, REAL size, + REAL x1, REAL y1, REAL x2, REAL y2) +{ + HGDIOBJ oldbrush, oldpen; + HBRUSH brush; + HPEN pen; + POINT pt[4]; + REAL theta, dsmall, dbig, dx, dy, invert; + + if(x2 != x1) + theta = atan((y2 - y1) / (x2 - x1)); + else if(y2 != y1){ + theta = M_PI_2 * (y2 > y1 ? 1.0 : -1.0); + } + else + return; + + invert = ((x2 - x1) >= 0.0 ? 1.0 : -1.0); + brush = CreateSolidBrush(color); + pen = CreatePen(PS_SOLID, 1, color); + oldbrush = SelectObject(hdc, brush); + oldpen = SelectObject(hdc, pen); + + switch(cap){ + case LineCapFlat: + break; + case LineCapSquare: + case LineCapSquareAnchor: + case LineCapDiamondAnchor: + size = size * (cap & LineCapNoAnchor ? ANCHOR_WIDTH : 1.0) / 2.0; + if(cap == LineCapDiamondAnchor){ + dsmall = cos(theta + M_PI_2) * size; + dbig = sin(theta + M_PI_2) * size; + } + else{ + dsmall = cos(theta + M_PI_4) * size; + dbig = sin(theta + M_PI_4) * size; + } + + /* calculating the latter points from the earlier points makes them + * look a little better because of rounding issues */ + pt[0].x = roundr(x2 - dsmall); + pt[1].x = roundr(((REAL)pt[0].x) + dbig + dsmall); + + pt[0].y = roundr(y2 - dbig); + pt[3].y = roundr(((REAL)pt[0].y) + dsmall + dbig); + + pt[1].y = roundr(y2 - dsmall); + pt[2].y = roundr(dbig + dsmall + ((REAL)pt[1].y)); + + pt[3].x = roundr(x2 - dbig); + pt[2].x = roundr(((REAL)pt[3].x) + dsmall + dbig); + + Polygon(hdc, pt, 4); + + break; + case LineCapArrowAnchor: + size = size * 4.0 / sqrt(3.0); + + dx = cos(M_PI / 6.0 + theta) * size * invert; + dy = sin(M_PI / 6.0 + theta) * size * invert; + + pt[0].x = roundr(x2 - dx); + pt[0].y = roundr(y2 - dy); + + dx = cos(- M_PI / 6.0 + theta) * size * invert; + dy = sin(- M_PI / 6.0 + theta) * size * invert; + + pt[1].x = roundr(x2 - dx); + pt[1].y = roundr(y2 - dy); + + pt[2].x = roundr(x2); + pt[2].y = roundr(y2); + + Polygon(hdc, pt, 3); + + break; + case LineCapRoundAnchor: + dx = dy = ANCHOR_WIDTH * size / 2.0; + + x2 = (REAL) roundr(x2 - dx); + y2 = (REAL) roundr(y2 - dy); + + Ellipse(hdc, (INT) x2, (INT) y2, roundr(x2 + 2.0 * dx), + roundr(y2 + 2.0 * dy)); + break; + case LineCapTriangle: + size = size / 2.0; + dx = cos(M_PI_2 + theta) * size; + dy = sin(M_PI_2 + theta) * size; + + /* Using roundr here can make the triangle float off the end of the + * line. */ + pt[0].x = ((x2 - x1) >= 0 ? floor(x2 - dx) : ceil(x2 - dx)); + pt[0].y = ((y2 - y1) >= 0 ? floor(y2 - dy) : ceil(y2 - dy)); + pt[1].x = roundr(pt[0].x + 2.0 * dx); + pt[1].y = roundr(pt[0].y + 2.0 * dy); + + dx = cos(theta) * size * invert; + dy = sin(theta) * size * invert; + + pt[2].x = roundr(x2 + dx); + pt[2].y = roundr(y2 + dy); + + Polygon(hdc, pt, 3); + + break; + case LineCapRound: + dx = -cos(M_PI_2 + theta) * size * invert; + dy = -sin(M_PI_2 + theta) * size * invert; + + pt[0].x = ((x2 - x1) >= 0 ? floor(x2 - dx) : ceil(x2 - dx)); + pt[0].y = ((y2 - y1) >= 0 ? floor(y2 - dy) : ceil(y2 - dy)); + pt[1].x = roundr(pt[0].x + 2.0 * dx); + pt[1].y = roundr(pt[0].y + 2.0 * dy); + + dx = dy = size / 2.0; + + x2 = (REAL) roundr(x2 - dx); + y2 = (REAL) roundr(y2 - dy); + + Pie(hdc, (INT) x2, (INT) y2, roundr(x2 + 2.0 * dx), + roundr(y2 + 2.0 * dy), pt[0].x, pt[0].y, pt[1].x, pt[1].y); + break; + case LineCapCustom: + FIXME("line cap not implemented\n"); + default: + break; + } + + SelectObject(hdc, oldbrush); + SelectObject(hdc, oldpen); + DeleteObject(brush); + DeleteObject(pen); +} + +/* Shortens the line by the given percent by changing x2, y2. + * If percent is > 1.0 then the line will change direction. */ +static void shorten_line_percent(REAL x1, REAL y1, REAL *x2, REAL *y2, REAL percent) +{ + REAL dist, theta, dx, dy; + + if((y1 == *y2) && (x1 == *x2)) + return; + + dist = sqrt((*x2 - x1) * (*x2 - x1) + (*y2 - y1) * (*y2 - y1)) * percent; + theta = (*x2 == x1 ? M_PI_2 : atan((*y2 - y1) / (*x2 - x1))); + dx = cos(theta) * dist; + dy = sin(theta) * dist; + + *x2 = *x2 + fabs(dx) * (*x2 > x1 ? -1.0 : 1.0); + *y2 = *y2 + fabs(dy) * (*y2 > y1 ? -1.0 : 1.0); +} + +/* Shortens the line by the given amount by changing x2, y2. + * If the amount is greater than the distance, the line will become length 0. */ +static void shorten_line_amt(REAL x1, REAL y1, REAL *x2, REAL *y2, REAL amt) +{ + REAL dx, dy, percent; + + dx = *x2 - x1; + dy = *y2 - y1; + if(dx == 0 && dy == 0) + return; + + percent = amt / sqrt(dx * dx + dy * dy); + if(percent >= 1.0){ + *x2 = x1; + *y2 = y1; + return; + } + + shorten_line_percent(x1, y1, x2, y2, percent); +} + +/* Draws lines between the given points, and if caps is true then draws an endcap + * at the end of the last line. FIXME: Startcaps not implemented. */ +static void draw_polyline(HDC hdc, GpPen *pen, GDIPCONST GpPointF * pt, + INT count, BOOL caps) +{ + POINT *pti = GdipAlloc(count * sizeof(POINT)); + REAL x = pt[count - 1].X, y = pt[count - 1].Y; + INT i; + + if(caps){ + if(pen->endcap == LineCapArrowAnchor) + shorten_line_amt(pt[count-2].X, pt[count-2].Y, &x, &y, pen->width); + + draw_cap(hdc, pen->color, pen->endcap, pen->width, pt[count-2].X, + pt[count-2].Y, pt[count - 1].X, pt[count - 1].Y); + } + + for(i = 0; i < count - 1; i ++){ + pti[i].x = roundr(pt[i].X); + pti[i].y = roundr(pt[i].Y); + } + + pti[i].x = roundr(x); + pti[i].y = roundr(y); + + Polyline(hdc, pti, count); + GdipFree(pti); +} + GpStatus WINGDIPAPI GdipCreateFromHDC(HDC hdc, GpGraphics **graphics) { if(hdc == NULL) @@ -248,16 +457,21 @@ GpStatus WINGDIPAPI GdipDrawLineI(GpGraphics *graphics, GpPen *pen, INT x1, INT y1, INT x2, INT y2) { INT save_state; + GpPointF pt[2]; if(!pen || !graphics) return InvalidParameter; + pt[0].X = (REAL)x1; + pt[0].Y = (REAL)y1; + pt[1].X = (REAL)x2; + pt[1].Y = (REAL)y2; + save_state = SaveDC(graphics->hdc); EndPath(graphics->hdc); SelectObject(graphics->hdc, pen->gdipen); - MoveToEx(graphics->hdc, x1, y1, NULL); - LineTo(graphics->hdc, x2, y2); + draw_polyline(graphics->hdc, pen, pt, 2, TRUE); RestoreDC(graphics->hdc, save_state); diff --git a/dlls/gdiplus/pen.c b/dlls/gdiplus/pen.c index 0fcbb69..52515d5 100644 --- a/dlls/gdiplus/pen.c +++ b/dlls/gdiplus/pen.c @@ -77,11 +77,6 @@ GpStatus WINGDIPAPI GdipSetPenEndCap(GpPen *pen, GpLineCap cap) { if(!pen) return InvalidParameter; - if(cap != LineCapFlat){ - FIXME("Not implemented for non-flat EndCap\n"); - return NotImplemented; - } - pen->endcap = cap; return Ok;
1
0
0
0
Hans Leidekker : pdh: Add tests for opening and closing queries.
by Alexandre Julliard
09 Jul '07
09 Jul '07
Module: wine Branch: master Commit: 0a6f6874afc88fa4582f513b3c5ea8c9448fe8b1 URL:
http://source.winehq.org/git/wine.git/?a=commit;h=0a6f6874afc88fa4582f513b3…
Author: Hans Leidekker <hans(a)it.vu.nl> Date: Sun Jul 8 14:06:08 2007 +0200 pdh: Add tests for opening and closing queries. --- .gitignore | 5 ++++ Makefile.in | 2 + configure | 3 ++ configure.ac | 1 + dlls/Makefile.in | 5 ++++ dlls/pdh/Makefile.in | 1 + dlls/pdh/tests/Makefile.in | 13 ++++++++++ dlls/pdh/tests/pdh.c | 54 +++++++++++++++++++++++++++++++++++++++++ programs/winetest/Makefile.in | 3 ++ programs/winetest/winetest.rc | 1 + 10 files changed, 88 insertions(+), 0 deletions(-) diff --git a/.gitignore b/.gitignore index 7c7ccff..2aba4ae 100644 --- a/.gitignore +++ b/.gitignore @@ -431,6 +431,10 @@ dlls/olesvr.dll16 dlls/olesvr32/libolesvr32.def dlls/opengl32/libopengl32.def dlls/opengl32/version.res +dlls/pdh/libpdh.def +dlls/pdh/tests/*.ok +dlls/pdh/tests/pdh_crosstest.exe +dlls/pdh/tests/testlist.c dlls/powrprof/libpowrprof.def dlls/printui/printui.res dlls/psapi/libpsapi.def @@ -883,6 +887,7 @@ programs/winetest/ntprint_test.exe programs/winetest/odbccp32_test.exe programs/winetest/ole32_test.exe programs/winetest/oleaut32_test.exe +programs/winetest/pdh_test.exe programs/winetest/psapi_test.exe programs/winetest/quartz_test.exe programs/winetest/riched20_test.exe diff --git a/Makefile.in b/Makefile.in index 1963967..e416465 100644 --- a/Makefile.in +++ b/Makefile.in @@ -332,6 +332,7 @@ ALL_MAKEFILES = \ dlls/olesvr32/Makefile \ dlls/opengl32/Makefile \ dlls/pdh/Makefile \ + dlls/pdh/tests/Makefile \ dlls/powrprof/Makefile \ dlls/printui/Makefile \ dlls/psapi/Makefile \ @@ -690,6 +691,7 @@ dlls/olepro32/Makefile: dlls/olepro32/Makefile.in dlls/Makedll.rules dlls/olesvr32/Makefile: dlls/olesvr32/Makefile.in dlls/Makedll.rules dlls/opengl32/Makefile: dlls/opengl32/Makefile.in dlls/Makedll.rules dlls/pdh/Makefile: dlls/pdh/Makefile.in dlls/Makedll.rules +dlls/pdh/tests/Makefile: dlls/pdh/tests/Makefile.in dlls/Maketest.rules dlls/powrprof/Makefile: dlls/powrprof/Makefile.in dlls/Makedll.rules dlls/printui/Makefile: dlls/printui/Makefile.in dlls/Makedll.rules dlls/psapi/Makefile: dlls/psapi/Makefile.in dlls/Makedll.rules diff --git a/configure b/configure index 47240f5..3a9a625 100755 --- a/configure +++ b/configure @@ -20471,6 +20471,8 @@ ac_config_files="$ac_config_files dlls/opengl32/Makefile" ac_config_files="$ac_config_files dlls/pdh/Makefile" +ac_config_files="$ac_config_files dlls/pdh/tests/Makefile" + ac_config_files="$ac_config_files dlls/powrprof/Makefile" ac_config_files="$ac_config_files dlls/printui/Makefile" @@ -21549,6 +21551,7 @@ do "dlls/olesvr32/Makefile") CONFIG_FILES="$CONFIG_FILES dlls/olesvr32/Makefile" ;; "dlls/opengl32/Makefile") CONFIG_FILES="$CONFIG_FILES dlls/opengl32/Makefile" ;; "dlls/pdh/Makefile") CONFIG_FILES="$CONFIG_FILES dlls/pdh/Makefile" ;; + "dlls/pdh/tests/Makefile") CONFIG_FILES="$CONFIG_FILES dlls/pdh/tests/Makefile" ;; "dlls/powrprof/Makefile") CONFIG_FILES="$CONFIG_FILES dlls/powrprof/Makefile" ;; "dlls/printui/Makefile") CONFIG_FILES="$CONFIG_FILES dlls/printui/Makefile" ;; "dlls/psapi/Makefile") CONFIG_FILES="$CONFIG_FILES dlls/psapi/Makefile" ;; diff --git a/configure.ac b/configure.ac index 01165a0..885bdcc 100644 --- a/configure.ac +++ b/configure.ac @@ -1661,6 +1661,7 @@ AC_CONFIG_FILES([dlls/olepro32/Makefile]) AC_CONFIG_FILES([dlls/olesvr32/Makefile]) AC_CONFIG_FILES([dlls/opengl32/Makefile]) AC_CONFIG_FILES([dlls/pdh/Makefile]) +AC_CONFIG_FILES([dlls/pdh/tests/Makefile]) AC_CONFIG_FILES([dlls/powrprof/Makefile]) AC_CONFIG_FILES([dlls/printui/Makefile]) AC_CONFIG_FILES([dlls/psapi/Makefile]) diff --git a/dlls/Makefile.in b/dlls/Makefile.in index 56412cf..9cc2ec7 100644 --- a/dlls/Makefile.in +++ b/dlls/Makefile.in @@ -274,6 +274,7 @@ TESTSUBDIRS = \ odbccp32/tests \ ole32/tests \ oleaut32/tests \ + pdh/tests \ psapi/tests \ quartz/tests \ riched20/tests \ @@ -550,6 +551,7 @@ IMPORT_LIBS = \ olepro32/libolepro32.$(IMPLIBEXT) \ olesvr32/libolesvr32.$(IMPLIBEXT) \ opengl32/libopengl32.$(IMPLIBEXT) \ + pdh/libpdh.$(IMPLIBEXT) \ powrprof/libpowrprof.$(IMPLIBEXT) \ psapi/libpsapi.$(IMPLIBEXT) \ quartz/libquartz.$(IMPLIBEXT) \ @@ -840,6 +842,9 @@ olesvr32/libolesvr32.$(IMPLIBEXT): olesvr32/olesvr32.spec $(WINEBUILD) opengl32/libopengl32.$(IMPLIBEXT): opengl32/opengl32.spec $(WINEBUILD) @cd opengl32 && $(MAKE) libopengl32.$(IMPLIBEXT) +pdh/libpdh.$(IMPLIBEXT): pdh/pdh.spec $(WINEBUILD) + @cd pdh && $(MAKE) libpdh.$(IMPLIBEXT) + powrprof/libpowrprof.$(IMPLIBEXT): powrprof/powrprof.spec $(WINEBUILD) @cd powrprof && $(MAKE) libpowrprof.$(IMPLIBEXT) diff --git a/dlls/pdh/Makefile.in b/dlls/pdh/Makefile.in index 38155aa..d9920ea 100644 --- a/dlls/pdh/Makefile.in +++ b/dlls/pdh/Makefile.in @@ -3,6 +3,7 @@ TOPOBJDIR = ../.. SRCDIR = @srcdir@ VPATH = @srcdir@ MODULE = pdh.dll +IMPORTLIB = libpdh.$(IMPLIBEXT) IMPORTS = kernel32 C_SRCS = \ diff --git a/dlls/pdh/tests/Makefile.in b/dlls/pdh/tests/Makefile.in new file mode 100644 index 0000000..9f89dff --- /dev/null +++ b/dlls/pdh/tests/Makefile.in @@ -0,0 +1,13 @@ +TOPSRCDIR = @top_srcdir@ +TOPOBJDIR = ../../.. +SRCDIR = @srcdir@ +VPATH = @srcdir@ +TESTDLL = pdh.dll +IMPORTS = pdh kernel32 + +CTESTS = \ + pdh.c + +@MAKE_TEST_RULES@ + +@DEPENDENCIES@ # everything below this line is overwritten by make depend diff --git a/dlls/pdh/tests/pdh.c b/dlls/pdh/tests/pdh.c new file mode 100644 index 0000000..872f2a1 --- /dev/null +++ b/dlls/pdh/tests/pdh.c @@ -0,0 +1,54 @@ +/* + * Tests for pdh.dll (Performance Data Helper) + * + * Copyright 2007 Hans Leidekker + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA + */ + +#include <stdio.h> + +#include "windows.h" + +#include "pdh.h" +#include "pdhmsg.h" + +#include "wine/test.h" + +static void test_open_close_query( void ) +{ + PDH_STATUS ret; + PDH_HQUERY query; + + ret = PdhOpenQueryA( NULL, 0, NULL ); + ok(ret == PDH_INVALID_ARGUMENT, "PdhOpenQueryA failed 0x%08x\n", ret); + + ret = PdhOpenQueryA( NULL, 0, &query ); + ok(ret == ERROR_SUCCESS, "PdhOpenQueryA failed 0x%08x\n", ret); + + ret = PdhCloseQuery( NULL ); + ok(ret == PDH_INVALID_HANDLE, "PdhCloseQuery failed 0x%08x\n", ret); + + ret = PdhCloseQuery( &query ); + ok(ret == PDH_INVALID_HANDLE, "PdhCloseQuery failed 0x%08x\n", ret); + + ret = PdhCloseQuery( query ); + ok(ret == ERROR_SUCCESS, "PdhCloseQuery failed 0x%08x\n", ret); +} + +START_TEST(pdh) +{ + test_open_close_query(); +} diff --git a/programs/winetest/Makefile.in b/programs/winetest/Makefile.in index 3b85ea9..f0eeac4 100644 --- a/programs/winetest/Makefile.in +++ b/programs/winetest/Makefile.in @@ -64,6 +64,7 @@ TESTBINS = \ odbccp32_test.exe \ ole32_test.exe \ oleaut32_test.exe \ + pdh_test.exe \ psapi_test.exe \ quartz_test.exe \ riched20_test.exe \ @@ -171,6 +172,8 @@ ole32_test.exe: $(DLLDIR)/ole32/tests/ole32_test.exe$(DLLEXT) cp $(DLLDIR)/ole32/tests/ole32_test.exe$(DLLEXT) $@ && $(STRIP) $@ oleaut32_test.exe: $(DLLDIR)/oleaut32/tests/oleaut32_test.exe$(DLLEXT) cp $(DLLDIR)/oleaut32/tests/oleaut32_test.exe$(DLLEXT) $@ && $(STRIP) $@ +pdh_test.exe: $(DLLDIR)/pdh/tests/pdh_test.exe$(DLLEXT) + cp $(DLLDIR)/pdh/tests/pdh_test.exe$(DLLEXT) $@ && $(STRIP) $@ psapi_test.exe: $(DLLDIR)/psapi/tests/psapi_test.exe$(DLLEXT) cp $(DLLDIR)/psapi/tests/psapi_test.exe$(DLLEXT) $@ && $(STRIP) $@ quartz_test.exe: $(DLLDIR)/quartz/tests/quartz_test.exe$(DLLEXT) diff --git a/programs/winetest/winetest.rc b/programs/winetest/winetest.rc index d6d0c0d..37a9e5c 100644 --- a/programs/winetest/winetest.rc +++ b/programs/winetest/winetest.rc @@ -187,6 +187,7 @@ ntprint_test.exe TESTRES "ntprint_test.exe" odbccp32_test.exe TESTRES "odbccp32_test.exe" ole32_test.exe TESTRES "ole32_test.exe" oleaut32_test.exe TESTRES "oleaut32_test.exe" +pdh_test.exe TESTRES "pdh_test.exe" psapi_test.exe TESTRES "psapi_test.exe" quartz_test.exe TESTRES "quartz_test.exe" riched20_test.exe TESTRES "riched20_test.exe"
1
0
0
0
Vitaliy Margolen : dinput: Rename set_dinput_hook and call it from the base class.
by Alexandre Julliard
09 Jul '07
09 Jul '07
Module: wine Branch: master Commit: 8f28d4369e04af31d87faea1e05e2118b4fd21ba URL:
http://source.winehq.org/git/wine.git/?a=commit;h=8f28d4369e04af31d87faea1e…
Author: Vitaliy Margolen <wine-patches(a)kievinfo.com> Date: Fri Jul 6 23:36:39 2007 -0600 dinput: Rename set_dinput_hook and call it from the base class. Since keyboard's acquire and unacquire don't do anything special just call the base class. --- dlls/dinput/device.c | 5 +++++ dlls/dinput/dinput_main.c | 4 ++-- dlls/dinput/dinput_private.h | 2 +- dlls/dinput/keyboard.c | 38 ++++---------------------------------- dlls/dinput/mouse.c | 2 -- 5 files changed, 12 insertions(+), 39 deletions(-) diff --git a/dlls/dinput/device.c b/dlls/dinput/device.c index 618665f..1dc6e4a 100644 --- a/dlls/dinput/device.c +++ b/dlls/dinput/device.c @@ -563,7 +563,10 @@ HRESULT WINAPI IDirectInputDevice2AImpl_Acquire(LPDIRECTINPUTDEVICE8A iface) res = This->acquired ? S_FALSE : DI_OK; This->acquired = 1; if (res == DI_OK) + { This->queue_head = This->queue_tail = This->overflow = 0; + check_dinput_hooks(iface); + } LeaveCriticalSection(&This->crit); return res; @@ -581,6 +584,8 @@ HRESULT WINAPI IDirectInputDevice2AImpl_Unacquire(LPDIRECTINPUTDEVICE8A iface) EnterCriticalSection(&This->crit); res = !This->acquired ? DI_NOEFFECT : DI_OK; This->acquired = 0; + if (res == DI_OK) + check_dinput_hooks(iface); LeaveCriticalSection(&This->crit); return res; diff --git a/dlls/dinput/dinput_main.c b/dlls/dinput/dinput_main.c index b723de3..20550c7 100644 --- a/dlls/dinput/dinput_main.c +++ b/dlls/dinput/dinput_main.c @@ -854,12 +854,12 @@ static BOOL check_hook_thread(void) return hook_thread_hwnd != 0; } -HHOOK set_dinput_hook(int hook_id, LPVOID proc) +void check_dinput_hooks(LPDIRECTINPUTDEVICE8A iface) { HWND hwnd; EnterCriticalSection(&dinput_hook_crit); hwnd = hook_thread_hwnd; LeaveCriticalSection(&dinput_hook_crit); - return (HHOOK)SendMessageW(hwnd, WM_USER+0x10, (WPARAM)hook_id, (LPARAM)proc); + SendMessageW(hwnd, WM_USER+0x10, 1, 0); } diff --git a/dlls/dinput/dinput_private.h b/dlls/dinput/dinput_private.h index 4bce692..a371263 100644 --- a/dlls/dinput/dinput_private.h +++ b/dlls/dinput/dinput_private.h @@ -57,7 +57,7 @@ extern const struct dinput_device joystick_linuxinput_device; extern HINSTANCE DINPUT_instance; -extern HHOOK set_dinput_hook(int hook_id, LPVOID proc); +extern void check_dinput_hooks(LPDIRECTINPUTDEVICE8A); typedef void (*DI_EVENT_PROC)(LPDIRECTINPUTDEVICE8A, WPARAM, LPARAM); #endif /* __WINE_DLLS_DINPUT_DINPUT_PRIVATE_H */ diff --git a/dlls/dinput/keyboard.c b/dlls/dinput/keyboard.c index 745ab7f..ef66ed9 100644 --- a/dlls/dinput/keyboard.c +++ b/dlls/dinput/keyboard.c @@ -287,36 +287,6 @@ static HRESULT WINAPI SysKeyboardAImpl_GetDeviceState( return DI_OK; } -static HRESULT WINAPI SysKeyboardAImpl_Unacquire(LPDIRECTINPUTDEVICE8A iface); - -static HRESULT WINAPI SysKeyboardAImpl_Acquire(LPDIRECTINPUTDEVICE8A iface) -{ - SysKeyboardImpl *This = (SysKeyboardImpl *)iface; - HRESULT res; - - TRACE("(%p)\n",This); - - if ((res = IDirectInputDevice2AImpl_Acquire(iface)) != DI_OK) return res; - - set_dinput_hook(WH_KEYBOARD_LL, KeyboardCallback); - - return DI_OK; -} - -static HRESULT WINAPI SysKeyboardAImpl_Unacquire(LPDIRECTINPUTDEVICE8A iface) -{ - SysKeyboardImpl *This = (SysKeyboardImpl *)iface; - HRESULT res; - - TRACE("(this=%p)\n",This); - - if ((res = IDirectInputDevice2AImpl_Unacquire(iface)) != DI_OK) return res; - - set_dinput_hook(WH_KEYBOARD_LL, NULL); - - return DI_OK; -} - /****************************************************************************** * GetCapabilities : get the device capablitites */ @@ -442,8 +412,8 @@ static const IDirectInputDevice8AVtbl SysKeyboardAvt = IDirectInputDevice2AImpl_EnumObjects, IDirectInputDevice2AImpl_GetProperty, IDirectInputDevice2AImpl_SetProperty, - SysKeyboardAImpl_Acquire, - SysKeyboardAImpl_Unacquire, + IDirectInputDevice2AImpl_Acquire, + IDirectInputDevice2AImpl_Unacquire, SysKeyboardAImpl_GetDeviceState, IDirectInputDevice2AImpl_GetDeviceData, IDirectInputDevice2AImpl_SetDataFormat, @@ -484,8 +454,8 @@ static const IDirectInputDevice8WVtbl SysKeyboardWvt = IDirectInputDevice2WImpl_EnumObjects, XCAST(GetProperty)IDirectInputDevice2AImpl_GetProperty, XCAST(SetProperty)IDirectInputDevice2AImpl_SetProperty, - XCAST(Acquire)SysKeyboardAImpl_Acquire, - XCAST(Unacquire)SysKeyboardAImpl_Unacquire, + XCAST(Acquire)IDirectInputDevice2AImpl_Acquire, + XCAST(Unacquire)IDirectInputDevice2AImpl_Unacquire, XCAST(GetDeviceState)SysKeyboardAImpl_GetDeviceState, XCAST(GetDeviceData)IDirectInputDevice2AImpl_GetDeviceData, XCAST(SetDataFormat)IDirectInputDevice2AImpl_SetDataFormat, diff --git a/dlls/dinput/mouse.c b/dlls/dinput/mouse.c index 0e9a349..eeada11 100644 --- a/dlls/dinput/mouse.c +++ b/dlls/dinput/mouse.c @@ -398,7 +398,6 @@ static HRESULT WINAPI SysMouseAImpl_Acquire(LPDIRECTINPUTDEVICE8A iface) /* Install our mouse hook */ if (This->base.dwCoopLevel & DISCL_EXCLUSIVE) ShowCursor(FALSE); /* hide cursor */ - set_dinput_hook(WH_MOUSE_LL, dinput_mouse_hook); /* Get the window dimension and find the center */ GetWindowRect(This->base.win, &rect); @@ -433,7 +432,6 @@ static HRESULT WINAPI SysMouseAImpl_Unacquire(LPDIRECTINPUTDEVICE8A iface) if ((res = IDirectInputDevice2AImpl_Unacquire(iface)) != DI_OK) return res; - set_dinput_hook(WH_MOUSE_LL, NULL); if (This->base.dwCoopLevel & DISCL_EXCLUSIVE) ShowCursor(TRUE); /* show cursor */
1
0
0
0
Vitaliy Margolen : dinput: Handle multiple keyboard and mouse devices.
by Alexandre Julliard
09 Jul '07
09 Jul '07
Module: wine Branch: master Commit: deb74efc04b52d5a8dfb747b4b683d7fd7e6f3a6 URL:
http://source.winehq.org/git/wine.git/?a=commit;h=deb74efc04b52d5a8dfb747b4…
Author: Vitaliy Margolen <wine-patches(a)kievinfo.com> Date: Fri Jul 6 23:36:30 2007 -0600 dinput: Handle multiple keyboard and mouse devices. --- dlls/dinput/device_private.h | 1 + dlls/dinput/dinput_main.c | 89 ++++++++++++++++++++++++++++++------------ dlls/dinput/dinput_private.h | 1 + dlls/dinput/keyboard.c | 38 ++++-------------- dlls/dinput/mouse.c | 25 ++---------- 5 files changed, 79 insertions(+), 75 deletions(-) Diff:
http://source.winehq.org/git/wine.git/?a=commitdiff;h=deb74efc04b52d5a8dfb7…
1
0
0
0
Vitaliy Margolen : dinput: Export Mouse and Keyboard GUIDs.
by Alexandre Julliard
09 Jul '07
09 Jul '07
Module: wine Branch: master Commit: 6d6e4f4ea25759d3f66cc890564dc767a1dafcc8 URL:
http://source.winehq.org/git/wine.git/?a=commit;h=6d6e4f4ea25759d3f66cc8905…
Author: Vitaliy Margolen <wine-patches(a)kievinfo.com> Date: Fri Jul 6 23:36:22 2007 -0600 dinput: Export Mouse and Keyboard GUIDs. --- dlls/dinput/device_private.h | 2 ++ dlls/dinput/keyboard.c | 7 ++----- dlls/dinput/mouse.c | 7 ++----- 3 files changed, 6 insertions(+), 10 deletions(-) diff --git a/dlls/dinput/device_private.h b/dlls/dinput/device_private.h index 2ac609b..6d874d4 100644 --- a/dlls/dinput/device_private.h +++ b/dlls/dinput/device_private.h @@ -91,6 +91,8 @@ typedef struct { extern BOOL DIEnumDevicesCallbackAtoW(LPCDIDEVICEOBJECTINSTANCEA, LPVOID); +extern const GUID DInput_Wine_Keyboard_GUID; +extern const GUID DInput_Wine_Mouse_GUID; /* Various debug tools */ extern void _dump_cooperativelevel_DI(DWORD dwFlags) ; diff --git a/dlls/dinput/keyboard.c b/dlls/dinput/keyboard.c index ad44023..0c5aef0 100644 --- a/dlls/dinput/keyboard.c +++ b/dlls/dinput/keyboard.c @@ -90,11 +90,8 @@ static LRESULT CALLBACK KeyboardCallback( int code, WPARAM wparam, LPARAM lparam return CallNextHookEx(0, code, wparam, lparam); } -static const GUID DInput_Wine_Keyboard_GUID = { /* 0ab8648a-7735-11d2-8c73-71df54a96441 */ - 0x0ab8648a, - 0x7735, - 0x11d2, - {0x8c, 0x73, 0x71, 0xdf, 0x54, 0xa9, 0x64, 0x41} +const GUID DInput_Wine_Keyboard_GUID = { /* 0ab8648a-7735-11d2-8c73-71df54a96441 */ + 0x0ab8648a, 0x7735, 0x11d2, {0x8c, 0x73, 0x71, 0xdf, 0x54, 0xa9, 0x64, 0x41} }; static void fill_keyboard_dideviceinstanceA(LPDIDEVICEINSTANCEA lpddi, DWORD version) { diff --git a/dlls/dinput/mouse.c b/dlls/dinput/mouse.c index 3c80e7e..df04ee5 100644 --- a/dlls/dinput/mouse.c +++ b/dlls/dinput/mouse.c @@ -71,11 +71,8 @@ struct SysMouseImpl /* FIXME: This is ugly and not thread safe :/ */ static IDirectInputDevice8A* current_lock = NULL; -static const GUID DInput_Wine_Mouse_GUID = { /* 9e573ed8-7734-11d2-8d4a-23903fb6bdf7 */ - 0x9e573ed8, - 0x7734, - 0x11d2, - {0x8d, 0x4a, 0x23, 0x90, 0x3f, 0xb6, 0xbd, 0xf7} +const GUID DInput_Wine_Mouse_GUID = { /* 9e573ed8-7734-11d2-8d4a-23903fb6bdf7 */ + 0x9e573ed8, 0x7734, 0x11d2, {0x8d, 0x4a, 0x23, 0x90, 0x3f, 0xb6, 0xbd, 0xf7} }; static void fill_mouse_dideviceinstanceA(LPDIDEVICEINSTANCEA lpddi, DWORD version) {
1
0
0
0
Vitaliy Margolen : dinput: Keep a list of all IDirectInput objects and check it instead of refcount to create /destroy hook thread.
by Alexandre Julliard
09 Jul '07
09 Jul '07
Module: wine Branch: master Commit: fe1f1362b88280724043ff21ab67ee6010773451 URL:
http://source.winehq.org/git/wine.git/?a=commit;h=fe1f1362b88280724043ff21a…
Author: Vitaliy Margolen <wine-patches(a)kievinfo.com> Date: Fri Jul 6 23:36:18 2007 -0600 dinput: Keep a list of all IDirectInput objects and check it instead of refcount to create/destroy hook thread. --- dlls/dinput/dinput_main.c | 109 ++++++++++++++++++------------------------ dlls/dinput/dinput_private.h | 1 + 2 files changed, 48 insertions(+), 62 deletions(-) diff --git a/dlls/dinput/dinput_main.c b/dlls/dinput/dinput_main.c index 52be7f3..2399f2c 100644 --- a/dlls/dinput/dinput_main.c +++ b/dlls/dinput/dinput_main.c @@ -77,8 +77,9 @@ BOOL WINAPI DllMain( HINSTANCE inst, DWORD reason, LPVOID reserv) return TRUE; } -static BOOL create_hook_thread(void); -static void release_hook_thread(void); +static BOOL check_hook_thread(void); +static CRITICAL_SECTION dinput_hook_crit; +static struct list direct_input_list = LIST_INIT( direct_input_list ); /****************************************************************************** * DirectInputCreateEx (DINPUT.@) @@ -88,55 +89,48 @@ HRESULT WINAPI DirectInputCreateEx( LPUNKNOWN punkOuter) { IDirectInputImpl* This; - HRESULT res = DIERR_OLDDIRECTINPUTVERSION; LPCVOID vtable = NULL; TRACE("(%p,%04x,%s,%p,%p)\n", hinst, dwVersion, debugstr_guid(riid), ppDI, punkOuter); - if (IsEqualGUID(&IID_IDirectInputA,riid) || - IsEqualGUID(&IID_IDirectInput2A,riid) || - IsEqualGUID(&IID_IDirectInput7A,riid)) - { - vtable = &ddi7avt; - res = DI_OK; - } + if (IsEqualGUID( &IID_IDirectInputA, riid ) || + IsEqualGUID( &IID_IDirectInput2A, riid ) || + IsEqualGUID( &IID_IDirectInput7A, riid )) vtable = &ddi7avt; + else if (IsEqualGUID( &IID_IDirectInputW, riid ) || + IsEqualGUID( &IID_IDirectInput2W, riid ) || + IsEqualGUID( &IID_IDirectInput7W, riid )) vtable = &ddi7wvt; + else if (IsEqualGUID( &IID_IDirectInput8A, riid )) vtable = &ddi8avt; + else if (IsEqualGUID( &IID_IDirectInput8W, riid )) vtable = &ddi8wvt; + else + return DIERR_OLDDIRECTINPUTVERSION; - if (IsEqualGUID(&IID_IDirectInputW,riid) || - IsEqualGUID(&IID_IDirectInput2W,riid) || - IsEqualGUID(&IID_IDirectInput7W,riid)) - { - vtable = &ddi7wvt; - res = DI_OK; - } + if (!(This = HeapAlloc( GetProcessHeap(), 0, sizeof(IDirectInputImpl) ))) + return DIERR_OUTOFMEMORY; - if (IsEqualGUID(&IID_IDirectInput8A,riid)) - { - vtable = &ddi8avt; - res = DI_OK; - } + This->lpVtbl = vtable; + This->ref = 1; + This->dwVersion = dwVersion; + This->evsequence = 1; - if (IsEqualGUID(&IID_IDirectInput8W,riid)) - { - vtable = &ddi8wvt; - res = DI_OK; - } - if (res == DI_OK && !create_hook_thread()) res = DIERR_GENERIC; - if (res == DI_OK) - { - This = HeapAlloc(GetProcessHeap(), 0, sizeof(IDirectInputImpl)); - This->lpVtbl = vtable; - This->ref = 1; - This->dwVersion = dwVersion; - This->evsequence = 1; - *ppDI = This; + InitializeCriticalSection(&This->crit); + This->crit.DebugInfo->Spare[0] = (DWORD_PTR)(__FILE__ ": IDirectInputImpl*->crit"); - InitializeCriticalSection(&This->crit); - This->crit.DebugInfo->Spare[0] = (DWORD_PTR)(__FILE__ ": IDirectInputImpl*->crit"); + list_init( &This->devices_list ); - list_init( &This->devices_list ); + /* Add self to the list of the IDirectInputs */ + EnterCriticalSection( &dinput_hook_crit ); + list_add_head( &direct_input_list, &This->entry ); + LeaveCriticalSection( &dinput_hook_crit ); + + if (!check_hook_thread()) + { + IUnknown_Release( (LPDIRECTINPUT7A)This ); + return DIERR_GENERIC; } - return res; + + *ppDI = This; + return DI_OK; } /****************************************************************************** @@ -266,7 +260,12 @@ static ULONG WINAPI IDirectInputAImpl_Release(LPDIRECTINPUT7A iface) ref = InterlockedDecrement( &This->ref ); if (ref) return ref; - release_hook_thread(); + /* Remove self from the list of the IDirectInputs */ + EnterCriticalSection( &dinput_hook_crit ); + list_remove( &This->entry ); + LeaveCriticalSection( &dinput_hook_crit ); + + check_hook_thread(); This->crit.DebugInfo->Spare[0] = 0; DeleteCriticalSection( &This->crit ); @@ -734,7 +733,6 @@ static LRESULT CALLBACK dinput_hook_WndProc(HWND hWnd, UINT message, WPARAM wPar } static HWND hook_thread_hwnd; -static LONG hook_thread_refcount; static HANDLE hook_thread; static const WCHAR classW[]={'H','o','o','k','_','L','L','_','C','L',0}; @@ -763,7 +761,6 @@ static DWORD WINAPI hook_thread_proc(void *param) return 0; } -static CRITICAL_SECTION dinput_hook_crit; static CRITICAL_SECTION_DEBUG dinput_critsect_debug = { 0, 0, &dinput_hook_crit, @@ -772,15 +769,12 @@ static CRITICAL_SECTION_DEBUG dinput_critsect_debug = }; static CRITICAL_SECTION dinput_hook_crit = { &dinput_critsect_debug, -1, 0, 0, 0, 0 }; -static BOOL create_hook_thread(void) +static BOOL check_hook_thread(void) { - LONG ref; - EnterCriticalSection(&dinput_hook_crit); - ref = ++hook_thread_refcount; - TRACE("Refcount %d\n", ref); - if (ref == 1) + TRACE("IDirectInputs left: %d\n", list_count(&direct_input_list)); + if (!list_empty(&direct_input_list) && !hook_thread) { DWORD tid; HANDLE event; @@ -806,19 +800,7 @@ static BOOL create_hook_thread(void) } CloseHandle(event); } - LeaveCriticalSection(&dinput_hook_crit); - - return hook_thread_hwnd != 0; -} - -static void release_hook_thread(void) -{ - LONG ref; - - EnterCriticalSection(&dinput_hook_crit); - ref = --hook_thread_refcount; - TRACE("Releasing to %d\n", ref); - if (ref == 0) + else if (list_empty(&direct_input_list) && hook_thread) { HWND hwnd = hook_thread_hwnd; hook_thread_hwnd = 0; @@ -826,8 +808,11 @@ static void release_hook_thread(void) /* wait for hook thread to exit */ WaitForSingleObject(hook_thread, INFINITE); CloseHandle(hook_thread); + hook_thread = NULL; } LeaveCriticalSection(&dinput_hook_crit); + + return hook_thread_hwnd != 0; } HHOOK set_dinput_hook(int hook_id, LPVOID proc) diff --git a/dlls/dinput/dinput_private.h b/dlls/dinput/dinput_private.h index b29f61e..a5b74dc 100644 --- a/dlls/dinput/dinput_private.h +++ b/dlls/dinput/dinput_private.h @@ -34,6 +34,7 @@ struct IDirectInputImpl LONG ref; CRITICAL_SECTION crit; + struct list entry; /* entry into list of all IDirectInputs */ DWORD evsequence; /* unique sequence number for events */ DWORD dwVersion; /* direct input version number */
1
0
0
0
← Newer
1
...
75
76
77
78
79
80
81
...
96
Older →
Jump to page:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
Results per page:
10
25
50
100
200