Bug 45252 - Add local triangulation of cubic curve control points
Summary: Add local triangulation of cubic curve control points
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: Layout and Rendering (show other bugs)
Version: 528+ (Nightly build)
Hardware: All All
: P2 Normal
Assignee: Kenneth Russell
URL:
Keywords:
Depends on:
Blocks: 44729
  Show dependency treegraph
 
Reported: 2010-09-05 22:26 PDT by Kenneth Russell
Modified: 2010-09-27 16:43 PDT (History)
9 users (show)

See Also:


Attachments
Patch (22.80 KB, patch)
2010-09-05 22:41 PDT, Kenneth Russell
jamesr: review-
kbr: commit-queue-
Details | Formatted Diff | Diff
Revised patch (23.29 KB, patch)
2010-09-09 13:02 PDT, Kenneth Russell
kbr: commit-queue-
Details | Formatted Diff | Diff
Revised patch (23.37 KB, patch)
2010-09-09 21:48 PDT, Kenneth Russell
jamesr: review+
kbr: commit-queue-
Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Kenneth Russell 2010-09-05 22:26:59 PDT
As part of the GPU accelerated path rendering algorithm in https://bugs.webkit.org/show_bug.cgi?id=44729 , a local triangulation algorithm is needed for the four points defining a cubic curve. This triangulator needs to support walking the interior edges of the shape in order to feed those edges to a more general triangulation algorithm which handles filling of the interior of the shape.
Comment 1 Kenneth Russell 2010-09-05 22:41:24 PDT
Created attachment 66611 [details]
Patch

From the ChangeLog:

Adding a localized triangulation algorithm which takes as input the four control points of a cubic curve segment and provides both triangles as well as the ability to walk the interior edges. The latter will be used later to fill the interior of shapes bounded by these cubic curves, quadratic curves and line segments.
Comment 2 James Robinson 2010-09-08 16:23:32 PDT
Comment on attachment 66611 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=66611&action=prettypatch

> WebCore/platform/graphics/gpu/LoopBlinnLocalTriangulator.cpp:35
> +using namespace LoopBlinnMathUtils;
explicitly 'using' the functions used in this cpp

> WebCore/platform/graphics/gpu/LoopBlinnLocalTriangulator.cpp:39
> +    for (int i = 0; i < 3; i++)
nit: could use indexForVertex()

> WebCore/platform/graphics/gpu/LoopBlinnLocalTriangulator.cpp:45
> +LoopBlinnLocalTriangulator::Vertex* LoopBlinnLocalTriangulator::Triangle::nextVertex(LoopBlinnLocalTriangulator::Vertex* cur, bool ccw)
rename params as in header

> WebCore/platform/graphics/gpu/LoopBlinnLocalTriangulator.cpp:101
> +    bool done = false;
instead of having a done flag, could the work in the first half of this function be a helper that early-returns?

> WebCore/platform/graphics/gpu/LoopBlinnLocalTriangulator.cpp:107
> +    for (int i = 0; i < 4 && !done; i++)
> +        for (int j = i + 1; j < 4 && !done; j++)
these need braces

