Optimising SkiaSharp blit/copy
I tried writing my own blit function using unsafe code too, but it performed way worse than skia's werson (around 100ms) using this code:
IntPtr srcPtr = srcSurface.PeekPixels().GetPixels();
IntPtr dstPtr = dstSurface.PeekPixels().GetPixels();
unsafe {
int cbPixels = surfaceInfo.BytesSize;
void* srcPx = srcPtr.ToPointer();
void* dstPx = dstPtr.ToPointer();
for (int i = 0; i < cbPixels; i += 4) {
// assumes BGRA/RGBA (4bbp)
int pixel = *(int*) ((byte*) srcPx + i);
if (pixel != 0) {
*(int*) ((byte*) dstPx + i) = pixel;
}
}
}