|
|
|
|
@ -76,7 +76,7 @@ static void scene_node_init(struct wlr_scene_node *node,
|
|
|
|
|
wl_list_init(&node->link);
|
|
|
|
|
|
|
|
|
|
wl_signal_init(&node->events.destroy);
|
|
|
|
|
pixman_region32_init(&node->visible);
|
|
|
|
|
pixman_region64f_init(&node->visible);
|
|
|
|
|
|
|
|
|
|
if (parent != NULL) {
|
|
|
|
|
wl_list_insert(parent->children.prev, &node->link);
|
|
|
|
|
@ -126,7 +126,7 @@ void wlr_scene_node_destroy(struct wlr_scene_node *node) {
|
|
|
|
|
|
|
|
|
|
scene_buffer_set_buffer(scene_buffer, NULL);
|
|
|
|
|
scene_buffer_set_texture(scene_buffer, NULL);
|
|
|
|
|
pixman_region32_fini(&scene_buffer->opaque_region);
|
|
|
|
|
pixman_region64f_fini(&scene_buffer->opaque_region);
|
|
|
|
|
wlr_drm_syncobj_timeline_unref(scene_buffer->wait_timeline);
|
|
|
|
|
|
|
|
|
|
assert(wl_list_empty(&scene_buffer->events.output_leave.listener_list));
|
|
|
|
|
@ -161,7 +161,7 @@ void wlr_scene_node_destroy(struct wlr_scene_node *node) {
|
|
|
|
|
assert(wl_list_empty(&node->events.destroy.listener_list));
|
|
|
|
|
|
|
|
|
|
wl_list_remove(&node->link);
|
|
|
|
|
pixman_region32_fini(&node->visible);
|
|
|
|
|
pixman_region64f_fini(&node->visible);
|
|
|
|
|
free(node);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@ -215,10 +215,10 @@ struct wlr_scene_tree *wlr_scene_tree_create(struct wlr_scene_tree *parent) {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
typedef bool (*scene_node_box_iterator_func_t)(struct wlr_scene_node *node,
|
|
|
|
|
int sx, int sy, void *data);
|
|
|
|
|
double sx, double sy, void *data);
|
|
|
|
|
|
|
|
|
|
static bool _scene_nodes_in_box(struct wlr_scene_node *node, struct wlr_box *box,
|
|
|
|
|
scene_node_box_iterator_func_t iterator, void *user_data, int lx, int ly) {
|
|
|
|
|
static bool _scene_nodes_in_box(struct wlr_scene_node *node, struct wlr_fbox *box,
|
|
|
|
|
scene_node_box_iterator_func_t iterator, void *user_data, double lx, double ly) {
|
|
|
|
|
if (!node->enabled) {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
@ -235,10 +235,10 @@ static bool _scene_nodes_in_box(struct wlr_scene_node *node, struct wlr_box *box
|
|
|
|
|
break;
|
|
|
|
|
case WLR_SCENE_NODE_RECT:
|
|
|
|
|
case WLR_SCENE_NODE_BUFFER:;
|
|
|
|
|
struct wlr_box node_box = { .x = lx, .y = ly };
|
|
|
|
|
struct wlr_fbox node_box = { .x = lx, .y = ly };
|
|
|
|
|
scene_node_get_size(node, &node_box.width, &node_box.height);
|
|
|
|
|
|
|
|
|
|
if (wlr_box_intersection(&node_box, &node_box, box) &&
|
|
|
|
|
if (wlr_fbox_intersection(&node_box, &node_box, box) &&
|
|
|
|
|
iterator(node, lx, ly, user_data)) {
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
@ -248,17 +248,17 @@ static bool _scene_nodes_in_box(struct wlr_scene_node *node, struct wlr_box *box
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static bool scene_nodes_in_box(struct wlr_scene_node *node, struct wlr_box *box,
|
|
|
|
|
static bool scene_nodes_in_box(struct wlr_scene_node *node, struct wlr_fbox *box,
|
|
|
|
|
scene_node_box_iterator_func_t iterator, void *user_data) {
|
|
|
|
|
int x, y;
|
|
|
|
|
double x, y;
|
|
|
|
|
wlr_scene_node_coords(node, &x, &y);
|
|
|
|
|
|
|
|
|
|
return _scene_nodes_in_box(node, box, iterator, user_data, x, y);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void scene_node_opaque_region(struct wlr_scene_node *node, int x, int y,
|
|
|
|
|
pixman_region32_t *opaque) {
|
|
|
|
|
int width, height;
|
|
|
|
|
static void scene_node_opaque_region(struct wlr_scene_node *node, double x, double y,
|
|
|
|
|
pixman_region64f_t *opaque) {
|
|
|
|
|
double width, height;
|
|
|
|
|
scene_node_get_size(node, &width, &height);
|
|
|
|
|
|
|
|
|
|
if (node->type == WLR_SCENE_NODE_RECT) {
|
|
|
|
|
@ -278,21 +278,21 @@ static void scene_node_opaque_region(struct wlr_scene_node *node, int x, int y,
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!scene_buffer->buffer_is_opaque) {
|
|
|
|
|
pixman_region32_copy(opaque, &scene_buffer->opaque_region);
|
|
|
|
|
pixman_region32_intersect_rect(opaque, opaque, 0, 0, width, height);
|
|
|
|
|
pixman_region32_translate(opaque, x, y);
|
|
|
|
|
pixman_region64f_copy(opaque, &scene_buffer->opaque_region);
|
|
|
|
|
pixman_region64f_intersect_rectf(opaque, opaque, 0, 0, width, height);
|
|
|
|
|
pixman_region64f_translatef(opaque, x, y);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
pixman_region32_fini(opaque);
|
|
|
|
|
pixman_region32_init_rect(opaque, x, y, width, height);
|
|
|
|
|
pixman_region64f_fini(opaque);
|
|
|
|
|
pixman_region64f_init_rectf(opaque, x, y, width, height);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
struct scene_update_data {
|
|
|
|
|
pixman_region32_t *visible;
|
|
|
|
|
const pixman_region32_t *update_region;
|
|
|
|
|
struct wlr_box update_box;
|
|
|
|
|
pixman_region64f_t *visible;
|
|
|
|
|
const pixman_region64f_t *update_region;
|
|
|
|
|
struct wlr_fbox update_box;
|
|
|
|
|
struct wl_list *outputs;
|
|
|
|
|
bool calculate_visibility;
|
|
|
|
|
bool restack_xwayland_surfaces;
|
|
|
|
|
@ -302,11 +302,11 @@ struct scene_update_data {
|
|
|
|
|
#endif
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
static uint32_t region_area(const pixman_region32_t *region) {
|
|
|
|
|
uint32_t area = 0;
|
|
|
|
|
static double region_area(const pixman_region64f_t *region) {
|
|
|
|
|
double area = 0;
|
|
|
|
|
|
|
|
|
|
int nrects;
|
|
|
|
|
pixman_box32_t *rects = pixman_region32_rectangles(region, &nrects);
|
|
|
|
|
pixman_box64f_t *rects = pixman_region64f_rectangles(region, &nrects);
|
|
|
|
|
for (int i = 0; i < nrects; ++i) {
|
|
|
|
|
area += (rects[i].x2 - rects[i].x1) * (rects[i].y2 - rects[i].y1);
|
|
|
|
|
}
|
|
|
|
|
@ -314,8 +314,8 @@ static uint32_t region_area(const pixman_region32_t *region) {
|
|
|
|
|
return area;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void scale_region(pixman_region32_t *region, float scale, bool round_up) {
|
|
|
|
|
wlr_region_scale(region, region, scale);
|
|
|
|
|
static void scale_region(pixman_region32_t *region, pixman_region64f_t *src, float scale, bool round_up) {
|
|
|
|
|
wlr_region_scalef(region, src, scale);
|
|
|
|
|
|
|
|
|
|
if (round_up && floor(scale) != scale) {
|
|
|
|
|
wlr_region_expand(region, region, 1);
|
|
|
|
|
@ -325,7 +325,7 @@ static void scale_region(pixman_region32_t *region, float scale, bool round_up)
|
|
|
|
|
struct render_data {
|
|
|
|
|
enum wl_output_transform transform;
|
|
|
|
|
float scale;
|
|
|
|
|
struct wlr_box logical;
|
|
|
|
|
struct wlr_fbox logical;
|
|
|
|
|
int trans_width, trans_height;
|
|
|
|
|
|
|
|
|
|
struct wlr_scene_output *output;
|
|
|
|
|
@ -334,10 +334,10 @@ struct render_data {
|
|
|
|
|
pixman_region32_t damage;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
static void logical_to_buffer_coords(pixman_region32_t *region, const struct render_data *data,
|
|
|
|
|
bool round_up) {
|
|
|
|
|
static void logical_to_buffer_coords(pixman_region32_t *region, pixman_region64f_t *src,
|
|
|
|
|
const struct render_data *data, bool round_up) {
|
|
|
|
|
enum wl_output_transform transform = wlr_output_transform_invert(data->transform);
|
|
|
|
|
scale_region(region, data->scale, round_up);
|
|
|
|
|
scale_region(region, src, data->scale, round_up);
|
|
|
|
|
wlr_region_transform(region, region, transform, data->trans_width, data->trans_height);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@ -349,20 +349,22 @@ static void output_to_buffer_coords(pixman_region32_t *damage, struct wlr_output
|
|
|
|
|
wlr_output_transform_invert(output->transform), width, height);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static int scale_length(int length, int offset, float scale) {
|
|
|
|
|
static int scale_length(double length, double offset, float scale) {
|
|
|
|
|
return round((offset + length) * scale) - round(offset * scale);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void scale_box(struct wlr_box *box, float scale) {
|
|
|
|
|
box->width = scale_length(box->width, box->x, scale);
|
|
|
|
|
box->height = scale_length(box->height, box->y, scale);
|
|
|
|
|
box->x = round(box->x * scale);
|
|
|
|
|
box->y = round(box->y * scale);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void transform_output_box(struct wlr_box *box, const struct render_data *data) {
|
|
|
|
|
static void transform_output_box(struct wlr_box *box, struct wlr_fbox *src,
|
|
|
|
|
const struct render_data *data, bool scale_stretch) {
|
|
|
|
|
enum wl_output_transform transform = wlr_output_transform_invert(data->transform);
|
|
|
|
|
scale_box(box, data->scale);
|
|
|
|
|
if (scale_stretch) {
|
|
|
|
|
box->width = scale_length(src->width, src->x, data->scale);
|
|
|
|
|
box->height = scale_length(src->height, src->y, data->scale);
|
|
|
|
|
} else {
|
|
|
|
|
box->width = round(src->width * data->scale);
|
|
|
|
|
box->height = round(src->height * data->scale);
|
|
|
|
|
}
|
|
|
|
|
box->x = round(src->x * data->scale);
|
|
|
|
|
box->y = round(src->y * data->scale);
|
|
|
|
|
wlr_box_transform(box, box, transform, data->trans_width, data->trans_height);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@ -394,25 +396,77 @@ static void scene_output_damage_whole(struct wlr_scene_output *scene_output) {
|
|
|
|
|
pixman_region32_fini(&damage);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void scene_damage_outputs(struct wlr_scene *scene, const pixman_region32_t *damage) {
|
|
|
|
|
if (pixman_region32_empty(damage)) {
|
|
|
|
|
static void scene_damage_outputs(struct wlr_scene *scene, const pixman_region64f_t *damage) {
|
|
|
|
|
if (pixman_region64f_empty(damage)) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
struct wlr_scene_output *scene_output;
|
|
|
|
|
wl_list_for_each(scene_output, &scene->outputs, link) {
|
|
|
|
|
pixman_region64f_t logical_output_damage;
|
|
|
|
|
pixman_region64f_init(&logical_output_damage);
|
|
|
|
|
pixman_region64f_copy(&logical_output_damage, damage);
|
|
|
|
|
pixman_region64f_translatef(&logical_output_damage,
|
|
|
|
|
-scene_output->x, -scene_output->y);
|
|
|
|
|
pixman_region32_t output_damage;
|
|
|
|
|
pixman_region32_init(&output_damage);
|
|
|
|
|
pixman_region32_copy(&output_damage, damage);
|
|
|
|
|
pixman_region32_translate(&output_damage,
|
|
|
|
|
-scene_output->x, -scene_output->y);
|
|
|
|
|
scale_region(&output_damage, scene_output->output->scale, true);
|
|
|
|
|
scale_region(&output_damage, &logical_output_damage, scene_output->output->scale, true);
|
|
|
|
|
pixman_region64f_fini(&logical_output_damage);
|
|
|
|
|
output_to_buffer_coords(&output_damage, scene_output->output);
|
|
|
|
|
scene_output_damage(scene_output, &output_damage);
|
|
|
|
|
pixman_region32_fini(&output_damage);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void visible_region_active_outputs(struct wl_list *outputs, struct wlr_scene_output *ignore, pixman_region64f_t *visible,
|
|
|
|
|
uint64_t *active_outputs, size_t *count, struct wlr_scene_output **primary_output) {
|
|
|
|
|
double largest_overlap = 0;
|
|
|
|
|
|
|
|
|
|
if (!pixman_region64f_empty(visible)) {
|
|
|
|
|
double visible_area = region_area(visible);
|
|
|
|
|
|
|
|
|
|
struct wlr_scene_output *scene_output;
|
|
|
|
|
wl_list_for_each(scene_output, outputs, link) {
|
|
|
|
|
if (scene_output == ignore) {
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!scene_output->output->enabled) {
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
struct wlr_fbox output_box = {
|
|
|
|
|
.x = scene_output->x,
|
|
|
|
|
.y = scene_output->y,
|
|
|
|
|
};
|
|
|
|
|
int output_width, output_height;
|
|
|
|
|
wlr_output_effective_resolution(scene_output->output,
|
|
|
|
|
&output_width, &output_height);
|
|
|
|
|
output_box.width = output_width;
|
|
|
|
|
output_box.height = output_height;
|
|
|
|
|
|
|
|
|
|
pixman_region64f_t intersection;
|
|
|
|
|
pixman_region64f_init(&intersection);
|
|
|
|
|
pixman_region64f_intersect_rectf(&intersection, visible,
|
|
|
|
|
output_box.x, output_box.y, output_box.width, output_box.height);
|
|
|
|
|
uint32_t overlap = region_area(&intersection);
|
|
|
|
|
pixman_region64f_fini(&intersection);
|
|
|
|
|
|
|
|
|
|
// If the overlap accounts for less than 10% of the visible node area,
|
|
|
|
|
// ignore this output
|
|
|
|
|
if (overlap >= 0.1 * visible_area) {
|
|
|
|
|
if (overlap >= largest_overlap) {
|
|
|
|
|
largest_overlap = overlap;
|
|
|
|
|
*primary_output = scene_output;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
(*active_outputs) |= 1ull << scene_output->index;
|
|
|
|
|
(*count)++;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void update_node_update_outputs(struct wlr_scene_node *node,
|
|
|
|
|
struct wl_list *outputs, struct wlr_scene_output *ignore,
|
|
|
|
|
struct wlr_scene_output *force) {
|
|
|
|
|
@ -421,61 +475,22 @@ static void update_node_update_outputs(struct wlr_scene_node *node,
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
struct wlr_scene_buffer *scene_buffer = wlr_scene_buffer_from_node(node);
|
|
|
|
|
|
|
|
|
|
uint32_t largest_overlap = 0;
|
|
|
|
|
struct wlr_scene_output *old_primary_output = scene_buffer->primary_output;
|
|
|
|
|
scene_buffer->primary_output = NULL;
|
|
|
|
|
|
|
|
|
|
// let's update the outputs in two steps:
|
|
|
|
|
// - the primary outputs
|
|
|
|
|
// - the enter/leave signals
|
|
|
|
|
// This ensures that the enter/leave signals can rely on the primary output
|
|
|
|
|
// to have a reasonable value. Otherwise, they may get a value that's in
|
|
|
|
|
// the middle of a calculation.
|
|
|
|
|
size_t count = 0;
|
|
|
|
|
uint64_t active_outputs = 0;
|
|
|
|
|
struct wlr_scene_output *primary_output = NULL;
|
|
|
|
|
visible_region_active_outputs(outputs, ignore, &node->visible,
|
|
|
|
|
&active_outputs, &count, &primary_output);
|
|
|
|
|
|
|
|
|
|
if (!pixman_region32_empty(&node->visible)) {
|
|
|
|
|
uint32_t visible_area = region_area(&node->visible);
|
|
|
|
|
|
|
|
|
|
// let's update the outputs in two steps:
|
|
|
|
|
// - the primary outputs
|
|
|
|
|
// - the enter/leave signals
|
|
|
|
|
// This ensures that the enter/leave signals can rely on the primary output
|
|
|
|
|
// to have a reasonable value. Otherwise, they may get a value that's in
|
|
|
|
|
// the middle of a calculation.
|
|
|
|
|
struct wlr_scene_output *scene_output;
|
|
|
|
|
wl_list_for_each(scene_output, outputs, link) {
|
|
|
|
|
if (scene_output == ignore) {
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!scene_output->output->enabled) {
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
struct wlr_box output_box = {
|
|
|
|
|
.x = scene_output->x,
|
|
|
|
|
.y = scene_output->y,
|
|
|
|
|
};
|
|
|
|
|
wlr_output_effective_resolution(scene_output->output,
|
|
|
|
|
&output_box.width, &output_box.height);
|
|
|
|
|
|
|
|
|
|
pixman_region32_t intersection;
|
|
|
|
|
pixman_region32_init(&intersection);
|
|
|
|
|
pixman_region32_intersect_rect(&intersection, &node->visible,
|
|
|
|
|
output_box.x, output_box.y, output_box.width, output_box.height);
|
|
|
|
|
uint32_t overlap = region_area(&intersection);
|
|
|
|
|
pixman_region32_fini(&intersection);
|
|
|
|
|
|
|
|
|
|
// If the overlap accounts for less than 10% of the visible node area,
|
|
|
|
|
// ignore this output
|
|
|
|
|
if (overlap >= 0.1 * visible_area) {
|
|
|
|
|
if (overlap >= largest_overlap) {
|
|
|
|
|
largest_overlap = overlap;
|
|
|
|
|
scene_buffer->primary_output = scene_output;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
active_outputs |= 1ull << scene_output->index;
|
|
|
|
|
count++;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
scene_buffer->primary_output = primary_output;
|
|
|
|
|
if (old_primary_output != scene_buffer->primary_output) {
|
|
|
|
|
scene_buffer->prev_feedback_options =
|
|
|
|
|
(struct wlr_linux_dmabuf_feedback_v1_init_options){0};
|
|
|
|
|
@ -550,7 +565,7 @@ static struct wlr_xwayland_surface *scene_node_try_get_managed_xwayland_surface(
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void restack_xwayland_surface(struct wlr_scene_node *node,
|
|
|
|
|
struct wlr_box *box, struct scene_update_data *data) {
|
|
|
|
|
struct wlr_fbox *box, struct scene_update_data *data) {
|
|
|
|
|
struct wlr_xwayland_surface *xwayland_surface =
|
|
|
|
|
scene_node_try_get_managed_xwayland_surface(node);
|
|
|
|
|
if (!xwayland_surface) {
|
|
|
|
|
@ -559,7 +574,7 @@ static void restack_xwayland_surface(struct wlr_scene_node *node,
|
|
|
|
|
|
|
|
|
|
// ensure this node is entirely inside the update region. If not, we can't
|
|
|
|
|
// restack this node since we're not considering the whole thing.
|
|
|
|
|
if (wlr_box_contains_box(&data->update_box, box)) {
|
|
|
|
|
if (wlr_fbox_contains_box(&data->update_box, box)) {
|
|
|
|
|
if (data->restack_above) {
|
|
|
|
|
wlr_xwayland_surface_restack(xwayland_surface, data->restack_above, XCB_STACK_MODE_BELOW);
|
|
|
|
|
} else {
|
|
|
|
|
@ -572,23 +587,23 @@ static void restack_xwayland_surface(struct wlr_scene_node *node,
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
static bool scene_node_update_iterator(struct wlr_scene_node *node,
|
|
|
|
|
int lx, int ly, void *_data) {
|
|
|
|
|
double lx, double ly, void *_data) {
|
|
|
|
|
struct scene_update_data *data = _data;
|
|
|
|
|
|
|
|
|
|
struct wlr_box box = { .x = lx, .y = ly };
|
|
|
|
|
struct wlr_fbox box = { .x = lx, .y = ly };
|
|
|
|
|
scene_node_get_size(node, &box.width, &box.height);
|
|
|
|
|
|
|
|
|
|
pixman_region32_subtract(&node->visible, &node->visible, data->update_region);
|
|
|
|
|
pixman_region32_union(&node->visible, &node->visible, data->visible);
|
|
|
|
|
pixman_region32_intersect_rect(&node->visible, &node->visible,
|
|
|
|
|
pixman_region64f_subtract(&node->visible, &node->visible, data->update_region);
|
|
|
|
|
pixman_region64f_union(&node->visible, &node->visible, data->visible);
|
|
|
|
|
pixman_region64f_intersect_rectf(&node->visible, &node->visible,
|
|
|
|
|
lx, ly, box.width, box.height);
|
|
|
|
|
|
|
|
|
|
if (data->calculate_visibility) {
|
|
|
|
|
pixman_region32_t opaque;
|
|
|
|
|
pixman_region32_init(&opaque);
|
|
|
|
|
pixman_region64f_t opaque;
|
|
|
|
|
pixman_region64f_init(&opaque);
|
|
|
|
|
scene_node_opaque_region(node, lx, ly, &opaque);
|
|
|
|
|
pixman_region32_subtract(data->visible, data->visible, &opaque);
|
|
|
|
|
pixman_region32_fini(&opaque);
|
|
|
|
|
pixman_region64f_subtract(data->visible, data->visible, &opaque);
|
|
|
|
|
pixman_region64f_fini(&opaque);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
update_node_update_outputs(node, data->outputs, NULL, NULL);
|
|
|
|
|
@ -602,7 +617,7 @@ static bool scene_node_update_iterator(struct wlr_scene_node *node,
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void scene_node_visibility(struct wlr_scene_node *node,
|
|
|
|
|
pixman_region32_t *visible) {
|
|
|
|
|
pixman_region64f_t *visible) {
|
|
|
|
|
if (!node->enabled) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
@ -616,11 +631,11 @@ static void scene_node_visibility(struct wlr_scene_node *node,
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
pixman_region32_union(visible, visible, &node->visible);
|
|
|
|
|
pixman_region64f_union(visible, visible, &node->visible);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void scene_node_bounds(struct wlr_scene_node *node,
|
|
|
|
|
int x, int y, pixman_region32_t *visible) {
|
|
|
|
|
double x, double y, pixman_region64f_t *visible) {
|
|
|
|
|
if (!node->enabled) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
@ -634,18 +649,18 @@ static void scene_node_bounds(struct wlr_scene_node *node,
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int width, height;
|
|
|
|
|
double width, height;
|
|
|
|
|
scene_node_get_size(node, &width, &height);
|
|
|
|
|
pixman_region32_union_rect(visible, visible, x, y, width, height);
|
|
|
|
|
pixman_region64f_union_rectf(visible, visible, x, y, width, height);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void scene_update_region(struct wlr_scene *scene,
|
|
|
|
|
const pixman_region32_t *update_region) {
|
|
|
|
|
pixman_region32_t visible;
|
|
|
|
|
pixman_region32_init(&visible);
|
|
|
|
|
pixman_region32_copy(&visible, update_region);
|
|
|
|
|
const pixman_region64f_t *update_region) {
|
|
|
|
|
pixman_region64f_t visible;
|
|
|
|
|
pixman_region64f_init(&visible);
|
|
|
|
|
pixman_region64f_copy(&visible, update_region);
|
|
|
|
|
|
|
|
|
|
struct pixman_box32 *region_box = pixman_region32_extents(update_region);
|
|
|
|
|
struct pixman_box64f *region_box = pixman_region64f_extents(update_region);
|
|
|
|
|
struct scene_update_data data = {
|
|
|
|
|
.visible = &visible,
|
|
|
|
|
.update_region = update_region,
|
|
|
|
|
@ -663,7 +678,7 @@ static void scene_update_region(struct wlr_scene *scene,
|
|
|
|
|
// update node visibility and output enter/leave events
|
|
|
|
|
scene_nodes_in_box(&scene->tree.node, &data.update_box, scene_node_update_iterator, &data);
|
|
|
|
|
|
|
|
|
|
pixman_region32_fini(&visible);
|
|
|
|
|
pixman_region64f_fini(&visible);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void scene_node_cleanup_when_disabled(struct wlr_scene_node *node,
|
|
|
|
|
@ -681,7 +696,7 @@ static void scene_node_cleanup_when_disabled(struct wlr_scene_node *node,
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
pixman_region32_clear(&node->visible);
|
|
|
|
|
pixman_region64f_clear(&node->visible);
|
|
|
|
|
update_node_update_outputs(node, outputs, NULL, NULL);
|
|
|
|
|
|
|
|
|
|
#if WLR_HAS_XWAYLAND
|
|
|
|
|
@ -712,10 +727,10 @@ static void scene_node_cleanup_when_disabled(struct wlr_scene_node *node,
|
|
|
|
|
* being reparented to a disabled super tree.
|
|
|
|
|
*/
|
|
|
|
|
static void scene_node_update(struct wlr_scene_node *node,
|
|
|
|
|
pixman_region32_t *damage) {
|
|
|
|
|
pixman_region64f_t *damage) {
|
|
|
|
|
struct wlr_scene *scene = scene_node_get_root(node);
|
|
|
|
|
|
|
|
|
|
int x, y;
|
|
|
|
|
double x, y;
|
|
|
|
|
if (!wlr_scene_node_coords(node, &x, &y)) {
|
|
|
|
|
// We assume explicit damage on a disabled tree means the node was just
|
|
|
|
|
// disabled.
|
|
|
|
|
@ -724,34 +739,34 @@ static void scene_node_update(struct wlr_scene_node *node,
|
|
|
|
|
|
|
|
|
|
scene_update_region(scene, damage);
|
|
|
|
|
scene_damage_outputs(scene, damage);
|
|
|
|
|
pixman_region32_fini(damage);
|
|
|
|
|
pixman_region64f_fini(damage);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
pixman_region32_t visible;
|
|
|
|
|
pixman_region64f_t visible;
|
|
|
|
|
if (!damage) {
|
|
|
|
|
pixman_region32_init(&visible);
|
|
|
|
|
pixman_region64f_init(&visible);
|
|
|
|
|
scene_node_visibility(node, &visible);
|
|
|
|
|
damage = &visible;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
pixman_region32_t update_region;
|
|
|
|
|
pixman_region32_init(&update_region);
|
|
|
|
|
pixman_region32_copy(&update_region, damage);
|
|
|
|
|
pixman_region64f_t update_region;
|
|
|
|
|
pixman_region64f_init(&update_region);
|
|
|
|
|
pixman_region64f_copy(&update_region, damage);
|
|
|
|
|
scene_node_bounds(node, x, y, &update_region);
|
|
|
|
|
|
|
|
|
|
scene_update_region(scene, &update_region);
|
|
|
|
|
pixman_region32_fini(&update_region);
|
|
|
|
|
pixman_region64f_fini(&update_region);
|
|
|
|
|
|
|
|
|
|
scene_node_visibility(node, damage);
|
|
|
|
|
scene_damage_outputs(scene, damage);
|
|
|
|
|
pixman_region32_fini(damage);
|
|
|
|
|
pixman_region64f_fini(damage);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
struct wlr_scene_rect *wlr_scene_rect_create(struct wlr_scene_tree *parent,
|
|
|
|
|
int width, int height, const float color[static 4]) {
|
|
|
|
|
double width, double height, const float color[static 4]) {
|
|
|
|
|
assert(parent);
|
|
|
|
|
assert(width >= 0 && height >= 0);
|
|
|
|
|
|
|
|
|
|
@ -770,7 +785,7 @@ struct wlr_scene_rect *wlr_scene_rect_create(struct wlr_scene_tree *parent,
|
|
|
|
|
return scene_rect;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void wlr_scene_rect_set_size(struct wlr_scene_rect *rect, int width, int height) {
|
|
|
|
|
void wlr_scene_rect_set_size(struct wlr_scene_rect *rect, double width, double height) {
|
|
|
|
|
if (rect->width == width && rect->height == height) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
@ -874,7 +889,7 @@ struct wlr_scene_buffer *wlr_scene_buffer_create(struct wlr_scene_tree *parent,
|
|
|
|
|
wl_signal_init(&scene_buffer->events.output_sample);
|
|
|
|
|
wl_signal_init(&scene_buffer->events.frame_done);
|
|
|
|
|
|
|
|
|
|
pixman_region32_init(&scene_buffer->opaque_region);
|
|
|
|
|
pixman_region64f_init(&scene_buffer->opaque_region);
|
|
|
|
|
wl_list_init(&scene_buffer->buffer_release.link);
|
|
|
|
|
wl_list_init(&scene_buffer->renderer_destroy.link);
|
|
|
|
|
scene_buffer->opacity = 1;
|
|
|
|
|
@ -948,7 +963,7 @@ void wlr_scene_buffer_set_buffer_with_options(struct wlr_scene_buffer *scene_buf
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int lx, ly;
|
|
|
|
|
double lx, ly;
|
|
|
|
|
if (!wlr_scene_node_coords(&scene_buffer->node, &lx, &ly)) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
@ -1018,10 +1033,13 @@ void wlr_scene_buffer_set_buffer_with_options(struct wlr_scene_buffer *scene_buf
|
|
|
|
|
wlr_region_expand(&output_damage, &output_damage,
|
|
|
|
|
dist_x >= dist_y ? dist_x : dist_y);
|
|
|
|
|
|
|
|
|
|
pixman_region64f_t logical_cull_region;
|
|
|
|
|
pixman_region64f_init(&logical_cull_region);
|
|
|
|
|
pixman_region64f_copy(&logical_cull_region, &scene_buffer->node.visible);
|
|
|
|
|
pixman_region32_t cull_region;
|
|
|
|
|
pixman_region32_init(&cull_region);
|
|
|
|
|
pixman_region32_copy(&cull_region, &scene_buffer->node.visible);
|
|
|
|
|
scale_region(&cull_region, output_scale, true);
|
|
|
|
|
scale_region(&cull_region, &logical_cull_region, output_scale, true);
|
|
|
|
|
pixman_region64f_fini(&logical_cull_region);
|
|
|
|
|
pixman_region32_translate(&cull_region, -lx * output_scale, -ly * output_scale);
|
|
|
|
|
pixman_region32_intersect(&output_damage, &output_damage, &cull_region);
|
|
|
|
|
pixman_region32_fini(&cull_region);
|
|
|
|
|
@ -1052,23 +1070,23 @@ void wlr_scene_buffer_set_buffer(struct wlr_scene_buffer *scene_buffer,
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void wlr_scene_buffer_set_opaque_region(struct wlr_scene_buffer *scene_buffer,
|
|
|
|
|
const pixman_region32_t *region) {
|
|
|
|
|
if (pixman_region32_equal(&scene_buffer->opaque_region, region)) {
|
|
|
|
|
const pixman_region64f_t *region) {
|
|
|
|
|
if (pixman_region64f_equal(&scene_buffer->opaque_region, region)) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
pixman_region32_copy(&scene_buffer->opaque_region, region);
|
|
|
|
|
pixman_region64f_copy(&scene_buffer->opaque_region, region);
|
|
|
|
|
|
|
|
|
|
int x, y;
|
|
|
|
|
double x, y;
|
|
|
|
|
if (!wlr_scene_node_coords(&scene_buffer->node, &x, &y)) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
pixman_region32_t update_region;
|
|
|
|
|
pixman_region32_init(&update_region);
|
|
|
|
|
pixman_region64f_t update_region;
|
|
|
|
|
pixman_region64f_init(&update_region);
|
|
|
|
|
scene_node_bounds(&scene_buffer->node, x, y, &update_region);
|
|
|
|
|
scene_update_region(scene_node_get_root(&scene_buffer->node), &update_region);
|
|
|
|
|
pixman_region32_fini(&update_region);
|
|
|
|
|
pixman_region64f_fini(&update_region);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void wlr_scene_buffer_set_source_box(struct wlr_scene_buffer *scene_buffer,
|
|
|
|
|
@ -1088,7 +1106,7 @@ void wlr_scene_buffer_set_source_box(struct wlr_scene_buffer *scene_buffer,
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void wlr_scene_buffer_set_dest_size(struct wlr_scene_buffer *scene_buffer,
|
|
|
|
|
int width, int height) {
|
|
|
|
|
double width, double height) {
|
|
|
|
|
if (scene_buffer->dst_width == width && scene_buffer->dst_height == height) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
@ -1111,7 +1129,7 @@ void wlr_scene_buffer_set_transform(struct wlr_scene_buffer *scene_buffer,
|
|
|
|
|
|
|
|
|
|
void wlr_scene_buffer_send_frame_done(struct wlr_scene_buffer *scene_buffer,
|
|
|
|
|
struct wlr_scene_frame_done_event *event) {
|
|
|
|
|
if (!pixman_region32_empty(&scene_buffer->node.visible)) {
|
|
|
|
|
if (!pixman_region64f_empty(&scene_buffer->node.visible)) {
|
|
|
|
|
wl_signal_emit_mutable(&scene_buffer->events.frame_done, event);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
@ -1199,7 +1217,7 @@ static struct wlr_texture *scene_buffer_get_texture(
|
|
|
|
|
return texture;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void scene_node_get_size(struct wlr_scene_node *node, int *width, int *height) {
|
|
|
|
|
void scene_node_get_size(struct wlr_scene_node *node, double *width, double *height) {
|
|
|
|
|
*width = 0;
|
|
|
|
|
*height = 0;
|
|
|
|
|
|
|
|
|
|
@ -1217,9 +1235,10 @@ void scene_node_get_size(struct wlr_scene_node *node, int *width, int *height) {
|
|
|
|
|
*width = scene_buffer->dst_width;
|
|
|
|
|
*height = scene_buffer->dst_height;
|
|
|
|
|
} else {
|
|
|
|
|
*width = scene_buffer->buffer_width;
|
|
|
|
|
*height = scene_buffer->buffer_height;
|
|
|
|
|
wlr_output_transform_coords(scene_buffer->transform, width, height);
|
|
|
|
|
int w = scene_buffer->buffer_width, h = scene_buffer->buffer_height;
|
|
|
|
|
wlr_output_transform_coords(scene_buffer->transform, &w, &h);
|
|
|
|
|
*width = w;
|
|
|
|
|
*height = h;
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
@ -1230,9 +1249,9 @@ void wlr_scene_node_set_enabled(struct wlr_scene_node *node, bool enabled) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int x, y;
|
|
|
|
|
pixman_region32_t visible;
|
|
|
|
|
pixman_region32_init(&visible);
|
|
|
|
|
double x, y;
|
|
|
|
|
pixman_region64f_t visible;
|
|
|
|
|
pixman_region64f_init(&visible);
|
|
|
|
|
if (wlr_scene_node_coords(node, &x, &y)) {
|
|
|
|
|
scene_node_visibility(node, &visible);
|
|
|
|
|
}
|
|
|
|
|
@ -1242,7 +1261,7 @@ void wlr_scene_node_set_enabled(struct wlr_scene_node *node, bool enabled) {
|
|
|
|
|
scene_node_update(node, &visible);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void wlr_scene_node_set_position(struct wlr_scene_node *node, int x, int y) {
|
|
|
|
|
void wlr_scene_node_set_position(struct wlr_scene_node *node, double x, double y) {
|
|
|
|
|
if (node->x == x && node->y == y) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
@ -1312,9 +1331,9 @@ void wlr_scene_node_reparent(struct wlr_scene_node *node,
|
|
|
|
|
assert(&ancestor->node != node);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int x, y;
|
|
|
|
|
pixman_region32_t visible;
|
|
|
|
|
pixman_region32_init(&visible);
|
|
|
|
|
double x, y;
|
|
|
|
|
pixman_region64f_t visible;
|
|
|
|
|
pixman_region64f_init(&visible);
|
|
|
|
|
if (wlr_scene_node_coords(node, &x, &y)) {
|
|
|
|
|
scene_node_visibility(node, &visible);
|
|
|
|
|
}
|
|
|
|
|
@ -1326,10 +1345,10 @@ void wlr_scene_node_reparent(struct wlr_scene_node *node,
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool wlr_scene_node_coords(struct wlr_scene_node *node,
|
|
|
|
|
int *lx_ptr, int *ly_ptr) {
|
|
|
|
|
double *lx_ptr, double *ly_ptr) {
|
|
|
|
|
assert(node);
|
|
|
|
|
|
|
|
|
|
int lx = 0, ly = 0;
|
|
|
|
|
double lx = 0, ly = 0;
|
|
|
|
|
bool enabled = true;
|
|
|
|
|
while (true) {
|
|
|
|
|
lx += node->x;
|
|
|
|
|
@ -1348,7 +1367,7 @@ bool wlr_scene_node_coords(struct wlr_scene_node *node,
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void scene_node_for_each_scene_buffer(struct wlr_scene_node *node,
|
|
|
|
|
int lx, int ly, wlr_scene_buffer_iterator_func_t user_iterator,
|
|
|
|
|
double lx, double ly, wlr_scene_buffer_iterator_func_t user_iterator,
|
|
|
|
|
void *user_data) {
|
|
|
|
|
if (!node->enabled) {
|
|
|
|
|
return;
|
|
|
|
|
@ -1381,7 +1400,7 @@ struct node_at_data {
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
static bool scene_node_at_iterator(struct wlr_scene_node *node,
|
|
|
|
|
int lx, int ly, void *data) {
|
|
|
|
|
double lx, double ly, void *data) {
|
|
|
|
|
struct node_at_data *at_data = data;
|
|
|
|
|
|
|
|
|
|
double rx = at_data->lx - lx;
|
|
|
|
|
@ -1404,9 +1423,9 @@ static bool scene_node_at_iterator(struct wlr_scene_node *node,
|
|
|
|
|
|
|
|
|
|
struct wlr_scene_node *wlr_scene_node_at(struct wlr_scene_node *node,
|
|
|
|
|
double lx, double ly, double *nx, double *ny) {
|
|
|
|
|
struct wlr_box box = {
|
|
|
|
|
.x = floor(lx),
|
|
|
|
|
.y = floor(ly),
|
|
|
|
|
struct wlr_fbox box = {
|
|
|
|
|
.x = lx,
|
|
|
|
|
.y = ly,
|
|
|
|
|
.width = 1,
|
|
|
|
|
.height = 1
|
|
|
|
|
};
|
|
|
|
|
@ -1431,8 +1450,9 @@ struct wlr_scene_node *wlr_scene_node_at(struct wlr_scene_node *node,
|
|
|
|
|
|
|
|
|
|
struct render_list_entry {
|
|
|
|
|
struct wlr_scene_node *node;
|
|
|
|
|
bool scale_stretch;
|
|
|
|
|
bool highlight_transparent_region;
|
|
|
|
|
int x, y;
|
|
|
|
|
double x, y;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
static float get_luminance_multiplier(const struct wlr_color_luminances *src_lum,
|
|
|
|
|
@ -1443,31 +1463,41 @@ static float get_luminance_multiplier(const struct wlr_color_luminances *src_lum
|
|
|
|
|
static void scene_entry_render(struct render_list_entry *entry, const struct render_data *data) {
|
|
|
|
|
struct wlr_scene_node *node = entry->node;
|
|
|
|
|
|
|
|
|
|
pixman_region64f_t logical_render_region;
|
|
|
|
|
pixman_region64f_init(&logical_render_region);
|
|
|
|
|
pixman_region64f_copy(&logical_render_region, &node->visible);
|
|
|
|
|
pixman_region64f_translatef(&logical_render_region, -data->logical.x, -data->logical.y);
|
|
|
|
|
|
|
|
|
|
pixman_region32_t render_region;
|
|
|
|
|
pixman_region32_init(&render_region);
|
|
|
|
|
pixman_region32_copy(&render_region, &node->visible);
|
|
|
|
|
pixman_region32_translate(&render_region, -data->logical.x, -data->logical.y);
|
|
|
|
|
logical_to_buffer_coords(&render_region, data, true);
|
|
|
|
|
logical_to_buffer_coords(&render_region, &logical_render_region, data, true);
|
|
|
|
|
pixman_region64f_fini(&logical_render_region);
|
|
|
|
|
|
|
|
|
|
pixman_region32_intersect(&render_region, &render_region, &data->damage);
|
|
|
|
|
if (pixman_region32_empty(&render_region)) {
|
|
|
|
|
pixman_region32_fini(&render_region);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int x = entry->x - data->logical.x;
|
|
|
|
|
int y = entry->y - data->logical.y;
|
|
|
|
|
double x = entry->x - data->logical.x;
|
|
|
|
|
double y = entry->y - data->logical.y;
|
|
|
|
|
|
|
|
|
|
struct wlr_box dst_box = {
|
|
|
|
|
struct wlr_fbox node_box = {
|
|
|
|
|
.x = x,
|
|
|
|
|
.y = y,
|
|
|
|
|
};
|
|
|
|
|
scene_node_get_size(node, &dst_box.width, &dst_box.height);
|
|
|
|
|
transform_output_box(&dst_box, data);
|
|
|
|
|
scene_node_get_size(node, &node_box.width, &node_box.height);
|
|
|
|
|
struct wlr_box dst_box = {0};
|
|
|
|
|
transform_output_box(&dst_box, &node_box, data, entry->scale_stretch);
|
|
|
|
|
|
|
|
|
|
pixman_region64f_t logical_opaque;
|
|
|
|
|
pixman_region64f_init(&logical_opaque);
|
|
|
|
|
scene_node_opaque_region(node, x, y, &logical_opaque);
|
|
|
|
|
|
|
|
|
|
pixman_region32_t opaque;
|
|
|
|
|
pixman_region32_init(&opaque);
|
|
|
|
|
scene_node_opaque_region(node, x, y, &opaque);
|
|
|
|
|
logical_to_buffer_coords(&opaque, data, false);
|
|
|
|
|
logical_to_buffer_coords(&opaque, &logical_opaque, data, false);
|
|
|
|
|
pixman_region64f_fini(&logical_opaque);
|
|
|
|
|
pixman_region32_subtract(&opaque, &render_region, &opaque);
|
|
|
|
|
|
|
|
|
|
switch (node->type) {
|
|
|
|
|
@ -1862,7 +1892,7 @@ struct wlr_scene_output *wlr_scene_get_scene_output(struct wlr_scene *scene,
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void wlr_scene_output_set_position(struct wlr_scene_output *scene_output,
|
|
|
|
|
int lx, int ly) {
|
|
|
|
|
double lx, double ly) {
|
|
|
|
|
if (scene_output->x == lx && scene_output->y == ly) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
@ -1890,8 +1920,9 @@ static bool scene_node_invisible(struct wlr_scene_node *node) {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
struct render_list_constructor_data {
|
|
|
|
|
struct wlr_box box;
|
|
|
|
|
struct wlr_fbox box;
|
|
|
|
|
struct wl_array *render_list;
|
|
|
|
|
struct wlr_scene_output *scene_output;
|
|
|
|
|
bool calculate_visibility;
|
|
|
|
|
bool highlight_transparent_region;
|
|
|
|
|
bool fractional_scale;
|
|
|
|
|
@ -1906,8 +1937,23 @@ static bool scene_buffer_is_black_opaque(struct wlr_scene_buffer *scene_buffer)
|
|
|
|
|
scene_buffer->opacity == 1.0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static struct wlr_scene_node *scene_node_scaling_group(struct wlr_scene_node *node) {
|
|
|
|
|
struct wlr_scene_node *scaling_group = node;
|
|
|
|
|
while (true) {
|
|
|
|
|
if (node->scaling_group) {
|
|
|
|
|
scaling_group = node;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
if (node->parent == NULL) {
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
node = &node->parent->node;
|
|
|
|
|
}
|
|
|
|
|
return scaling_group;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static bool construct_render_list_iterator(struct wlr_scene_node *node,
|
|
|
|
|
int lx, int ly, void *_data) {
|
|
|
|
|
double lx, double ly, void *_data) {
|
|
|
|
|
struct render_list_constructor_data *data = _data;
|
|
|
|
|
|
|
|
|
|
if (scene_node_invisible(node)) {
|
|
|
|
|
@ -1938,17 +1984,40 @@ static bool construct_render_list_iterator(struct wlr_scene_node *node,
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
pixman_region32_t intersection;
|
|
|
|
|
pixman_region32_init(&intersection);
|
|
|
|
|
pixman_region32_intersect_rect(&intersection, &node->visible,
|
|
|
|
|
pixman_region64f_t intersection;
|
|
|
|
|
pixman_region64f_init(&intersection);
|
|
|
|
|
pixman_region64f_intersect_rectf(&intersection, &node->visible,
|
|
|
|
|
data->box.x, data->box.y,
|
|
|
|
|
data->box.width, data->box.height);
|
|
|
|
|
if (pixman_region32_empty(&intersection)) {
|
|
|
|
|
pixman_region32_fini(&intersection);
|
|
|
|
|
if (pixman_region64f_empty(&intersection)) {
|
|
|
|
|
pixman_region64f_fini(&intersection);
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
pixman_region32_fini(&intersection);
|
|
|
|
|
pixman_region64f_fini(&intersection);
|
|
|
|
|
|
|
|
|
|
bool scale_stretch = false;
|
|
|
|
|
if (data->scene_output != NULL) {
|
|
|
|
|
struct wlr_scene_node *scaling_group = scene_node_scaling_group(node);
|
|
|
|
|
|
|
|
|
|
double x, y;
|
|
|
|
|
wlr_scene_node_coords(scaling_group, &x, &y);
|
|
|
|
|
|
|
|
|
|
pixman_region64f_t visible;
|
|
|
|
|
pixman_region64f_init(&visible);
|
|
|
|
|
scene_node_bounds(scaling_group, x, y, &visible);
|
|
|
|
|
|
|
|
|
|
uint64_t active_outputs;
|
|
|
|
|
size_t count;
|
|
|
|
|
struct wlr_scene_output *primary_output = NULL;
|
|
|
|
|
visible_region_active_outputs(&data->scene_output->scene->outputs, NULL, &visible,
|
|
|
|
|
&active_outputs, &count, &primary_output);
|
|
|
|
|
pixman_region64f_fini(&visible);
|
|
|
|
|
|
|
|
|
|
scale_stretch = primary_output != NULL &&
|
|
|
|
|
data->scene_output != primary_output &&
|
|
|
|
|
data->scene_output->output->scale != primary_output->output->scale;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
struct render_list_entry *entry = wl_array_add(data->render_list, sizeof(*entry));
|
|
|
|
|
if (!entry) {
|
|
|
|
|
@ -1959,6 +2028,7 @@ static bool construct_render_list_iterator(struct wlr_scene_node *node,
|
|
|
|
|
.node = node,
|
|
|
|
|
.x = lx,
|
|
|
|
|
.y = ly,
|
|
|
|
|
.scale_stretch = scale_stretch,
|
|
|
|
|
.highlight_transparent_region = data->highlight_transparent_region,
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
@ -2116,11 +2186,12 @@ static enum scene_direct_scanout_result scene_entry_try_direct_scanout(
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Translate the position from scene coordinates to output coordinates
|
|
|
|
|
pending.buffer_dst_box.x = entry->x - scene_output->x;
|
|
|
|
|
pending.buffer_dst_box.y = entry->y - scene_output->y;
|
|
|
|
|
|
|
|
|
|
scene_node_get_size(node, &pending.buffer_dst_box.width, &pending.buffer_dst_box.height);
|
|
|
|
|
transform_output_box(&pending.buffer_dst_box, data);
|
|
|
|
|
struct wlr_fbox node_box = {
|
|
|
|
|
.x = entry->x - scene_output->x,
|
|
|
|
|
.y = entry->y - scene_output->y
|
|
|
|
|
};
|
|
|
|
|
scene_node_get_size(node, &node_box.width, &node_box.height);
|
|
|
|
|
transform_output_box(&pending.buffer_dst_box, &node_box, data, false);
|
|
|
|
|
|
|
|
|
|
struct wlr_buffer *wlr_buffer = buffer->buffer;
|
|
|
|
|
struct wlr_client_buffer *client_buffer = wlr_client_buffer_get(wlr_buffer);
|
|
|
|
|
@ -2278,6 +2349,16 @@ cleanup_transforms:
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static bool scene_outputs_have_multiple_scale_factors(struct wlr_scene *scene, float scale) {
|
|
|
|
|
struct wlr_scene_output *scene_output;
|
|
|
|
|
wl_list_for_each(scene_output, &scene->outputs, link) {
|
|
|
|
|
if (scene_output->output->enabled && scene_output->output->scale != scale) {
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool wlr_scene_output_build_state(struct wlr_scene_output *scene_output,
|
|
|
|
|
struct wlr_output_state *state, const struct wlr_scene_output_state_options *options) {
|
|
|
|
|
struct wlr_scene_output_state_options default_options = {0};
|
|
|
|
|
@ -2346,9 +2427,13 @@ bool wlr_scene_output_build_state(struct wlr_scene_output *scene_output,
|
|
|
|
|
render_data.logical.width = render_data.trans_width / render_data.scale;
|
|
|
|
|
render_data.logical.height = render_data.trans_height / render_data.scale;
|
|
|
|
|
|
|
|
|
|
bool multiple_output_scales =
|
|
|
|
|
scene_outputs_have_multiple_scale_factors(scene_output->scene, render_data.scale);
|
|
|
|
|
|
|
|
|
|
struct render_list_constructor_data list_con = {
|
|
|
|
|
.box = render_data.logical,
|
|
|
|
|
.render_list = &scene_output->render_list,
|
|
|
|
|
.scene_output = multiple_output_scales ? scene_output : NULL,
|
|
|
|
|
.calculate_visibility = scene_output->scene->calculate_visibility,
|
|
|
|
|
.highlight_transparent_region = scene_output->scene->highlight_transparent_region,
|
|
|
|
|
.fractional_scale = floor(render_data.scale) != render_data.scale,
|
|
|
|
|
@ -2519,13 +2604,17 @@ bool wlr_scene_output_build_state(struct wlr_scene_output *scene_output,
|
|
|
|
|
// that may have been omitted from the render list via the black
|
|
|
|
|
// rect optimization. In order to ensure we don't cull background
|
|
|
|
|
// rendering in that black rect region, consider the node's visibility.
|
|
|
|
|
pixman_region64f_t logical_opaque;
|
|
|
|
|
pixman_region64f_init(&logical_opaque);
|
|
|
|
|
scene_node_opaque_region(entry->node, entry->x, entry->y, &logical_opaque);
|
|
|
|
|
pixman_region64f_intersect(&logical_opaque, &logical_opaque, &entry->node->visible);
|
|
|
|
|
pixman_region64f_translatef(&logical_opaque, -scene_output->x, -scene_output->y);
|
|
|
|
|
|
|
|
|
|
pixman_region32_t opaque;
|
|
|
|
|
pixman_region32_init(&opaque);
|
|
|
|
|
scene_node_opaque_region(entry->node, entry->x, entry->y, &opaque);
|
|
|
|
|
pixman_region32_intersect(&opaque, &opaque, &entry->node->visible);
|
|
|
|
|
logical_to_buffer_coords(&opaque, &logical_opaque, &render_data, false);
|
|
|
|
|
pixman_region64f_fini(&logical_opaque);
|
|
|
|
|
|
|
|
|
|
pixman_region32_translate(&opaque, -scene_output->x, -scene_output->y);
|
|
|
|
|
logical_to_buffer_coords(&opaque, &render_data, false);
|
|
|
|
|
pixman_region32_subtract(&background, &background, &opaque);
|
|
|
|
|
pixman_region32_fini(&opaque);
|
|
|
|
|
}
|
|
|
|
|
@ -2655,8 +2744,8 @@ void wlr_scene_output_send_frame_done(struct wlr_scene_output *scene_output,
|
|
|
|
|
scene_output, now);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void scene_output_for_each_scene_buffer(const struct wlr_box *output_box,
|
|
|
|
|
struct wlr_scene_node *node, int lx, int ly,
|
|
|
|
|
static void scene_output_for_each_scene_buffer(const struct wlr_fbox *output_box,
|
|
|
|
|
struct wlr_scene_node *node, double lx, double ly,
|
|
|
|
|
wlr_scene_buffer_iterator_func_t user_iterator, void *user_data) {
|
|
|
|
|
if (!node->enabled) {
|
|
|
|
|
return;
|
|
|
|
|
@ -2666,11 +2755,11 @@ static void scene_output_for_each_scene_buffer(const struct wlr_box *output_box,
|
|
|
|
|
ly += node->y;
|
|
|
|
|
|
|
|
|
|
if (node->type == WLR_SCENE_NODE_BUFFER) {
|
|
|
|
|
struct wlr_box node_box = { .x = lx, .y = ly };
|
|
|
|
|
struct wlr_fbox node_box = { .x = lx, .y = ly };
|
|
|
|
|
scene_node_get_size(node, &node_box.width, &node_box.height);
|
|
|
|
|
|
|
|
|
|
struct wlr_box intersection;
|
|
|
|
|
if (wlr_box_intersection(&intersection, output_box, &node_box)) {
|
|
|
|
|
struct wlr_fbox intersection;
|
|
|
|
|
if (wlr_fbox_intersection(&intersection, output_box, &node_box)) {
|
|
|
|
|
struct wlr_scene_buffer *scene_buffer =
|
|
|
|
|
wlr_scene_buffer_from_node(node);
|
|
|
|
|
user_iterator(scene_buffer, lx, ly, user_data);
|
|
|
|
|
@ -2687,9 +2776,11 @@ static void scene_output_for_each_scene_buffer(const struct wlr_box *output_box,
|
|
|
|
|
|
|
|
|
|
void wlr_scene_output_for_each_buffer(struct wlr_scene_output *scene_output,
|
|
|
|
|
wlr_scene_buffer_iterator_func_t iterator, void *user_data) {
|
|
|
|
|
struct wlr_box box = { .x = scene_output->x, .y = scene_output->y };
|
|
|
|
|
wlr_output_effective_resolution(scene_output->output,
|
|
|
|
|
&box.width, &box.height);
|
|
|
|
|
struct wlr_fbox box = { .x = scene_output->x, .y = scene_output->y };
|
|
|
|
|
int width, height;
|
|
|
|
|
wlr_output_effective_resolution(scene_output->output, &width, &height);
|
|
|
|
|
box.width = width;
|
|
|
|
|
box.height = height;
|
|
|
|
|
scene_output_for_each_scene_buffer(&box, &scene_output->scene->tree.node, 0, 0,
|
|
|
|
|
iterator, user_data);
|
|
|
|
|
}
|
|
|
|
|
|