mirror of
https://gitlab.freedesktop.org/wlroots/wlroots.git
synced 2026-06-13 14:32:57 -04:00
scene: use fractional positions
Signed-off-by: Loukas Agorgianitis <loukas@agorgianitis.com>
This commit is contained in:
parent
63318d28b1
commit
f5310778dd
5 changed files with 39 additions and 38 deletions
|
|
@ -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;
|
||||
|
|
@ -228,7 +228,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;
|
||||
|
|
|
|||
|
|
@ -104,7 +104,7 @@ static void bench_scene_node_at(struct wlr_scene *scene, struct tree_spec *spec)
|
|||
}
|
||||
|
||||
static void noop_iterator(struct wlr_scene_buffer *buffer,
|
||||
int sx, int sy, void *user_data) {
|
||||
double sx, double sy, void *user_data) {
|
||||
(void)buffer;
|
||||
(void)sx;
|
||||
(void)sy;
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
#include <limits.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <float.h>
|
||||
#include <wlr/backend/interface.h>
|
||||
#include <wlr/interfaces/wlr_ext_image_capture_source_v1.h>
|
||||
#include <wlr/interfaces/wlr_output.h>
|
||||
|
|
@ -34,8 +35,8 @@ struct scene_node_source_frame_event {
|
|||
|
||||
static size_t last_output_num = 0;
|
||||
|
||||
static void _get_scene_node_extents(struct wlr_scene_node *node, int lx, int ly,
|
||||
int *x_min, int *y_min, int *x_max, int *y_max) {
|
||||
static void _get_scene_node_extents(struct wlr_scene_node *node, double lx, double ly,
|
||||
double *x_min, double *y_min, double *x_max, double *y_max) {
|
||||
switch (node->type) {
|
||||
case WLR_SCENE_NODE_TREE:;
|
||||
struct wlr_scene_tree *scene_tree = wlr_scene_tree_from_node(node);
|
||||
|
|
@ -46,7 +47,7 @@ static void _get_scene_node_extents(struct wlr_scene_node *node, int lx, int ly,
|
|||
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 < *x_min) {
|
||||
|
|
@ -65,11 +66,11 @@ static void _get_scene_node_extents(struct wlr_scene_node *node, int lx, int ly,
|
|||
}
|
||||
}
|
||||
|
||||
static void get_scene_node_extents(struct wlr_scene_node *node, struct wlr_box *box) {
|
||||
int lx = 0, ly = 0;
|
||||
static void get_scene_node_extents(struct wlr_scene_node *node, struct wlr_fbox *box) {
|
||||
double lx = 0, ly = 0;
|
||||
wlr_scene_node_coords(node, &lx, &ly);
|
||||
*box = (struct wlr_box){ .x = INT_MAX, .y = INT_MAX };
|
||||
int x_max = INT_MIN, y_max = INT_MIN;
|
||||
*box = (struct wlr_fbox){ .x = DBL_MAX, .y = DBL_MAX };
|
||||
double x_max = DBL_MIN, y_max = DBL_MIN;
|
||||
_get_scene_node_extents(node, lx, ly, &box->x, &box->y, &x_max, &y_max);
|
||||
box->width = x_max - box->x;
|
||||
box->height = y_max - box->y;
|
||||
|
|
@ -78,7 +79,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) {
|
||||
|
|
|
|||
|
|
@ -370,7 +370,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);
|
||||
struct wlr_output *output = get_surface_frame_pacing_output(surface->surface);
|
||||
if (!wl_list_empty(&surface->surface->current.frame_callback_list) && output && enabled) {
|
||||
|
|
|
|||
|
|
@ -202,10 +202,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;
|
||||
}
|
||||
|
|
@ -237,13 +237,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);
|
||||
|
|
@ -540,7 +540,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 };
|
||||
|
|
@ -588,7 +588,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;
|
||||
}
|
||||
|
|
@ -683,7 +683,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.
|
||||
|
|
@ -914,7 +914,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;
|
||||
}
|
||||
|
|
@ -1025,7 +1025,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;
|
||||
}
|
||||
|
|
@ -1196,7 +1196,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)) {
|
||||
|
|
@ -1208,7 +1208,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;
|
||||
}
|
||||
|
|
@ -1278,7 +1278,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)) {
|
||||
|
|
@ -1292,10 +1292,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;
|
||||
|
|
@ -1314,7 +1314,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;
|
||||
|
|
@ -1347,7 +1347,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;
|
||||
|
|
@ -1398,7 +1398,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 float get_luminance_multiplier(const struct wlr_color_luminances *src_lum,
|
||||
|
|
@ -1420,8 +1420,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,
|
||||
|
|
@ -1840,7 +1840,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;
|
||||
}
|
||||
|
|
@ -1885,7 +1885,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)) {
|
||||
|
|
@ -2651,7 +2651,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;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue