mirror of
				https://gitlab.freedesktop.org/wlroots/wlroots.git
				synced 2025-11-03 09:01:40 -05:00 
			
		
		
		
	wlr_scene: Change out surface specific iterator functions
Instead iterate over wlr_scene_buffer
This commit is contained in:
		
							parent
							
								
									5f56246571
								
							
						
					
					
						commit
						20cc1ce0b9
					
				
					 2 changed files with 33 additions and 29 deletions
				
			
		| 
						 | 
					@ -28,11 +28,18 @@ struct wlr_output_layout;
 | 
				
			||||||
struct wlr_xdg_surface;
 | 
					struct wlr_xdg_surface;
 | 
				
			||||||
struct wlr_layer_surface_v1;
 | 
					struct wlr_layer_surface_v1;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					struct wlr_scene_node;
 | 
				
			||||||
struct wlr_scene_buffer;
 | 
					struct wlr_scene_buffer;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					typedef void (*wlr_scene_node_iterator_func_t)(struct wlr_scene_node *node,
 | 
				
			||||||
 | 
						int sx, int sy, void *data);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
typedef bool (*wlr_scene_buffer_point_accepts_input_func_t)(
 | 
					typedef bool (*wlr_scene_buffer_point_accepts_input_func_t)(
 | 
				
			||||||
	struct wlr_scene_buffer *buffer, int sx, int sy);
 | 
						struct wlr_scene_buffer *buffer, int sx, int 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 {
 | 
					enum wlr_scene_node_type {
 | 
				
			||||||
	WLR_SCENE_NODE_ROOT,
 | 
						WLR_SCENE_NODE_ROOT,
 | 
				
			||||||
	WLR_SCENE_NODE_TREE,
 | 
						WLR_SCENE_NODE_TREE,
 | 
				
			||||||
| 
						 | 
					@ -176,9 +183,6 @@ struct wlr_scene_layer_surface_v1 {
 | 
				
			||||||
	struct wl_listener layer_surface_unmap;
 | 
						struct wl_listener layer_surface_unmap;
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
typedef void (*wlr_scene_node_iterator_func_t)(struct wlr_scene_node *node,
 | 
					 | 
				
			||||||
	int sx, int sy, void *data);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
/**
 | 
					/**
 | 
				
			||||||
 * Immediately destroy the scene-graph node.
 | 
					 * Immediately destroy the scene-graph node.
 | 
				
			||||||
 */
 | 
					 */
 | 
				
			||||||
| 
						 | 
					@ -224,12 +228,12 @@ void wlr_scene_node_reparent(struct wlr_scene_node *node,
 | 
				
			||||||
 */
 | 
					 */
 | 
				
			||||||
bool wlr_scene_node_coords(struct wlr_scene_node *node, int *lx, int *ly);
 | 
					bool wlr_scene_node_coords(struct wlr_scene_node *node, int *lx, int *ly);
 | 
				
			||||||
/**
 | 
					/**
 | 
				
			||||||
 * Call `iterator` on each surface in the scene-graph, with the surface's
 | 
					 * 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
 | 
					 * position in layout coordinates. The function is called from root to leaves
 | 
				
			||||||
 * (in rendering order).
 | 
					 * (in rendering order).
 | 
				
			||||||
 */
 | 
					 */
 | 
				
			||||||
void wlr_scene_node_for_each_surface(struct wlr_scene_node *node,
 | 
					void wlr_scene_node_for_each_buffer(struct wlr_scene_node *node,
 | 
				
			||||||
	wlr_surface_iterator_func_t iterator, void *user_data);
 | 
						wlr_scene_buffer_iterator_func_t iterator, void *user_data);
 | 
				
			||||||
/**
 | 
					/**
 | 
				
			||||||
 * Find the topmost node in this scene-graph that contains the point at the
 | 
					 * Find the topmost node in this scene-graph that contains the point at the
 | 
				
			||||||
 * given layout-local coordinates. (For surface nodes, this means accepting
 | 
					 * given layout-local coordinates. (For surface nodes, this means accepting
 | 
				
			||||||
| 
						 | 
					@ -373,12 +377,12 @@ bool wlr_scene_output_commit(struct wlr_scene_output *scene_output);
 | 
				
			||||||
void wlr_scene_output_send_frame_done(struct wlr_scene_output *scene_output,
 | 
					void wlr_scene_output_send_frame_done(struct wlr_scene_output *scene_output,
 | 
				
			||||||
	struct timespec *now);
 | 
						struct timespec *now);
 | 
				
			||||||
/**
 | 
					/**
 | 
				
			||||||
 * Call `iterator` on each surface in the scene-graph visible on the output,
 | 
					 * Call `iterator` on each buffer in the scene-graph visible on the output,
 | 
				
			||||||
 * with the surface's position in layout coordinates. The function is called
 | 
					 * with the buffer's position in layout coordinates. The function is called
 | 
				
			||||||
 * from root to leaves (in rendering order).
 | 
					 * from root to leaves (in rendering order).
 | 
				
			||||||
 */
 | 
					 */
 | 
				
			||||||
void wlr_scene_output_for_each_surface(struct wlr_scene_output *scene_output,
 | 
					void wlr_scene_output_for_each_buffer(struct wlr_scene_output *scene_output,
 | 
				
			||||||
	wlr_surface_iterator_func_t iterator, void *user_data);
 | 
						wlr_scene_buffer_iterator_func_t iterator, void *user_data);
 | 
				
			||||||
/**
 | 
					/**
 | 
				
			||||||
 * Get a scene-graph output from a wlr_output.
 | 
					 * Get a scene-graph output from a wlr_output.
 | 
				
			||||||
 *
 | 
					 *
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -785,8 +785,8 @@ bool wlr_scene_node_coords(struct wlr_scene_node *node,
 | 
				
			||||||
	return enabled;
 | 
						return enabled;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static void scene_node_for_each_surface(struct wlr_scene_node *node,
 | 
					static void scene_node_for_each_scene_buffer(struct wlr_scene_node *node,
 | 
				
			||||||
		int lx, int ly, wlr_surface_iterator_func_t user_iterator,
 | 
							int lx, int ly, wlr_scene_buffer_iterator_func_t user_iterator,
 | 
				
			||||||
		void *user_data) {
 | 
							void *user_data) {
 | 
				
			||||||
	if (!node->state.enabled) {
 | 
						if (!node->state.enabled) {
 | 
				
			||||||
		return;
 | 
							return;
 | 
				
			||||||
| 
						 | 
					@ -795,20 +795,20 @@ static void scene_node_for_each_surface(struct wlr_scene_node *node,
 | 
				
			||||||
	lx += node->state.x;
 | 
						lx += node->state.x;
 | 
				
			||||||
	ly += node->state.y;
 | 
						ly += node->state.y;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if (node->type == WLR_SCENE_NODE_SURFACE) {
 | 
						if (node->type == WLR_SCENE_NODE_BUFFER) {
 | 
				
			||||||
		struct wlr_scene_surface *scene_surface = wlr_scene_surface_from_node(node);
 | 
							struct wlr_scene_buffer *scene_buffer = wlr_scene_buffer_from_node(node);
 | 
				
			||||||
		user_iterator(scene_surface->surface, lx, ly, user_data);
 | 
							user_iterator(scene_buffer, lx, ly, user_data);
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	struct wlr_scene_node *child;
 | 
						struct wlr_scene_node *child;
 | 
				
			||||||
	wl_list_for_each(child, &node->state.children, state.link) {
 | 
						wl_list_for_each(child, &node->state.children, state.link) {
 | 
				
			||||||
		scene_node_for_each_surface(child, lx, ly, user_iterator, user_data);
 | 
							scene_node_for_each_scene_buffer(child, lx, ly, user_iterator, user_data);
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void wlr_scene_node_for_each_surface(struct wlr_scene_node *node,
 | 
					void wlr_scene_node_for_each_buffer(struct wlr_scene_node *node,
 | 
				
			||||||
		wlr_surface_iterator_func_t user_iterator, void *user_data) {
 | 
							wlr_scene_buffer_iterator_func_t user_iterator, void *user_data) {
 | 
				
			||||||
	scene_node_for_each_surface(node, 0, 0, user_iterator, user_data);
 | 
						scene_node_for_each_scene_buffer(node, 0, 0, user_iterator, user_data);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
struct wlr_scene_node *wlr_scene_node_at(struct wlr_scene_node *node,
 | 
					struct wlr_scene_node *wlr_scene_node_at(struct wlr_scene_node *node,
 | 
				
			||||||
| 
						 | 
					@ -1399,9 +1399,9 @@ void wlr_scene_output_send_frame_done(struct wlr_scene_output *scene_output,
 | 
				
			||||||
		scene_output, now);
 | 
							scene_output, now);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static void scene_output_for_each_surface(const struct wlr_box *output_box,
 | 
					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, int lx, int ly,
 | 
				
			||||||
		wlr_surface_iterator_func_t user_iterator, void *user_data) {
 | 
							wlr_scene_buffer_iterator_func_t user_iterator, void *user_data) {
 | 
				
			||||||
	if (!node->state.enabled) {
 | 
						if (!node->state.enabled) {
 | 
				
			||||||
		return;
 | 
							return;
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
| 
						 | 
					@ -1409,30 +1409,30 @@ static void scene_output_for_each_surface(const struct wlr_box *output_box,
 | 
				
			||||||
	lx += node->state.x;
 | 
						lx += node->state.x;
 | 
				
			||||||
	ly += node->state.y;
 | 
						ly += node->state.y;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if (node->type == WLR_SCENE_NODE_SURFACE) {
 | 
						if (node->type == WLR_SCENE_NODE_BUFFER) {
 | 
				
			||||||
		struct wlr_box node_box = { .x = lx, .y = ly };
 | 
							struct wlr_box node_box = { .x = lx, .y = ly };
 | 
				
			||||||
		scene_node_get_size(node, &node_box.width, &node_box.height);
 | 
							scene_node_get_size(node, &node_box.width, &node_box.height);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		struct wlr_box intersection;
 | 
							struct wlr_box intersection;
 | 
				
			||||||
		if (wlr_box_intersection(&intersection, output_box, &node_box)) {
 | 
							if (wlr_box_intersection(&intersection, output_box, &node_box)) {
 | 
				
			||||||
			struct wlr_scene_surface *scene_surface =
 | 
								struct wlr_scene_buffer *scene_buffer =
 | 
				
			||||||
				wlr_scene_surface_from_node(node);
 | 
									wlr_scene_buffer_from_node(node);
 | 
				
			||||||
			user_iterator(scene_surface->surface, lx, ly, user_data);
 | 
								user_iterator(scene_buffer, lx, ly, user_data);
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	struct wlr_scene_node *child;
 | 
						struct wlr_scene_node *child;
 | 
				
			||||||
	wl_list_for_each(child, &node->state.children, state.link) {
 | 
						wl_list_for_each(child, &node->state.children, state.link) {
 | 
				
			||||||
		scene_output_for_each_surface(output_box, child, lx, ly,
 | 
							scene_output_for_each_scene_buffer(output_box, child, lx, ly,
 | 
				
			||||||
			user_iterator, user_data);
 | 
								user_iterator, user_data);
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void wlr_scene_output_for_each_surface(struct wlr_scene_output *scene_output,
 | 
					void wlr_scene_output_for_each_buffer(struct wlr_scene_output *scene_output,
 | 
				
			||||||
		wlr_surface_iterator_func_t iterator, void *user_data) {
 | 
							wlr_scene_buffer_iterator_func_t iterator, void *user_data) {
 | 
				
			||||||
	struct wlr_box box = { .x = scene_output->x, .y = scene_output->y };
 | 
						struct wlr_box box = { .x = scene_output->x, .y = scene_output->y };
 | 
				
			||||||
	wlr_output_effective_resolution(scene_output->output,
 | 
						wlr_output_effective_resolution(scene_output->output,
 | 
				
			||||||
		&box.width, &box.height);
 | 
							&box.width, &box.height);
 | 
				
			||||||
	scene_output_for_each_surface(&box, &scene_output->scene->node, 0, 0,
 | 
						scene_output_for_each_scene_buffer(&box, &scene_output->scene->node, 0, 0,
 | 
				
			||||||
		iterator, user_data);
 | 
							iterator, user_data);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue