summaryrefslogtreecommitdiff
path: root/include/render/fx_renderer
diff options
context:
space:
mode:
authorWilliam McKinnon <[email protected]>2024-04-15 01:32:22 -0400
committerGitHub <[email protected]>2024-04-15 01:32:22 -0400
commite1f4bc5996b1c77c7fa8536b7c03d9eb4140227d (patch)
tree3fa8045ca37131acc96c88cec4a2f920de6113fb /include/render/fx_renderer
parent7e723f983b074e62e676caffe21cd5527b524587 (diff)
feat: add functions required by SwayFX (#35)
Diffstat (limited to 'include/render/fx_renderer')
-rw-r--r--include/render/fx_renderer/fx_renderer.h93
-rw-r--r--include/render/fx_renderer/shaders.h41
2 files changed, 41 insertions, 93 deletions
diff --git a/include/render/fx_renderer/fx_renderer.h b/include/render/fx_renderer/fx_renderer.h
index 83ac305..1028038 100644
--- a/include/render/fx_renderer/fx_renderer.h
+++ b/include/render/fx_renderer/fx_renderer.h
@@ -2,7 +2,7 @@
#define _FX_OPENGL_H
#include <GLES2/gl2.h>
-#include <GLES2/gl2ext.h>
+#include <scenefx/render/fx_renderer/fx_renderer.h>
#include <stdbool.h>
#include <time.h>
#include <wlr/render/egl.h>
@@ -11,9 +11,6 @@
#include <wlr/util/addon.h>
#include <wlr/util/box.h>
-#include "render/fx_renderer/shaders.h"
-#include "render/pass.h"
-
struct fx_pixel_format {
uint32_t drm_format;
// optional field, if empty then internalformat = format
@@ -84,102 +81,14 @@ struct fx_texture {
struct wlr_addon buffer_addon;
};
-struct fx_texture_attribs {
- GLenum target; /* either GL_TEXTURE_2D or GL_TEXTURE_EXTERNAL_OES */
- GLuint tex;
-
- bool has_alpha;
-};
-
struct fx_texture *fx_get_texture(struct wlr_texture *wlr_texture);
-struct wlr_texture *fx_texture_from_buffer(struct wlr_renderer *wlr_renderer,
- struct wlr_buffer *buffer);
-
void fx_texture_destroy(struct fx_texture *texture);
bool wlr_texture_is_fx(struct wlr_texture *wlr_texture);
-void fx_texture_get_attribs(struct wlr_texture *texture,
- struct fx_texture_attribs *attribs);
-
-///
-/// fx_renderer
-///
-
-struct fx_renderer {
- struct wlr_renderer wlr_renderer;
-
- float projection[9];
- struct wlr_egl *egl;
- int drm_fd;
-
- const char *exts_str;
- struct {
- bool EXT_read_format_bgra;
- bool KHR_debug;
- bool OES_egl_image_external;
- bool OES_egl_image;
- bool EXT_texture_type_2_10_10_10_REV;
- bool OES_texture_half_float_linear;
- bool EXT_texture_norm16;
- bool EXT_disjoint_timer_query;
- } exts;
-
- struct {
- PFNGLEGLIMAGETARGETTEXTURE2DOESPROC glEGLImageTargetTexture2DOES;
- PFNGLDEBUGMESSAGECALLBACKKHRPROC glDebugMessageCallbackKHR;
- PFNGLDEBUGMESSAGECONTROLKHRPROC glDebugMessageControlKHR;
- PFNGLPOPDEBUGGROUPKHRPROC glPopDebugGroupKHR;
- PFNGLPUSHDEBUGGROUPKHRPROC glPushDebugGroupKHR;
- PFNGLEGLIMAGETARGETRENDERBUFFERSTORAGEOESPROC glEGLImageTargetRenderbufferStorageOES;
- PFNGLGETGRAPHICSRESETSTATUSKHRPROC glGetGraphicsResetStatusKHR;
- PFNGLGENQUERIESEXTPROC glGenQueriesEXT;
- PFNGLDELETEQUERIESEXTPROC glDeleteQueriesEXT;
- PFNGLQUERYCOUNTEREXTPROC glQueryCounterEXT;
- PFNGLGETQUERYOBJECTIVEXTPROC glGetQueryObjectivEXT;
- PFNGLGETQUERYOBJECTUI64VEXTPROC glGetQueryObjectui64vEXT;
- PFNGLGETINTEGER64VEXTPROC glGetInteger64vEXT;
- } procs;
-
- struct {
- struct quad_shader quad;
- 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;
- struct blur_shader blur1;
- struct blur_shader blur2;
- struct blur_effects_shader blur_effects;
- } shaders;
-
- struct wl_list buffers; // fx_framebuffer.link
- struct wl_list textures; // fx_texture.link
-
- struct fx_framebuffer *current_buffer;
- uint32_t viewport_width, viewport_height;
-
- // Contains the blurred background for tiled windows
- struct fx_framebuffer *optimized_blur_buffer;
- // Contains the original pixels to draw over the areas where artifact are visible
- struct fx_framebuffer *blur_saved_pixels_buffer;
- // Blur swaps between the two effects buffers everytime it scales the image
- // Buffer used for effects
- struct fx_framebuffer *effects_buffer;
- // Swap buffer used for effects
- struct fx_framebuffer *effects_buffer_swapped;
-
- // The region where there's blur
- pixman_region32_t blur_padding_region;
-
- bool blur_buffer_dirty;
-};
-
bool wlr_renderer_is_fx(struct wlr_renderer *wlr_renderer);
-struct fx_renderer *fx_get_renderer(
- struct wlr_renderer *wlr_renderer);
struct fx_render_timer *fx_get_render_timer(
struct wlr_render_timer *timer);
struct fx_texture *fx_get_texture(
diff --git a/include/render/fx_renderer/shaders.h b/include/render/fx_renderer/shaders.h
index 226dd36..94aa029 100644
--- a/include/render/fx_renderer/shaders.h
+++ b/include/render/fx_renderer/shaders.h
@@ -20,6 +20,14 @@ enum fx_tex_shader_source {
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,
+ SHADER_SOURCE_QUAD_ROUND_BOTTOM_RIGHT = 4,
+ SHADER_SOURCE_QUAD_ROUND_BOTTOM_LEFT = 5,
+};
+
struct quad_shader {
GLuint program;
GLint proj;
@@ -29,6 +37,18 @@ struct quad_shader {
bool link_quad_program(struct quad_shader *shader);
+struct quad_round_shader {
+ GLuint program;
+ GLint proj;
+ GLint color;
+ GLint pos_attrib;
+ GLint size;
+ GLint position;
+ GLint radius;
+};
+
+bool link_quad_round_program(struct quad_round_shader *shader, enum fx_rounded_quad_shader_source source);
+
struct tex_shader {
GLuint program;
GLint proj;
@@ -39,16 +59,35 @@ struct tex_shader {
GLint size;
GLint position;
GLint radius;
+ GLint has_titlebar;
GLint discard_transparent;
+ GLint dim;
+ GLint dim_color;
};
bool link_tex_program(struct tex_shader *shader, enum fx_tex_shader_source source);
-struct stencil_mask_shader {
+struct rounded_border_corner_shader {
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;
+};
+
+bool link_rounded_border_corner_program(struct rounded_border_corner_shader *shader);
+
+struct stencil_mask_shader {
+ GLuint program;
+ GLint proj;
+ GLint pos_attrib;
GLint half_size;
GLint position;
GLint radius;