Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

swayfx compat changes #84

Merged
merged 9 commits into from
Jan 4, 2025
12 changes: 3 additions & 9 deletions include/render/fx_renderer/fx_renderer.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
#include <time.h>
#include <wlr/render/egl.h>
#include <wlr/render/interface.h>
#include <wlr/render/swapchain.h>
#include <wlr/render/wlr_texture.h>
#include <wlr/util/addon.h>
#include <wlr/util/box.h>
Expand Down Expand Up @@ -50,7 +51,8 @@ struct fx_framebuffer {

/** Should only be used with custom fbs */
void fx_framebuffer_get_or_create_custom(struct fx_renderer *fx_renderer,
struct wlr_output *output, struct fx_framebuffer **fx_buffer);
struct wlr_output *output, struct wlr_swapchain *swapchain,
struct fx_framebuffer **fx_buffer);

struct fx_framebuffer *fx_framebuffer_get_or_create(struct fx_renderer *renderer,
struct wlr_buffer *wlr_buffer);
Expand Down Expand Up @@ -176,15 +178,7 @@ struct fx_renderer {
struct quad_shader quad;
struct quad_grad_shader quad_grad;
struct quad_round_shader quad_round;
struct quad_round_shader quad_round_tl;
struct quad_round_shader quad_round_tr;
struct quad_round_shader quad_round_bl;
struct quad_round_shader quad_round_br;
struct quad_grad_round_shader quad_grad_round;
struct quad_grad_round_shader quad_grad_round_tl;
struct quad_grad_round_shader quad_grad_round_tr;
struct quad_grad_round_shader quad_grad_round_bl;
struct quad_grad_round_shader quad_grad_round_br;
struct tex_shader tex_rgba;
struct tex_shader tex_rgbx;
struct tex_shader tex_ext;
Expand Down
23 changes: 13 additions & 10 deletions include/render/fx_renderer/shaders.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,6 @@ 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;
Expand Down Expand Up @@ -67,9 +59,14 @@ struct quad_round_shader {
GLint window_half_size;
GLint window_position;
GLint window_radius;

GLint round_top_left;
GLint round_top_right;
GLint round_bottom_left;
GLint round_bottom_right;
};

bool link_quad_round_program(struct quad_round_shader *shader, enum fx_rounded_quad_shader_source source);
bool link_quad_round_program(struct quad_round_shader *shader);

struct quad_grad_round_shader {
GLuint program;
Expand All @@ -89,10 +86,15 @@ struct quad_grad_round_shader {
GLint count;
GLint blend;

GLint round_top_left;
GLint round_top_right;
GLint round_bottom_left;
GLint round_bottom_right;

int max_len;
};

bool link_quad_grad_round_program(struct quad_grad_round_shader *shader, enum fx_rounded_quad_shader_source source, int max_len);
bool link_quad_grad_round_program(struct quad_grad_round_shader *shader, int max_len);

struct tex_shader {
GLuint program;
Expand All @@ -107,6 +109,7 @@ struct tex_shader {
GLint discard_transparent;
GLint dim;
GLint dim_color;

GLint round_top_left;
GLint round_top_right;
GLint round_bottom_left;
Expand Down
3 changes: 1 addition & 2 deletions include/scenefx/render/fx_renderer/fx_renderer.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,7 @@ struct fx_renderer;
struct wlr_renderer *fx_renderer_create_with_drm_fd(int drm_fd);
struct wlr_renderer *fx_renderer_create(struct wlr_backend *backend);

struct fx_renderer *fx_get_renderer(
struct wlr_renderer *wlr_renderer);
struct fx_renderer *fx_get_renderer(struct wlr_renderer *wlr_renderer);

bool fx_renderer_check_ext(struct wlr_renderer *renderer, const char *ext);
GLuint fx_renderer_get_buffer_fbo(struct wlr_renderer *renderer, struct wlr_buffer *buffer);
Expand Down
13 changes: 10 additions & 3 deletions include/scenefx/render/pass.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#include <stdbool.h>
#include <wlr/render/pass.h>
#include <wlr/render/interface.h>
#include <wlr/render/swapchain.h>

#include "render/egl.h"
#include "scenefx/types/fx/corner_location.h"
Expand All @@ -18,6 +19,12 @@ struct fx_gles_render_pass {
struct fx_render_timer *timer;
};

struct fx_buffer_pass_options {
const struct wlr_buffer_pass_options *base;

struct wlr_swapchain *swapchain;
};

/**
* Begin a new render pass with the supplied destination buffer.
*
Expand All @@ -26,7 +33,7 @@ struct fx_gles_render_pass {
*/
struct fx_gles_render_pass *fx_renderer_begin_buffer_pass(struct wlr_renderer *wlr_renderer,
struct wlr_buffer *wlr_buffer, struct wlr_output *output,
const struct wlr_buffer_pass_options *options);
const struct fx_buffer_pass_options *options);

struct fx_gradient {
float degree;
Expand Down Expand Up @@ -65,7 +72,7 @@ struct fx_render_rect_grad_options {
struct fx_render_rounded_rect_options {
struct wlr_render_rect_options base;
int corner_radius;
enum corner_location corner_location;
enum corner_location corners;

struct wlr_box window_box;
int window_corner_radius;
Expand All @@ -75,7 +82,7 @@ struct fx_render_rounded_rect_grad_options {
struct wlr_render_rect_options base;
struct fx_gradient gradient;
int corner_radius;
enum corner_location corner_location;
enum corner_location corners;
};

struct fx_render_box_shadow_options {
Expand Down
5 changes: 3 additions & 2 deletions include/scenefx/types/wlr_scene.h
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,7 @@ struct wlr_scene_rect {
int width, height;
float color[4];
int corner_radius;
enum corner_location corners;
};

/** A scene-graph node displaying a shadow */
Expand Down Expand Up @@ -413,8 +414,8 @@ void wlr_scene_rect_set_size(struct wlr_scene_rect *rect, int width, int height)
/**
* Change the corner radius of an existing rectangle node.
*/
void wlr_scene_rect_set_corner_radius(struct wlr_scene_rect *rect, int corner_radius);

void wlr_scene_rect_set_corner_radius(struct wlr_scene_rect *rect, int corner_radius,
enum corner_location corners);

/**
* Change the color of an existing rectangle node.
Expand Down
1 change: 0 additions & 1 deletion meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,6 @@ pkgconfig.generate(
name: versioned_name,
version: meson.project_version(),
filebase: meson.project_name(),
name: meson.project_name(),
description: 'Wlroots effects library',
subdirs: versioned_name,
)
8 changes: 6 additions & 2 deletions render/fx_renderer/fx_framebuffer.c
Original file line number Diff line number Diff line change
Expand Up @@ -69,9 +69,12 @@ GLuint fx_framebuffer_get_fbo(struct fx_framebuffer *buffer) {
}

void fx_framebuffer_get_or_create_custom(struct fx_renderer *renderer,
struct wlr_output *output, struct fx_framebuffer **fx_framebuffer) {
struct wlr_output *output, struct wlr_swapchain *swapchain,
struct fx_framebuffer **fx_framebuffer) {
struct wlr_allocator *allocator = output->allocator;
struct wlr_swapchain *swapchain = output->swapchain;
if (!swapchain) {
swapchain = output->swapchain;
}
int width = output->width;
int height = output->height;
struct wlr_buffer *wlr_buffer = NULL;
Expand Down Expand Up @@ -170,3 +173,4 @@ void fx_framebuffer_destroy(struct fx_framebuffer *fx_buffer) {

free(fx_buffer);
}

Loading