mirror of
https://gitlab.freedesktop.org/emersion/libliftoff.git
synced 2025-01-30 20:34:19 +01:00
List planes by allocation order
Given a primary plane with zpos=0 and overlay planes with zpos 1 2, we want first to allocate the primary plane, then the furthest overlay plane, then the remaining one: 0 2 1. References: https://github.com/emersion/libhwc/issues/3
This commit is contained in:
parent
dac885222b
commit
e2df5e73d0
2 changed files with 37 additions and 9 deletions
43
display.c
43
display.c
|
@ -8,7 +8,7 @@
|
||||||
#include "private.h"
|
#include "private.h"
|
||||||
|
|
||||||
static int guess_plane_zpos_from_type(struct hwc_display *display,
|
static int guess_plane_zpos_from_type(struct hwc_display *display,
|
||||||
uint32_t plane_id, int type)
|
uint32_t plane_id, uint32_t type)
|
||||||
{
|
{
|
||||||
struct hwc_plane *primary;
|
struct hwc_plane *primary;
|
||||||
|
|
||||||
|
@ -35,14 +35,14 @@ static int guess_plane_zpos_from_type(struct hwc_display *display,
|
||||||
|
|
||||||
static struct hwc_plane *plane_create(struct hwc_display *display, uint32_t id)
|
static struct hwc_plane *plane_create(struct hwc_display *display, uint32_t id)
|
||||||
{
|
{
|
||||||
struct hwc_plane *plane;
|
struct hwc_plane *plane, *cur;
|
||||||
drmModePlane *drm_plane;
|
drmModePlane *drm_plane;
|
||||||
drmModeObjectProperties *drm_props;
|
drmModeObjectProperties *drm_props;
|
||||||
uint32_t i;
|
uint32_t i;
|
||||||
drmModePropertyRes *drm_prop;
|
drmModePropertyRes *drm_prop;
|
||||||
struct hwc_plane_property *prop;
|
struct hwc_plane_property *prop;
|
||||||
uint64_t value;
|
uint64_t value;
|
||||||
bool has_zpos = false;
|
bool has_type = false, has_zpos = false;
|
||||||
|
|
||||||
plane = calloc(1, sizeof(*plane));
|
plane = calloc(1, sizeof(*plane));
|
||||||
if (plane == NULL) {
|
if (plane == NULL) {
|
||||||
|
@ -82,18 +82,45 @@ static struct hwc_plane *plane_create(struct hwc_display *display, uint32_t id)
|
||||||
plane->props_len++;
|
plane->props_len++;
|
||||||
|
|
||||||
value = drm_props->prop_values[i];
|
value = drm_props->prop_values[i];
|
||||||
if (strcmp(prop->name, "type") == 0 && !has_zpos) {
|
if (strcmp(prop->name, "type") == 0) {
|
||||||
plane->zpos = guess_plane_zpos_from_type(display,
|
plane->type = value;
|
||||||
plane->id,
|
has_type = true;
|
||||||
type);
|
|
||||||
} else if (strcmp(prop->name, "zpos") == 0) {
|
} else if (strcmp(prop->name, "zpos") == 0) {
|
||||||
plane->zpos = zpos;
|
plane->zpos = value;
|
||||||
has_zpos = true;
|
has_zpos = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
drmModeFreeObjectProperties(drm_props);
|
drmModeFreeObjectProperties(drm_props);
|
||||||
|
|
||||||
|
if (!has_type) {
|
||||||
|
fprintf(stderr, "plane %d is missing the 'type' property\n",
|
||||||
|
plane->id);
|
||||||
|
free(plane);
|
||||||
|
return NULL;
|
||||||
|
} else if (!has_zpos) {
|
||||||
|
plane->zpos = guess_plane_zpos_from_type(display, plane->id,
|
||||||
|
plane->type);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* During plane allocation, we will use the plane list order to fill
|
||||||
|
* planes with FBs. Primary planes need to be filled first, then planes
|
||||||
|
* far from the primary planes, then planes closer and closer to the
|
||||||
|
* primary plane. */
|
||||||
|
if (plane->type == DRM_PLANE_TYPE_PRIMARY) {
|
||||||
|
hwc_list_insert(&display->planes, &plane->link);
|
||||||
|
} else {
|
||||||
|
hwc_list_for_each(cur, &display->planes, link) {
|
||||||
|
if (cur->type != DRM_PLANE_TYPE_PRIMARY &&
|
||||||
|
plane->zpos >= cur->zpos) {
|
||||||
|
hwc_list_insert(cur->link.prev, &plane->link);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (plane->link.next == NULL) { /* not inserted */
|
||||||
hwc_list_insert(display->planes.prev, &plane->link);
|
hwc_list_insert(display->planes.prev, &plane->link);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return plane;
|
return plane;
|
||||||
}
|
}
|
||||||
|
|
|
@ -41,6 +41,7 @@ struct hwc_layer_property {
|
||||||
struct hwc_plane {
|
struct hwc_plane {
|
||||||
uint32_t id;
|
uint32_t id;
|
||||||
uint32_t possible_crtcs;
|
uint32_t possible_crtcs;
|
||||||
|
uint32_t type;
|
||||||
int zpos; /* greater values mean closer to the eye */
|
int zpos; /* greater values mean closer to the eye */
|
||||||
/* TODO: formats */
|
/* TODO: formats */
|
||||||
struct hwc_list link; /* hwc_display.planes */
|
struct hwc_list link; /* hwc_display.planes */
|
||||||
|
|
Loading…
Add table
Reference in a new issue