fix nextRgba not called when switching to texture render (#8792)

Because rgba buffer render doesn't support multi display, when switch to
multi display, it is possible that rgba.valid has been set to valid but
nextRgab is not called, when switching back to single display,
rgba.valid is still true.

Fix by rgba buffer, rgba texture and  gpu texture using different messages.

Signed-off-by: 21pages <sunboeasy@gmail.com>
This commit is contained in:
21pages 2024-07-24 12:06:16 +08:00 committed by GitHub
parent 8a4a2b5732
commit 57d1b1ecc4
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 21 additions and 23 deletions

View File

@ -2547,11 +2547,6 @@ class FFI {
}
} else if (message is EventToUI_Rgba) {
final display = message.field0;
if (imageModel.useTextureRender || ffiModel.pi.forceTextureRender) {
//debugPrint("EventToUI_Rgba display:$display");
textureModel.setTextureType(display: display, gpuTexture: false);
onEvent2UIRgba();
} else {
// Fetch the image buffer from rust codes.
final sz = platformFFI.getRgbaSize(sessionId, display);
if (sz == 0) {
@ -2565,14 +2560,17 @@ class FFI {
} else {
platformFFI.nextRgba(sessionId, display);
}
}
} else if (message is EventToUI_Texture) {
final display = message.field0;
debugPrint("EventToUI_Texture display:$display");
if (hasGpuTextureRender) {
textureModel.setTextureType(display: display, gpuTexture: true);
onEvent2UIRgba();
final gpuTexture = message.field1;
debugPrint(
"EventToUI_Texture display:$display, gpuTexture:$gpuTexture");
if (gpuTexture && !hasGpuTextureRender) {
debugPrint('the gpuTexture is not supported.');
return;
}
textureModel.setTextureType(display: display, gpuTexture: gpuTexture);
onEvent2UIRgba();
}
}();
});

View File

@ -794,7 +794,7 @@ impl InvokeUiSession for FlutterHandler {
for (_, session) in self.session_handlers.read().unwrap().iter() {
if session.renderer.on_texture(display, texture) {
if let Some(stream) = &session.event_stream {
stream.add(EventToUI::Texture(display));
stream.add(EventToUI::Texture(display, true));
}
}
}
@ -1087,7 +1087,7 @@ impl FlutterHandler {
if use_texture_render || session.displays.len() > 1 {
if session.renderer.on_rgba(display, rgba) {
if let Some(stream) = &session.event_stream {
stream.add(EventToUI::Rgba(display));
stream.add(EventToUI::Texture(display, false));
}
}
}

View File

@ -89,7 +89,7 @@ pub fn stop_global_event_stream(app_type: String) {
pub enum EventToUI {
Event(String),
Rgba(usize),
Texture(usize),
Texture(usize, bool), // (display, gpu_texture)
}
pub fn host_stop_system_key_propagate(_stopped: bool) {