fix crash, current rgba ffi design still ugly and dangerous
This commit is contained in:
parent
33186e28d1
commit
c469329d19
@ -80,13 +80,12 @@ class FFI {
|
|||||||
setByName('connect', id);
|
setByName('connect', id);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void _clearRgbaFrame() {
|
static void clearRgbaFrame() {
|
||||||
if (_lastRgbaFrame != null && _lastRgbaFrame != nullptr)
|
if (_lastRgbaFrame != null && _lastRgbaFrame != nullptr)
|
||||||
_freeRgba(_lastRgbaFrame);
|
_freeRgba(_lastRgbaFrame);
|
||||||
}
|
}
|
||||||
|
|
||||||
static Uint8List getRgba() {
|
static Uint8List getRgba() {
|
||||||
_clearRgbaFrame();
|
|
||||||
_lastRgbaFrame = _getRgba();
|
_lastRgbaFrame = _getRgba();
|
||||||
if (_lastRgbaFrame == null || _lastRgbaFrame == nullptr) return null;
|
if (_lastRgbaFrame == null || _lastRgbaFrame == nullptr) return null;
|
||||||
final ref = _lastRgbaFrame.ref;
|
final ref = _lastRgbaFrame.ref;
|
||||||
@ -115,7 +114,6 @@ class FFI {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void close() {
|
static void close() {
|
||||||
_clearRgbaFrame();
|
|
||||||
setByName('close', '');
|
setByName('close', '');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -21,6 +21,7 @@ class _RemotePageState extends State<RemotePage> {
|
|||||||
ui.Image _image;
|
ui.Image _image;
|
||||||
PeerInfo _pi = PeerInfo();
|
PeerInfo _pi = PeerInfo();
|
||||||
Display _display = Display();
|
Display _display = Display();
|
||||||
|
bool _decoding = false;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void initState() {
|
void initState() {
|
||||||
@ -39,6 +40,7 @@ class _RemotePageState extends State<RemotePage> {
|
|||||||
FFI.close();
|
FFI.close();
|
||||||
_interval.cancel();
|
_interval.cancel();
|
||||||
dismissLoading();
|
dismissLoading();
|
||||||
|
_decoding = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
void interval() {
|
void interval() {
|
||||||
@ -53,15 +55,21 @@ class _RemotePageState extends State<RemotePage> {
|
|||||||
handleSwitchDisplay(evt);
|
handleSwitchDisplay(evt);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
var rgba = FFI.getRgba();
|
if (!_decoding) {
|
||||||
if (rgba != null) {
|
var rgba = FFI.getRgba();
|
||||||
ui.decodeImageFromPixels(
|
if (rgba != null) {
|
||||||
rgba, _display.width, _display.height, ui.PixelFormat.bgra8888,
|
_decoding = true;
|
||||||
(__image) {
|
ui.decodeImageFromPixels(
|
||||||
setState(() {
|
rgba, _display.width, _display.height, ui.PixelFormat.bgra8888,
|
||||||
_image = __image;
|
(__image) {
|
||||||
|
FFI.clearRgbaFrame();
|
||||||
|
if (_decoding == null) return;
|
||||||
|
_decoding = false;
|
||||||
|
setState(() {
|
||||||
|
_image = __image;
|
||||||
|
});
|
||||||
});
|
});
|
||||||
});
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user