draw many paths with same paint

224 views
Skip to first unread message

jingc...@gmail.com

unread,
Nov 27, 2017, 3:59:14 AM11/27/17
to skia-discuss
    I want to draw many paths  with same paint.  when drawing each path  i use "canvas.drawPath(path, paint) " .   Does the skia have the function i use to draw many paths  with same paint one time rather than mang times.

Shawn Riordan

unread,
Nov 27, 2017, 8:23:37 AM11/27/17
to skia-discuss
You could combine all the paths into one mega-path.

Cary Clark

unread,
Nov 27, 2017, 8:39:07 AM11/27/17
to skia-d...@googlegroups.com
Note that combining paths with SkPath::addPath()  into one path won't always draw the same.

- if the paint has any transparency (e.g., a transfer mode, or antialiasing) drawing the paths all at once won't generate the same result.
- if the paths have multiple contours, combining them to respect winding is non-trivial
- if the paths have different fill types, again combining them is not necessarily straightforward.

The latter two conditions can be worked around by using SkOpBuilder if the paths are drawn with paint fill style.


--
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+unsubscribe@googlegroups.com.
To post to this group, send email to skia-d...@googlegroups.com.
Visit this group at https://groups.google.com/group/skia-discuss.
For more options, visit https://groups.google.com/d/optout.

Brian Osman

unread,
Nov 27, 2017, 10:14:54 AM11/27/17
to skia-d...@googlegroups.com
Also, in some cases it may be faster to draw each path separately vs. drawing them all at once. At least with the GPU backend, it's likely that you encounter a situation where the individual paths draw using a faster/simpler algorithm (in particular, if they're known to be convex), but the combined path would be arbitrarily complex and has to use a more complex algorithm.


On Mon, Nov 27, 2017 at 8:39 AM 'Cary Clark' via skia-discuss <skia-d...@googlegroups.com> wrote:
Note that combining paths with SkPath::addPath()  into one path won't always draw the same.

- if the paint has any transparency (e.g., a transfer mode, or antialiasing) drawing the paths all at once won't generate the same result.
- if the paths have multiple contours, combining them to respect winding is non-trivial
- if the paths have different fill types, again combining them is not necessarily straightforward.

The latter two conditions can be worked around by using SkOpBuilder if the paths are drawn with paint fill style.

On Mon, Nov 27, 2017 at 8:23 AM, Shawn Riordan <craste...@gmail.com> wrote:
You could combine all the paths into one mega-path.


On Monday, November 27, 2017 at 1:59:14 AM UTC-7, jingc...@gmail.com wrote:
    I want to draw many paths  with same paint.  when drawing each path  i use "canvas.drawPath(path, paint) " .   Does the skia have the function i use to draw many paths  with same paint one time rather than mang times.

--
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 post to this group, send email to skia-d...@googlegroups.com.
Visit this group at https://groups.google.com/group/skia-discuss.
For more options, visit https://groups.google.com/d/optout.

--
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.

Shawn Riordan

unread,
Nov 27, 2017, 5:37:59 PM11/27/17
to skia-discuss
What does Skia's text rendering code do?  All the glyphs end up paths at some point, correct?  

Cary Clark

unread,
Nov 28, 2017, 8:50:20 AM11/28/17
to skia-d...@googlegroups.com
Not necessarily. Text and path back-ends overlap, but text has other requirements, like color emoji, and other capabilities, like LCD rendering. On the GPU, text can take advantage of distance fields as an alternative. Text also is better behaved than paths, so the text back-end doesn't have to deal with arbitrary cubic curves, for instance.

To unsubscribe from this group and stop receiving emails from it, send an email to skia-discuss+unsubscribe@googlegroups.com.

Jim Van Verth

unread,
Nov 28, 2017, 10:04:16 AM11/28/17
to skia-d...@googlegroups.com
On the GPU, text is generally small enough and reused enough that glyphs can be stored in a texture atlas, and a run of text can be rendered with a single draw. If the glyph data is a path, we rasterize the path before uploading it. We do the same for small concave paths. 

Reply all
Reply to author
Forward
0 new messages