seems fix first image crossline issue

This commit is contained in:
open-trade 2020-11-28 17:42:29 +08:00
parent b81ecdf318
commit fa78e7b291

View File

@ -29,7 +29,7 @@ typedef F5 = Pointer<RgbaFrame> Function();
class FfiModel with ChangeNotifier { class FfiModel with ChangeNotifier {
PeerInfo _pi; PeerInfo _pi;
Display _display; Display _display;
bool _decoding; var _decoding = false;
bool _waitForImage; bool _waitForImage;
bool _initialized = false; bool _initialized = false;
final _permissions = Map<String, bool>(); final _permissions = Map<String, bool>();
@ -60,7 +60,6 @@ class FfiModel with ChangeNotifier {
void clear() { void clear() {
_pi = PeerInfo(); _pi = PeerInfo();
_display = Display(); _display = Display();
_decoding = false;
_waitForImage = false; _waitForImage = false;
clearPermissions(); clearPermissions();
} }
@ -106,11 +105,13 @@ class FfiModel with ChangeNotifier {
dismissLoading(); dismissLoading();
} }
_decoding = true; _decoding = true;
final pid = FFI.id;
ui.decodeImageFromPixels( ui.decodeImageFromPixels(
rgba, _display.width, _display.height, ui.PixelFormat.bgra8888, rgba, _display.width, _display.height, ui.PixelFormat.bgra8888,
(image) { (image) {
FFI.clearRgbaFrame(); FFI.clearRgbaFrame();
_decoding = false; _decoding = false;
if (FFI.id != pid) return;
try { try {
// my throw exception, because the listener maybe already dispose // my throw exception, because the listener maybe already dispose
FFI.imageModel.update(image); FFI.imageModel.update(image);
@ -365,8 +366,10 @@ class CursorModel with ChangeNotifier {
var height = int.parse(evt['height']); var height = int.parse(evt['height']);
List<dynamic> colors = json.decode(evt['colors']); List<dynamic> colors = json.decode(evt['colors']);
final rgba = Uint8List.fromList(colors.map((s) => s as int).toList()); final rgba = Uint8List.fromList(colors.map((s) => s as int).toList());
var pid = FFI.id;
ui.decodeImageFromPixels(rgba, width, height, ui.PixelFormat.rgba8888, ui.decodeImageFromPixels(rgba, width, height, ui.PixelFormat.rgba8888,
(image) { (image) {
if (FFI.id != pid) return;
_image = image; _image = image;
_images[id] = Tuple3(image, _hotx, _hoty); _images[id] = Tuple3(image, _hotx, _hoty);
try { try {
@ -413,6 +416,7 @@ class CursorModel with ChangeNotifier {
} }
class FFI { class FFI {
static String id = "";
static String _dir = ''; static String _dir = '';
static F1 _freeCString; static F1 _freeCString;
static F2 _getByName; static F2 _getByName;
@ -496,6 +500,7 @@ class FFI {
static void connect(String id) { static void connect(String id) {
setByName('connect', id); setByName('connect', id);
FFI.id = id;
} }
static void clearRgbaFrame() { static void clearRgbaFrame() {
@ -532,6 +537,7 @@ class FFI {
} }
static void close() { static void close() {
id = "";
setByName('close', ''); setByName('close', '');
imageModel.update(null); imageModel.update(null);
cursorModel.clear(); cursorModel.clear();