diff options
Diffstat (limited to 'include')
-rw-r--r-- | include/render/fx_renderer/fx_renderer.h | 45 | ||||
-rw-r--r-- | include/render/fx_renderer/fx_stencilbuffer.h | 20 | ||||
-rw-r--r-- | include/types/fx/shadow_data.h | 17 | ||||
-rw-r--r-- | include/wlr/types/wlr_scene.h | 8 |
4 files changed, 90 insertions, 0 deletions
diff --git a/include/render/fx_renderer/fx_renderer.h b/include/render/fx_renderer/fx_renderer.h index 2067c04..f569aa9 100644 --- a/include/render/fx_renderer/fx_renderer.h +++ b/include/render/fx_renderer/fx_renderer.h @@ -8,6 +8,8 @@ #include <wlr/render/wlr_texture.h> #include <wlr/util/addon.h> #include <wlr/util/box.h> +#include "render/fx_renderer/fx_stencilbuffer.h" +#include "types/fx/shadow_data.h" enum fx_tex_shader_source { SHADER_SOURCE_TEXTURE_RGBA = 1, @@ -34,9 +36,32 @@ struct tex_shader { GLint radius; }; +struct stencil_mask_shader { + GLuint program; + GLint proj; + GLint color; + GLint pos_attrib; + GLint half_size; + GLint position; + GLint radius; +}; + +struct box_shadow_shader { + GLuint program; + GLint proj; + GLint color; + GLint pos_attrib; + GLint position; + GLint size; + GLint blur_sigma; + GLint corner_radius; +}; + struct fx_renderer { float projection[9]; + struct fx_stencilbuffer stencil_buffer; + struct wlr_addon addon; struct { @@ -52,6 +77,8 @@ struct fx_renderer { struct tex_shader tex_rgba; struct tex_shader tex_rgbx; struct tex_shader tex_ext; + struct box_shadow_shader box_shadow; + struct stencil_mask_shader stencil_mask; } shaders; }; @@ -71,6 +98,19 @@ void fx_renderer_clear(const float color[static 4]); void fx_renderer_scissor(struct wlr_box *box); +// Initialize the stenciling work +void fx_renderer_stencil_mask_init(void); + +// Close the mask +void fx_renderer_stencil_mask_close(bool draw_inside_mask); + +// Finish stenciling and clear the buffer +void fx_renderer_stencil_mask_fini(void); + +void fx_renderer_stencil_enable(void); + +void fx_renderer_stencil_disable(void); + bool fx_render_subtexture_with_matrix(struct fx_renderer *renderer, struct wlr_texture *wlr_texture, const struct wlr_fbox *src_box, const struct wlr_box *dst_box, const float matrix[static 9], @@ -79,4 +119,9 @@ bool fx_render_subtexture_with_matrix(struct fx_renderer *renderer, void fx_render_rect(struct fx_renderer *renderer, const struct wlr_box *box, const float color[static 4], const float projection[static 9]); +void fx_render_box_shadow(struct fx_renderer *renderer, + const struct wlr_box *box, const struct wlr_box *stencil_box, + const float matrix[static 9], int corner_radius, + struct shadow_data *shadow_data); + #endif diff --git a/include/render/fx_renderer/fx_stencilbuffer.h b/include/render/fx_renderer/fx_stencilbuffer.h new file mode 100644 index 0000000..6909f96 --- /dev/null +++ b/include/render/fx_renderer/fx_stencilbuffer.h @@ -0,0 +1,20 @@ +#ifndef FX_STENCILBUFFER_H +#define FX_STENCILBUFFER_H + +#include <GLES2/gl2.h> +#include <stdbool.h> +#include <wlr/render/wlr_texture.h> + +struct fx_stencilbuffer { + GLuint rb; + int width; + int height; +}; + +struct fx_stencilbuffer fx_stencilbuffer_create(void); + +void fx_stencilbuffer_init(struct fx_stencilbuffer *stencil_buffer, int width, int height); + +void fx_stencilbuffer_release(struct fx_stencilbuffer *stencil_buffer); + +#endif diff --git a/include/types/fx/shadow_data.h b/include/types/fx/shadow_data.h new file mode 100644 index 0000000..804acfe --- /dev/null +++ b/include/types/fx/shadow_data.h @@ -0,0 +1,17 @@ +#ifndef TYPES_DECORATION_DATA +#define TYPES_DECORATION_DATA + +#include <stdbool.h> +#include <wlr/util/addon.h> + +struct shadow_data { + bool enabled; + float *color; + float blur_sigma; +}; + +struct shadow_data shadow_data_get_default(void); + +bool scene_buffer_has_shadow(struct shadow_data *data); + +#endif diff --git a/include/wlr/types/wlr_scene.h b/include/wlr/types/wlr_scene.h index 138e0e2..7b4c002 100644 --- a/include/wlr/types/wlr_scene.h +++ b/include/wlr/types/wlr_scene.h @@ -23,6 +23,7 @@ #include <wayland-server-core.h> #include <wlr/types/wlr_compositor.h> #include <wlr/types/wlr_damage_ring.h> +#include "types/fx/shadow_data.h" struct wlr_output; struct wlr_output_layout; @@ -151,6 +152,7 @@ struct wlr_scene_buffer { float opacity; int corner_radius; + struct shadow_data shadow_data; uint64_t active_outputs; struct wlr_texture *texture; @@ -388,6 +390,12 @@ void wlr_scene_buffer_set_corner_radius(struct wlr_scene_buffer *scene_buffer, int radii); /** +* Sets the shadow of this buffer +*/ +void wlr_scene_buffer_set_shadow_data(struct wlr_scene_buffer *scene_buffer, + struct shadow_data shadow_data); + +/** * Calls the buffer's frame_done signal. */ void wlr_scene_buffer_send_frame_done(struct wlr_scene_buffer *scene_buffer, |