Restore Android images and retained frames when graphics resume
This commit is contained in:
1 parent
17c3c90465
commit
41f56bdd47
5 files changed
+62
-16
No files matched your search
@@ -32,6 +32,7 @@ for directory in (
|
||||
command.extend(["--module-path", str(directory)])
|
||||
# KSS imports Kryon as kryon/NAME, and account code imports oqs/Oqs.
|
||||
command.extend(["--module-path", f"kryon={kryon / 'src/ui'}"])
|
||||
command.extend(["--module-path", f"kryon={kryon / 'src/backend'}"])
|
||||
command.extend(["--module-path", f"oqs={root / 'build/packages/oqs/src'}"])
|
||||
command.extend(["-o", str(args.output)])
|
||||
command.extend(str(path.relative_to(root)) for path in sources)
|
||||
|
||||
@@ -360,6 +360,7 @@ InnerBreeze :: struct {
|
||||
start_speed_preview_speed: s32
|
||||
camera: Camera
|
||||
graphics_reload_requested: s32
|
||||
graphics_context: *void
|
||||
meditation: MeditationPracticeState
|
||||
sun_salutation: SunSalutationPracticeState
|
||||
breath_in_sound: SoundHandle
|
||||
|
||||
+38
-5
@@ -18,6 +18,10 @@ GetTime :: () -> float64 #foreign c;
|
||||
#import, file "../platform/asset_download.zi";
|
||||
#import, file "../platform/asset_download_types.zi";
|
||||
#import, file "../platform/android/android_device.zi";
|
||||
#import, file "../platform/android/graphics_context.zi";
|
||||
#if #defined(ANDROID_BUILD) {
|
||||
#import "kryon/raylib_runtime"
|
||||
}
|
||||
#if #defined(DESKTOP_TRAY_ENABLED) {
|
||||
#import, file "../platform/desktop_tray.zi";
|
||||
}
|
||||
@@ -304,18 +308,44 @@ app_draw_close_prompt :: (app: *InnerBreeze) {
|
||||
}
|
||||
}
|
||||
|
||||
app_reload_graphics_resources :: (app: *InnerBreeze) {
|
||||
if app == null || app.graphics_reload_requested == 0 {
|
||||
return
|
||||
app_reload_graphics_resources :: (app: *InnerBreeze) -> bool {
|
||||
if app == null {
|
||||
return false
|
||||
}
|
||||
context_lost: bool = false
|
||||
#if #defined(ANDROID_BUILD) {
|
||||
context := AndroidGraphicsContext()
|
||||
if context == null {
|
||||
// EndDrawing continues polling Android events until the surface
|
||||
// is rebound. Do not populate any GPU caches in the meantime.
|
||||
return false
|
||||
}
|
||||
context_lost = app.graphics_context != null &&
|
||||
app.graphics_context != context
|
||||
app.graphics_context = context
|
||||
}
|
||||
if app.graphics_reload_requested == 0 && !context_lost {
|
||||
return true
|
||||
}
|
||||
app.graphics_reload_requested = 0
|
||||
if PreviewMode() != 0 {
|
||||
return
|
||||
return true
|
||||
}
|
||||
TraceLog(LOG_INFO, "ANDROID: Reloading graphics resources")
|
||||
#if #defined(ANDROID_BUILD) {
|
||||
ResetRaylibGraphics(context_lost)
|
||||
if context_lost {
|
||||
app.ui.route_transition_texture = Texture2D.{}
|
||||
app.ui.route_transition_texture_owned = false
|
||||
app.ui.route_transition_active = false
|
||||
app.ui.route_transition_pending = false
|
||||
}
|
||||
app.ui.retained_frame_unchanged = false
|
||||
}
|
||||
if !LoadLocaleFont(app) {
|
||||
TraceLog(LOG_WARNING, "FONT: Failed to reload Noto UI font")
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
#program_export
|
||||
@@ -583,6 +613,7 @@ app_init :: (vapp: *void) {
|
||||
if !SessionValid(app.ui.session) { return }
|
||||
android_text_input_open(app.ui.session)
|
||||
#if #defined(ANDROID_BUILD) {
|
||||
app.graphics_context = AndroidGraphicsContext()
|
||||
if practice_active(app) != null {
|
||||
android_allow_screen_off()
|
||||
}
|
||||
@@ -1231,7 +1262,9 @@ app_update_draw :: (vapp: *void, viewport: Rectangle) {
|
||||
frame_decision := app_update_frame_pacing(app, frame_sample)
|
||||
app.ui.frame_target_fps = frame_decision.state.target_fps
|
||||
app.ui.frame_target_changed = frame_decision.apply_target
|
||||
app_reload_graphics_resources(app)
|
||||
if !app_reload_graphics_resources(app) {
|
||||
return
|
||||
}
|
||||
full_width = cast(s32)viewport.width
|
||||
full_height = cast(s32)viewport.height
|
||||
view_width = full_width
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
#if #defined(ANDROID_BUILD) {
|
||||
egl :: #system_library "EGL";
|
||||
AndroidCurrentContext :: () -> *void #foreign egl "eglGetCurrentContext";
|
||||
}
|
||||
|
||||
AndroidGraphicsContext :: () -> *void {
|
||||
#if #defined(ANDROID_BUILD) {
|
||||
return AndroidCurrentContext()
|
||||
}
|
||||
return null
|
||||
}
|
||||
+11
-11
@@ -1,6 +1,14 @@
|
||||
{
|
||||
"format": 1,
|
||||
"packages": [
|
||||
{
|
||||
"commit": "327d65c45c22acbf16dbbc543eded4a397bd63ef",
|
||||
"dependencies": {"raylib": "p5a77c9c35110e925"},
|
||||
"id": "p0005addd0de6e17d",
|
||||
"name": "kryon",
|
||||
"ref": "master",
|
||||
"url": "https://github.com/kryonlabs/kryon.git"
|
||||
},
|
||||
{
|
||||
"commit": "b31299434c785d0f2bd82f36b5bfd2fd36ba1216",
|
||||
"dependencies": {},
|
||||
@@ -38,20 +46,12 @@
|
||||
},
|
||||
{
|
||||
"commit": "396f1efedb702b1aacdd724a7b611302d95a0adc",
|
||||
"dependencies": {"kryon": "p91058dbb38147019"},
|
||||
"dependencies": {"kryon": "p0005addd0de6e17d"},
|
||||
"id": "p7b9204ab0ad2089f",
|
||||
"name": "Game2D",
|
||||
"ref": "master",
|
||||
"url": "https://github.com/kryonlabs/game2d.git"
|
||||
},
|
||||
{
|
||||
"commit": "9280a98e57d05c7b914bf08d7039d23e1813edd8",
|
||||
"dependencies": {"raylib": "p5a77c9c35110e925"},
|
||||
"id": "p91058dbb38147019",
|
||||
"name": "kryon",
|
||||
"ref": "master",
|
||||
"url": "https://github.com/kryonlabs/kryon.git"
|
||||
},
|
||||
{
|
||||
"commit": "e6b9e783747536f34700aab4bd10718c2fecab3f",
|
||||
"dependencies": {},
|
||||
@@ -89,7 +89,7 @@
|
||||
},
|
||||
{
|
||||
"commit": "e1f07e615e9255a513dbb6d66e5e6e9d335ef690",
|
||||
"dependencies": {"kryon": "p91058dbb38147019"},
|
||||
"dependencies": {"kryon": "p0005addd0de6e17d"},
|
||||
"id": "pfdf70946e0505dfe",
|
||||
"name": "Kss",
|
||||
"ref": "master",
|
||||
@@ -97,7 +97,7 @@
|
||||
}
|
||||
],
|
||||
"root": {
|
||||
"dependencies": {"curl": "pc4b263336680098b", "daochi_client": "pd84d39ba79dc890c", "game2d": "p7b9204ab0ad2089f", "kryon": "p91058dbb38147019", "kss": "pfdf70946e0505dfe", "liboqs": "pb34994bf01670ac3", "monocypher": "pccdfe79ccaafde45", "oqs": "p55635fc8976895a9", "rini": "p09fa77e94b0dfc6c", "sqlite": "p151b83a361c86f2d"},
|
||||
"dependencies": {"curl": "pc4b263336680098b", "daochi_client": "pd84d39ba79dc890c", "game2d": "p7b9204ab0ad2089f", "kryon": "p0005addd0de6e17d", "kss": "pfdf70946e0505dfe", "liboqs": "pb34994bf01670ac3", "monocypher": "pccdfe79ccaafde45", "oqs": "p55635fc8976895a9", "rini": "p09fa77e94b0dfc6c", "sqlite": "p151b83a361c86f2d"},
|
||||
"name": "Inbe"
|
||||
},
|
||||
"toolchain": {
|
||||
|
||||
Reference in new issue
Block a user