[PATCH] d2d: Suppress last empty segment also for D2D1_FIGURE_END_OPEN

Henri Verbeet hverbeet at gmail.com
Mon Jan 3 09:40:50 CST 2022


On Mon, 3 Jan 2022 at 15:10, Stefan Brüns <stefan.bruens at rwth-aachen.de> wrote:
> On Montag, 3. Januar 2022 12:58:50 CET you wrote:
> > On Fri, 31 Dec 2021 at 08:23, Stefan Brüns <stefan.bruens at rwth-aachen.de>
> wrote:
> > > When the last vertex is coincident with the first vertex, the last
> > > segment should be suppressed for both END_OPEN and END_CLOSED.
> > >
> > > When the last, zero length segment is not omitted
> > > d2d_geometry_intersect_self will add invalid segments.
> >
> > Unfortunately, I don't think that's correct. For an END_OPEN figure,
> > the first and last vertex coinciding doesn't imply that the last
> > segment is a zero-length segment.
>
> Please supply an example where coinciding does not mean zero length.
>
> Last vertex refers to the second vertex of the last segment, not its start
> vertex.
>
Consider for example a triangle like this:

     p0, p3
       /\
      /  \
     /____\
   p1      p2

and the corresponding Direct2D calls:

    BeginFigure(p0, ...);
    AddLine(p1);
    AddLine(p2);
    AddLine(p3);
    EndFigure(END_OPEN/END_CLOSED);

In the END_CLOSED case, we'd first create three segments:

    p0->p1
    p1->p2
    p2->p3

and then we'd have a fourth implicit zero-length segment p3->p0. By
removing the p3 vertex, we replace the p2->p3 and p3->p0 segments with
an implicit p2->p0 segment.

In the END_OPEN case however, we just have the three explicit segments
above, without the implicit p3->p0 segment. In that case, removing the
p3 vertex simply removes the p2->p3 segment, and we'd be left with the
following figure:

       p0
       /
      /
     /____
   p1      p2

Looking at d2d_geometry_intersect_self() though, it looks like it
doesn't take D2D_FIGURE_FLAG_CLOSED into account, probably because it
predates its introduction. Perhaps that explains the behaviour you're
seeing. In any case, thanks for looking into this!

Henri



More information about the wine-devel mailing list