scene: use fractional positions

Signed-off-by: Loukas Agorgianitis <loukas@agorgianitis.com>
This commit is contained in:
Loukas Agorgianitis 2025-04-05 20:32:25 +03:00
parent 1f0fb95e3b
commit 8a54671d2c
No known key found for this signature in database
GPG key ID: DDC6FA7D5BB332E6
4 changed files with 35 additions and 35 deletions

View file

@ -50,7 +50,7 @@ typedef bool (*wlr_scene_buffer_point_accepts_input_func_t)(
struct wlr_scene_buffer *buffer, double *sx, double *sy);
typedef void (*wlr_scene_buffer_iterator_func_t)(
struct wlr_scene_buffer *buffer, int sx, int sy, void *user_data);
struct wlr_scene_buffer *buffer, double sx, double sy, void *user_data);
enum wlr_scene_node_type {
WLR_SCENE_NODE_TREE,
@ -66,7 +66,7 @@ struct wlr_scene_node {
struct wl_list link; // wlr_scene_tree.children
bool enabled;
int x, y; // relative to parent
double x, y; // relative to parent
struct {
struct wl_signal destroy;
@ -230,7 +230,7 @@ struct wlr_scene_output {
struct wlr_damage_ring damage_ring;
int x, y;
double x, y;
struct {
struct wl_signal destroy;
@ -301,7 +301,7 @@ void wlr_scene_node_set_enabled(struct wlr_scene_node *node, bool enabled);
/**
* Set the position of the node relative to its parent.
*/
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);
/**
* Move the node right above the specified sibling.
* Asserts that node and sibling are distinct and share the same parent.
@ -332,7 +332,7 @@ void wlr_scene_node_reparent(struct wlr_scene_node *node,
*
* True is returned if the node and all of its ancestors are enabled.
*/
bool wlr_scene_node_coords(struct wlr_scene_node *node, int *lx, int *ly);
bool wlr_scene_node_coords(struct wlr_scene_node *node, double *lx, double *ly);
/**
* Call `iterator` on each buffer in the scene-graph, with the buffer's
* position in layout coordinates. The function is called from root to leaves
@ -591,7 +591,7 @@ void wlr_scene_output_destroy(struct wlr_scene_output *scene_output);
* Set the output's position in the scene-graph.
*/
void wlr_scene_output_set_position(struct wlr_scene_output *scene_output,
int lx, int ly);
double lx, double ly);
struct wlr_scene_output_state_options {
struct wlr_scene_timer *timer;

View file

@ -34,7 +34,7 @@ struct scene_node_source_frame_event {
static size_t last_output_num = 0;
static void _get_scene_node_extents(struct wlr_scene_node *node, struct wlr_box *box, int lx, int ly) {
static void _get_scene_node_extents(struct wlr_scene_node *node, struct wlr_fbox *box, double lx, double ly) {
switch (node->type) {
case WLR_SCENE_NODE_TREE:;
struct wlr_scene_tree *scene_tree = wlr_scene_tree_from_node(node);
@ -45,7 +45,7 @@ static void _get_scene_node_extents(struct wlr_scene_node *node, struct wlr_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 (node_box.x < box->x) {
@ -64,9 +64,9 @@ static void _get_scene_node_extents(struct wlr_scene_node *node, struct wlr_box
}
}
static void get_scene_node_extents(struct wlr_scene_node *node, struct wlr_box *box) {
*box = (struct wlr_box){ .x = INT_MAX, .y = INT_MAX };
int lx = 0, ly = 0;
static void get_scene_node_extents(struct wlr_scene_node *node, struct wlr_fbox *box) {
*box = (struct wlr_fbox){ .x = INT_MAX, .y = INT_MAX };
double lx = 0, ly = 0;
wlr_scene_node_coords(node, &lx, &ly);
_get_scene_node_extents(node, box, lx, ly);
}
@ -74,7 +74,7 @@ static void get_scene_node_extents(struct wlr_scene_node *node, struct wlr_box *
static void source_render(struct scene_node_source *source) {
struct wlr_scene_output *scene_output = source->scene_output;
struct wlr_box extents;
struct wlr_fbox extents;
get_scene_node_extents(source->node, &extents);
if (extents.width == 0 || extents.height == 0) {

View file

@ -352,7 +352,7 @@ static void handle_scene_surface_surface_commit(
// schedule the frame however if the node is enabled and there is an
// output intersecting, otherwise the frame done events would never reach
// the surface anyway.
int lx, ly;
double lx, ly;
bool enabled = wlr_scene_node_coords(&scene_buffer->node, &lx, &ly);
if (!wl_list_empty(&surface->surface->current.frame_callback_list) &&

View file

@ -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) {
scene_node_box_iterator_func_t iterator, void *user_data, double lx, double ly) {
if (!node->enabled) {
return false;
}
@ -250,13 +250,13 @@ 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_box *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,
static void scene_node_opaque_region(struct wlr_scene_node *node, double x, double y,
pixman_region32_t *opaque) {
int width, height;
scene_node_get_size(node, &width, &height);
@ -572,7 +572,7 @@ 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 };
@ -620,7 +620,7 @@ static void scene_node_visibility(struct wlr_scene_node *node,
}
static void scene_node_bounds(struct wlr_scene_node *node,
int x, int y, pixman_region32_t *visible) {
double x, double y, pixman_region32_t *visible) {
if (!node->enabled) {
return;
}
@ -715,7 +715,7 @@ static void scene_node_update(struct wlr_scene_node *node,
pixman_region32_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.
@ -948,7 +948,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;
}
@ -1059,7 +1059,7 @@ void wlr_scene_buffer_set_opaque_region(struct wlr_scene_buffer *scene_buffer,
pixman_region32_copy(&scene_buffer->opaque_region, region);
int x, y;
double x, y;
if (!wlr_scene_node_coords(&scene_buffer->node, &x, &y)) {
return;
}
@ -1230,7 +1230,7 @@ void wlr_scene_node_set_enabled(struct wlr_scene_node *node, bool enabled) {
return;
}
int x, y;
double x, y;
pixman_region32_t visible;
pixman_region32_init(&visible);
if (wlr_scene_node_coords(node, &x, &y)) {
@ -1242,7 +1242,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,7 +1312,7 @@ void wlr_scene_node_reparent(struct wlr_scene_node *node,
assert(&ancestor->node != node);
}
int x, y;
double x, y;
pixman_region32_t visible;
pixman_region32_init(&visible);
if (wlr_scene_node_coords(node, &x, &y)) {
@ -1326,10 +1326,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 +1348,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 +1381,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;
@ -1432,7 +1432,7 @@ struct wlr_scene_node *wlr_scene_node_at(struct wlr_scene_node *node,
struct render_list_entry {
struct wlr_scene_node *node;
bool highlight_transparent_region;
int x, y;
double x, y;
};
static void scene_entry_render(struct render_list_entry *entry, const struct render_data *data) {
@ -1449,8 +1449,8 @@ static void scene_entry_render(struct render_list_entry *entry, const struct ren
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 = {
.x = x,
@ -1849,7 +1849,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;
}
@ -1894,7 +1894,7 @@ static bool scene_buffer_is_black_opaque(struct wlr_scene_buffer *scene_buffer)
}
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)) {
@ -2633,7 +2633,7 @@ void wlr_scene_output_send_frame_done(struct wlr_scene_output *scene_output,
}
static void scene_output_for_each_scene_buffer(const struct wlr_box *output_box,
struct wlr_scene_node *node, int lx, int ly,
struct wlr_scene_node *node, double lx, double ly,
wlr_scene_buffer_iterator_func_t user_iterator, void *user_data) {
if (!node->enabled) {
return;