summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorErik Reider <[email protected]>2023-04-17 23:24:48 +0200
committerGitHub <[email protected]>2023-04-17 23:24:48 +0200
commitcbfb7af7fd4728f993124e81f8666a2e8cee6085 (patch)
tree081e51028d59da49480be6bff9c580bbdadca9cd /include
parent7d774f769cec2faec25d01120b05589a34b4eb0b (diff)
Add kawase blur (#120)
Co-authored-by: Erik Reider <[email protected]> Co-authored-by: Will McKinnon <[email protected]>
Diffstat (limited to 'include')
-rw-r--r--include/sway/commands.h4
-rw-r--r--include/sway/config.h14
-rw-r--r--include/sway/desktop/fx_renderer/fx_framebuffer.h23
-rw-r--r--include/sway/desktop/fx_renderer/fx_renderer.h44
-rw-r--r--include/sway/desktop/fx_renderer/fx_texture.h18
-rw-r--r--include/sway/output.h2
-rw-r--r--include/sway/server.h1
-rw-r--r--include/sway/tree/container.h2
8 files changed, 100 insertions, 8 deletions
diff --git a/include/sway/commands.h b/include/sway/commands.h
index 91b1fc58..b895d5f2 100644
--- a/include/sway/commands.h
+++ b/include/sway/commands.h
@@ -109,6 +109,10 @@ sway_cmd cmd_bindcode;
sway_cmd cmd_bindgesture;
sway_cmd cmd_bindswitch;
sway_cmd cmd_bindsym;
+sway_cmd cmd_blur;
+sway_cmd cmd_blur_passes;
+sway_cmd cmd_blur_radius;
+sway_cmd cmd_blur_xray;
sway_cmd cmd_border;
sway_cmd cmd_client_noop;
sway_cmd cmd_client_focused;
diff --git a/include/sway/config.h b/include/sway/config.h
index 2dc4b52d..cabc9cf5 100644
--- a/include/sway/config.h
+++ b/include/sway/config.h
@@ -470,23 +470,33 @@ enum xwayland_mode {
XWAYLAND_MODE_IMMEDIATE,
};
+struct blur_parameters {
+ int num_passes;
+ int radius;
+};
+
/**
* The configuration struct. The result of loading a config file.
*/
struct sway_config {
- // SwayFX config options
int corner_radius;
bool smart_corner_radius;
+
float default_dim_inactive;
- // dim_inactive colors
struct {
float unfocused[4];
float urgent[4];
} dim_inactive_colors;
+
bool shadow_enabled;
bool shadows_on_csd_enabled;
int shadow_blur_sigma;
float shadow_color[4];
+
+ bool blur_enabled;
+ bool blur_xray;
+ struct blur_parameters blur_params;
+
bool titlebar_separator;
bool scratchpad_minimize;
diff --git a/include/sway/desktop/fx_renderer/fx_framebuffer.h b/include/sway/desktop/fx_renderer/fx_framebuffer.h
new file mode 100644
index 00000000..965c1def
--- /dev/null
+++ b/include/sway/desktop/fx_renderer/fx_framebuffer.h
@@ -0,0 +1,23 @@
+#ifndef FX_FRAMEBUFFER_H
+#define FX_FRAMEBUFFER_H
+
+#include <GLES2/gl2.h>
+#include <stdbool.h>
+#include <wlr/types/wlr_output.h>
+
+#include "sway/desktop/fx_renderer/fx_texture.h"
+
+struct fx_framebuffer {
+ struct fx_texture texture;
+ GLuint fb;
+};
+
+void fx_framebuffer_bind(struct fx_framebuffer *buffer, GLsizei width, GLsizei height);
+
+void fx_framebuffer_create(struct wlr_output *output, struct fx_framebuffer *buffer,
+ bool bind);
+
+void fx_framebuffer_release(struct fx_framebuffer *buffer);
+
+
+#endif
diff --git a/include/sway/desktop/fx_renderer/fx_renderer.h b/include/sway/desktop/fx_renderer/fx_renderer.h
index a48a00e1..37887d30 100644
--- a/include/sway/desktop/fx_renderer/fx_renderer.h
+++ b/include/sway/desktop/fx_renderer/fx_renderer.h
@@ -5,6 +5,9 @@
#include <GLES2/gl2ext.h>
#include <stdbool.h>
+#include "sway/desktop/fx_renderer/fx_framebuffer.h"
+#include "sway/desktop/fx_renderer/fx_texture.h"
+
enum corner_location { ALL, TOP_LEFT, TOP_RIGHT, BOTTOM_LEFT, BOTTOM_RIGHT, NONE };
enum fx_tex_shader_source {
@@ -24,8 +27,9 @@ struct decoration_data {
float saturation;
int corner_radius;
float dim;
- float* dim_color;
+ float *dim_color;
bool has_titlebar;
+ bool blur;
};
struct gles2_tex_shader {
@@ -54,13 +58,34 @@ struct rounded_quad_shader {
GLint radius;
};
+struct blur_shader {
+ GLuint program;
+ GLint proj;
+ GLint tex;
+ GLint pos_attrib;
+ GLint tex_attrib;
+ GLint radius;
+ GLint halfpixel;
+};
+
struct fx_renderer {
struct wlr_egl *egl;
float projection[9];
+ struct sway_output *sway_output;
+
GLuint stencil_buffer_id;
+ struct fx_framebuffer wlr_buffer; // Just the framebuffer used by wlroots
+ struct fx_framebuffer main_buffer; // The main FB used for rendering
+ struct fx_framebuffer blur_buffer; // Contains the blurred background for tiled windows
+ // Blur swaps between the two effects buffers everytime it scales the image
+ struct fx_framebuffer effects_buffer; // Buffer used for effects
+ struct fx_framebuffer effects_buffer_swapped; // Swap buffer used for effects
+
+ bool blur_buffer_dirty;
+
struct {
bool OES_egl_image_external;
} exts;
@@ -83,6 +108,9 @@ struct fx_renderer {
struct rounded_quad_shader rounded_tl_quad;
struct rounded_quad_shader rounded_tr_quad;
+ struct blur_shader blur1;
+ struct blur_shader blur2;
+
struct {
GLuint program;
GLint proj;
@@ -117,19 +145,21 @@ struct fx_renderer {
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_fini(struct fx_renderer *renderer);
+
+void fx_renderer_begin(struct fx_renderer *renderer, struct sway_output *output);
-void fx_renderer_end();
+void fx_renderer_end(struct fx_renderer *renderer);
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,
+bool fx_render_subtexture_with_matrix(struct fx_renderer *renderer, struct fx_texture *fx_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,
+bool fx_render_texture_with_matrix(struct fx_renderer *renderer, struct fx_texture *fx_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,
@@ -146,4 +176,8 @@ void fx_render_border_corner(struct fx_renderer *renderer, const struct wlr_box
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);
+void fx_render_blur(struct fx_renderer *renderer, struct sway_output *output,
+ const float matrix[static 9], struct fx_framebuffer **buffer,
+ struct blur_shader *shader, const struct wlr_box *box, int blur_radius);
+
#endif
diff --git a/include/sway/desktop/fx_renderer/fx_texture.h b/include/sway/desktop/fx_renderer/fx_texture.h
new file mode 100644
index 00000000..0c375913
--- /dev/null
+++ b/include/sway/desktop/fx_renderer/fx_texture.h
@@ -0,0 +1,18 @@
+#ifndef FX_TEXTURE_H
+#define FX_TEXTURE_H
+
+#include <GLES2/gl2.h>
+#include <stdbool.h>
+#include <wlr/render/wlr_texture.h>
+
+struct fx_texture {
+ GLuint target;
+ GLuint id;
+ bool has_alpha;
+ int width;
+ int height;
+};
+
+struct fx_texture fx_texture_from_wlr_texture(struct wlr_texture* tex);
+
+#endif
diff --git a/include/sway/output.h b/include/sway/output.h
index a6bec10a..65f7ca1a 100644
--- a/include/sway/output.h
+++ b/include/sway/output.h
@@ -24,6 +24,8 @@ struct sway_output {
struct sway_server *server;
struct wl_list link;
+ struct fx_renderer *renderer;
+
struct wl_list layers[4]; // sway_layer_surface::link
struct wlr_box usable_area;
diff --git a/include/sway/server.h b/include/sway/server.h
index 0c2eccf3..96c3623f 100644
--- a/include/sway/server.h
+++ b/include/sway/server.h
@@ -37,7 +37,6 @@ struct sway_server {
// secondary headless backend used for creating virtual outputs on-the-fly
struct wlr_backend *headless_backend;
struct wlr_renderer *wlr_renderer;
- struct fx_renderer *renderer;
struct wlr_allocator *allocator;
struct wlr_compositor *compositor;
diff --git a/include/sway/tree/container.h b/include/sway/tree/container.h
index 1d8e5a36..3cd668f9 100644
--- a/include/sway/tree/container.h
+++ b/include/sway/tree/container.h
@@ -115,6 +115,8 @@ struct sway_container {
bool shadow_enabled;
+ bool blur_enabled;
+
float saturation;
float alpha;