Join GitHub today
GitHub is home to over 40 million developers working together to host and review code, manage projects, and build software together.
Sign up[WIP] Skia SKPaint pooling #2376
Conversation
This comment has been minimized.
This comment has been minimized.
@Gillibald @kekekeks any thoughts on this? LGTM from a quick review but I'm not so familiar with this code. Any idea why it's still WIP? |
This comment has been minimized.
This comment has been minimized.
I think this is currently blocked by the SkiaSharp dependency. It uses a not yet released API. I like these changes a lot. |
This comment has been minimized.
This comment has been minimized.
I thought about this a bit more. Maybe we should cache shaders instead of paint and mutate a single instance of paint instead. We could cache resources like shaders per DrawingContext. There are some situations where we need a new instance of paint but the common scenario just needs one per DrawingContext. This approach would make it easier to control aliasing and interpolation. A draw call would not need an extra parameter for filter, interpretation, aliasing and instead we configure this on the DrawingContext's paint. |
This comment has been minimized.
This comment has been minimized.
I think this need a bit more thinking about. I think we still have cases where we multiple |
MarchingCube commentedMar 17, 2019
What does the pull request do?
Leverages my recent changes to SkiaSharp (mono/SkiaSharp#807) to speed up rendering by avoiding constant allocation of
SKPaint
objects. I benchmarked this by rendering aRectangle
1000 times using immediate renderer.SkiaSharp did not push any new package yet, so this will have to wait until they release a new version on nuget.
What is the current behavior?
No pooling
Additionally
ThreadSafeObjectPool
has a locking issue -Get
andReturn
obtain 2 different locks which can lead to some strange race conditions.What is the updated/expected behavior with this PR?
Pooling
How was the solution implemented (if it's not obvious)?
DrawingContextImpl.CreatePaint
will utilize one of three availableSKPaint
pools. If we are dealing with most common case (solid color brushes) it will use either a pool for normal brushes or use a pen pool (that enables stroke). In case of other brush type theGeneral
pool will be used that supports any kind of paint. Pools for brushes and pens do not reset, so it is important to ensure all paint properties will be assigned during construction (Color
for brushes, all stroke properties for pens).Checklist
Breaking changes
Fixed issues
cc: @Gillibald @kekekeks