libliftoff/output.c

97 lines
2.2 KiB
C
Raw Normal View History

#include <assert.h>
2019-12-12 23:40:01 +01:00
#include <inttypes.h>
2019-08-21 22:07:37 +02:00
#include <stdlib.h>
#include <string.h>
#include <sys/types.h>
2019-08-21 22:07:37 +02:00
#include "private.h"
struct liftoff_output *liftoff_output_create(struct liftoff_device *device,
uint32_t crtc_id)
2019-08-21 22:07:37 +02:00
{
struct liftoff_output *output;
ssize_t crtc_index;
size_t i;
crtc_index = -1;
for (i = 0; i < device->crtcs_len; i++) {
if (device->crtcs[i] == crtc_id) {
crtc_index = i;
break;
}
}
if (crtc_index < 0) {
return NULL;
}
2019-08-21 22:07:37 +02:00
output = calloc(1, sizeof(*output));
if (output == NULL) {
return NULL;
}
output->device = device;
2019-08-21 22:07:37 +02:00
output->crtc_id = crtc_id;
output->crtc_index = crtc_index;
liftoff_list_init(&output->layers);
liftoff_list_insert(&device->outputs, &output->link);
2019-08-21 22:07:37 +02:00
return output;
}
void liftoff_output_destroy(struct liftoff_output *output)
2019-08-21 22:07:37 +02:00
{
if (output == NULL) {
return;
}
liftoff_list_remove(&output->link);
2019-08-21 22:07:37 +02:00
free(output);
}
void liftoff_output_set_composition_layer(struct liftoff_output *output,
struct liftoff_layer *layer)
{
assert(layer->output == output);
if (layer != output->composition_layer) {
output->layers_changed = true;
}
output->composition_layer = layer;
}
2019-12-12 23:40:01 +01:00
void output_log_layers(struct liftoff_output *output) {
struct liftoff_layer *layer;
size_t i;
if (!log_has(LIFTOFF_DEBUG)) {
return;
}
2019-12-12 23:40:01 +01:00
liftoff_log(LIFTOFF_DEBUG, "Layers on CRTC %"PRIu32":", output->crtc_id);
liftoff_list_for_each(layer, &output->layers, link) {
if (layer->force_composition) {
liftoff_log(LIFTOFF_DEBUG, " Layer %p "
"(forced composition):", (void *)layer);
} else {
if (!layer_has_fb(layer)) {
continue;
}
liftoff_log(LIFTOFF_DEBUG, " Layer %p:", (void *)layer);
}
2019-12-12 23:40:01 +01:00
for (i = 0; i < layer->props_len; i++) {
char *name = layer->props[i].name;
uint64_t value = layer->props[i].value;
if (strcmp(name, "CRTC_X") == 0 ||
strcmp(name, "CRTC_Y") == 0) {
liftoff_log(LIFTOFF_DEBUG, " %s = %"PRIi32,
name, (int32_t)value);
} else if (strcmp(name, "SRC_W") == 0 ||
strcmp(name, "SRC_H") == 0) {
liftoff_log(LIFTOFF_DEBUG, " %s = %"PRIu64,
name, value >> 16);
} else {
liftoff_log(LIFTOFF_DEBUG, " %s = %"PRIu64,
name, value);
}
2019-12-12 23:40:01 +01:00
}
}
}