SkPath vs SkPathBuilder

54 views
Skip to first unread message

L2000

unread,
Oct 15, 2024, 2:03:39 AMOct 15
to skia-discuss
Hi
    I would like to know the difference between skpath and skpathbuilder. When i tried using both in my project, I found skpath showing variable and larger time for drawing compared to SkPathBuilder. I have measured time for the following snippet code :

SkPath : (time taken ~ 400 - 600 micro secs)

SkPath path;
int y = 0;
for ( int i = 0 ; i<= 50 ; i++){
    int x = 0;
    for(int j = 0; j<=50 ; j++){
         path.moveTo(x, y);
         path.lineTo(x+colWidth, y);
         path.lineTo(x+colWidth, y+rowHt);
         x +=5;
       }
      y += 5;
}
canvas->drawPath(path, paint);

SkPathBuilder: ( time taken ~ 150 - 300 micro sec)

SkPathBuilder builder;
int y = 0;
for ( int i = 0 ; i<= 50 ; i++){
    int x = 0;
    for(int j = 0; j<=50 ; j++){
         builder.moveTo({x,y});
         builder.lineTo({x+colWidth, y});
         builder.lineTo({x+colWidth, y+rowHt});
         x +=5;
       }
      y += 5;
}
canvas->drawPath(builder.detach(), paint);

Regrads
Priya


w...@weltz-online.de

unread,
Oct 23, 2024, 4:37:18 AMOct 23
to skia-discuss
I assume, that is the way a builder should work. You add your drawing commands and at the end all calculations are done. When you use a normal path directly, these calculations had to be done each time you change something on the path.
Reply all
Reply to author
Forward
0 new messages