opt: reduce copy and malloc times for both of flutter and rust

This commit is contained in:
Kingtous
2023-02-12 01:52:11 +08:00
parent f521b1665a
commit 01d30bce9e
7 changed files with 105 additions and 38 deletions

View File

@@ -3,6 +3,7 @@ use std::{
ops::{Deref, DerefMut},
sync::{Arc, Mutex},
};
use std::sync::RwLock;
use sciter::{
dom::{
@@ -17,6 +18,7 @@ use sciter::{
use hbb_common::{
allow_err, fs::TransferJobMeta, log, message_proto::*, rendezvous_proto::ConnType,
};
use hbb_common::tokio::io::AsyncReadExt;
use crate::{
client::*,
@@ -201,12 +203,12 @@ impl InvokeUiSession for SciterHandler {
self.call("adaptSize", &make_args!());
}
fn on_rgba(&self, data: Vec<u8>) {
fn on_rgba(&self, data: Arc<RwLock<Vec<u8>>>) {
VIDEO
.lock()
.unwrap()
.as_mut()
.map(|v| v.render_frame(&data).ok());
.map(|v| v.render_frame(data.read().unwrap().as_ref()).ok());
}
fn set_peer_info(&self, pi: &PeerInfo) {
@@ -284,9 +286,7 @@ impl InvokeUiSession for SciterHandler {
}
/// RGBA is directly rendered by [on_rgba]. No need to store the rgba for the sciter ui.
fn get_rgba(&self) -> Option<Vec<u8>> {
None
}
fn get_rgba(&mut self, _buffer: *mut u8) {}
}
pub struct SciterSession(Session<SciterHandler>);