You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
perf(skia): Reuse surfaces/bitmaps and reduce native calls
- Cache surfaces and bitmap between invocation
- Avoid repetitive calls ending up calling native code (transition is costly), e.g.
- successive calls to properties like `surface.Canvas` and `_bitmap.Width`
- multiple calls to `_bitmap.GetPixels(out _)`
- Dispose existing `SKBitmap` and `SKSurface` when needed (e.g. window resizing)
- Removed nullable on `float? _dpi;` is already assigned to a value (by
.ctor) and `UpdateDpi` never set it to `null`
Measuring the impact was tricky since there are huge differences between
frame redraw times. I ended up logging an average of a 1000 frames.
Numbers are in ticks (100 ns).
**before**
```
trce: Uno.UI.Runtime.Skia.SoftwareRenderSurface[0]
Average render time: 116098
trce: Uno.UI.Runtime.Skia.SoftwareRenderSurface[0]
Average render time: 116879
trce: Uno.UI.Runtime.Skia.SoftwareRenderSurface[0]
Average render time: 114771
trce: Uno.UI.Runtime.Skia.SoftwareRenderSurface[0]
Average render time: 114271
```
**after**
```
trce: Uno.UI.Runtime.Skia.SoftwareRenderSurface[0]
Average render time: 112252
trce: Uno.UI.Runtime.Skia.SoftwareRenderSurface[0]
Average render time: 114341
trce: Uno.UI.Runtime.Skia.SoftwareRenderSurface[0]
Average render time: 115398
trce: Uno.UI.Runtime.Skia.SoftwareRenderSurface[0]
Average render time: 113393
```
0 commit comments