Skip to content

Commit

Permalink
Removed wlr_scene impl. Should be moved into future PR instead
Browse files Browse the repository at this point in the history
  • Loading branch information
ErikReider committed Feb 26, 2024
1 parent 19822f1 commit e18878d
Show file tree
Hide file tree
Showing 6 changed files with 50 additions and 303 deletions.
2 changes: 0 additions & 2 deletions include/scenefx/types/fx/blur_data.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@ struct blur_data {

struct blur_data blur_data_get_default(void);

bool scene_buffer_should_blur(bool backdrop_blur, struct blur_data *blur_data);

bool blur_data_should_parameters_blur_effects(struct blur_data *blur_data);

bool blur_data_cmp(struct blur_data *a, struct blur_data *b);
Expand Down
4 changes: 2 additions & 2 deletions include/scenefx/types/fx/shadow_data.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#ifndef TYPES_FX_SHADOW_DATA_H
#define TYPES_FX_SHADOW_DATA_H
#ifndef TYPES_DECORATION_DATA
#define TYPES_DECORATION_DATA

#include <stdbool.h>
#include <wlr/util/addon.h>
Expand Down
39 changes: 1 addition & 38 deletions include/scenefx/types/wlr_scene.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@

#include <pixman.h>
#include "scenefx/types/fx/shadow_data.h"
#include "scenefx/types/fx/blur_data.h"
#include <time.h>
#include <wayland-server-core.h>
#include <wlr/render/wlr_renderer.h>
Expand Down Expand Up @@ -112,8 +111,6 @@ struct wlr_scene {
enum wlr_scene_debug_damage_option debug_damage_option;
bool direct_scanout;
bool calculate_visibility;

struct blur_data blur_data;
};

/** A scene-graph node displaying a single surface. */
Expand Down Expand Up @@ -179,13 +176,10 @@ struct wlr_scene_buffer {
*/
struct wlr_scene_output *primary_output;

float opacity;
int corner_radius;
struct shadow_data shadow_data;
bool backdrop_blur;
bool backdrop_blur_optimized;
bool backdrop_blur_ignore_transparent;

float opacity;
enum wlr_scale_filter_mode filter_mode;
struct wlr_fbox src_box;
int dst_width, dst_height;
Expand Down Expand Up @@ -320,9 +314,6 @@ struct wlr_scene *wlr_scene_create(void);
void wlr_scene_set_presentation(struct wlr_scene *scene,
struct wlr_presentation *presentation);

/** Sets the global blur parameters */
void wlr_scene_set_blur_data(struct wlr_scene *scene, struct blur_data blur_data);

/**
* Handles linux_dmabuf_v1 feedback for all surfaces in the scene.
*
Expand Down Expand Up @@ -471,34 +462,6 @@ void wlr_scene_buffer_set_corner_radius(struct wlr_scene_buffer *scene_buffer,
void wlr_scene_buffer_set_shadow_data(struct wlr_scene_buffer *scene_buffer,
struct shadow_data shadow_data);

/**
* Sets the whether or not the buffer should render backdrop blur
*/
void wlr_scene_buffer_set_backdrop_blur(struct wlr_scene_buffer *scene_buffer,
bool enabled);

/**
* Sets the whether the backdrop blur should use optimized blur or not
*/
void wlr_scene_buffer_set_backdrop_blur_optimized(struct wlr_scene_buffer *scene_buffer,
bool enabled);

/**
* Sets the whether the backdrop blur should not render in fully transparent
* segments.
*/
void wlr_scene_buffer_set_backdrop_blur_ignore_transparent(
struct wlr_scene_buffer *scene_buffer, bool enabled);

/**
* Tells the renderer to re-render the optimized blur. Very expensive so should
* only be called when needed.
*
* An example use would be to call this when a "static" node changes, like a
* wallpaper.
*/
void wlr_scene_optimized_blur_mark_dirty(struct wlr_scene *scene);

/**
* Calls the buffer's frame_done signal.
*/
Expand Down
78 changes: 46 additions & 32 deletions tinywl/tinywl.c
Original file line number Diff line number Diff line change
Expand Up @@ -557,6 +557,50 @@ static void server_cursor_frame(struct wl_listener *listener, void *data) {
wlr_seat_pointer_notify_frame(server->seat);
}

static void output_configure_scene(struct wlr_scene_node *node,
struct tinywl_toplevel *toplevel) {
if (!node->enabled) {
return;
}

struct tinywl_toplevel *_toplevel = node->data;
if (_toplevel) {
toplevel = _toplevel;
}

if (node->type == WLR_SCENE_NODE_BUFFER) {
struct wlr_scene_buffer *buffer = wlr_scene_buffer_from_node(node);

struct wlr_scene_surface * scene_surface =
wlr_scene_surface_try_from_buffer(buffer);
if (!scene_surface) {
return;
}

struct wlr_xdg_surface *xdg_surface =
wlr_xdg_surface_try_from_wlr_surface(scene_surface->surface);

if (toplevel &&
xdg_surface &&
xdg_surface->role == WLR_XDG_SURFACE_ROLE_TOPLEVEL) {
// TODO: Be able to set whole decoration_data instead of calling
// each individually?
wlr_scene_buffer_set_opacity(buffer, toplevel->opacity);

if (!wlr_subsurface_try_from_wlr_surface(xdg_surface->surface)) {
wlr_scene_buffer_set_corner_radius(buffer, toplevel->corner_radius);
wlr_scene_buffer_set_shadow_data(buffer, toplevel->shadow_data);
}
}
} else if (node->type == WLR_SCENE_NODE_TREE) {
struct wlr_scene_tree *tree = wl_container_of(node, tree, node);
struct wlr_scene_node *node;
wl_list_for_each(node, &tree->children, link) {
output_configure_scene(node, toplevel);
}
}
}

static void output_frame(struct wl_listener *listener, void *data) {
/* This function is called every time an output is ready to display a frame,
* generally at the output's refresh rate (e.g. 60Hz). */
Expand All @@ -566,6 +610,8 @@ static void output_frame(struct wl_listener *listener, void *data) {
struct wlr_scene_output *scene_output = wlr_scene_get_scene_output(
scene, output->wlr_output);

output_configure_scene(&scene_output->scene->tree.node, NULL);

/* Render the scene if needed and commit the output */
wlr_scene_output_commit(scene_output, NULL);

Expand Down Expand Up @@ -657,42 +703,10 @@ static void server_new_output(struct wl_listener *listener, void *data) {
wlr_scene_output_layout_add_output(server->scene_layout, l_output, scene_output);
}

static void iter_xdg_scene_buffers(struct wlr_scene_buffer *buffer, int sx,
int sy, void *user_data) {
struct tinywl_toplevel *toplevel = user_data;

struct wlr_scene_surface * scene_surface = wlr_scene_surface_try_from_buffer(buffer);
if (!scene_surface) {
return;
}

struct wlr_xdg_surface *xdg_surface =
wlr_xdg_surface_try_from_wlr_surface(scene_surface->surface);
if (toplevel &&
xdg_surface &&
xdg_surface->role == WLR_XDG_SURFACE_ROLE_TOPLEVEL) {
// TODO: Be able to set whole decoration_data instead of calling
// each individually?
wlr_scene_buffer_set_opacity(buffer, toplevel->opacity);

if (!wlr_subsurface_try_from_wlr_surface(xdg_surface->surface)) {
wlr_scene_buffer_set_corner_radius(buffer, toplevel->corner_radius);
wlr_scene_buffer_set_shadow_data(buffer, toplevel->shadow_data);

wlr_scene_buffer_set_backdrop_blur(buffer, true);
wlr_scene_buffer_set_backdrop_blur_optimized(buffer, false);
wlr_scene_buffer_set_backdrop_blur_ignore_transparent(buffer, true);
}
}
}

static void xdg_toplevel_map(struct wl_listener *listener, void *data) {
/* Called when the surface is mapped, or ready to display on-screen. */
struct tinywl_toplevel *toplevel = wl_container_of(listener, toplevel, map);

wlr_scene_node_for_each_buffer(&toplevel->scene_tree->node,
iter_xdg_scene_buffers, toplevel);

wl_list_insert(&toplevel->server->toplevels, &toplevel->link);

focus_toplevel(toplevel, toplevel->xdg_toplevel->base->surface);
Expand Down
4 changes: 0 additions & 4 deletions types/fx/blur_data.c
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,6 @@ struct blur_data blur_data_get_default(void) {
};
}

bool scene_buffer_should_blur(bool backdrop_blur, struct blur_data *blur_data) {
return backdrop_blur && blur_data->radius > 0 && blur_data->num_passes > 0;
}

bool blur_data_should_parameters_blur_effects(struct blur_data *blur_data) {
return blur_data->brightness != 1.0f
|| blur_data->saturation != 1.0f
Expand Down
Loading

0 comments on commit e18878d

Please sign in to comment.