> WebCore/platform/graphics/gpu/LoopBlinnLocalTriangulator.cpp:231
> +                    if (!next->marked()
> +                        && !isSharedEdge(v, next)
> +                        && (!next->interior() || next->end())) {
intentation looks funny. I think the predicate can go one line

> WebCore/platform/graphics/gpu/LoopBlinnLocalTriangulator.cpp:242
> +            // Something went wrong with the above algorithm; add the last
add a FIXME?

> WebCore/platform/graphics/gpu/LoopBlinnLocalTriangulator.h:46
> +        Vertex()
initialize the flags in here

> WebCore/platform/graphics/gpu/LoopBlinnLocalTriangulator.h:141
> +        Vertex* nextVertex(Vertex* cur, bool ccw);
cur -> current

ccw -> counterClockWise, or an enum { ClockWise, CounterClockWise }

> WebCore/platform/graphics/gpu/LoopBlinnLocalTriangulator.h:165
> +        Vertex* m_vertices[3];
Add a comment indicating why these are raw pointers (that they point to data from the arena or something of that sort).

> WebCore/platform/graphics/gpu/LoopBlinnLocalTriangulator.h:196
> +    void triangulate(bool computeInsideEdges,
> +                     bool fillRightSide);
these bool params should be enums so callsites look more like triangulage(ComputeInsideEdges, FillLeftSide);
Comment 3 Kenneth Russell 2010-09-09 13:02:45 PDT
Created attachment 67083 [details]
Revised patch

Revised patch addressing above code review comments.
Comment 4 Kenneth Russell 2010-09-09 13:04:05 PDT
(In reply to comment #2)
> (From update of attachment 66611 [details])
> View in context: https://bugs.webkit.org/attachment.cgi?id=66611&action=prettypatch
> 
> > WebCore/platform/graphics/gpu/LoopBlinnLocalTriangulator.cpp:35
> > +using namespace LoopBlinnMathUtils;
> explicitly 'using' the functions used in this cpp

Done.

> > WebCore/platform/graphics/gpu/LoopBlinnLocalTriangulator.cpp:39
> > +    for (int i = 0; i < 3; i++)
> nit: could use indexForVertex()

Done.

> > WebCore/platform/graphics/gpu/LoopBlinnLocalTriangulator.cpp:45
> > +LoopBlinnLocalTriangulator::Vertex* LoopBlinnLocalTriangulator::Triangle::nextVertex(LoopBlinnLocalTriangulator::Vertex* cur, bool ccw)
> rename params as in header

Done.

> > WebCore/platform/graphics/gpu/LoopBlinnLocalTriangulator.cpp:101
> > +    bool done = false;
> instead of having a done flag, could the work in the first half of this function be a helper that early-returns?

Yes. Done; refactored first half into triangulateHelper.

> > WebCore/platform/graphics/gpu/LoopBlinnLocalTriangulator.cpp:107
> > +    for (int i = 0; i < 4 && !done; i++)
> > +        for (int j = i + 1; j < 4 && !done; j++)
> these need braces

Done.

> > WebCore/platform/graphics/gpu/LoopBlinnLocalTriangulator.cpp:231
> > +                    if (!next->marked()
> > +                        && !isSharedEdge(v, next)
> > +                        && (!next->interior() || next->end())) {
> intentation looks funny. I think the predicate can go one line

Done.

> > WebCore/platform/graphics/gpu/LoopBlinnLocalTriangulator.cpp:242
> > +            // Something went wrong with the above algorithm; add the last
> add a FIXME?

Done.

> > WebCore/platform/graphics/gpu/LoopBlinnLocalTriangulator.h:46
> > +        Vertex()
> initialize the flags in here

Done.

> > WebCore/platform/graphics/gpu/LoopBlinnLocalTriangulator.h:141
> > +        Vertex* nextVertex(Vertex* cur, bool ccw);
> cur -> current
> 
> ccw -> counterClockWise, or an enum { ClockWise, CounterClockWise }

Done.

> > WebCore/platform/graphics/gpu/LoopBlinnLocalTriangulator.h:165
> > +        Vertex* m_vertices[3];
> Add a comment indicating why these are raw pointers (that they point to data from the arena or something of that sort).

Done.

> > WebCore/platform/graphics/gpu/LoopBlinnLocalTriangulator.h:196
> > +    void triangulate(bool computeInsideEdges,
> > +                     bool fillRightSide);
> these bool params should be enums so callsites look more like triangulage(ComputeInsideEdges, FillLeftSide);

Done.
Comment 5 Kenneth Russell 2010-09-09 21:48:00 PDT
Created attachment 67149 [details]
Revised patch

Renamed numTriangles to numberOfTriangles and numInteriorVertices to numberOfInteriorVertices to avoid abbreviations.
Comment 6 James Robinson 2010-09-15 13:46:31 PDT
Comment on attachment 67149 [details]
Revised patch

View in context: https://bugs.webkit.org/attachment.cgi?id=67149&action=prettypatch

Looks good!
Comment 7 Kenneth Russell 2010-09-22 08:31:49 PDT
Committed r68045: <http://trac.webkit.org/changeset/68045>
Comment 8 Kenneth Russell 2010-09-27 16:08:06 PDT
Committed r68439: <http://trac.webkit.org/changeset/68439>
Comment 9 WebKit Review Bot 2010-09-27 16:43:47 PDT
http://trac.webkit.org/changeset/68439 might have broken Qt Linux Release
The following changes are on the blame list:
http://trac.webkit.org/changeset/68440
http://trac.webkit.org/changeset/68439