render: pass rendering state together in a struct

This lets us easily add rendering state that we need in the future
This commit is contained in:
Alexander Orzechowski 2023-04-27 11:19:58 +02:00 committed by Simon Ser
parent 33cfdbe886
commit d5cc474aef
6 changed files with 156 additions and 159 deletions

View file

@ -12,6 +12,7 @@
#include "sway/input/text_input.h"
struct sway_seat;
struct render_context;
struct sway_seatop_impl {
void (*button)(struct sway_seat *seat, uint32_t time_msec,
@ -49,8 +50,7 @@ struct sway_seatop_impl {
uint32_t time_msec, enum wlr_tablet_tool_tip_state state);
void (*end)(struct sway_seat *seat);
void (*unref)(struct sway_seat *seat, struct sway_container *con);
void (*render)(struct sway_seat *seat, struct sway_output *output,
const pixman_region32_t *damage);
void (*render)(struct sway_seat *seat, struct render_context *ctx);
bool allow_set_cursor;
};
@ -356,8 +356,7 @@ void seatop_unref(struct sway_seat *seat, struct sway_container *con);
* Instructs a seatop to render anything that it needs to render
* (eg. dropzone for move-tiling)
*/
void seatop_render(struct sway_seat *seat, struct sway_output *output,
const pixman_region32_t *damage);
void seatop_render(struct sway_seat *seat, struct render_context *ctx);
bool seatop_allows_set_cursor(struct sway_seat *seat);

View file

@ -65,6 +65,12 @@ struct sway_output_non_desktop {
struct wl_listener destroy;
};
struct render_context {
struct sway_output *output;
struct wlr_renderer *renderer;
const pixman_region32_t *output_damage;
};
struct sway_output *output_create(struct wlr_output *wlr_output);
void output_destroy(struct sway_output *output);
@ -115,7 +121,7 @@ bool output_has_opaque_overlay_layer_surface(struct sway_output *output);
struct sway_workspace *output_get_active_workspace(struct sway_output *output);
void output_render(struct sway_output *output, pixman_region32_t *damage);
void output_render(struct render_context *ctx);
void output_surface_for_each_surface(struct sway_output *output,
struct wlr_surface *surface, double ox, double oy,
@ -168,8 +174,7 @@ void output_get_box(struct sway_output *output, struct wlr_box *box);
enum sway_container_layout output_get_default_layout(
struct sway_output *output);
void render_rect(struct sway_output *output,
const pixman_region32_t *output_damage, const struct wlr_box *_box,
void render_rect(struct render_context *ctx, const struct wlr_box *_box,
float color[static 4]);
void premultiply_alpha(float color[4], float opacity);