From c833514757970638cce1f540962bc4a2ed9d9437 Mon Sep 17 00:00:00 2001 From: LunaDL <91587464+EnzoDLofi@users.noreply.github.com> Date: Sun, 29 Nov 2026 01:17:14 -0400 Subject: [PATCH] Restore HDR caches when rolling back layer swap --- app/src/main/cpp/waylandcomp/src/sc_layer.c | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/app/src/main/cpp/waylandcomp/src/sc_layer.c b/app/src/main/cpp/waylandcomp/src/sc_layer.c index 4848072337..a0e3df4941 100644 --- a/app/src/main/cpp/waylandcomp/src/sc_layer.c +++ b/app/src/main/cpp/waylandcomp/src/sc_layer.c @@ -868,7 +868,8 @@ static ASurfaceControl *swap_sc_begin(struct layer *l) { return old; } -static void rollback_swap_sc(struct layer *l, ASurfaceControl *old, int was_shown) { +static void rollback_swap_sc(struct layer *l, ASurfaceControl *old, int was_shown, + int32_t ds_applied, uint32_t md_applied, float hr_applied) { if (!old) return; ASurfaceControl *fresh = l->sc; l->sc = old; @@ -876,7 +877,7 @@ static void rollback_swap_sc(struct layer *l, ASurfaceControl *old, int was_show l->recreate_pending = 1; l->geo_valid = 0; l->fps_applied = -1.0f; - l->ds_applied = -1; l->md_applied = 0; l->hr_applied = -1.0f; + l->ds_applied = ds_applied; l->md_applied = md_applied; l->hr_applied = hr_applied; if (fresh) api.release(fresh); } @@ -886,6 +887,9 @@ static int present_slot(struct layer *l, int idx, const int r[8], const struct d ASurfaceTransaction *tx = api.txCreate(); if (!tx) return -1; const int was_shown = l->shown; + const int32_t ds_applied = l->ds_applied; + const uint32_t md_applied = l->md_applied; + const float hr_applied = l->hr_applied; ASurfaceControl *old = swap_sc_begin(l); if (old) api.setZOrder(tx, l->sc, l->z); api.setBuffer(tx, l->sc, s->ahb, -1); @@ -896,7 +900,7 @@ static int present_slot(struct layer *l, int idx, const int r[8], const struct d if (old) retire_ops(tx, old); if (add_complete_on(tx, l, old ? old : l->sc, l->cur_slot, l->cur_token, old ? 1 : 0) != 0) { api.txDelete(tx); - rollback_swap_sc(l, old, was_shown); + rollback_swap_sc(l, old, was_shown, ds_applied, md_applied, hr_applied); droiddeck_log("layer", "%s: frame transition skipped because its release callback could not be allocated", l->name); return -1; } @@ -958,6 +962,9 @@ int sc_layer_present_ahb(AHardwareBuffer *ahb, int w, int h, int acquire_fd, voi ASurfaceTransaction *tx = api.txCreate(); if (!tx) goto unavailable; const int was_shown = l->shown; + const int32_t ds_applied = l->ds_applied; + const uint32_t md_applied = l->md_applied; + const float hr_applied = l->hr_applied; ASurfaceControl *old = swap_sc_begin(l); if (old) api.setZOrder(tx, l->sc, l->z); api.setBuffer(tx, l->sc, ahb, acquire_fd); @@ -968,7 +975,7 @@ int sc_layer_present_ahb(AHardwareBuffer *ahb, int w, int h, int acquire_fd, voi if (add_complete_on(tx, l, old ? old : l->sc, l->cur_slot, l->cur_token == token ? NULL : l->cur_token, old ? 1 : 0) != 0) { api.txDelete(tx); - rollback_swap_sc(l, old, was_shown); + rollback_swap_sc(l, old, was_shown, ds_applied, md_applied, hr_applied); droiddeck_log("layer", "zero-copy: frame transition skipped because its release callback could not be allocated"); return -1; }