Nikolay Sivov : gdiplus: Move some Beziers helpers to gdiplus. c to use them for graphicspath.
Alexandre Julliard
julliard at winehq.org
Mon Aug 4 08:53:46 CDT 2008
Module: wine
Branch: master
Commit: 2fb0c7e639d0c8ff8920a44f5400629503925133
URL: http://source.winehq.org/git/wine.git/?a=commit;h=2fb0c7e639d0c8ff8920a44f5400629503925133
Author: Nikolay Sivov <bunglehead at gmail.com>
Date: Sun Aug 3 02:44:57 2008 +0400
gdiplus: Move some Beziers helpers to gdiplus.c to use them for graphicspath.
---
dlls/gdiplus/gdiplus.c | 26 ++++++++++++++++++++++++++
dlls/gdiplus/gdiplus_private.h | 6 ++++++
dlls/gdiplus/graphics.c | 29 -----------------------------
3 files changed, 32 insertions(+), 29 deletions(-)
diff --git a/dlls/gdiplus/gdiplus.c b/dlls/gdiplus/gdiplus.c
index fb38497..070a80f 100644
--- a/dlls/gdiplus/gdiplus.c
+++ b/dlls/gdiplus/gdiplus.c
@@ -285,3 +285,29 @@ REAL convert_unit(HDC hdc, GpUnit unit)
return 1.0;
}
}
+
+/* Calculates Bezier points from cardinal spline points. */
+void calc_curve_bezier(CONST GpPointF *pts, REAL tension, REAL *x1,
+ REAL *y1, REAL *x2, REAL *y2)
+{
+ REAL xdiff, ydiff;
+
+ /* calculate tangent */
+ xdiff = pts[2].X - pts[0].X;
+ ydiff = pts[2].Y - pts[0].Y;
+
+ /* apply tangent to get control points */
+ *x1 = pts[1].X - tension * xdiff;
+ *y1 = pts[1].Y - tension * ydiff;
+ *x2 = pts[1].X + tension * xdiff;
+ *y2 = pts[1].Y + tension * ydiff;
+}
+
+/* Calculates Bezier points from cardinal spline endpoints. */
+void calc_curve_bezier_endp(REAL xend, REAL yend, REAL xadj, REAL yadj,
+ REAL tension, REAL *x, REAL *y)
+{
+ /* tangent at endpoints is the line from the endpoint to the adjacent point */
+ *x = roundr(tension * (xadj - xend) + xend);
+ *y = roundr(tension * (yadj - yend) + yend);
+}
diff --git a/dlls/gdiplus/gdiplus_private.h b/dlls/gdiplus/gdiplus_private.h
index 8fe8862..3611239 100644
--- a/dlls/gdiplus/gdiplus_private.h
+++ b/dlls/gdiplus/gdiplus_private.h
@@ -38,6 +38,7 @@
#define INCH_HIMETRIC (2540)
#define VERSION_MAGIC 0xdbc01001
+#define TENSION_CONST (0.3)
COLORREF ARGB2COLORREF(ARGB color);
extern INT arc2polybezier(GpPointF * points, REAL x1, REAL y1, REAL x2, REAL y2,
@@ -46,6 +47,11 @@ extern REAL gdiplus_atan2(REAL dy, REAL dx);
extern GpStatus hresult_to_status(HRESULT res);
extern REAL convert_unit(HDC hdc, GpUnit unit);
+extern void calc_curve_bezier(CONST GpPointF *pts, REAL tension, REAL *x1,
+ REAL *y1, REAL *x2, REAL *y2);
+extern void calc_curve_bezier_endp(REAL xend, REAL yend, REAL xadj, REAL yadj,
+ REAL tension, REAL *x, REAL *y);
+
static inline INT roundr(REAL x)
{
return (INT) floorf(x + 0.5);
diff --git a/dlls/gdiplus/graphics.c b/dlls/gdiplus/graphics.c
index 4448b6a..2450b47 100644
--- a/dlls/gdiplus/graphics.c
+++ b/dlls/gdiplus/graphics.c
@@ -42,7 +42,6 @@
WINE_DEFAULT_DEBUG_CHANNEL(gdiplus);
/* looks-right constants */
-#define TENSION_CONST (0.3)
#define ANCHOR_WIDTH (2.0)
#define MAX_ITERS (50)
@@ -194,34 +193,6 @@ static void draw_pie(GpGraphics *graphics, REAL x, REAL y, REAL width,
pti[2].y, pti[3].x, pti[3].y);
}
-/* GdipDrawCurve helper function.
- * Calculates Bezier points from cardinal spline points. */
-static void calc_curve_bezier(CONST GpPointF *pts, REAL tension, REAL *x1,
- REAL *y1, REAL *x2, REAL *y2)
-{
- REAL xdiff, ydiff;
-
- /* calculate tangent */
- xdiff = pts[2].X - pts[0].X;
- ydiff = pts[2].Y - pts[0].Y;
-
- /* apply tangent to get control points */
- *x1 = pts[1].X - tension * xdiff;
- *y1 = pts[1].Y - tension * ydiff;
- *x2 = pts[1].X + tension * xdiff;
- *y2 = pts[1].Y + tension * ydiff;
-}
-
-/* GdipDrawCurve helper function.
- * Calculates Bezier points from cardinal spline endpoints. */
-static void calc_curve_bezier_endp(REAL xend, REAL yend, REAL xadj, REAL yadj,
- REAL tension, REAL *x, REAL *y)
-{
- /* tangent at endpoints is the line from the endpoint to the adjacent point */
- *x = roundr(tension * (xadj - xend) + xend);
- *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. Probably
* should not be called on an hdc that has a path you care about. */
More information about the wine-cvs
mailing list