2019-12-25 18:53:58 +01:00
|
|
|
/*
|
|
|
|
* This an unstable interface of wlroots. No guarantees are made regarding the
|
|
|
|
* future consistency of this API.
|
|
|
|
*/
|
|
|
|
#ifndef WLR_USE_UNSTABLE
|
|
|
|
#error "Add -DWLR_USE_UNSTABLE to enable unstable wlroots features"
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef WLR_TYPES_WLR_SCENE_H
|
|
|
|
#define WLR_TYPES_WLR_SCENE_H
|
|
|
|
|
|
|
|
/**
|
|
|
|
* The scene-graph API provides a declarative way to display surfaces. The
|
|
|
|
* compositor creates a scene, adds surfaces, then renders the scene on
|
|
|
|
* outputs.
|
|
|
|
*
|
|
|
|
* The scene-graph API only supports basic 2D composition operations (like the
|
|
|
|
* KMS API or the Wayland protocol does). For anything more complicated,
|
|
|
|
* compositors need to implement custom rendering logic.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <pixman.h>
|
2023-02-08 03:33:10 +01:00
|
|
|
#include <time.h>
|
2019-12-25 18:53:58 +01:00
|
|
|
#include <wayland-server-core.h>
|
2023-06-20 00:17:23 +02:00
|
|
|
#include <wlr/render/wlr_renderer.h>
|
2022-05-22 09:18:43 +02:00
|
|
|
#include <wlr/types/wlr_damage_ring.h>
|
2023-02-08 03:33:10 +01:00
|
|
|
#include <wlr/types/wlr_linux_dmabuf_v1.h>
|
|
|
|
#include <wlr/util/addon.h>
|
|
|
|
#include <wlr/util/box.h>
|
2019-12-25 18:53:58 +01:00
|
|
|
|
|
|
|
struct wlr_output;
|
2021-09-02 12:47:28 +02:00
|
|
|
struct wlr_output_layout;
|
2023-08-22 11:52:45 +02:00
|
|
|
struct wlr_output_layout_output;
|
2021-10-25 18:29:24 +02:00
|
|
|
struct wlr_xdg_surface;
|
2022-01-09 23:48:24 +01:00
|
|
|
struct wlr_layer_surface_v1;
|
2022-11-13 01:31:55 +01:00
|
|
|
struct wlr_drag_icon;
|
2023-02-08 03:33:10 +01:00
|
|
|
struct wlr_surface;
|
2019-12-25 18:53:58 +01:00
|
|
|
|
2022-04-12 17:47:59 +02:00
|
|
|
struct wlr_scene_node;
|
2022-05-19 20:24:05 +02:00
|
|
|
struct wlr_scene_buffer;
|
2023-08-22 11:52:45 +02:00
|
|
|
struct wlr_scene_output_layout;
|
2022-05-19 20:24:05 +02:00
|
|
|
|
2023-02-08 03:33:10 +01:00
|
|
|
struct wlr_presentation;
|
2023-02-20 22:54:52 +01:00
|
|
|
struct wlr_linux_dmabuf_v1;
|
2023-06-11 16:22:55 +02:00
|
|
|
struct wlr_output_state;
|
2023-02-08 03:33:10 +01:00
|
|
|
|
2022-05-19 20:24:05 +02:00
|
|
|
typedef bool (*wlr_scene_buffer_point_accepts_input_func_t)(
|
|
|
|
struct wlr_scene_buffer *buffer, int sx, int sy);
|
|
|
|
|
2022-04-12 17:47:59 +02:00
|
|
|
typedef void (*wlr_scene_buffer_iterator_func_t)(
|
|
|
|
struct wlr_scene_buffer *buffer, int sx, int sy, void *user_data);
|
|
|
|
|
2019-12-25 18:53:58 +01:00
|
|
|
enum wlr_scene_node_type {
|
2021-08-20 11:25:02 +02:00
|
|
|
WLR_SCENE_NODE_TREE,
|
2021-08-13 22:20:48 +02:00
|
|
|
WLR_SCENE_NODE_RECT,
|
2021-09-20 16:05:19 +02:00
|
|
|
WLR_SCENE_NODE_BUFFER,
|
2019-12-25 18:53:58 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
/** A node is an object in the scene. */
|
|
|
|
struct wlr_scene_node {
|
|
|
|
enum wlr_scene_node_type type;
|
2022-05-31 01:23:27 +02:00
|
|
|
struct wlr_scene_tree *parent;
|
2022-04-06 14:17:21 +02:00
|
|
|
|
2022-05-19 00:16:44 +02:00
|
|
|
struct wl_list link; // wlr_scene_tree.children
|
2022-04-06 14:17:21 +02:00
|
|
|
|
|
|
|
bool enabled;
|
|
|
|
int x, y; // relative to parent
|
2019-12-25 18:53:58 +01:00
|
|
|
|
|
|
|
struct {
|
|
|
|
struct wl_signal destroy;
|
|
|
|
} events;
|
2021-08-10 10:42:03 +02:00
|
|
|
|
|
|
|
void *data;
|
2022-05-19 20:25:34 +02:00
|
|
|
|
|
|
|
struct wlr_addon_set addons;
|
2022-06-25 23:58:13 +02:00
|
|
|
|
|
|
|
// private state
|
|
|
|
|
|
|
|
pixman_region32_t visible;
|
2019-12-25 18:53:58 +01:00
|
|
|
};
|
|
|
|
|
2022-05-21 00:28:08 +02:00
|
|
|
enum wlr_scene_debug_damage_option {
|
|
|
|
WLR_SCENE_DEBUG_DAMAGE_NONE,
|
|
|
|
WLR_SCENE_DEBUG_DAMAGE_RERENDER,
|
|
|
|
WLR_SCENE_DEBUG_DAMAGE_HIGHLIGHT
|
|
|
|
};
|
|
|
|
|
2022-05-31 01:26:08 +02:00
|
|
|
/** A sub-tree in the scene-graph. */
|
|
|
|
struct wlr_scene_tree {
|
2022-05-31 19:34:50 +02:00
|
|
|
struct wlr_scene_node node;
|
2022-05-19 00:16:44 +02:00
|
|
|
|
2022-05-31 19:34:50 +02:00
|
|
|
struct wl_list children; // wlr_scene_node.link
|
2022-05-31 01:26:08 +02:00
|
|
|
};
|
|
|
|
|
2019-12-25 18:53:58 +01:00
|
|
|
/** The root scene-graph node. */
|
|
|
|
struct wlr_scene {
|
2022-05-31 01:26:08 +02:00
|
|
|
struct wlr_scene_tree tree;
|
2021-08-17 12:24:11 +02:00
|
|
|
|
|
|
|
struct wl_list outputs; // wlr_scene_output.link
|
2021-12-14 18:35:44 +01:00
|
|
|
|
|
|
|
// May be NULL
|
|
|
|
struct wlr_presentation *presentation;
|
2023-02-20 22:54:52 +01:00
|
|
|
struct wlr_linux_dmabuf_v1 *linux_dmabuf_v1;
|
2022-03-21 01:56:13 +01:00
|
|
|
|
|
|
|
// private state
|
|
|
|
|
2021-12-14 18:35:44 +01:00
|
|
|
struct wl_listener presentation_destroy;
|
2023-02-20 22:54:52 +01:00
|
|
|
struct wl_listener linux_dmabuf_v1_destroy;
|
2022-05-21 00:28:08 +02:00
|
|
|
|
|
|
|
enum wlr_scene_debug_damage_option debug_damage_option;
|
2022-08-08 06:40:21 +02:00
|
|
|
bool direct_scanout;
|
2022-06-26 00:34:26 +02:00
|
|
|
bool calculate_visibility;
|
2019-12-25 18:53:58 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
/** A scene-graph node displaying a single surface. */
|
|
|
|
struct wlr_scene_surface {
|
2022-05-19 20:26:50 +02:00
|
|
|
struct wlr_scene_buffer *buffer;
|
2019-12-25 18:53:58 +01:00
|
|
|
struct wlr_surface *surface;
|
|
|
|
|
|
|
|
// private state
|
|
|
|
|
2022-05-19 20:26:50 +02:00
|
|
|
struct wlr_addon addon;
|
2021-12-09 23:17:16 +01:00
|
|
|
|
2022-11-26 21:48:53 +01:00
|
|
|
struct wl_listener outputs_update;
|
2022-05-19 20:26:50 +02:00
|
|
|
struct wl_listener output_enter;
|
|
|
|
struct wl_listener output_leave;
|
2023-07-14 15:06:13 +02:00
|
|
|
struct wl_listener output_sample;
|
2022-05-19 20:26:50 +02:00
|
|
|
struct wl_listener frame_done;
|
2019-12-25 18:53:58 +01:00
|
|
|
struct wl_listener surface_destroy;
|
2021-08-17 15:12:47 +02:00
|
|
|
struct wl_listener surface_commit;
|
2019-12-25 18:53:58 +01:00
|
|
|
};
|
|
|
|
|
2021-08-13 22:20:48 +02:00
|
|
|
/** A scene-graph node displaying a solid-colored rectangle */
|
|
|
|
struct wlr_scene_rect {
|
|
|
|
struct wlr_scene_node node;
|
|
|
|
int width, height;
|
|
|
|
float color[4];
|
|
|
|
};
|
|
|
|
|
2023-01-21 22:23:30 +01:00
|
|
|
struct wlr_scene_outputs_update_event {
|
|
|
|
struct wlr_scene_output **active;
|
|
|
|
size_t size;
|
|
|
|
};
|
|
|
|
|
2023-07-14 15:16:12 +02:00
|
|
|
struct wlr_scene_output_sample_event {
|
|
|
|
struct wlr_scene_output *output;
|
|
|
|
bool direct_scanout;
|
|
|
|
};
|
|
|
|
|
2021-09-20 16:05:19 +02:00
|
|
|
/** A scene-graph node displaying a buffer */
|
|
|
|
struct wlr_scene_buffer {
|
|
|
|
struct wlr_scene_node node;
|
2022-05-19 20:16:52 +02:00
|
|
|
|
|
|
|
// May be NULL
|
2021-09-20 16:05:19 +02:00
|
|
|
struct wlr_buffer *buffer;
|
|
|
|
|
2022-05-19 00:08:35 +02:00
|
|
|
struct {
|
2023-01-21 22:23:30 +01:00
|
|
|
struct wl_signal outputs_update; // struct wlr_scene_outputs_update_event
|
2022-05-19 00:08:35 +02:00
|
|
|
struct wl_signal output_enter; // struct wlr_scene_output
|
|
|
|
struct wl_signal output_leave; // struct wlr_scene_output
|
2023-07-14 15:16:12 +02:00
|
|
|
struct wl_signal output_sample; // struct wlr_scene_output_sample_event
|
2022-05-19 20:23:10 +02:00
|
|
|
struct wl_signal frame_done; // struct timespec
|
2022-05-19 00:08:35 +02:00
|
|
|
} events;
|
|
|
|
|
2022-05-19 20:24:05 +02:00
|
|
|
// May be NULL
|
|
|
|
wlr_scene_buffer_point_accepts_input_func_t point_accepts_input;
|
|
|
|
|
2022-04-25 04:32:58 +02:00
|
|
|
/**
|
|
|
|
* The output that the largest area of this buffer is displayed on.
|
|
|
|
* This may be NULL if the buffer is not currently displayed on any
|
|
|
|
* outputs. This is the output that should be used for frame callbacks,
|
|
|
|
* presentation feedback, etc.
|
|
|
|
*/
|
|
|
|
struct wlr_scene_output *primary_output;
|
|
|
|
|
2023-05-27 10:20:25 +02:00
|
|
|
float opacity;
|
2023-06-20 00:17:23 +02:00
|
|
|
enum wlr_scale_filter_mode filter_mode;
|
2021-09-20 17:41:52 +02:00
|
|
|
struct wlr_fbox src_box;
|
2021-09-20 18:05:11 +02:00
|
|
|
int dst_width, dst_height;
|
2021-09-20 18:19:05 +02:00
|
|
|
enum wl_output_transform transform;
|
2022-06-26 05:26:12 +02:00
|
|
|
pixman_region32_t opaque_region;
|
2023-04-07 18:17:12 +02:00
|
|
|
|
|
|
|
// private state
|
|
|
|
|
|
|
|
uint64_t active_outputs;
|
|
|
|
struct wlr_texture *texture;
|
2023-02-20 22:54:52 +01:00
|
|
|
struct wlr_linux_dmabuf_feedback_v1_init_options prev_feedback_options;
|
2021-09-20 16:05:19 +02:00
|
|
|
};
|
|
|
|
|
2021-08-17 12:24:11 +02:00
|
|
|
/** A viewport for an output in the scene-graph */
|
|
|
|
struct wlr_scene_output {
|
|
|
|
struct wlr_output *output;
|
|
|
|
struct wl_list link; // wlr_scene.outputs
|
|
|
|
struct wlr_scene *scene;
|
|
|
|
struct wlr_addon addon;
|
|
|
|
|
2022-05-22 09:18:43 +02:00
|
|
|
struct wlr_damage_ring damage_ring;
|
2021-08-17 15:12:47 +02:00
|
|
|
|
2021-08-17 12:24:11 +02:00
|
|
|
int x, y;
|
2021-10-20 16:08:47 +02:00
|
|
|
|
2022-05-31 20:39:53 +02:00
|
|
|
struct {
|
|
|
|
struct wl_signal destroy;
|
|
|
|
} events;
|
|
|
|
|
2021-10-20 16:08:47 +02:00
|
|
|
// private state
|
|
|
|
|
2022-05-19 00:08:35 +02:00
|
|
|
uint8_t index;
|
2021-10-20 16:08:47 +02:00
|
|
|
bool prev_scanout;
|
2022-05-19 20:01:03 +02:00
|
|
|
|
|
|
|
struct wl_listener output_commit;
|
2022-06-29 20:10:08 +02:00
|
|
|
struct wl_listener output_damage;
|
2022-05-22 09:18:43 +02:00
|
|
|
struct wl_listener output_needs_frame;
|
2022-07-03 18:20:41 +02:00
|
|
|
|
|
|
|
struct wl_list damage_highlight_regions;
|
2022-08-14 08:17:09 +02:00
|
|
|
|
2022-08-18 11:54:03 +02:00
|
|
|
struct wl_array render_list;
|
2021-08-17 12:24:11 +02:00
|
|
|
};
|
|
|
|
|
2023-06-08 11:42:25 +02:00
|
|
|
struct wlr_scene_timer {
|
|
|
|
int64_t pre_render_duration;
|
|
|
|
struct wlr_render_timer *render_timer;
|
|
|
|
};
|
|
|
|
|
2022-01-09 23:48:24 +01:00
|
|
|
/** A layer shell scene helper */
|
|
|
|
struct wlr_scene_layer_surface_v1 {
|
2022-05-31 01:23:27 +02:00
|
|
|
struct wlr_scene_tree *tree;
|
2022-01-09 23:48:24 +01:00
|
|
|
struct wlr_layer_surface_v1 *layer_surface;
|
|
|
|
|
|
|
|
// private state
|
|
|
|
|
|
|
|
struct wl_listener tree_destroy;
|
|
|
|
struct wl_listener layer_surface_destroy;
|
|
|
|
struct wl_listener layer_surface_map;
|
|
|
|
struct wl_listener layer_surface_unmap;
|
|
|
|
};
|
|
|
|
|
2019-12-25 18:53:58 +01:00
|
|
|
/**
|
|
|
|
* Immediately destroy the scene-graph node.
|
|
|
|
*/
|
|
|
|
void wlr_scene_node_destroy(struct wlr_scene_node *node);
|
2020-05-06 16:16:45 +02:00
|
|
|
/**
|
|
|
|
* Enable or disable this node. If a node is disabled, all of its children are
|
|
|
|
* implicitly disabled as well.
|
|
|
|
*/
|
|
|
|
void wlr_scene_node_set_enabled(struct wlr_scene_node *node, bool enabled);
|
2019-12-25 18:53:58 +01:00
|
|
|
/**
|
|
|
|
* 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);
|
|
|
|
/**
|
|
|
|
* Move the node right above the specified sibling.
|
2021-10-13 16:00:53 +02:00
|
|
|
* Asserts that node and sibling are distinct and share the same parent.
|
2019-12-25 18:53:58 +01:00
|
|
|
*/
|
|
|
|
void wlr_scene_node_place_above(struct wlr_scene_node *node,
|
|
|
|
struct wlr_scene_node *sibling);
|
|
|
|
/**
|
|
|
|
* Move the node right below the specified sibling.
|
2021-10-13 16:00:53 +02:00
|
|
|
* Asserts that node and sibling are distinct and share the same parent.
|
2019-12-25 18:53:58 +01:00
|
|
|
*/
|
|
|
|
void wlr_scene_node_place_below(struct wlr_scene_node *node,
|
|
|
|
struct wlr_scene_node *sibling);
|
2021-10-13 16:11:54 +02:00
|
|
|
/**
|
|
|
|
* Move the node above all of its sibling nodes.
|
|
|
|
*/
|
|
|
|
void wlr_scene_node_raise_to_top(struct wlr_scene_node *node);
|
|
|
|
/**
|
|
|
|
* Move the node below all of its sibling nodes.
|
|
|
|
*/
|
|
|
|
void wlr_scene_node_lower_to_bottom(struct wlr_scene_node *node);
|
2021-08-23 21:32:59 +02:00
|
|
|
/**
|
|
|
|
* Move the node to another location in the tree.
|
|
|
|
*/
|
|
|
|
void wlr_scene_node_reparent(struct wlr_scene_node *node,
|
2022-05-31 01:23:27 +02:00
|
|
|
struct wlr_scene_tree *new_parent);
|
2021-08-17 13:20:32 +02:00
|
|
|
/**
|
|
|
|
* Get the node's layout-local coordinates.
|
|
|
|
*
|
|
|
|
* 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);
|
2019-12-25 18:53:58 +01:00
|
|
|
/**
|
2022-04-12 17:47:59 +02:00
|
|
|
* Call `iterator` on each buffer in the scene-graph, with the buffer's
|
2019-12-25 18:53:58 +01:00
|
|
|
* position in layout coordinates. The function is called from root to leaves
|
|
|
|
* (in rendering order).
|
|
|
|
*/
|
2022-04-12 17:47:59 +02:00
|
|
|
void wlr_scene_node_for_each_buffer(struct wlr_scene_node *node,
|
|
|
|
wlr_scene_buffer_iterator_func_t iterator, void *user_data);
|
2021-08-10 11:26:34 +02:00
|
|
|
/**
|
2021-08-28 21:14:16 +02:00
|
|
|
* Find the topmost node in this scene-graph that contains the point at the
|
|
|
|
* given layout-local coordinates. (For surface nodes, this means accepting
|
|
|
|
* input events at that point.) Returns the node and coordinates relative to the
|
|
|
|
* returned node, or NULL if no node is found at that location.
|
2021-08-10 11:26:34 +02:00
|
|
|
*/
|
2021-08-28 21:14:16 +02:00
|
|
|
struct wlr_scene_node *wlr_scene_node_at(struct wlr_scene_node *node,
|
|
|
|
double lx, double ly, double *nx, double *ny);
|
2019-12-25 18:53:58 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Create a new scene-graph.
|
|
|
|
*/
|
|
|
|
struct wlr_scene *wlr_scene_create(void);
|
2023-02-08 03:33:10 +01:00
|
|
|
|
2021-12-14 18:35:44 +01:00
|
|
|
/**
|
|
|
|
* Handle presentation feedback for all surfaces in the scene, assuming that
|
|
|
|
* scene outputs and the scene rendering functions are used.
|
|
|
|
*
|
2022-05-24 18:46:59 +02:00
|
|
|
* Asserts that a struct wlr_presentation hasn't already been set for the scene.
|
2021-12-14 18:35:44 +01:00
|
|
|
*/
|
|
|
|
void wlr_scene_set_presentation(struct wlr_scene *scene,
|
|
|
|
struct wlr_presentation *presentation);
|
2019-12-25 18:53:58 +01:00
|
|
|
|
2023-02-20 22:54:52 +01:00
|
|
|
/**
|
|
|
|
* Handles linux_dmabuf_v1 feedback for all surfaces in the scene.
|
|
|
|
*
|
|
|
|
* Asserts that a struct wlr_linux_dmabuf_v1 hasn't already been set for the scene.
|
|
|
|
*/
|
|
|
|
void wlr_scene_set_linux_dmabuf_v1(struct wlr_scene *scene,
|
|
|
|
struct wlr_linux_dmabuf_v1 *linux_dmabuf_v1);
|
|
|
|
|
|
|
|
|
2021-08-20 11:25:02 +02:00
|
|
|
/**
|
|
|
|
* Add a node displaying nothing but its children.
|
|
|
|
*/
|
2022-05-31 01:23:27 +02:00
|
|
|
struct wlr_scene_tree *wlr_scene_tree_create(struct wlr_scene_tree *parent);
|
2021-08-20 11:25:02 +02:00
|
|
|
|
2019-12-25 18:53:58 +01:00
|
|
|
/**
|
|
|
|
* Add a node displaying a single surface to the scene-graph.
|
|
|
|
*
|
|
|
|
* The child sub-surfaces are ignored.
|
2021-12-09 23:17:16 +01:00
|
|
|
*
|
2022-05-24 18:46:59 +02:00
|
|
|
* wlr_surface_send_enter() and wlr_surface_send_leave() will be called
|
2021-12-09 23:17:16 +01:00
|
|
|
* automatically based on the position of the surface and outputs in
|
|
|
|
* the scene.
|
2019-12-25 18:53:58 +01:00
|
|
|
*/
|
2022-05-31 01:23:27 +02:00
|
|
|
struct wlr_scene_surface *wlr_scene_surface_create(struct wlr_scene_tree *parent,
|
2019-12-25 18:53:58 +01:00
|
|
|
struct wlr_surface *surface);
|
|
|
|
|
2022-06-05 19:03:35 +02:00
|
|
|
/**
|
|
|
|
* If this node represents a wlr_scene_buffer, that buffer will be returned. It
|
|
|
|
* is not legal to feed a node that does not represent a wlr_scene_buffer.
|
|
|
|
*/
|
2022-03-28 12:19:45 +02:00
|
|
|
struct wlr_scene_buffer *wlr_scene_buffer_from_node(struct wlr_scene_node *node);
|
|
|
|
|
2022-06-05 19:06:18 +02:00
|
|
|
/**
|
|
|
|
* If this node represents a wlr_scene_tree, that tree will be returned. It
|
|
|
|
* is not legal to feed a node that does not represent a wlr_scene_tree.
|
|
|
|
*/
|
|
|
|
struct wlr_scene_tree *wlr_scene_tree_from_node(struct wlr_scene_node *node);
|
|
|
|
|
2023-05-27 10:20:07 +02:00
|
|
|
/**
|
|
|
|
* If this node represents a wlr_scene_rect, that rect will be returned. It
|
|
|
|
* is not legal to feed a node that does not represent a wlr_scene_rect.
|
|
|
|
*/
|
|
|
|
struct wlr_scene_rect *wlr_scene_rect_from_node(struct wlr_scene_node *node);
|
|
|
|
|
2022-05-19 20:26:50 +02:00
|
|
|
/**
|
2022-05-24 18:46:59 +02:00
|
|
|
* If this buffer is backed by a surface, then the struct wlr_scene_surface is
|
2022-05-19 20:26:50 +02:00
|
|
|
* returned. If not, NULL will be returned.
|
|
|
|
*/
|
2023-02-04 08:57:42 +01:00
|
|
|
struct wlr_scene_surface *wlr_scene_surface_try_from_buffer(
|
2022-05-19 20:26:50 +02:00
|
|
|
struct wlr_scene_buffer *scene_buffer);
|
|
|
|
|
2021-08-13 22:20:48 +02:00
|
|
|
/**
|
|
|
|
* Add a node displaying a solid-colored rectangle to the scene-graph.
|
|
|
|
*/
|
2022-05-31 01:23:27 +02:00
|
|
|
struct wlr_scene_rect *wlr_scene_rect_create(struct wlr_scene_tree *parent,
|
2021-08-13 22:20:48 +02:00
|
|
|
int width, int height, const float color[static 4]);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Change the width and height of an existing rectangle node.
|
|
|
|
*/
|
|
|
|
void wlr_scene_rect_set_size(struct wlr_scene_rect *rect, int width, int height);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Change the color of an existing rectangle node.
|
|
|
|
*/
|
|
|
|
void wlr_scene_rect_set_color(struct wlr_scene_rect *rect, const float color[static 4]);
|
|
|
|
|
2021-09-20 16:05:19 +02:00
|
|
|
/**
|
|
|
|
* Add a node displaying a buffer to the scene-graph.
|
2022-05-19 20:16:52 +02:00
|
|
|
*
|
|
|
|
* If the buffer is NULL, this node will not be displayed.
|
2021-09-20 16:05:19 +02:00
|
|
|
*/
|
2022-05-31 01:23:27 +02:00
|
|
|
struct wlr_scene_buffer *wlr_scene_buffer_create(struct wlr_scene_tree *parent,
|
2021-09-20 16:05:19 +02:00
|
|
|
struct wlr_buffer *buffer);
|
|
|
|
|
2022-05-19 20:17:51 +02:00
|
|
|
/**
|
|
|
|
* Sets the buffer's backing buffer.
|
|
|
|
*
|
|
|
|
* If the buffer is NULL, the buffer node will not be displayed.
|
|
|
|
*/
|
|
|
|
void wlr_scene_buffer_set_buffer(struct wlr_scene_buffer *scene_buffer,
|
|
|
|
struct wlr_buffer *buffer);
|
|
|
|
|
2022-05-19 04:37:05 +02:00
|
|
|
/**
|
|
|
|
* Sets the buffer's backing buffer with a custom damage region.
|
|
|
|
*
|
|
|
|
* The damage region is in buffer-local coordinates. If the region is NULL,
|
|
|
|
* the whole buffer node will be damaged.
|
|
|
|
*/
|
|
|
|
void wlr_scene_buffer_set_buffer_with_damage(struct wlr_scene_buffer *scene_buffer,
|
2022-10-24 13:03:35 +02:00
|
|
|
struct wlr_buffer *buffer, const pixman_region32_t *region);
|
2022-05-19 04:37:05 +02:00
|
|
|
|
2022-06-26 05:26:12 +02:00
|
|
|
/**
|
|
|
|
* Sets the buffer's opaque region. This is an optimization hint used to
|
|
|
|
* determine if buffers which reside under this one need to be rendered or not.
|
|
|
|
*/
|
|
|
|
void wlr_scene_buffer_set_opaque_region(struct wlr_scene_buffer *scene_buffer,
|
2022-10-24 13:03:35 +02:00
|
|
|
const pixman_region32_t *region);
|
2022-06-26 05:26:12 +02:00
|
|
|
|
2021-09-20 17:41:52 +02:00
|
|
|
/**
|
|
|
|
* Set the source rectangle describing the region of the buffer which will be
|
|
|
|
* sampled to render this node. This allows cropping the buffer.
|
|
|
|
*
|
|
|
|
* If NULL, the whole buffer is sampled. By default, the source box is NULL.
|
|
|
|
*/
|
|
|
|
void wlr_scene_buffer_set_source_box(struct wlr_scene_buffer *scene_buffer,
|
|
|
|
const struct wlr_fbox *box);
|
|
|
|
|
2021-09-20 18:05:11 +02:00
|
|
|
/**
|
|
|
|
* Set the destination size describing the region of the scene-graph the buffer
|
|
|
|
* will be painted onto. This allows scaling the buffer.
|
|
|
|
*
|
|
|
|
* If zero, the destination size will be the buffer size. By default, the
|
|
|
|
* destination size is zero.
|
|
|
|
*/
|
|
|
|
void wlr_scene_buffer_set_dest_size(struct wlr_scene_buffer *scene_buffer,
|
|
|
|
int width, int height);
|
|
|
|
|
2021-09-20 18:19:05 +02:00
|
|
|
/**
|
|
|
|
* Set a transform which will be applied to the buffer.
|
|
|
|
*/
|
|
|
|
void wlr_scene_buffer_set_transform(struct wlr_scene_buffer *scene_buffer,
|
|
|
|
enum wl_output_transform transform);
|
|
|
|
|
2023-05-27 10:20:25 +02:00
|
|
|
/**
|
|
|
|
* Sets the opacity of this buffer
|
|
|
|
*/
|
|
|
|
void wlr_scene_buffer_set_opacity(struct wlr_scene_buffer *scene_buffer,
|
|
|
|
float opacity);
|
|
|
|
|
2023-06-20 00:17:23 +02:00
|
|
|
/**
|
|
|
|
* Sets the filter mode to use when scaling the buffer
|
|
|
|
*/
|
|
|
|
void wlr_scene_buffer_set_filter_mode(struct wlr_scene_buffer *scene_buffer,
|
|
|
|
enum wlr_scale_filter_mode filter_mode);
|
|
|
|
|
2022-05-19 20:23:10 +02:00
|
|
|
/**
|
|
|
|
* Calls the buffer's frame_done signal.
|
|
|
|
*/
|
|
|
|
void wlr_scene_buffer_send_frame_done(struct wlr_scene_buffer *scene_buffer,
|
|
|
|
struct timespec *now);
|
|
|
|
|
2021-08-17 12:24:11 +02:00
|
|
|
/**
|
|
|
|
* Add a viewport for the specified output to the scene-graph.
|
|
|
|
*
|
|
|
|
* An output can only be added once to the scene-graph.
|
|
|
|
*/
|
|
|
|
struct wlr_scene_output *wlr_scene_output_create(struct wlr_scene *scene,
|
|
|
|
struct wlr_output *output);
|
|
|
|
/**
|
|
|
|
* Destroy a scene-graph output.
|
|
|
|
*/
|
|
|
|
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);
|
2023-06-11 16:22:55 +02:00
|
|
|
|
2023-06-08 11:42:25 +02:00
|
|
|
struct wlr_scene_output_state_options {
|
|
|
|
struct wlr_scene_timer *timer;
|
|
|
|
};
|
|
|
|
|
2021-08-17 12:30:17 +02:00
|
|
|
/**
|
|
|
|
* Render and commit an output.
|
|
|
|
*/
|
2023-06-08 11:42:25 +02:00
|
|
|
bool wlr_scene_output_commit(struct wlr_scene_output *scene_output,
|
|
|
|
const struct wlr_scene_output_state_options *options);
|
2023-06-11 16:22:55 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Render and populate given output state.
|
|
|
|
*/
|
|
|
|
bool wlr_scene_output_build_state(struct wlr_scene_output *scene_output,
|
2023-06-08 11:42:25 +02:00
|
|
|
struct wlr_output_state *state, const struct wlr_scene_output_state_options *options);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Retrieve the duration in nanoseconds between the last wlr_scene_output_commit() call and the end
|
|
|
|
* of its operations, including those on the GPU that may have finished after the call returned.
|
|
|
|
*
|
|
|
|
* Returns -1 if the duration is unavailable.
|
|
|
|
*/
|
|
|
|
int64_t wlr_scene_timer_get_duration_ns(struct wlr_scene_timer *timer);
|
|
|
|
void wlr_scene_timer_finish(struct wlr_scene_timer *timer);
|
2023-06-11 16:22:55 +02:00
|
|
|
|
2021-12-13 17:23:47 +01:00
|
|
|
/**
|
|
|
|
* Call wlr_surface_send_frame_done() on all surfaces in the scene rendered by
|
2022-05-24 18:46:59 +02:00
|
|
|
* wlr_scene_output_commit() for which wlr_scene_surface.primary_output
|
2021-12-13 17:23:47 +01:00
|
|
|
* matches the given scene_output.
|
|
|
|
*/
|
|
|
|
void wlr_scene_output_send_frame_done(struct wlr_scene_output *scene_output,
|
|
|
|
struct timespec *now);
|
2021-10-20 18:16:27 +02:00
|
|
|
/**
|
2022-04-12 17:47:59 +02:00
|
|
|
* Call `iterator` on each buffer in the scene-graph visible on the output,
|
|
|
|
* with the buffer's position in layout coordinates. The function is called
|
2021-10-20 18:16:27 +02:00
|
|
|
* from root to leaves (in rendering order).
|
|
|
|
*/
|
2022-04-12 17:47:59 +02:00
|
|
|
void wlr_scene_output_for_each_buffer(struct wlr_scene_output *scene_output,
|
|
|
|
wlr_scene_buffer_iterator_func_t iterator, void *user_data);
|
2021-11-30 20:55:04 +01:00
|
|
|
/**
|
2022-05-24 18:46:59 +02:00
|
|
|
* Get a scene-graph output from a struct wlr_output.
|
2021-11-30 20:55:04 +01:00
|
|
|
*
|
|
|
|
* If the output hasn't been added to the scene-graph, returns NULL.
|
|
|
|
*/
|
|
|
|
struct wlr_scene_output *wlr_scene_get_scene_output(struct wlr_scene *scene,
|
|
|
|
struct wlr_output *output);
|
2021-10-20 18:16:27 +02:00
|
|
|
|
2021-09-02 12:47:28 +02:00
|
|
|
/**
|
|
|
|
* Attach an output layout to a scene.
|
|
|
|
*
|
2023-08-22 11:52:45 +02:00
|
|
|
* With an attached `wlr_scene_output_layout`, removing or repositioning an output in the output
|
|
|
|
* layout will respectively remove or reposition a corresponding scene-graph output. When the output
|
|
|
|
* layout is destroyed, scene-graph outputs which were attached to this helper will be destroyed.
|
|
|
|
*
|
|
|
|
* When adding an output to the output_layout, users must also create a `wlr_scene_output` and pass
|
|
|
|
* it to wlr_scene_output_layout_add_output().
|
2021-09-02 12:47:28 +02:00
|
|
|
*/
|
2023-08-22 11:52:45 +02:00
|
|
|
struct wlr_scene_output_layout *wlr_scene_attach_output_layout(struct wlr_scene *scene,
|
2021-09-02 12:47:28 +02:00
|
|
|
struct wlr_output_layout *output_layout);
|
|
|
|
|
2023-08-22 11:52:45 +02:00
|
|
|
/**
|
|
|
|
* Add an output to the scene, with its positioning defined by the output layout.
|
|
|
|
*/
|
|
|
|
void wlr_scene_output_layout_add_output(struct wlr_scene_output_layout *sol,
|
|
|
|
struct wlr_output_layout_output *lo, struct wlr_scene_output *so);
|
|
|
|
|
2021-08-20 12:41:23 +02:00
|
|
|
/**
|
|
|
|
* Add a node displaying a surface and all of its sub-surfaces to the
|
|
|
|
* scene-graph.
|
|
|
|
*/
|
2022-05-31 01:23:27 +02:00
|
|
|
struct wlr_scene_tree *wlr_scene_subsurface_tree_create(
|
|
|
|
struct wlr_scene_tree *parent, struct wlr_surface *surface);
|
2021-08-20 12:41:23 +02:00
|
|
|
|
2021-10-25 18:29:24 +02:00
|
|
|
/**
|
|
|
|
* Add a node displaying an xdg_surface and all of its sub-surfaces to the
|
|
|
|
* scene-graph.
|
|
|
|
*
|
|
|
|
* The origin of the returned scene-graph node will match the top-left corner
|
|
|
|
* of the xdg_surface window geometry.
|
|
|
|
*/
|
2022-05-31 01:23:27 +02:00
|
|
|
struct wlr_scene_tree *wlr_scene_xdg_surface_create(
|
|
|
|
struct wlr_scene_tree *parent, struct wlr_xdg_surface *xdg_surface);
|
2021-10-25 18:29:24 +02:00
|
|
|
|
2022-01-09 23:48:24 +01:00
|
|
|
/**
|
|
|
|
* Add a node displaying a layer_surface_v1 and all of its sub-surfaces to the
|
|
|
|
* scene-graph.
|
|
|
|
*
|
|
|
|
* The origin of the returned scene-graph node will match the top-left corner
|
|
|
|
* of the layer surface.
|
|
|
|
*/
|
|
|
|
struct wlr_scene_layer_surface_v1 *wlr_scene_layer_surface_v1_create(
|
2022-05-31 01:23:27 +02:00
|
|
|
struct wlr_scene_tree *parent, struct wlr_layer_surface_v1 *layer_surface);
|
2022-01-09 23:48:24 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Configure a layer_surface_v1, position its scene node in accordance to its
|
|
|
|
* current state, and update the remaining usable area.
|
|
|
|
*
|
|
|
|
* full_area represents the entire area that may be used by the layer surface
|
|
|
|
* if its exclusive_zone is -1, and is usually the output dimensions.
|
|
|
|
* usable_area represents what remains of full_area that can be used if
|
|
|
|
* exclusive_zone is >= 0. usable_area is updated if the surface has a positive
|
|
|
|
* exclusive_zone, so that it can be used for the next layer surface.
|
|
|
|
*/
|
|
|
|
void wlr_scene_layer_surface_v1_configure(
|
|
|
|
struct wlr_scene_layer_surface_v1 *scene_layer_surface,
|
|
|
|
const struct wlr_box *full_area, struct wlr_box *usable_area);
|
|
|
|
|
2022-11-13 01:31:55 +01:00
|
|
|
/**
|
|
|
|
* Add a node displaying a drag icon and all its sub-surfaces to the
|
|
|
|
* scene-graph.
|
|
|
|
*/
|
|
|
|
struct wlr_scene_tree *wlr_scene_drag_icon_create(
|
|
|
|
struct wlr_scene_tree *parent, struct wlr_drag_icon *drag_icon);
|
|
|
|
|
2019-12-25 18:53:58 +01:00
|
|
|
#endif
|