Merge pull request #3218 from Kingtous/master

opt: early unlock frame
This commit is contained in:
RustDesk 2023-02-15 17:14:25 +08:00 committed by GitHub
commit 6e12e77f51
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 4 deletions

View File

@ -438,15 +438,17 @@ class ImageModel with ChangeNotifier {
} }
final pid = parent.target?.id; final pid = parent.target?.id;
ui.decodeImageFromPixels( img.decodeImageFromPixels(
rgba, rgba,
parent.target?.ffiModel.display.width ?? 0, parent.target?.ffiModel.display.width ?? 0,
parent.target?.ffiModel.display.height ?? 0, parent.target?.ffiModel.display.height ?? 0,
isWeb ? ui.PixelFormat.rgba8888 : ui.PixelFormat.bgra8888, (image) { isWeb ? ui.PixelFormat.rgba8888 : ui.PixelFormat.bgra8888,
if (parent.target?.id != pid) return; onPixelsCopied: () {
try {
// Unlock the rgba memory from rust codes. // Unlock the rgba memory from rust codes.
platformFFI.nextRgba(id); platformFFI.nextRgba(id);
}).then((image) {
if (parent.target?.id != pid) return;
try {
// my throw exception, because the listener maybe already dispose // my throw exception, because the listener maybe already dispose
update(image); update(image);
} catch (e) { } catch (e) {

View File

@ -11,6 +11,7 @@ Future<ui.Image> decodeImageFromPixels(
int? rowBytes, int? rowBytes,
int? targetWidth, int? targetWidth,
int? targetHeight, int? targetHeight,
VoidCallback? onPixelsCopied,
bool allowUpscaling = true, bool allowUpscaling = true,
}) async { }) async {
if (targetWidth != null) { if (targetWidth != null) {
@ -22,6 +23,7 @@ Future<ui.Image> decodeImageFromPixels(
final ui.ImmutableBuffer buffer = final ui.ImmutableBuffer buffer =
await ui.ImmutableBuffer.fromUint8List(pixels); await ui.ImmutableBuffer.fromUint8List(pixels);
onPixelsCopied?.call();
final ui.ImageDescriptor descriptor = ui.ImageDescriptor.raw( final ui.ImageDescriptor descriptor = ui.ImageDescriptor.raw(
buffer, buffer,
width: width, width: width,