Add support for reading immutable plane zpos

If zpos is present, instead of guessing the zpos from the plane type, just use
it. If two planes have the same zpos, we consider their relative position as
undefined.

We don't handle the case where some planes have zpos set but some others don't.

References: https://github.com/emersion/libhwc/issues/4
This commit is contained in:
Simon Ser 2019-09-09 19:46:44 +03:00
parent 42db49c6fe
commit dac885222b
No known key found for this signature in database
GPG key ID: 0FDE7BE0E88F5E48

View file

@ -41,7 +41,8 @@ static struct hwc_plane *plane_create(struct hwc_display *display, uint32_t id)
uint32_t i;
drmModePropertyRes *drm_prop;
struct hwc_plane_property *prop;
int type = -1;
uint64_t value;
bool has_zpos = false;
plane = calloc(1, sizeof(*plane));
if (plane == NULL) {
@ -80,17 +81,18 @@ static struct hwc_plane *plane_create(struct hwc_display *display, uint32_t id)
drmModeFreeProperty(drm_prop);
plane->props_len++;
if (strcmp(prop->name, "type") == 0) {
type = drm_props->prop_values[i];
value = drm_props->prop_values[i];
if (strcmp(prop->name, "type") == 0 && !has_zpos) {
plane->zpos = guess_plane_zpos_from_type(display,
plane->id,
type);
} else if (strcmp(prop->name, "zpos") == 0) {
plane->zpos = zpos;
has_zpos = true;
}
}
drmModeFreeObjectProperties(drm_props);
if (type >= 0) {
plane->zpos = guess_plane_zpos_from_type(display, plane->id,
type);
}
hwc_list_insert(display->planes.prev, &plane->link);
return plane;