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;
ui.decodeImageFromPixels(
img.decodeImageFromPixels(
rgba,
parent.target?.ffiModel.display.width ?? 0,
parent.target?.ffiModel.display.height ?? 0,
isWeb ? ui.PixelFormat.rgba8888 : ui.PixelFormat.bgra8888, (image) {
if (parent.target?.id != pid) return;
try {
isWeb ? ui.PixelFormat.rgba8888 : ui.PixelFormat.bgra8888,
onPixelsCopied: () {
// Unlock the rgba memory from rust codes.
platformFFI.nextRgba(id);
}).then((image) {
if (parent.target?.id != pid) return;
try {
// my throw exception, because the listener maybe already dispose
update(image);
} catch (e) {

View File

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