From cab9dc83ec8f557ef3e28152887c28e54b0625e6 Mon Sep 17 00:00:00 2001 From: Waozi Date: Tue, 17 Nov 2026 23:16:39 -0300 Subject: [PATCH] Keep the captured screen's orientation in route fades Opening Habits' shop on Kryon's desktop host closed Inner Breeze. The route fade kept only the previous screen's texture and drew it as a bottom-up raylib frame, but the desktop host's snapshot is upright: the flipped draw failed the whole frame and the app quit. The fade now keeps the captured surface itself, with the orientation its host reports. The test's orientation checks land with the Kryon pin that reports it. --- src/app/app_frame_transition.zi | 48 +++++++++++---------------- src/app/app_types.zi | 7 ++-- src/app/application_frame.zi | 2 +- tests/graphics_transition_behavior.zi | 28 ++++++++++++---- 4 files changed, 48 insertions(+), 37 deletions(-) diff --git a/src/app/app_frame_transition.zi b/src/app/app_frame_transition.zi index f8cbb45dd..cd5ee1752 100644 --- a/src/app/app_frame_transition.zi +++ b/src/app/app_frame_transition.zi @@ -7,17 +7,20 @@ APP_ROUTE_TRANSITION_SECONDS :: 0.24; +// Releases the previous screen when this app owns its copy, and forgets it. +app_route_transition_forget :: (app: *InnerBreeze, context_lost: bool) { + if !context_lost && app.ui.route_transition_surface_owned && + FrameSurfaceValid(app.ui.route_transition_surface) { + unused FrameSurfaceRelease(app.ui.route_transition_surface) + } + app.ui.route_transition_surface = FrameSurface.{} + app.ui.route_transition_surface_owned = false +} + #program_export app_route_transition_cancel :: (app: *InnerBreeze, context_lost: bool = false) { if app == null { return } - surface: FrameSurface - surface.texture = app.ui.route_transition_texture - if !context_lost && app.ui.route_transition_texture_owned && - FrameSurfaceValid(surface) { - FrameSurfaceRelease(surface) - } - app.ui.route_transition_texture = Texture2D.{} - app.ui.route_transition_texture_owned = false + app_route_transition_forget(app, context_lost) app.ui.route_transition_active = false app.ui.route_transition_pending = false } @@ -32,19 +35,16 @@ app_route_transition_request :: (app: *InnerBreeze) { app.ui.route_transition_pending = true } +// Keeps the whole captured surface, so the fade draws it the way its host +// stored its rows. #program_export app_route_transition_capture :: (app: *InnerBreeze, - texture: Texture2D, now_seconds: float64, owns_texture: bool) { + surface: FrameSurface, now_seconds: float64, owns_surface: bool) { if app == null || !app.ui.route_transition_pending { return } app.ui.route_transition_pending = false - surface: FrameSurface - surface.texture = app.ui.route_transition_texture - if app.ui.route_transition_texture_owned && FrameSurfaceValid(surface) { - app.ui.route_transition_texture = FrameSurfaceRelease(surface).texture - } - app.ui.route_transition_texture_owned = owns_texture - app.ui.route_transition_texture = texture - surface.texture = texture + app_route_transition_forget(app, false) + app.ui.route_transition_surface = surface + app.ui.route_transition_surface_owned = owns_surface app.ui.route_transition_active = FrameSurfaceValid(surface) app.ui.route_transition_started = now_seconds } @@ -55,13 +55,7 @@ app_route_transition_advance :: (app: *InnerBreeze, if app == null || !app.ui.route_transition_active { return } if now_seconds - app.ui.route_transition_started < APP_ROUTE_TRANSITION_SECONDS { return } - surface: FrameSurface - surface.texture = app.ui.route_transition_texture - if app.ui.route_transition_texture_owned && FrameSurfaceValid(surface) { - app.ui.route_transition_texture = FrameSurfaceRelease(surface).texture - } - app.ui.route_transition_texture = Texture2D.{} - app.ui.route_transition_texture_owned = false + app_route_transition_forget(app, false) app.ui.route_transition_active = false } @@ -69,10 +63,8 @@ app_route_transition_advance :: (app: *InnerBreeze, app_route_transition_draw :: (app: *InnerBreeze, bounds: Rectangle, now_seconds: float64) { if app == null || !app.ui.route_transition_active { return } - surface: FrameSurface - surface.texture = app.ui.route_transition_texture elapsed := cast(float32)(now_seconds - app.ui.route_transition_started) - FrameTransition(app.ui.session, surface, bounds, elapsed, - APP_ROUTE_TRANSITION_SECONDS) + FrameTransition(app.ui.session, app.ui.route_transition_surface, bounds, + elapsed, APP_ROUTE_TRANSITION_SECONDS) } diff --git a/src/app/app_types.zi b/src/app/app_types.zi index 00d11eae3..d57bdb506 100644 --- a/src/app/app_types.zi +++ b/src/app/app_types.zi @@ -5,6 +5,7 @@ #import "router_props" #import "session" #import "file_download" +#import "frame_transition" #import, file "../platform/media_types.zi"; #import, file "../core/types.zi"; #import, file "route_types.zi"; @@ -446,8 +447,10 @@ AppUiState :: struct { route_transition_pending: bool route_transition_active: bool route_transition_started: float64 - route_transition_texture: Texture2D - route_transition_texture_owned: bool + // The previous screen with its row orientation: raylib's retained frames + // are bottom-up, the desktop host's snapshots upright. + route_transition_surface: FrameSurface + route_transition_surface_owned: bool frame_text: FrameTextStore rest_break_requested: bool sync_requested: bool diff --git a/src/app/application_frame.zi b/src/app/application_frame.zi index f1fc833bb..2d5ca26a1 100644 --- a/src/app/application_frame.zi +++ b/src/app/application_frame.zi @@ -151,7 +151,7 @@ app_capture_route_transition :: (app: *InnerBreeze) { } // Input can change the route while updateapp builds the destination. // Capture the last presented frame before app_finish_frame paints it. - app_route_transition_capture(app, surface.texture, HostSeconds(), true) + app_route_transition_capture(app, surface, HostSeconds(), true) } app_finish_frame :: (app: *InnerBreeze) { diff --git a/tests/graphics_transition_behavior.zi b/tests/graphics_transition_behavior.zi index f15592449..c5e30f516 100644 --- a/tests/graphics_transition_behavior.zi +++ b/tests/graphics_transition_behavior.zi @@ -1,6 +1,7 @@ #import, file "../src/app/app_frame_transition.zi"; #import, file "../src/app/app_types.zi"; #import "drawing_props" +#import "frame_transition" released: s32; wrong_texture: bool; @@ -16,16 +17,22 @@ DisposeFrameTexture :: (texture: Texture2D) { } } +Frame :: () -> FrameSurface { + surface: FrameSurface + surface.texture = Texture2D.{42, 20, 20, 1, 7} + return surface +} + Prepared :: (app: *InnerBreeze, owned: bool) { - app.ui.route_transition_texture = Texture2D.{42, 20, 20, 1, 7} - app.ui.route_transition_texture_owned = owned + app.ui.route_transition_surface = Frame() + app.ui.route_transition_surface_owned = owned app.ui.route_transition_active = true app.ui.route_transition_pending = true } Cleared :: (app: *InnerBreeze) -> bool { - return app.ui.route_transition_texture.id == 0 && - !app.ui.route_transition_texture_owned && + return app.ui.route_transition_surface.texture.id == 0 && + !app.ui.route_transition_surface_owned && !app.ui.route_transition_active && !app.ui.route_transition_pending } @@ -54,10 +61,10 @@ main :: () -> s32 { Prepared(*app, true) app_route_transition_request(*app) if released != 2 || wrong_texture || app.ui.route_transition_active || - !app.ui.route_transition_pending || app.ui.route_transition_texture.id != 0 { + !app.ui.route_transition_pending || app.ui.route_transition_surface.texture.id != 0 { return 5 } - app_route_transition_capture(*app, Texture2D.{42, 20, 20, 1, 7}, 1.0, false) + app_route_transition_capture(*app, Frame(), 1.0, false) if !app.ui.route_transition_active || app.ui.route_transition_pending { return 6 } @@ -66,5 +73,14 @@ main :: () -> s32 { !app.ui.route_transition_pending { return 7 } + + // The fade keeps the captured surface itself, which carries the host's + // row orientation, and releases an owned one when it ends. + app_route_transition_capture(*app, Frame(), 2.0, true) + if !app.ui.route_transition_active || app.ui.route_transition_surface.texture.id != 42 { + return 9 + } + app_route_transition_advance(*app, 2.0 + cast(float64)APP_ROUTE_TRANSITION_SECONDS) + if released != 3 || wrong_texture || !Cleared(*app) { return 11 } return 0 }