Skip to content

Commit 3f0db25

Browse files
authored
Merge pull request #1278 from ionite34/dev
Dev
2 parents 12f8d3d + b5ef26d commit 3f0db25

2 files changed

Lines changed: 19 additions & 5 deletions

File tree

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@ and this project adheres to [Semantic Versioning 2.0](https://semver.org/spec/v2
3030
- Fixed Animagine XL and other SDXL models with "anima" in the name being misdetected as the Anima architecture
3131
- Fixed the running-package exit confirmation not appearing when quitting via **⌘Q, the macOS app menu, or the Dock** — it previously only showed when closing the window directly, so those paths could tear down running packages without warning. All quit paths now prompt
3232
- Fixed an empty strip of space appearing below the native window title bar on macOS and Linux; the Windows-only caption area (icon, title, and min/max/close buttons) is now collapsed on those platforms so content sits directly under the system title bar
33+
### Performance
34+
- Optimized SKBitmap-to-WriteableBitmap conversion used throughout Inference and Image Lab; pixel data is now copied directly native-to-native (single bulk copy when strides match, per-row otherwise) instead of round-tripping every scanline through a temporary managed buffer, reducing allocations and GC pressure on full-resolution images
3335
### Supporters
3436
#### 🌟 Visionaries
3537
A massive thank you to our brilliant Visionaries: **Waterclouds**, **bluepopsicle**, **Ibixat**, **Droolguy**, **snotty**, **LG**, **whudunit**, **MrMxyzptlk12836**, **Psilocyfer18731**, **KalAbaddon**, and **moon_milky2843**! There's a little of your support behind every fix and refinement in this update, and we're grateful for all of it. A warm welcome to our newest Visionary, **cusalapapen1481**; it's wonderful to have you with us! 💛

StabilityMatrix.Avalonia/Extensions/SkiaExtensions.cs

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
using System;
2-
using System.Runtime.InteropServices;
32
using Avalonia;
43
using Avalonia.Media;
54
using Avalonia.Media.Imaging;
@@ -193,7 +192,7 @@ public static Bitmap ToAvaloniaBitmap(this SKImage image, Vector dpi)
193192
return result;
194193
}
195194

196-
private static void CopyPixelRows(
195+
private static unsafe void CopyPixelRows(
197196
IntPtr source,
198197
int sourceRowBytes,
199198
IntPtr destination,
@@ -202,12 +201,25 @@ int height
202201
)
203202
{
204203
var bytesPerRow = Math.Min(sourceRowBytes, destinationRowBytes);
205-
var buffer = new byte[bytesPerRow];
204+
var src = (byte*)source;
205+
var dest = (byte*)destination;
206+
207+
// When strides match the buffer is contiguous, so copy it all in one shot.
208+
if (sourceRowBytes == destinationRowBytes)
209+
{
210+
var totalBytes = (long)sourceRowBytes * height;
211+
Buffer.MemoryCopy(src, dest, totalBytes, totalBytes);
212+
return;
213+
}
206214

207215
for (var row = 0; row < height; row++)
208216
{
209-
Marshal.Copy(IntPtr.Add(source, row * sourceRowBytes), buffer, 0, bytesPerRow);
210-
Marshal.Copy(buffer, 0, IntPtr.Add(destination, row * destinationRowBytes), bytesPerRow);
217+
Buffer.MemoryCopy(
218+
src + ((long)row * sourceRowBytes),
219+
dest + ((long)row * destinationRowBytes),
220+
bytesPerRow,
221+
bytesPerRow
222+
);
211223
}
212224
}
213225

0 commit comments

Comments
 (0)