Replace liftoff_layer_property.changed with prev_value

Keep track of the previous value, e.g. to figure out when a layer goes from
disabled (no FB_ID or zero alpha) to enabled.
This commit is contained in:
Simon Ser 2020-12-05 12:28:50 +01:00
parent 1700cbf1c9
commit b936348acc
No known key found for this signature in database
GPG key ID: 0FDE7BE0E88F5E48
3 changed files with 18 additions and 17 deletions

View file

@ -491,9 +491,13 @@ static bool layer_needs_realloc(struct liftoff_layer *layer)
size_t i;
struct liftoff_layer_property *prop;
if (layer->changed) {
return true;
}
for (i = 0; i < layer->props_len; i++) {
prop = &layer->props[i];
if (!prop->changed) {
if (prop->value == prop->prev_value) {
continue;
}
@ -503,7 +507,7 @@ static bool layer_needs_realloc(struct liftoff_layer *layer)
* non-zero to non-zero, we can try to re-use the previous
* allocation. */
if (strcmp(prop->name, "FB_ID") == 0) {
if (layer->force_composition || prop->value == 0) {
if (prop->value == 0) {
return true;
}
/* TODO: check format/modifier is the same. Check

View file

@ -48,12 +48,13 @@ struct liftoff_layer {
struct liftoff_plane *plane;
int current_priority, pending_priority;
/* prop added or force_composition changed */
bool changed;
};
struct liftoff_layer_property {
char name[DRM_PROP_NAME_LEN];
uint64_t value;
bool changed;
uint64_t value, prev_value;
};
struct liftoff_plane {

22
layer.c
View file

@ -76,32 +76,27 @@ void liftoff_layer_set_property(struct liftoff_layer *layer, const char *name,
memset(prop, 0, sizeof(*prop));
strncpy(prop->name, name, sizeof(prop->name) - 1);
prop->changed = true;
} else {
prop->changed = prop->value != value;
layer->changed = true;
}
prop->value = value;
if (strcmp(name, "FB_ID") == 0) {
if (strcmp(name, "FB_ID") == 0 && layer->force_composition) {
layer->force_composition = false;
prop->changed = true;
layer->changed = true;
}
}
void liftoff_layer_set_fb_composited(struct liftoff_layer *layer)
{
struct liftoff_layer_property *prop;
if (layer->force_composition) {
return;
}
liftoff_layer_set_property(layer, "FB_ID", 0);
prop = layer_get_property(layer, "FB_ID");
prop->changed = true;
layer->force_composition = true;
layer->changed = true;
}
uint32_t liftoff_layer_get_plane_id(struct liftoff_layer *layer)
@ -142,8 +137,10 @@ void layer_mark_clean(struct liftoff_layer *layer)
{
size_t i;
layer->changed = false;
for (i = 0; i < layer->props_len; i++) {
layer->props[i].changed = false;
layer->props[i].prev_value = layer->props[i].value;
}
}
@ -161,10 +158,9 @@ static void log_priority(struct liftoff_layer *layer)
void layer_update_priority(struct liftoff_layer *layer, bool make_current) {
struct liftoff_layer_property *prop;
/* TODO: also bump priority when updating other
* properties */
/* TODO: also bump priority when updating other properties */
prop = layer_get_property(layer, "FB_ID");
if (prop != NULL && prop->changed) {
if (prop != NULL && prop->prev_value != prop->value) {
layer->pending_priority++;
}