From 420364dd191fa3c22370bbaa34f178b07bcb8318 Mon Sep 17 00:00:00 2001 From: Will McKinnon Date: Thu, 6 Apr 2023 18:49:51 -0400 Subject: structure: moved fx_renderer and related fuctions to a folder --- include/sway/desktop/fx_renderer.h | 149 ------------------------- include/sway/desktop/fx_renderer/fx_renderer.h | 149 +++++++++++++++++++++++++ include/sway/desktop/fx_renderer/matrix.h | 9 ++ include/sway/output.h | 2 +- 4 files changed, 159 insertions(+), 150 deletions(-) delete mode 100644 include/sway/desktop/fx_renderer.h create mode 100644 include/sway/desktop/fx_renderer/fx_renderer.h create mode 100644 include/sway/desktop/fx_renderer/matrix.h (limited to 'include/sway') diff --git a/include/sway/desktop/fx_renderer.h b/include/sway/desktop/fx_renderer.h deleted file mode 100644 index a48a00e1..00000000 --- a/include/sway/desktop/fx_renderer.h +++ /dev/null @@ -1,149 +0,0 @@ -#ifndef _SWAY_OPENGL_H -#define _SWAY_OPENGL_H - -#include -#include -#include - -enum corner_location { ALL, TOP_LEFT, TOP_RIGHT, BOTTOM_LEFT, BOTTOM_RIGHT, NONE }; - -enum fx_tex_shader_source { - SHADER_SOURCE_TEXTURE_RGBA = 1, - SHADER_SOURCE_TEXTURE_RGBX = 2, - SHADER_SOURCE_TEXTURE_EXTERNAL = 3, -}; - -enum fx_rounded_quad_shader_source { - SHADER_SOURCE_QUAD_ROUND = 1, - SHADER_SOURCE_QUAD_ROUND_TOP_LEFT = 2, - SHADER_SOURCE_QUAD_ROUND_TOP_RIGHT = 3, -}; - -struct decoration_data { - float alpha; - float saturation; - int corner_radius; - float dim; - float* dim_color; - bool has_titlebar; -}; - -struct gles2_tex_shader { - GLuint program; - GLint proj; - GLint tex; - GLint alpha; - GLint pos_attrib; - GLint tex_attrib; - GLint size; - GLint position; - GLint radius; - GLint saturation; - GLint dim; - GLint dim_color; - GLint has_titlebar; -}; - -struct rounded_quad_shader { - GLuint program; - GLint proj; - GLint color; - GLint pos_attrib; - GLint size; - GLint position; - GLint radius; -}; - -struct fx_renderer { - struct wlr_egl *egl; - - float projection[9]; - - GLuint stencil_buffer_id; - - struct { - bool OES_egl_image_external; - } exts; - - struct { - PFNGLEGLIMAGETARGETTEXTURE2DOESPROC glEGLImageTargetTexture2DOES; - } procs; - - - // Shaders - struct { - struct { - GLuint program; - GLint proj; - GLint color; - GLint pos_attrib; - } quad; - - struct rounded_quad_shader rounded_quad; - struct rounded_quad_shader rounded_tl_quad; - struct rounded_quad_shader rounded_tr_quad; - - struct { - GLuint program; - GLint proj; - GLint color; - GLint pos_attrib; - GLint is_top_left; - GLint is_top_right; - GLint is_bottom_left; - GLint is_bottom_right; - GLint position; - GLint radius; - GLint half_size; - GLint half_thickness; - } corner; - - struct { - GLuint program; - GLint proj; - GLint color; - GLint pos_attrib; - GLint position; - GLint size; - GLint blur_sigma; - GLint corner_radius; - } box_shadow; - - struct gles2_tex_shader tex_rgba; - struct gles2_tex_shader tex_rgbx; - struct gles2_tex_shader tex_ext; - } shaders; -}; - -struct fx_renderer *fx_renderer_create(struct wlr_egl *egl); - -void fx_renderer_begin(struct fx_renderer *renderer, uint32_t width, uint32_t height); - -void fx_renderer_end(); - -void fx_renderer_clear(const float color[static 4]); - -void fx_renderer_scissor(struct wlr_box *box); - -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], - struct decoration_data deco_data); - -bool fx_render_texture_with_matrix(struct fx_renderer *renderer, struct wlr_texture *wlr_texture, - const struct wlr_box *dst_box, const float matrix[static 9], struct decoration_data deco_data); - -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_rounded_rect(struct fx_renderer *renderer, const struct wlr_box *box, - const float color[static 4], const float projection[static 9], - int radius, enum corner_location corner_location); - -void fx_render_border_corner(struct fx_renderer *renderer, const struct wlr_box *box, - const float color[static 4], const float projection[static 9], - enum corner_location corner_location, int radius, int border_thickness); - -void fx_render_box_shadow(struct fx_renderer *renderer, const struct wlr_box *box, - const float color[static 4], const float projection[static 9], int radius, float blur_sigma); - -#endif diff --git a/include/sway/desktop/fx_renderer/fx_renderer.h b/include/sway/desktop/fx_renderer/fx_renderer.h new file mode 100644 index 00000000..a48a00e1 --- /dev/null +++ b/include/sway/desktop/fx_renderer/fx_renderer.h @@ -0,0 +1,149 @@ +#ifndef _SWAY_OPENGL_H +#define _SWAY_OPENGL_H + +#include +#include +#include + +enum corner_location { ALL, TOP_LEFT, TOP_RIGHT, BOTTOM_LEFT, BOTTOM_RIGHT, NONE }; + +enum fx_tex_shader_source { + SHADER_SOURCE_TEXTURE_RGBA = 1, + SHADER_SOURCE_TEXTURE_RGBX = 2, + SHADER_SOURCE_TEXTURE_EXTERNAL = 3, +}; + +enum fx_rounded_quad_shader_source { + SHADER_SOURCE_QUAD_ROUND = 1, + SHADER_SOURCE_QUAD_ROUND_TOP_LEFT = 2, + SHADER_SOURCE_QUAD_ROUND_TOP_RIGHT = 3, +}; + +struct decoration_data { + float alpha; + float saturation; + int corner_radius; + float dim; + float* dim_color; + bool has_titlebar; +}; + +struct gles2_tex_shader { + GLuint program; + GLint proj; + GLint tex; + GLint alpha; + GLint pos_attrib; + GLint tex_attrib; + GLint size; + GLint position; + GLint radius; + GLint saturation; + GLint dim; + GLint dim_color; + GLint has_titlebar; +}; + +struct rounded_quad_shader { + GLuint program; + GLint proj; + GLint color; + GLint pos_attrib; + GLint size; + GLint position; + GLint radius; +}; + +struct fx_renderer { + struct wlr_egl *egl; + + float projection[9]; + + GLuint stencil_buffer_id; + + struct { + bool OES_egl_image_external; + } exts; + + struct { + PFNGLEGLIMAGETARGETTEXTURE2DOESPROC glEGLImageTargetTexture2DOES; + } procs; + + + // Shaders + struct { + struct { + GLuint program; + GLint proj; + GLint color; + GLint pos_attrib; + } quad; + + struct rounded_quad_shader rounded_quad; + struct rounded_quad_shader rounded_tl_quad; + struct rounded_quad_shader rounded_tr_quad; + + struct { + GLuint program; + GLint proj; + GLint color; + GLint pos_attrib; + GLint is_top_left; + GLint is_top_right; + GLint is_bottom_left; + GLint is_bottom_right; + GLint position; + GLint radius; + GLint half_size; + GLint half_thickness; + } corner; + + struct { + GLuint program; + GLint proj; + GLint color; + GLint pos_attrib; + GLint position; + GLint size; + GLint blur_sigma; + GLint corner_radius; + } box_shadow; + + struct gles2_tex_shader tex_rgba; + struct gles2_tex_shader tex_rgbx; + struct gles2_tex_shader tex_ext; + } shaders; +}; + +struct fx_renderer *fx_renderer_create(struct wlr_egl *egl); + +void fx_renderer_begin(struct fx_renderer *renderer, uint32_t width, uint32_t height); + +void fx_renderer_end(); + +void fx_renderer_clear(const float color[static 4]); + +void fx_renderer_scissor(struct wlr_box *box); + +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], + struct decoration_data deco_data); + +bool fx_render_texture_with_matrix(struct fx_renderer *renderer, struct wlr_texture *wlr_texture, + const struct wlr_box *dst_box, const float matrix[static 9], struct decoration_data deco_data); + +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_rounded_rect(struct fx_renderer *renderer, const struct wlr_box *box, + const float color[static 4], const float projection[static 9], + int radius, enum corner_location corner_location); + +void fx_render_border_corner(struct fx_renderer *renderer, const struct wlr_box *box, + const float color[static 4], const float projection[static 9], + enum corner_location corner_location, int radius, int border_thickness); + +void fx_render_box_shadow(struct fx_renderer *renderer, const struct wlr_box *box, + const float color[static 4], const float projection[static 9], int radius, float blur_sigma); + +#endif diff --git a/include/sway/desktop/fx_renderer/matrix.h b/include/sway/desktop/fx_renderer/matrix.h new file mode 100644 index 00000000..6931e8d2 --- /dev/null +++ b/include/sway/desktop/fx_renderer/matrix.h @@ -0,0 +1,9 @@ +#ifndef _MATRIX_H +#define _MATRIX_H + +#include + +void matrix_projection(float mat[static 9], int width, int height, + enum wl_output_transform transform); + +#endif diff --git a/include/sway/output.h b/include/sway/output.h index 2d702741..a6bec10a 100644 --- a/include/sway/output.h +++ b/include/sway/output.h @@ -6,7 +6,7 @@ #include #include #include "config.h" -#include "sway/desktop/fx_renderer.h" +#include "sway/desktop/fx_renderer/fx_renderer.h" #include "sway/tree/node.h" #include "sway/tree/view.h" -- cgit v1.2.3