[4/5] gdiplus: Send paths to gdi32 in device coordinates.
Vincent Povirk
vincent at codeweavers.com
Thu Aug 31 14:14:07 CDT 2017
Signed-off-by: Vincent Povirk <vincent at codeweavers.com>
---
dlls/gdiplus/graphics.c | 59 ++++++++++++++++++++++++++++++++++++++-----------
dlls/gdiplus/region.c | 4 ++++
2 files changed, 50 insertions(+), 13 deletions(-)
diff --git a/dlls/gdiplus/graphics.c b/dlls/gdiplus/graphics.c
index 3ac9952..f4dc3e6 100644
--- a/dlls/gdiplus/graphics.c
+++ b/dlls/gdiplus/graphics.c
@@ -249,6 +249,14 @@ static INT prepare_dc(GpGraphics *graphics, GpPen *pen)
width *= units_to_pixels(pen->width, pen->unit == UnitWorld ? graphics->unit : pen->unit, graphics->xres);
width *= graphics->scale;
+
+ pt[0].X = 0.0;
+ pt[0].Y = 0.0;
+ pt[1].X = 1.0;
+ pt[1].Y = 1.0;
+ gdip_transform_points(graphics, WineCoordinateSpaceGdiDevice, CoordinateSpaceDevice, pt, 2);
+ width *= sqrt((pt[1].X - pt[0].X) * (pt[1].X - pt[0].X) +
+ (pt[1].Y - pt[0].Y) * (pt[1].Y - pt[0].Y)) / sqrt(2.0);
}
if(pen->dash == DashStyleCustom){
@@ -1573,7 +1581,10 @@ static void draw_cap(GpGraphics *graphics, COLORREF color, GpLineCap cap, REAL s
ptf[3].X = x2 - dbig;
ptf[2].X = x2 + dsmall;
- transform_and_round_points(graphics, pt, ptf, 4);
+ gdip_transform_points(graphics, WineCoordinateSpaceGdiDevice, CoordinateSpaceWorld, ptf, 3);
+
+ round_points(pt, ptf, 3);
+
Polygon(graphics->hdc, pt, 4);
break;
@@ -1595,7 +1606,10 @@ static void draw_cap(GpGraphics *graphics, COLORREF color, GpLineCap cap, REAL s
ptf[2].X = x2;
ptf[2].Y = y2;
- transform_and_round_points(graphics, pt, ptf, 3);
+ gdip_transform_points(graphics, WineCoordinateSpaceGdiDevice, CoordinateSpaceWorld, ptf, 3);
+
+ round_points(pt, ptf, 3);
+
Polygon(graphics->hdc, pt, 3);
break;
@@ -1607,7 +1621,10 @@ static void draw_cap(GpGraphics *graphics, COLORREF color, GpLineCap cap, REAL s
ptf[1].X = x2 + dx;
ptf[1].Y = y2 + dy;
- transform_and_round_points(graphics, pt, ptf, 2);
+ gdip_transform_points(graphics, WineCoordinateSpaceGdiDevice, CoordinateSpaceWorld, ptf, 3);
+
+ round_points(pt, ptf, 3);
+
Ellipse(graphics->hdc, pt[0].x, pt[0].y, pt[1].x, pt[1].y);
break;
@@ -1627,7 +1644,10 @@ static void draw_cap(GpGraphics *graphics, COLORREF color, GpLineCap cap, REAL s
ptf[2].X = x2 + dx;
ptf[2].Y = y2 + dy;
- transform_and_round_points(graphics, pt, ptf, 3);
+ gdip_transform_points(graphics, WineCoordinateSpaceGdiDevice, CoordinateSpaceWorld, ptf, 3);
+
+ round_points(pt, ptf, 3);
+
Polygon(graphics->hdc, pt, 3);
break;
@@ -1647,7 +1667,10 @@ static void draw_cap(GpGraphics *graphics, COLORREF color, GpLineCap cap, REAL s
ptf[3].X = x2 + dx;
ptf[3].Y = y2 + dy;
- transform_and_round_points(graphics, pt, ptf, 4);
+ gdip_transform_points(graphics, WineCoordinateSpaceGdiDevice, CoordinateSpaceWorld, ptf, 3);
+
+ round_points(pt, ptf, 3);
+
Pie(graphics->hdc, pt[0].x, pt[0].y, pt[1].x, pt[1].y, pt[2].x,
pt[2].y, pt[3].x, pt[3].y);
@@ -1673,7 +1696,9 @@ static void draw_cap(GpGraphics *graphics, COLORREF color, GpLineCap cap, REAL s
GdipTranslateMatrix(&matrix, x2, y2, MatrixOrderAppend);
GdipTransformMatrixPoints(&matrix, custptf, count);
- transform_and_round_points(graphics, custpt, custptf, count);
+ gdip_transform_points(graphics, WineCoordinateSpaceGdiDevice, CoordinateSpaceWorld, ptf, 3);
+
+ round_points(pt, ptf, 3);
for(i = 0; i < count; i++)
tp[i] = convert_path_point_type(custom->pathdata.Types[i]);
@@ -1896,7 +1921,9 @@ static GpStatus draw_poly(GpGraphics *graphics, GpPen *pen, GDIPCONST GpPointF *
}
}
- transform_and_round_points(graphics, pti, ptcopy, count);
+ gdip_transform_points(graphics, WineCoordinateSpaceGdiDevice, CoordinateSpaceWorld, ptcopy, count);
+
+ round_points(pti, ptcopy, count);
for(i = 0; i < count; i++){
tp[i] = convert_path_point_type(types[i]);
@@ -3433,9 +3460,13 @@ static GpStatus GDI32_GdipDrawPath(GpGraphics *graphics, GpPen *pen, GpPath *pat
if (hrgn)
ExtSelectClipRgn(graphics->hdc, hrgn, RGN_AND);
+ gdi_transform_acquire(graphics);
+
retval = draw_poly(graphics, pen, path->pathdata.Points,
path->pathdata.Types, path->pathdata.Count, TRUE);
+ gdi_transform_release(graphics);
+
end:
restore_dc(graphics, save_state);
DeleteObject(hrgn);
@@ -4114,17 +4145,19 @@ static GpStatus GDI32_GdipFillPath(GpGraphics *graphics, GpBrush *brush, GpPath
if (hrgn)
ExtSelectClipRgn(graphics->hdc, hrgn, RGN_AND);
+ gdi_transform_acquire(graphics);
+
BeginPath(graphics->hdc);
retval = draw_poly(graphics, NULL, path->pathdata.Points,
path->pathdata.Types, path->pathdata.Count, FALSE);
- if(retval != Ok)
- goto end;
-
- EndPath(graphics->hdc);
- brush_fill_path(graphics, brush);
+ if(retval == Ok)
+ {
+ EndPath(graphics->hdc);
+ brush_fill_path(graphics, brush);
+ }
- retval = Ok;
+ gdi_transform_release(graphics);
end:
RestoreDC(graphics->hdc, save_state);
diff --git a/dlls/gdiplus/region.c b/dlls/gdiplus/region.c
index 015b677..8a2ca6b 100644
--- a/dlls/gdiplus/region.c
+++ b/dlls/gdiplus/region.c
@@ -1059,6 +1059,8 @@ static GpStatus get_path_hrgn(GpPath *path, GpGraphics *graphics, HRGN *hrgn)
SetPolyFillMode(graphics->hdc, (path->fill == FillModeAlternate ? ALTERNATE
: WINDING));
+ gdi_transform_acquire(graphics);
+
stat = trace_path(graphics, path);
if (stat == Ok)
{
@@ -1066,6 +1068,8 @@ static GpStatus get_path_hrgn(GpPath *path, GpGraphics *graphics, HRGN *hrgn)
stat = *hrgn ? Ok : OutOfMemory;
}
+ gdi_transform_release(graphics);
+
RestoreDC(graphics->hdc, save_state);
if (new_hdc)
{
--
2.7.4
More information about the wine-patches
mailing list