gdiplus: Scale widened dashes to the pen width.
Signed-off-by: Zebediah Figura <zfigura@codeweavers.com> Signed-off-by: Vincent Povirk <vincent@codeweavers.com> Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
parent
860deac1c7
commit
7e1522cdd6
|
@ -2063,6 +2063,7 @@ static void widen_dashed_figure(GpPath *path, GpPen *pen, int start, int end,
|
||||||
REAL dash_pos=0.0;
|
REAL dash_pos=0.0;
|
||||||
int dash_index=0;
|
int dash_index=0;
|
||||||
const REAL *dash_pattern;
|
const REAL *dash_pattern;
|
||||||
|
REAL *dash_pattern_scaled;
|
||||||
int dash_count;
|
int dash_count;
|
||||||
GpPointF *tmp_points;
|
GpPointF *tmp_points;
|
||||||
REAL segment_dy;
|
REAL segment_dy;
|
||||||
|
@ -2101,6 +2102,12 @@ static void widen_dashed_figure(GpPath *path, GpPen *pen, int start, int end,
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
dash_pattern_scaled = heap_alloc(dash_count * sizeof(REAL));
|
||||||
|
if (!dash_pattern_scaled) return;
|
||||||
|
|
||||||
|
for (i = 0; i < dash_count; i++)
|
||||||
|
dash_pattern_scaled[i] = pen->width * dash_pattern[i];
|
||||||
|
|
||||||
tmp_points = heap_alloc_zero((end - start + 2) * sizeof(GpPoint));
|
tmp_points = heap_alloc_zero((end - start + 2) * sizeof(GpPoint));
|
||||||
if (!tmp_points) return; /* FIXME */
|
if (!tmp_points) return; /* FIXME */
|
||||||
|
|
||||||
|
@ -2149,7 +2156,7 @@ static void widen_dashed_figure(GpPath *path, GpPen *pen, int start, int end,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (dash_pattern[dash_index] - dash_pos > segment_length - segment_pos)
|
if (dash_pattern_scaled[dash_index] - dash_pos > segment_length - segment_pos)
|
||||||
{
|
{
|
||||||
/* advance to next segment */
|
/* advance to next segment */
|
||||||
if ((dash_index % 2) == 0)
|
if ((dash_index % 2) == 0)
|
||||||
|
@ -2163,7 +2170,7 @@ static void widen_dashed_figure(GpPath *path, GpPen *pen, int start, int end,
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
/* advance to next dash in pattern */
|
/* advance to next dash in pattern */
|
||||||
segment_pos += dash_pattern[dash_index] - dash_pos;
|
segment_pos += dash_pattern_scaled[dash_index] - dash_pos;
|
||||||
dash_pos = 0.0;
|
dash_pos = 0.0;
|
||||||
if (++dash_index == dash_count)
|
if (++dash_index == dash_count)
|
||||||
dash_index = 0;
|
dash_index = 0;
|
||||||
|
@ -2175,8 +2182,7 @@ static void widen_dashed_figure(GpPath *path, GpPen *pen, int start, int end,
|
||||||
if (dash_index % 2 == 0 && num_tmp_points != 0)
|
if (dash_index % 2 == 0 && num_tmp_points != 0)
|
||||||
{
|
{
|
||||||
/* last dash overflows last segment */
|
/* last dash overflows last segment */
|
||||||
tmp_points[num_tmp_points] = path->pathdata.Points[end];
|
widen_open_figure(tmp_points, pen, 0, num_tmp_points-1,
|
||||||
widen_open_figure(tmp_points, pen, 0, num_tmp_points,
|
|
||||||
draw_start_cap ? pen->startcap : LineCapFlat, pen->customstart,
|
draw_start_cap ? pen->startcap : LineCapFlat, pen->customstart,
|
||||||
closed ? LineCapFlat : pen->endcap, pen->customend, last_point);
|
closed ? LineCapFlat : pen->endcap, pen->customend, last_point);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1065,6 +1065,17 @@ static path_test_t widenline_wide_path[] = {
|
||||||
{5.0, 20.0, PathPointTypeLine|PathPointTypeCloseSubpath, 0, 0} /*3*/
|
{5.0, 20.0, PathPointTypeLine|PathPointTypeCloseSubpath, 0, 0} /*3*/
|
||||||
};
|
};
|
||||||
|
|
||||||
|
static path_test_t widenline_dash_path[] = {
|
||||||
|
{5.0, 0.0, PathPointTypeStart, 0, 0}, /*0*/
|
||||||
|
{35.0, 0.0, PathPointTypeLine, 0, 0}, /*1*/
|
||||||
|
{35.0, 10.0, PathPointTypeLine, 0, 0}, /*2*/
|
||||||
|
{5.0, 10.0, PathPointTypeLine|PathPointTypeCloseSubpath, 0, 0}, /*3*/
|
||||||
|
{45.0, 0.0, PathPointTypeStart, 0, 0}, /*4*/
|
||||||
|
{50.0, 0.0, PathPointTypeLine, 0, 0}, /*5*/
|
||||||
|
{50.0, 10.0, PathPointTypeLine, 0, 0}, /*6*/
|
||||||
|
{45.0, 10.0, PathPointTypeLine|PathPointTypeCloseSubpath, 0, 0}, /*7*/
|
||||||
|
};
|
||||||
|
|
||||||
static void test_widen(void)
|
static void test_widen(void)
|
||||||
{
|
{
|
||||||
GpStatus status;
|
GpStatus status;
|
||||||
|
@ -1139,6 +1150,22 @@ static void test_widen(void)
|
||||||
status = GdipScaleMatrix(m, 1.0, 0.5, MatrixOrderAppend);
|
status = GdipScaleMatrix(m, 1.0, 0.5, MatrixOrderAppend);
|
||||||
expect(Ok, status);
|
expect(Ok, status);
|
||||||
|
|
||||||
|
/* dashed line */
|
||||||
|
status = GdipResetPath(path);
|
||||||
|
expect(Ok, status);
|
||||||
|
status = GdipAddPathLine(path, 5.0, 5.0, 50.0, 5.0);
|
||||||
|
expect(Ok, status);
|
||||||
|
|
||||||
|
status = GdipSetPenDashStyle(pen, DashStyleDash);
|
||||||
|
expect(Ok, status);
|
||||||
|
|
||||||
|
status = GdipWidenPath(path, pen, m, 1.0);
|
||||||
|
expect(Ok, status);
|
||||||
|
ok_path(path, widenline_dash_path, sizeof(widenline_dash_path)/sizeof(path_test_t), FALSE);
|
||||||
|
|
||||||
|
status = GdipSetPenDashStyle(pen, DashStyleSolid);
|
||||||
|
expect(Ok, status);
|
||||||
|
|
||||||
/* pen width in UnitWorld */
|
/* pen width in UnitWorld */
|
||||||
GdipDeletePen(pen);
|
GdipDeletePen(pen);
|
||||||
status = GdipCreatePen1(0xffffffff, 10.0, UnitWorld, &pen);
|
status = GdipCreatePen1(0xffffffff, 10.0, UnitWorld, &pen);
|
||||||
|
|
Loading…
Reference in New Issue