private void OnPaint(int width, int height) { _pixelBuffer.EnsureAlloc(width, height); _ixenSurface.ComputeLayout(width, height); _skImageInfo = new SKImageInfo(width, height, SKColorType.Bgra8888, SKAlphaType.Premul); _painted = false; try { using (_skSurface = SKSurface.Create(_skImageInfo, _pixelBuffer.Ptr, _pixelBuffer.RowBytes)) { if (_skSurface != null) { _ixenSurface.Render(_skSurface.Canvas); _painted = true; } } } finally { if (_painted) { WindowApi.SetWindowPixelsBuffer(_windowPtr, _pixelBuffer.Ptr); } } }