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

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion 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
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
9 changes: 8 additions & 1 deletion 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
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,
)
7 changes: 5 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
14 changes: 9 additions & 5 deletions render/fx_renderer/fx_pass.c
Original file line number Diff line number Diff line change
Expand Up @@ -926,7 +926,7 @@ void fx_render_pass_add_optimized_blur(struct fx_gles_render_pass *pass,
struct fx_framebuffer *buffer = get_main_buffer_blur(pass, &blur_options);

// Update the optimized blur buffer if invalid
fx_framebuffer_get_or_create_custom(renderer, pass->output,
fx_framebuffer_get_or_create_custom(renderer, pass->output, NULL,
&pass->fx_effect_framebuffers->optimized_blur_buffer);

// Render the newly blurred content into the blur_buffer
Expand Down Expand Up @@ -1051,7 +1051,8 @@ static struct fx_gles_render_pass *begin_buffer_pass(struct fx_framebuffer *buff

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) {
struct wlr_output *output, const struct fx_buffer_pass_options *fx_options) {
const struct wlr_buffer_pass_options *options = fx_options->base;
struct fx_renderer *renderer = fx_get_renderer(wlr_renderer);

renderer->basic_renderer = (output == NULL);
Expand All @@ -1077,9 +1078,12 @@ struct fx_gles_render_pass *fx_renderer_begin_buffer_pass(
// Update the buffers if needed
if (!renderer->basic_renderer) {
fbos = fx_effect_framebuffers_try_get(output);
fx_framebuffer_get_or_create_custom(renderer, output, &fbos->blur_saved_pixels_buffer);
fx_framebuffer_get_or_create_custom(renderer, output, &fbos->effects_buffer);
fx_framebuffer_get_or_create_custom(renderer, output, &fbos->effects_buffer_swapped);
fx_framebuffer_get_or_create_custom(renderer, output, fx_options->swapchain,
&fbos->blur_saved_pixels_buffer);
fx_framebuffer_get_or_create_custom(renderer, output, fx_options->swapchain,
&fbos->effects_buffer);
fx_framebuffer_get_or_create_custom(renderer, output, fx_options->swapchain,
&fbos->effects_buffer_swapped);

pixman_region32_init(&fbos->blur_padding_region);
}
Expand Down
5 changes: 4 additions & 1 deletion render/fx_renderer/fx_renderer.c
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,10 @@ static void fx_renderer_destroy(struct wlr_renderer *wlr_renderer) {
static struct wlr_render_pass *begin_buffer_pass(struct wlr_renderer *wlr_renderer,
struct wlr_buffer *wlr_buffer, const struct wlr_buffer_pass_options *options) {
struct fx_gles_render_pass *pass =
fx_renderer_begin_buffer_pass(wlr_renderer, wlr_buffer, NULL, options);
fx_renderer_begin_buffer_pass(wlr_renderer, wlr_buffer, NULL, &(struct fx_buffer_pass_options) {
.base = options,
.swapchain = NULL,
});
if (!pass) {
return NULL;
}
Expand Down
11 changes: 8 additions & 3 deletions types/scene/wlr_scene.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#include <assert.h>
#include <pixman.h>
#include <stdio.h>
#include <stdlib.h>
#include <scenefx/types/wlr_scene.h>
#include <string.h>
Expand Down Expand Up @@ -842,6 +843,7 @@ struct wlr_scene_optimized_blur *wlr_scene_optimized_blur_create(

void wlr_scene_optimized_blur_set_size(struct wlr_scene_optimized_blur *blur_node,
int width, int height) {
assert(blur_node);
if (blur_node->width == width && blur_node->height == height) {
return;
}
Expand Down Expand Up @@ -2423,9 +2425,12 @@ bool wlr_scene_output_build_state(struct wlr_scene_output *scene_output,

struct fx_gles_render_pass *render_pass =
fx_renderer_begin_buffer_pass(output->renderer, buffer, output,
&(struct wlr_buffer_pass_options) {
.timer = timer ? timer->render_timer : NULL,
.color_transform = options->color_transform,
&(struct fx_buffer_pass_options) {
.base = &(struct wlr_buffer_pass_options){
.timer = timer ? timer->render_timer : NULL,
.color_transform = options->color_transform,
},
.swapchain = swapchain,
}
);
if (render_pass == NULL) {
Expand Down