Multithreading issue about skia

2,216 views
Skip to first unread message

liang jian

unread,
May 10, 2012, 11:13:41 AM5/10/12
to skia-discuss
To speed up rendering, I want to use skia library to render in a
multi-threaded way(using raster backend), each thread has its own
canvas object and its own bitmap object. Is this guaranteed to be safe
by skia?
AFAIK, cairo is not guaranteed to be safe even if I create
different cairo context for each thread to do multi-thread rendering,
it seems that cairo will use some global objects for rendering (shared
by all cairo context), such as cairo pattern, and access to these
objects is not protected by lock, this will cause race condition. Does
skia has the same issue as cairo?

Mike Reed

unread,
May 10, 2012, 11:29:01 AM5/10/12
to skia-d...@googlegroups.com
Skia is thread-safe, in that you can draw different objects into different canvases, each in their own thread. All of Skia's access to globals are protected.

Skia objects (with very few exceptions) are not sharable between threads (exceptions are SkTypeface and drawing a SkBitmap). Thus if you have created paints with anything non-trivial in them (e.g. shaders, filters), those will not work corrected if shared between threads. This is something we are actively working on, but for now, unless you're drawing bitmaps or text, you'll need to make a deep copy of any Skia object you have that you want to draw in more than one thread.



--
You received this message because you are subscribed to the Google Groups "skia-discuss" group.
To post to this group, send email to skia-d...@googlegroups.com.
To unsubscribe from this group, send email to skia-discuss...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/skia-discuss?hl=en.


liang jian

unread,
May 11, 2012, 12:44:22 AM5/11/12
to skia-d...@googlegroups.com
   Thank you for the reply. I think skia is a better solution to a high performance graphics system than cairo.

Matthew Leibowitz

unread,
May 30, 2017, 1:56:43 PM5/30/17
to skia-discuss
Looking at this post, it is quite old, so I was wondering if anything has changed?

Also, I am wondering just what the best way to do background image processing for UI. An example would be to render some image on a background thread, but then when the image is finished, to blit it to the UI. This is great for the cases where the image processing performance is not essential, but the UI must stay responsive.

stephane

unread,
Feb 24, 2024, 2:17:00 AM2/24/24
to skia-discuss
Hi, I m  Looking for the exact same information. can we create image in backgroundthread but draw it on the form sksurface in the main ui thread ? 

Clark Kent

unread,
Mar 4, 2024, 12:14:11 PM3/4/24
to skia-discuss
not sure if SkPicture is thread safe or not, tho i imagine it would be safe to use from multiple threads

eg

thread 1 and 2 draws to SkPicture
thread 3 waits for thread 1 and 2 then draws their SkPicture objects
Reply all
Reply to author
Forward
0 new messages