mirror of
https://github.com/Droid-Deck/DroidDeck.git
synced 2026-12-05 12:35:42 +00:00
Fix zero-copy layer transition callback failures
This commit is contained in:
1 parent
e3ba2bc68d
commit
cd1e9dde15
1 file changed
+30
-7
@@ -397,12 +397,16 @@ static void retire_sc(struct layer *l) {
|
||||
ASurfaceTransaction *tx = api.txCreate();
|
||||
if (tx) {
|
||||
retire_ops(tx, l->sc);
|
||||
if (add_complete(tx, l, l->cur_slot, l->cur_token, 1) != 0) api.release(l->sc);
|
||||
if (add_complete(tx, l, l->cur_slot, l->cur_token, 1) != 0) {
|
||||
api.txDelete(tx);
|
||||
droiddeck_log("layer", "%s: retirement deferred because its release callback could not be allocated", l->name);
|
||||
return;
|
||||
}
|
||||
api.txApply(tx);
|
||||
api.txDelete(tx);
|
||||
} else {
|
||||
if (l->cur_token) ahb_swapchain_layer_released(l->cur_token, -1);
|
||||
api.release(l->sc);
|
||||
droiddeck_log("layer", "%s: retirement deferred because a transaction could not be allocated", l->name);
|
||||
return;
|
||||
}
|
||||
droiddeck_log("layer", "%s: SurfaceControl retired (window %p)", l->name, (void *)l->win);
|
||||
l->sc = NULL; l->win = NULL;
|
||||
@@ -832,6 +836,16 @@ static ASurfaceControl *swap_sc_begin(struct layer *l) {
|
||||
return old;
|
||||
}
|
||||
|
||||
static void rollback_swap_sc(struct layer *l, ASurfaceControl *old) {
|
||||
if (!old) return;
|
||||
ASurfaceControl *fresh = l->sc;
|
||||
l->sc = old;
|
||||
l->shown = 1;
|
||||
l->recreate_pending = 1;
|
||||
l->geo_valid = 0;
|
||||
if (fresh) api.release(fresh);
|
||||
}
|
||||
|
||||
static int present_slot(struct layer *l, int idx, const int r[8], const struct droiddeck_color *color,
|
||||
int translucent) {
|
||||
struct slot *s = &l->slots[idx];
|
||||
@@ -848,8 +862,12 @@ static int present_slot(struct layer *l, int idx, const int r[8], const struct d
|
||||
apply_colour(tx, l, color);
|
||||
if (!l->shown) api.setVisibility(tx, l->sc, ASC_VISIBILITY_SHOW);
|
||||
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 && old)
|
||||
api.release(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);
|
||||
droiddeck_log("layer", "%s: frame transition skipped because its release callback could not be allocated", l->name);
|
||||
return -1;
|
||||
}
|
||||
pthread_mutex_lock(&g_lock);
|
||||
s->busy = 1;
|
||||
pthread_mutex_unlock(&g_lock);
|
||||
@@ -917,8 +935,9 @@ 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);
|
||||
if (old) api.release(old);
|
||||
rollback_swap_sc(l, old);
|
||||
l->ds_applied = -1; l->md_applied = 0; l->hr_applied = -1.0f;
|
||||
droiddeck_log("layer", "zero-copy: frame transition skipped because its release callback could not be allocated");
|
||||
return -1;
|
||||
}
|
||||
apply_present_time(tx, 1);
|
||||
@@ -1173,7 +1192,11 @@ static void hide_layer(struct layer *l) {
|
||||
if (!tx) return;
|
||||
replace_with_blank(tx, l);
|
||||
api.setVisibility(tx, l->sc, ASC_VISIBILITY_HIDE);
|
||||
add_complete(tx, l, l->cur_slot, l->cur_token, 0);
|
||||
if (add_complete(tx, l, l->cur_slot, l->cur_token, 0) != 0) {
|
||||
api.txDelete(tx);
|
||||
droiddeck_log("layer", "%s: hide deferred because its release callback could not be allocated", l->name);
|
||||
return;
|
||||
}
|
||||
api.txApply(tx); api.txDelete(tx);
|
||||
l->shown = 0; l->cur_slot = -1; l->cur_token = NULL;
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user