mirror of
https://gitlab.freedesktop.org/emersion/libliftoff.git
synced 2024-12-26 21:59:18 +01:00
Replace liftoff_layer_get_plane_id with liftoff_layer_get_plane
Users can get back the plane ID with liftoff_plane_get_id.
This commit is contained in:
parent
8260fa67d7
commit
bcb6e3cfb8
8 changed files with 41 additions and 21 deletions
|
@ -111,6 +111,7 @@ int main(int argc, char *argv[])
|
||||||
struct liftoff_layer *composition_layer;
|
struct liftoff_layer *composition_layer;
|
||||||
struct dumb_fb fbs[MAX_LAYERS_LEN] = {0};
|
struct dumb_fb fbs[MAX_LAYERS_LEN] = {0};
|
||||||
struct liftoff_layer *layers[MAX_LAYERS_LEN];
|
struct liftoff_layer *layers[MAX_LAYERS_LEN];
|
||||||
|
struct liftoff_plane *plane;
|
||||||
drmModeAtomicReq *req;
|
drmModeAtomicReq *req;
|
||||||
int ret;
|
int ret;
|
||||||
size_t i;
|
size_t i;
|
||||||
|
@ -200,7 +201,7 @@ int main(int argc, char *argv[])
|
||||||
|
|
||||||
/* Composite layers that didn't make it into a plane */
|
/* Composite layers that didn't make it into a plane */
|
||||||
for (i = 1; i < layers_len; i++) {
|
for (i = 1; i < layers_len; i++) {
|
||||||
if (liftoff_layer_get_plane_id(layers[i]) == 0) {
|
if (liftoff_layer_get_plane(layers[i]) == NULL) {
|
||||||
composite(drm_fd, &composition_fb, &fbs[i],
|
composite(drm_fd, &composition_fb, &fbs[i],
|
||||||
i * 100, i * 100);
|
i * 100, i * 100);
|
||||||
}
|
}
|
||||||
|
@ -212,11 +213,13 @@ int main(int argc, char *argv[])
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
plane = liftoff_layer_get_plane(composition_layer);
|
||||||
printf("Composition layer got assigned to plane %u\n",
|
printf("Composition layer got assigned to plane %u\n",
|
||||||
liftoff_layer_get_plane_id(composition_layer));
|
plane ? liftoff_plane_get_id(plane) : 0);
|
||||||
for (i = 0; i < layers_len; i++) {
|
for (i = 0; i < layers_len; i++) {
|
||||||
|
plane = liftoff_layer_get_plane(layers[i]);
|
||||||
printf("Layer %zu got assigned to plane %u\n", i,
|
printf("Layer %zu got assigned to plane %u\n", i,
|
||||||
liftoff_layer_get_plane_id(layers[i]));
|
plane ? liftoff_plane_get_id(plane) : 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
sleep(1);
|
sleep(1);
|
||||||
|
|
|
@ -92,6 +92,7 @@ static bool draw(void)
|
||||||
int ret, inc;
|
int ret, inc;
|
||||||
size_t i;
|
size_t i;
|
||||||
uint32_t flags;
|
uint32_t flags;
|
||||||
|
struct liftoff_plane *plane;
|
||||||
|
|
||||||
active_layer = &layers[active_layer_idx];
|
active_layer = &layers[active_layer_idx];
|
||||||
|
|
||||||
|
@ -124,8 +125,13 @@ static bool draw(void)
|
||||||
drmModeAtomicFree(req);
|
drmModeAtomicFree(req);
|
||||||
|
|
||||||
for (i = 0; i < sizeof(layers) / sizeof(layers[0]); i++) {
|
for (i = 0; i < sizeof(layers) / sizeof(layers[0]); i++) {
|
||||||
|
plane = liftoff_layer_get_plane(layers[i].layer);
|
||||||
|
if (plane != NULL) {
|
||||||
printf("Layer %zu got assigned to plane %u\n", i,
|
printf("Layer %zu got assigned to plane %u\n", i,
|
||||||
liftoff_layer_get_plane_id(layers[i].layer));
|
liftoff_plane_get_id(plane));
|
||||||
|
} else {
|
||||||
|
printf("Layer %zu has no plane assigned\n", i);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -74,6 +74,7 @@ int main(int argc, char *argv[])
|
||||||
drmModeCrtc *crtcs[MAX_OUTPUTS], *crtc;
|
drmModeCrtc *crtcs[MAX_OUTPUTS], *crtc;
|
||||||
struct liftoff_output *outputs[MAX_OUTPUTS], *output;
|
struct liftoff_output *outputs[MAX_OUTPUTS], *output;
|
||||||
struct liftoff_layer *layers[MAX_OUTPUTS * LAYERS_PER_OUTPUT];
|
struct liftoff_layer *layers[MAX_OUTPUTS * LAYERS_PER_OUTPUT];
|
||||||
|
struct liftoff_plane *plane;
|
||||||
size_t outputs_len, layers_len;
|
size_t outputs_len, layers_len;
|
||||||
drmModeAtomicReq *req;
|
drmModeAtomicReq *req;
|
||||||
int ret;
|
int ret;
|
||||||
|
@ -168,8 +169,13 @@ int main(int argc, char *argv[])
|
||||||
}
|
}
|
||||||
|
|
||||||
for (i = 0; i < layers_len; i++) {
|
for (i = 0; i < layers_len; i++) {
|
||||||
|
plane = liftoff_layer_get_plane(layers[i]);
|
||||||
|
if (plane != NULL) {
|
||||||
printf("Layer %zu got assigned to plane %u\n", i,
|
printf("Layer %zu got assigned to plane %u\n", i,
|
||||||
liftoff_layer_get_plane_id(layers[i]));
|
liftoff_plane_get_id(plane));
|
||||||
|
} else {
|
||||||
|
printf("Layer %zu has no plane assigned\n", i);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
sleep(1);
|
sleep(1);
|
||||||
|
|
|
@ -72,6 +72,7 @@ int main(int argc, char *argv[])
|
||||||
drmModeConnector *connector;
|
drmModeConnector *connector;
|
||||||
struct liftoff_output *output;
|
struct liftoff_output *output;
|
||||||
struct liftoff_layer *layers[LAYERS_LEN];
|
struct liftoff_layer *layers[LAYERS_LEN];
|
||||||
|
struct liftoff_plane *plane;
|
||||||
drmModeAtomicReq *req;
|
drmModeAtomicReq *req;
|
||||||
int ret;
|
int ret;
|
||||||
size_t i;
|
size_t i;
|
||||||
|
@ -140,8 +141,13 @@ int main(int argc, char *argv[])
|
||||||
}
|
}
|
||||||
|
|
||||||
for (i = 0; i < sizeof(layers) / sizeof(layers[0]); i++) {
|
for (i = 0; i < sizeof(layers) / sizeof(layers[0]); i++) {
|
||||||
|
plane = liftoff_layer_get_plane(layers[i]);
|
||||||
|
if (plane != NULL) {
|
||||||
printf("Layer %zu got assigned to plane %u\n", i,
|
printf("Layer %zu got assigned to plane %u\n", i,
|
||||||
liftoff_layer_get_plane_id(layers[i]));
|
liftoff_plane_get_id(plane));
|
||||||
|
} else {
|
||||||
|
printf("Layer %zu has no plane assigned\n", i);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
sleep(1);
|
sleep(1);
|
||||||
|
|
|
@ -122,9 +122,9 @@ void liftoff_layer_set_fb_composited(struct liftoff_layer *layer);
|
||||||
/**
|
/**
|
||||||
* Retrieve the plane mapped to this layer.
|
* Retrieve the plane mapped to this layer.
|
||||||
*
|
*
|
||||||
* Zero is returned if no plane is mapped.
|
* NULL is returned if no plane is mapped.
|
||||||
*/
|
*/
|
||||||
uint32_t liftoff_layer_get_plane_id(struct liftoff_layer *layer);
|
struct liftoff_plane *liftoff_layer_get_plane(struct liftoff_layer *layer);
|
||||||
|
|
||||||
enum liftoff_log_priority {
|
enum liftoff_log_priority {
|
||||||
LIFTOFF_SILENT,
|
LIFTOFF_SILENT,
|
||||||
|
|
7
layer.c
7
layer.c
|
@ -99,12 +99,9 @@ void liftoff_layer_set_fb_composited(struct liftoff_layer *layer)
|
||||||
layer->changed = true;
|
layer->changed = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t liftoff_layer_get_plane_id(struct liftoff_layer *layer)
|
struct liftoff_plane *liftoff_layer_get_plane(struct liftoff_layer *layer)
|
||||||
{
|
{
|
||||||
if (layer->plane == NULL) {
|
return layer->plane;
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
return layer->plane->id;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void layer_get_rect(struct liftoff_layer *layer, struct liftoff_rect *rect)
|
void layer_get_rect(struct liftoff_layer *layer, struct liftoff_rect *rect)
|
||||||
|
|
|
@ -616,6 +616,7 @@ static void run_test(struct test_layer *test_layers)
|
||||||
struct liftoff_device *device;
|
struct liftoff_device *device;
|
||||||
struct liftoff_output *output;
|
struct liftoff_output *output;
|
||||||
struct liftoff_layer *layers[64];
|
struct liftoff_layer *layers[64];
|
||||||
|
struct liftoff_plane *plane;
|
||||||
drmModeAtomicReq *req;
|
drmModeAtomicReq *req;
|
||||||
bool ok;
|
bool ok;
|
||||||
int ret;
|
int ret;
|
||||||
|
@ -662,9 +663,10 @@ static void run_test(struct test_layer *test_layers)
|
||||||
drmModeAtomicFree(req);
|
drmModeAtomicFree(req);
|
||||||
|
|
||||||
for (i = 0; test_layers[i].width > 0; i++) {
|
for (i = 0; test_layers[i].width > 0; i++) {
|
||||||
plane_id = liftoff_layer_get_plane_id(layers[i]);
|
plane = liftoff_layer_get_plane(layers[i]);
|
||||||
mock_plane = NULL;
|
mock_plane = NULL;
|
||||||
if (plane_id != 0) {
|
if (plane != NULL) {
|
||||||
|
plane_id = liftoff_plane_get_id(plane);
|
||||||
mock_plane = liftoff_mock_drm_get_plane(plane_id);
|
mock_plane = liftoff_mock_drm_get_plane(plane_id);
|
||||||
}
|
}
|
||||||
plane_index_got = -1;
|
plane_index_got = -1;
|
||||||
|
|
|
@ -84,7 +84,7 @@ static int test_prop_default(const char *prop_name)
|
||||||
assert(ok);
|
assert(ok);
|
||||||
ret = drmModeAtomicCommit(drm_fd, req, 0, NULL);
|
ret = drmModeAtomicCommit(drm_fd, req, 0, NULL);
|
||||||
assert(ret == 0);
|
assert(ret == 0);
|
||||||
assert(liftoff_layer_get_plane_id(layer) == 0);
|
assert(liftoff_layer_get_plane(layer) == NULL);
|
||||||
drmModeAtomicFree(req);
|
drmModeAtomicFree(req);
|
||||||
|
|
||||||
/* The layer should get assigned to the plane without the prop when
|
/* The layer should get assigned to the plane without the prop when
|
||||||
|
@ -98,7 +98,7 @@ static int test_prop_default(const char *prop_name)
|
||||||
assert(ok);
|
assert(ok);
|
||||||
ret = drmModeAtomicCommit(drm_fd, req, 0, NULL);
|
ret = drmModeAtomicCommit(drm_fd, req, 0, NULL);
|
||||||
assert(ret == 0);
|
assert(ret == 0);
|
||||||
assert(liftoff_layer_get_plane_id(layer) != 0);
|
assert(liftoff_layer_get_plane(layer) != NULL);
|
||||||
drmModeAtomicFree(req);
|
drmModeAtomicFree(req);
|
||||||
|
|
||||||
/* The layer should get assigned to the plane with the prop when using
|
/* The layer should get assigned to the plane with the prop when using
|
||||||
|
@ -114,7 +114,7 @@ static int test_prop_default(const char *prop_name)
|
||||||
assert(ok);
|
assert(ok);
|
||||||
ret = drmModeAtomicCommit(drm_fd, req, 0, NULL);
|
ret = drmModeAtomicCommit(drm_fd, req, 0, NULL);
|
||||||
assert(ret == 0);
|
assert(ret == 0);
|
||||||
assert(liftoff_layer_get_plane_id(layer) != 0);
|
assert(liftoff_layer_get_plane(layer) != NULL);
|
||||||
drmModeAtomicFree(req);
|
drmModeAtomicFree(req);
|
||||||
|
|
||||||
liftoff_device_destroy(device);
|
liftoff_device_destroy(device);
|
||||||
|
|
Loading…
Reference in a new issue