SkPath sub selection woes

59 views
Skip to first unread message

Kalen White

unread,
Jan 5, 2022, 2:54:00 AM1/5/22
to skia-discuss

                 the following code doesnt effectively go through verbs to points

                 i've tried:   0, 1, 3, 0  ...  1, 2, 4, 1

                 ------------

                SkPath                        *u_path = some_path;

                SkSTArray<16, uint8_t, true> verbs;

                SkSTArray<16, SkPoint, true>   points;

                int n_verbs  = u_path->countVerbs();

                int n_points = u_path->countPoints();

                verbs.resize_back (n_verbs);

                points.resize_back(n_points);

                u_path->getPoints (&points[0], n_points);

                u_path->getVerbs  ( &verbs[0], n_verbs);

                

                int ip = 0;

                for (int i = 0; i < n_verbs; i++) {

                    switch (verbs[i]) {

                    case SkPath::kMove_Verb: // 1

                        ip += 1;

                        break;

                    case SkPath::kLine_Verb: // 2

                        ip += 2;

                        break;

                    case SkPath::kCubic_Verb: // 4

                        ip += 4;

                        break;

                    case SkPath::kClose_Verb: // 1

                        ip += 1;

                        break;

                    default:

                        assert(false);

                        break;

                    }

                }

                

                assert(n_points == ip);


I've tried every possible count for verb that could be.   the amount of points available absolutely does not line up with the verbs.  i only have move, line, and bezier segments in this path.  there is no conic or quad.  it asserts false for anything else, the only failure i get is on the check at the end.

i need to go through and splice out a set of ops after it moves between sub paths.   A simple lamba to iterate through sections of SkPath would be very useful, and SkPathMeasure reports thousands of segments (it must be after post-GPU).  I just need to perform a path operation and remove a couple paths.

Thanks

Kalen

Kalen White

unread,
Jan 5, 2022, 2:54:54 AM1/5/22
to skia-discuss
For Cubic I've tried 3 and 4.. It looks wrong there because I know it has to be 3, but that fails too.

Kalen White

unread,
Jan 5, 2022, 2:55:21 AM1/5/22
to skia-discuss
Line, move I've both tried 1 for each.  Close I've tried 0.  Nothing adds up.

Brian Salomon

unread,
Jan 6, 2022, 9:26:11 AM1/6/22
to skia-d...@googlegroups.com
It should be:

Move: 1
Line: 1
Quad: 2
Conic: 2
Cubic: 3
Close: 0

The logic for line, quad, conic, and cubic is that the first point of the curve segment is implicitly the previous point and so isn't stored redundantly. For close, the point is implicitly the point associated with the last move.

--
You received this message because you are subscribed to the Google Groups "skia-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to skia-discuss...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/skia-discuss/c765ae45-5889-4f13-ad76-1080dbc916a1n%40googlegroups.com.


--

Brian Salomon | Office Hours: go/bsalomon-office | bsal...@google.com

Greg Daniel

unread,
Jan 6, 2022, 9:32:10 AM1/6/22
to skia-discuss
If the above suggestion from Brian doesn't work, are you able to give a simple example path that doesn't work? Even better can you put your code into fiddle.skia.org that shows the counting not doing what you expect?

Reply all
Reply to author
Forward
0 new messages