mirror of
https://gitlab.freedesktop.org/wlroots/wlroots.git
synced 2026-06-15 14:33:01 -04:00
types/scene: split wlr_scene into modular components
Refactor the scene graph implementation by splitting wlr_scene.c into multiple focused units: buffer, node, rect and tree. Introduce corresponding public headers for each component. This reduces the size and complexity of the core scene file, improves code organization and makes individual parts of the scene graph easier to maintain and extend. As part of this refactor, drop unnecessary pointer indirection when passing scene trees (e.g. &scene->tree → scene->tree) and update all call sites accordingly. No functional changes intended.
This commit is contained in:
parent
b806de1d8c
commit
04501f8d8b
21 changed files with 2970 additions and 1999 deletions
|
|
@ -3,10 +3,6 @@
|
|||
|
||||
#include <wlr/types/wlr_scene.h>
|
||||
|
||||
struct wlr_scene *scene_node_get_root(struct wlr_scene_node *node);
|
||||
|
||||
void scene_node_get_size(struct wlr_scene_node *node, int *width, int *height);
|
||||
|
||||
void scene_surface_set_clip(struct wlr_scene_surface *surface, struct wlr_box *clip);
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -25,6 +25,8 @@
|
|||
#include <wlr/render/wlr_renderer.h>
|
||||
#include <wlr/types/wlr_damage_ring.h>
|
||||
#include <wlr/types/wlr_linux_dmabuf_v1.h>
|
||||
#include <wlr/types/wlr_scene_tree.h>
|
||||
#include <wlr/types/wlr_scene_buffer.h>
|
||||
#include <wlr/util/addon.h>
|
||||
#include <wlr/util/box.h>
|
||||
|
||||
|
|
@ -46,57 +48,18 @@ struct wlr_gamma_control_manager_v1;
|
|||
struct wlr_color_manager_v1;
|
||||
struct wlr_output_state;
|
||||
|
||||
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);
|
||||
|
||||
enum wlr_scene_node_type {
|
||||
WLR_SCENE_NODE_TREE,
|
||||
WLR_SCENE_NODE_RECT,
|
||||
WLR_SCENE_NODE_BUFFER,
|
||||
};
|
||||
|
||||
/** A node is an object in the scene. */
|
||||
struct wlr_scene_node {
|
||||
enum wlr_scene_node_type type;
|
||||
struct wlr_scene_tree *parent;
|
||||
|
||||
struct wl_list link; // wlr_scene_tree.children
|
||||
|
||||
bool enabled;
|
||||
int x, y; // relative to parent
|
||||
|
||||
struct {
|
||||
struct wl_signal destroy;
|
||||
} events;
|
||||
|
||||
void *data;
|
||||
|
||||
struct wlr_addon_set addons;
|
||||
|
||||
struct {
|
||||
pixman_region32_t visible;
|
||||
} WLR_PRIVATE;
|
||||
};
|
||||
|
||||
enum wlr_scene_debug_damage_option {
|
||||
WLR_SCENE_DEBUG_DAMAGE_NONE,
|
||||
WLR_SCENE_DEBUG_DAMAGE_RERENDER,
|
||||
WLR_SCENE_DEBUG_DAMAGE_HIGHLIGHT
|
||||
};
|
||||
|
||||
/** A sub-tree in the scene-graph. */
|
||||
struct wlr_scene_tree {
|
||||
struct wlr_scene_node node;
|
||||
|
||||
struct wl_list children; // wlr_scene_node.link
|
||||
};
|
||||
|
||||
/** The root scene-graph node. */
|
||||
struct wlr_scene {
|
||||
struct wlr_scene_tree tree;
|
||||
struct wlr_scene_tree *tree;
|
||||
|
||||
struct wl_list outputs; // wlr_scene_output.link
|
||||
|
||||
|
|
@ -138,13 +101,6 @@ struct wlr_scene_surface {
|
|||
} WLR_PRIVATE;
|
||||
};
|
||||
|
||||
/** A scene-graph node displaying a solid-colored rectangle */
|
||||
struct wlr_scene_rect {
|
||||
struct wlr_scene_node node;
|
||||
int width, height;
|
||||
float color[4];
|
||||
};
|
||||
|
||||
struct wlr_scene_outputs_update_event {
|
||||
struct wlr_scene_output **active;
|
||||
size_t size;
|
||||
|
|
@ -157,68 +113,6 @@ struct wlr_scene_output_sample_event {
|
|||
uint64_t release_point;
|
||||
};
|
||||
|
||||
struct wlr_scene_frame_done_event {
|
||||
struct wlr_scene_output *output;
|
||||
struct timespec when;
|
||||
};
|
||||
|
||||
/** A scene-graph node displaying a buffer */
|
||||
struct wlr_scene_buffer {
|
||||
struct wlr_scene_node node;
|
||||
|
||||
// May be NULL
|
||||
struct wlr_buffer *buffer;
|
||||
|
||||
struct {
|
||||
struct wl_signal outputs_update; // struct wlr_scene_outputs_update_event
|
||||
struct wl_signal output_sample; // struct wlr_scene_output_sample_event
|
||||
struct wl_signal frame_done; // struct wlr_scene_frame_done_event
|
||||
} events;
|
||||
|
||||
// May be NULL
|
||||
wlr_scene_buffer_point_accepts_input_func_t point_accepts_input;
|
||||
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
struct wlr_scene_output *primary_output;
|
||||
|
||||
float opacity;
|
||||
enum wlr_scale_filter_mode filter_mode;
|
||||
struct wlr_fbox src_box;
|
||||
int dst_width, dst_height;
|
||||
enum wl_output_transform transform;
|
||||
pixman_region32_t opaque_region;
|
||||
enum wlr_color_transfer_function transfer_function;
|
||||
enum wlr_color_named_primaries primaries;
|
||||
enum wlr_color_encoding color_encoding;
|
||||
enum wlr_color_range color_range;
|
||||
|
||||
struct {
|
||||
uint64_t active_outputs;
|
||||
struct wlr_texture *texture;
|
||||
struct wlr_linux_dmabuf_feedback_v1_init_options prev_feedback_options;
|
||||
|
||||
bool own_buffer;
|
||||
int buffer_width, buffer_height;
|
||||
bool buffer_is_opaque;
|
||||
|
||||
struct wlr_drm_syncobj_timeline *wait_timeline;
|
||||
uint64_t wait_point;
|
||||
|
||||
struct wl_listener buffer_release;
|
||||
struct wl_listener renderer_destroy;
|
||||
|
||||
// True if the underlying buffer is a wlr_single_pixel_buffer_v1
|
||||
bool is_single_pixel_buffer;
|
||||
// If is_single_pixel_buffer is set, contains the color of the buffer
|
||||
// as {R, G, B, A} where the max value of each component is UINT32_MAX
|
||||
uint32_t single_pixel_buffer_color[4];
|
||||
} WLR_PRIVATE;
|
||||
};
|
||||
|
||||
/** A viewport for an output in the scene-graph */
|
||||
struct wlr_scene_output {
|
||||
struct wlr_output *output;
|
||||
|
|
@ -289,66 +183,6 @@ struct wlr_scene_layer_surface_v1 {
|
|||
} WLR_PRIVATE;
|
||||
};
|
||||
|
||||
/**
|
||||
* Immediately destroy the scene-graph node.
|
||||
*/
|
||||
void wlr_scene_node_destroy(struct wlr_scene_node *node);
|
||||
/**
|
||||
* 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);
|
||||
/**
|
||||
* 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.
|
||||
* Asserts that node and sibling are distinct and share the same parent.
|
||||
*/
|
||||
void wlr_scene_node_place_above(struct wlr_scene_node *node,
|
||||
struct wlr_scene_node *sibling);
|
||||
/**
|
||||
* Move the node right below the specified sibling.
|
||||
* Asserts that node and sibling are distinct and share the same parent.
|
||||
*/
|
||||
void wlr_scene_node_place_below(struct wlr_scene_node *node,
|
||||
struct wlr_scene_node *sibling);
|
||||
/**
|
||||
* 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);
|
||||
/**
|
||||
* Move the node to another location in the tree.
|
||||
*/
|
||||
void wlr_scene_node_reparent(struct wlr_scene_node *node,
|
||||
struct wlr_scene_tree *new_parent);
|
||||
/**
|
||||
* 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);
|
||||
/**
|
||||
* 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
|
||||
* (in rendering order).
|
||||
*/
|
||||
void wlr_scene_node_for_each_buffer(struct wlr_scene_node *node,
|
||||
wlr_scene_buffer_iterator_func_t iterator, void *user_data);
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
struct wlr_scene_node *wlr_scene_node_at(struct wlr_scene_node *node,
|
||||
double lx, double ly, double *nx, double *ny);
|
||||
|
||||
/**
|
||||
* Create a new scene-graph.
|
||||
*
|
||||
|
|
@ -357,6 +191,8 @@ struct wlr_scene_node *wlr_scene_node_at(struct wlr_scene_node *node,
|
|||
*/
|
||||
struct wlr_scene *wlr_scene_create(void);
|
||||
|
||||
void wlr_scene_destroy(struct wlr_scene *scene);
|
||||
|
||||
/**
|
||||
* Handles linux_dmabuf_v1 feedback for all surfaces in the scene.
|
||||
*
|
||||
|
|
@ -381,11 +217,6 @@ void wlr_scene_set_gamma_control_manager_v1(struct wlr_scene *scene,
|
|||
*/
|
||||
void wlr_scene_set_color_manager_v1(struct wlr_scene *scene, struct wlr_color_manager_v1 *manager);
|
||||
|
||||
/**
|
||||
* Add a node displaying nothing but its children.
|
||||
*/
|
||||
struct wlr_scene_tree *wlr_scene_tree_create(struct wlr_scene_tree *parent);
|
||||
|
||||
/**
|
||||
* Add a node displaying a single surface to the scene-graph.
|
||||
*
|
||||
|
|
@ -416,24 +247,6 @@ struct wlr_scene_tree *wlr_scene_tree_create(struct wlr_scene_tree *parent);
|
|||
struct wlr_scene_surface *wlr_scene_surface_create(struct wlr_scene_tree *parent,
|
||||
struct wlr_surface *surface);
|
||||
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
struct wlr_scene_buffer *wlr_scene_buffer_from_node(struct wlr_scene_node *node);
|
||||
|
||||
/**
|
||||
* 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);
|
||||
|
||||
/**
|
||||
* 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);
|
||||
|
||||
/**
|
||||
* If this buffer is backed by a surface, then the struct wlr_scene_surface is
|
||||
* returned. If not, NULL will be returned.
|
||||
|
|
@ -447,135 +260,6 @@ struct wlr_scene_surface *wlr_scene_surface_try_from_buffer(
|
|||
void wlr_scene_surface_send_frame_done(struct wlr_scene_surface *scene_surface,
|
||||
const struct timespec *when);
|
||||
|
||||
/**
|
||||
* Add a node displaying a solid-colored rectangle to the scene-graph.
|
||||
*
|
||||
* The color argument must be a premultiplied color value.
|
||||
*/
|
||||
struct wlr_scene_rect *wlr_scene_rect_create(struct wlr_scene_tree *parent,
|
||||
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.
|
||||
*
|
||||
* The color argument must be a premultiplied color value.
|
||||
*/
|
||||
void wlr_scene_rect_set_color(struct wlr_scene_rect *rect, const float color[static 4]);
|
||||
|
||||
/**
|
||||
* Add a node displaying a buffer to the scene-graph.
|
||||
*
|
||||
* If the buffer is NULL, this node will not be displayed.
|
||||
*/
|
||||
struct wlr_scene_buffer *wlr_scene_buffer_create(struct wlr_scene_tree *parent,
|
||||
struct wlr_buffer *buffer);
|
||||
|
||||
/**
|
||||
* 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);
|
||||
|
||||
/**
|
||||
* 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,
|
||||
struct wlr_buffer *buffer, const pixman_region32_t *region);
|
||||
|
||||
/**
|
||||
* Options for wlr_scene_buffer_set_buffer_with_options().
|
||||
*/
|
||||
struct wlr_scene_buffer_set_buffer_options {
|
||||
// The damage region is in buffer-local coordinates. If the region is NULL,
|
||||
// the whole buffer node will be damaged.
|
||||
const pixman_region32_t *damage;
|
||||
|
||||
// Wait for a timeline synchronization point before reading from the buffer.
|
||||
struct wlr_drm_syncobj_timeline *wait_timeline;
|
||||
uint64_t wait_point;
|
||||
};
|
||||
|
||||
/**
|
||||
* Sets the buffer's backing buffer.
|
||||
*
|
||||
* If the buffer is NULL, the buffer node will not be displayed. If options is
|
||||
* NULL, empty options are used.
|
||||
*/
|
||||
void wlr_scene_buffer_set_buffer_with_options(struct wlr_scene_buffer *scene_buffer,
|
||||
struct wlr_buffer *buffer, const struct wlr_scene_buffer_set_buffer_options *options);
|
||||
|
||||
/**
|
||||
* 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,
|
||||
const pixman_region32_t *region);
|
||||
|
||||
/**
|
||||
* 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);
|
||||
|
||||
/**
|
||||
* 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);
|
||||
|
||||
/**
|
||||
* 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);
|
||||
|
||||
/**
|
||||
* Sets the opacity of this buffer
|
||||
*/
|
||||
void wlr_scene_buffer_set_opacity(struct wlr_scene_buffer *scene_buffer,
|
||||
float opacity);
|
||||
|
||||
/**
|
||||
* 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);
|
||||
|
||||
void wlr_scene_buffer_set_transfer_function(struct wlr_scene_buffer *scene_buffer,
|
||||
enum wlr_color_transfer_function transfer_function);
|
||||
|
||||
void wlr_scene_buffer_set_primaries(struct wlr_scene_buffer *scene_buffer,
|
||||
enum wlr_color_named_primaries primaries);
|
||||
|
||||
void wlr_scene_buffer_set_color_encoding(struct wlr_scene_buffer *scene_buffer,
|
||||
enum wlr_color_encoding encoding);
|
||||
|
||||
void wlr_scene_buffer_set_color_range(struct wlr_scene_buffer *scene_buffer,
|
||||
enum wlr_color_range range);
|
||||
|
||||
/**
|
||||
* Calls the buffer's frame_done signal.
|
||||
*/
|
||||
void wlr_scene_buffer_send_frame_done(struct wlr_scene_buffer *scene_buffer,
|
||||
struct wlr_scene_frame_done_event *event);
|
||||
|
||||
/**
|
||||
* Add a viewport for the specified output to the scene-graph.
|
||||
*
|
||||
|
|
|
|||
209
include/wlr/types/wlr_scene_buffer.h
Normal file
209
include/wlr/types/wlr_scene_buffer.h
Normal file
|
|
@ -0,0 +1,209 @@
|
|||
#ifndef WLR_TYPES_WLR_SCENE_BUFFER_H
|
||||
#define WLR_TYPES_WLR_SCENE_BUFFER_H
|
||||
|
||||
#include <wlr/types/wlr_scene_node.h>
|
||||
#include <wayland-server-core.h>
|
||||
#include <wlr/render/wlr_renderer.h>
|
||||
#include <wlr/types/wlr_damage_ring.h>
|
||||
#include <wlr/types/wlr_linux_dmabuf_v1.h>
|
||||
#include <wlr/util/addon.h>
|
||||
#include <wlr/util/box.h>
|
||||
|
||||
struct wlr_scene_buffer;
|
||||
|
||||
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);
|
||||
|
||||
/** A scene-graph node displaying a buffer */
|
||||
struct wlr_scene_buffer {
|
||||
struct wlr_scene_node node;
|
||||
|
||||
// May be NULL
|
||||
struct wlr_buffer *buffer;
|
||||
|
||||
struct {
|
||||
struct wl_signal outputs_update; // struct wlr_scene_outputs_update_event
|
||||
struct wl_signal output_enter; // struct wlr_scene_output
|
||||
struct wl_signal output_leave; // struct wlr_scene_output
|
||||
struct wl_signal output_sample; // struct wlr_scene_output_sample_event
|
||||
struct wl_signal frame_done; // struct timespec
|
||||
} events;
|
||||
|
||||
// May be NULL
|
||||
wlr_scene_buffer_point_accepts_input_func_t point_accepts_input;
|
||||
|
||||
/**
|
||||
* 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;
|
||||
|
||||
float opacity;
|
||||
enum wlr_scale_filter_mode filter_mode;
|
||||
struct wlr_fbox src_box;
|
||||
int dst_width, dst_height;
|
||||
enum wl_output_transform transform;
|
||||
pixman_region32_t opaque_region;
|
||||
enum wlr_color_transfer_function transfer_function;
|
||||
enum wlr_color_named_primaries primaries;
|
||||
enum wlr_color_encoding color_encoding;
|
||||
enum wlr_color_range color_range;
|
||||
|
||||
|
||||
struct {
|
||||
uint64_t active_outputs;
|
||||
struct wlr_texture *texture;
|
||||
struct wlr_linux_dmabuf_feedback_v1_init_options prev_feedback_options;
|
||||
|
||||
bool own_buffer;
|
||||
int buffer_width, buffer_height;
|
||||
bool buffer_is_opaque;
|
||||
|
||||
struct wlr_drm_syncobj_timeline *wait_timeline;
|
||||
uint64_t wait_point;
|
||||
|
||||
struct wl_listener buffer_release;
|
||||
struct wl_listener renderer_destroy;
|
||||
|
||||
// True if the underlying buffer is a wlr_single_pixel_buffer_v1
|
||||
bool is_single_pixel_buffer;
|
||||
// If is_single_pixel_buffer is set, contains the color of the buffer
|
||||
// as {R, G, B, A} where the max value of each component is UINT32_MAX
|
||||
uint32_t single_pixel_buffer_color[4];
|
||||
} WLR_PRIVATE;
|
||||
};
|
||||
|
||||
/**
|
||||
* Add a node displaying a buffer to the scene-graph.
|
||||
*
|
||||
* If the buffer is NULL, this node will not be displayed.
|
||||
*/
|
||||
struct wlr_scene_buffer *wlr_scene_buffer_create(struct wlr_scene_tree *parent,
|
||||
struct wlr_buffer *buffer);
|
||||
|
||||
/**
|
||||
* 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);
|
||||
|
||||
/**
|
||||
* 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,
|
||||
struct wlr_buffer *buffer, const pixman_region32_t *region);
|
||||
|
||||
/**
|
||||
* Options for wlr_scene_buffer_set_buffer_with_options().
|
||||
*/
|
||||
struct wlr_scene_buffer_set_buffer_options {
|
||||
// The damage region is in buffer-local coordinates. If the region is NULL,
|
||||
// the whole buffer node will be damaged.
|
||||
const pixman_region32_t *damage;
|
||||
|
||||
// Wait for a timeline synchronization point before reading from the buffer.
|
||||
struct wlr_drm_syncobj_timeline *wait_timeline;
|
||||
uint64_t wait_point;
|
||||
};
|
||||
|
||||
/**
|
||||
* Sets the buffer's backing buffer.
|
||||
*
|
||||
* If the buffer is NULL, the buffer node will not be displayed. If options is
|
||||
* NULL, empty options are used.
|
||||
*/
|
||||
void wlr_scene_buffer_set_buffer_with_options(struct wlr_scene_buffer *scene_buffer,
|
||||
struct wlr_buffer *buffer, const struct wlr_scene_buffer_set_buffer_options *options);
|
||||
|
||||
/**
|
||||
* 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,
|
||||
const pixman_region32_t *region);
|
||||
|
||||
/**
|
||||
* 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);
|
||||
|
||||
/**
|
||||
* 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);
|
||||
|
||||
/**
|
||||
* 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);
|
||||
|
||||
/**
|
||||
* Sets the opacity of this buffer
|
||||
*/
|
||||
void wlr_scene_buffer_set_opacity(struct wlr_scene_buffer *scene_buffer,
|
||||
float opacity);
|
||||
|
||||
/**
|
||||
* 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);
|
||||
|
||||
struct wlr_scene_frame_done_event {
|
||||
struct wlr_scene_output *output;
|
||||
struct timespec when;
|
||||
};
|
||||
|
||||
/**
|
||||
* Calls the buffer's frame_done signal.
|
||||
*/
|
||||
void wlr_scene_buffer_send_frame_done(struct wlr_scene_buffer *scene_buffer,
|
||||
struct wlr_scene_frame_done_event *event);
|
||||
|
||||
bool wlr_scene_node_is_buffer(const struct wlr_scene_node *node);
|
||||
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
struct wlr_scene_buffer *wlr_scene_buffer_from_node(struct wlr_scene_node *node);
|
||||
|
||||
void wlr_scene_buffer_set_transfer_function(struct wlr_scene_buffer *scene_buffer,
|
||||
enum wlr_color_transfer_function transfer_function);
|
||||
|
||||
void wlr_scene_buffer_set_primaries(struct wlr_scene_buffer *scene_buffer,
|
||||
enum wlr_color_named_primaries primaries);
|
||||
|
||||
void wlr_scene_buffer_set_color_encoding(struct wlr_scene_buffer *scene_buffer,
|
||||
enum wlr_color_encoding encoding);
|
||||
|
||||
void wlr_scene_buffer_set_color_range(struct wlr_scene_buffer *scene_buffer,
|
||||
enum wlr_color_range range);
|
||||
|
||||
/**
|
||||
* 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
|
||||
* (in rendering order).
|
||||
*/
|
||||
void wlr_scene_node_for_each_buffer(struct wlr_scene_node *node,
|
||||
wlr_scene_buffer_iterator_func_t iterator, void *user_data);
|
||||
#endif // WLR_TYPES_WLR_SCENE_BUFFER_H
|
||||
184
include/wlr/types/wlr_scene_node.h
Normal file
184
include/wlr/types/wlr_scene_node.h
Normal file
|
|
@ -0,0 +1,184 @@
|
|||
#ifndef WLR_USE_UNSTABLE
|
||||
#error "Add -DWLR_USE_UNSTABLE to enable unstable wlroots features"
|
||||
#endif
|
||||
|
||||
#ifndef WLR_TYPES_WLR_SCENE_NODE_H
|
||||
#define WLR_TYPES_WLR_SCENE_NODE_H
|
||||
|
||||
#include <pixman.h>
|
||||
#include <wayland-server-core.h>
|
||||
#include <wlr/util/addon.h>
|
||||
#include <wlr/util/box.h>
|
||||
#include <wlr/config.h>
|
||||
|
||||
#include <time.h>
|
||||
|
||||
#if WLR_HAS_XWAYLAND
|
||||
#include <wlr/xwayland/xwayland.h>
|
||||
#endif
|
||||
|
||||
struct wlr_scene_node;
|
||||
struct wlr_scene_output;
|
||||
struct wlr_render_list_entry;
|
||||
struct wlr_render_data;
|
||||
struct wlr_scene;
|
||||
struct wlr_scene_buffer;
|
||||
struct wlr_linux_dmabuf_feedback_v1_init_options;
|
||||
|
||||
typedef bool (*scene_node_box_iterator_func_t)(struct wlr_scene_node *node,
|
||||
int sx, int sy, void *data);
|
||||
|
||||
struct wlr_scene_update_data {
|
||||
pixman_region32_t *visible;
|
||||
const pixman_region32_t *update_region;
|
||||
struct wlr_box update_box;
|
||||
struct wl_list *outputs;
|
||||
bool calculate_visibility;
|
||||
bool restack_xwayland_surfaces;
|
||||
|
||||
#if WLR_HAS_XWAYLAND
|
||||
struct wlr_xwayland_surface *restack_above;
|
||||
#endif
|
||||
};
|
||||
|
||||
struct wlr_render_data {
|
||||
enum wl_output_transform transform;
|
||||
float scale;
|
||||
struct wlr_box logical;
|
||||
int trans_width, trans_height;
|
||||
|
||||
struct wlr_scene_output *output;
|
||||
|
||||
struct wlr_render_pass *render_pass;
|
||||
pixman_region32_t damage;
|
||||
};
|
||||
|
||||
struct wlr_render_list_constructor_data {
|
||||
struct wlr_box box;
|
||||
struct wl_array *render_list;
|
||||
bool calculate_visibility;
|
||||
bool highlight_transparent_region;
|
||||
bool fractional_scale;
|
||||
};
|
||||
|
||||
struct wlr_render_list_entry {
|
||||
struct wlr_scene_node *node;
|
||||
bool highlight_transparent_region;
|
||||
int x, y;
|
||||
};
|
||||
|
||||
struct wlr_scene_node_impl {
|
||||
void (*destroy)(struct wlr_scene_node *node);
|
||||
void (*set_enabled)(struct wlr_scene_node *node, bool enabled);
|
||||
void (*set_position)(struct wlr_scene_node *node, int x, int y);
|
||||
void (*bounds)(struct wlr_scene_node *node,
|
||||
int x, int y, pixman_region32_t *visible);
|
||||
void (*get_size)(struct wlr_scene_node *node,
|
||||
int *width, int *height);
|
||||
bool (*coords)(struct wlr_scene_node *node, int *lx_ptr, int *ly_ptr);
|
||||
struct wlr_scene_node *(*at)(struct wlr_scene_node *node,
|
||||
double lx, double ly, double *nx, double *ny);
|
||||
bool (*in_box)(struct wlr_scene_node *node, struct wlr_box *box,
|
||||
scene_node_box_iterator_func_t iterator, void *user_data);
|
||||
void (*opaque_region)(struct wlr_scene_node *node, int x, int y,
|
||||
pixman_region32_t *opaque);
|
||||
void (*update_outputs)(struct wlr_scene_node *node,
|
||||
struct wl_list *outputs, struct wlr_scene_output *ignore,
|
||||
struct wlr_scene_output *force);
|
||||
void (*update)(struct wlr_scene_node *node,
|
||||
pixman_region32_t *damage);
|
||||
void (*visibility)(struct wlr_scene_node *node,
|
||||
pixman_region32_t *visible);
|
||||
void (*frame_done)(struct wlr_scene_node *node,
|
||||
struct wlr_scene_output *scene_output, struct timespec *now);
|
||||
bool (*invisible)(struct wlr_scene_node *node);
|
||||
bool (*construct_render_list_iterator)(struct wlr_scene_node *node,
|
||||
int lx, int ly, void *_data);
|
||||
void (*render)(struct wlr_render_list_entry *entry, const struct wlr_render_data *data);
|
||||
void (*dmabuf_feedback)(struct wlr_render_list_entry *entry,
|
||||
struct wlr_scene_output *scene_output);
|
||||
void (*get_extents)(struct wlr_scene_node *node, int lx, int ly,
|
||||
int *x_min, int *y_min, int *x_max, int *y_max);
|
||||
struct wl_list *(*get_children)(struct wlr_scene_node *node);
|
||||
void (*restack_xwayland_surface)(struct wlr_scene_node *node,
|
||||
struct wlr_box *box, struct wlr_scene_update_data *data);
|
||||
void (*cleanup_when_disabled)(struct wlr_scene_node *node,
|
||||
bool xwayland_restack, struct wl_list *outputs);
|
||||
};
|
||||
|
||||
struct wlr_scene_node {
|
||||
const struct wlr_scene_node_impl *impl;
|
||||
|
||||
struct wlr_scene_tree *parent;
|
||||
struct wlr_scene *scene;
|
||||
|
||||
struct wl_list link; // wlr_scene_tree.children
|
||||
|
||||
bool enabled;
|
||||
int x, y; // relative to parent
|
||||
|
||||
struct {
|
||||
struct wl_signal destroy;
|
||||
} events;
|
||||
|
||||
void *data;
|
||||
|
||||
struct wlr_addon_set addons;
|
||||
|
||||
struct {
|
||||
pixman_region32_t visible;
|
||||
} WLR_PRIVATE;
|
||||
|
||||
struct wl_list children; // wlr_scene_node.link
|
||||
};
|
||||
|
||||
void wlr_scene_node_init(struct wlr_scene_node *node,
|
||||
const struct wlr_scene_node_impl *impl, struct wlr_scene_tree *parent);
|
||||
void wlr_scene_node_destroy(struct wlr_scene_node *node);
|
||||
|
||||
void wlr_scene_node_set_enabled(struct wlr_scene_node *node, bool enabled);
|
||||
void wlr_scene_node_set_position(struct wlr_scene_node *node, int x, int y);
|
||||
void wlr_scene_node_place_above(struct wlr_scene_node *node,
|
||||
struct wlr_scene_node *sibling);
|
||||
void wlr_scene_node_place_below(struct wlr_scene_node *node,
|
||||
struct wlr_scene_node *sibling);
|
||||
void wlr_scene_node_raise_to_top(struct wlr_scene_node *node);
|
||||
void wlr_scene_node_lower_to_bottom(struct wlr_scene_node *node);
|
||||
void wlr_scene_node_reparent(struct wlr_scene_node *node,
|
||||
struct wlr_scene_tree *new_parent);
|
||||
void wlr_scene_node_bounds(struct wlr_scene_node *node,
|
||||
int x, int y, pixman_region32_t *visible);
|
||||
void wlr_scene_node_get_size(struct wlr_scene_node *node,
|
||||
int *width, int *height);
|
||||
bool wlr_scene_node_coords(struct wlr_scene_node *node, int *lx_ptr, int *ly_ptr);
|
||||
struct wlr_scene_node *wlr_scene_node_at(struct wlr_scene_node *node,
|
||||
double lx, double ly, double *nx, double *ny);
|
||||
bool wlr_scene_node_nodes_in_box(struct wlr_scene_node *node, struct wlr_box *box,
|
||||
scene_node_box_iterator_func_t iterator, void *user_data);
|
||||
void wlr_scene_node_opaque_region(struct wlr_scene_node *node, int x, int y,
|
||||
pixman_region32_t *opaque);
|
||||
void wlr_scene_node_update_outputs(struct wlr_scene_node *node,
|
||||
struct wl_list *outputs, struct wlr_scene_output *ignore,
|
||||
struct wlr_scene_output *force);
|
||||
void wlr_scene_node_update(struct wlr_scene_node *node,
|
||||
pixman_region32_t *damage);
|
||||
void wlr_scene_node_visibility(struct wlr_scene_node *node,
|
||||
pixman_region32_t *visible);
|
||||
void wlr_scene_node_send_frame_done(struct wlr_scene_node *node,
|
||||
struct wlr_scene_output *scene_output, struct timespec *now);
|
||||
bool wlr_scene_node_invisible(struct wlr_scene_node *node);
|
||||
bool wlr_scene_node_construct_render_list_iterator(struct wlr_scene_node *node,
|
||||
int lx, int ly, void *_data);
|
||||
void wlr_scene_node_render(struct wlr_render_list_entry *entry, const struct wlr_render_data *data);
|
||||
void wlr_scene_node_dmabuf_feedback(struct wlr_render_list_entry *entry,
|
||||
struct wlr_scene_output *scene_output);
|
||||
void wlr_scene_node_restack_xwayland_surface_below(struct wlr_scene_node *node);
|
||||
void wlr_scene_node_get_extents(struct wlr_scene_node *node, int lx, int ly,
|
||||
int *x_min, int *y_min, int *x_max, int *y_max);
|
||||
struct wl_list *wlr_scene_node_get_children(struct wlr_scene_node *node);
|
||||
void wlr_scene_node_restack_xwayland_surface(struct wlr_scene_node *node,
|
||||
struct wlr_box *box, struct wlr_scene_update_data *data);
|
||||
void wlr_scene_node_cleanup_when_disabled(struct wlr_scene_node *node,
|
||||
bool xwayland_restack, struct wl_list *outputs);
|
||||
|
||||
#endif
|
||||
40
include/wlr/types/wlr_scene_rect.h
Normal file
40
include/wlr/types/wlr_scene_rect.h
Normal file
|
|
@ -0,0 +1,40 @@
|
|||
#ifndef WLR_TYPES_WLR_SCENE_RECT_H
|
||||
#define WLR_TYPES_WLR_SCENE_RECT_H
|
||||
|
||||
#include <wlr/types/wlr_scene_node.h>
|
||||
|
||||
struct wlr_scene_rect {
|
||||
struct wlr_scene_node node;
|
||||
int width, height;
|
||||
float color[4];
|
||||
};
|
||||
|
||||
/**
|
||||
* Add a node displaying a solid-colored rectangle to the scene-graph.
|
||||
*
|
||||
* The color argument must be a premultiplied color value.
|
||||
*/
|
||||
struct wlr_scene_rect *wlr_scene_rect_create(struct wlr_scene_tree *parent,
|
||||
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.
|
||||
*
|
||||
* The color argument must be a premultiplied color value.
|
||||
*/
|
||||
void wlr_scene_rect_set_color(struct wlr_scene_rect *rect, const float color[static 4]);
|
||||
|
||||
bool wlr_scene_node_is_rect(const struct wlr_scene_node *node);
|
||||
|
||||
/**
|
||||
* 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);
|
||||
|
||||
#endif
|
||||
32
include/wlr/types/wlr_scene_tree.h
Normal file
32
include/wlr/types/wlr_scene_tree.h
Normal file
|
|
@ -0,0 +1,32 @@
|
|||
#ifndef WLR_TYPES_WLR_SCENE_TREE_H
|
||||
#define WLR_TYPES_WLR_SCENE_TREE_H
|
||||
|
||||
#include <stdbool.h>
|
||||
|
||||
#include <wlr/types/wlr_scene_node.h>
|
||||
|
||||
#include <wayland-server-core.h>
|
||||
|
||||
struct wlr_scene;
|
||||
|
||||
struct wlr_scene_tree {
|
||||
struct wlr_scene_node node;
|
||||
|
||||
struct wl_list children; // wlr_scene_node.link
|
||||
};
|
||||
|
||||
/**
|
||||
* Add a node displaying nothing but its children.
|
||||
*/
|
||||
struct wlr_scene_tree *wlr_scene_tree_create(struct wlr_scene_tree *parent);
|
||||
struct wlr_scene_tree *wlr_root_scene_tree_create(struct wlr_scene *scene);
|
||||
|
||||
bool wlr_scene_node_is_tree(const struct wlr_scene_node *node);
|
||||
|
||||
/**
|
||||
* 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);
|
||||
|
||||
#endif // WLR_TYPES_WLR_SCENE_TREE_H
|
||||
Loading…
Add table
Add a link
Reference in a new issue