Conversation
|
I think we already get this for free somewhere with https://github.com/wlrfx/scenefx/blob/main/types/scene/wlr_scene.c#L297, let me double check the rendering loop in wlr_scene.c |
3d8b3bd to
91a8fcd
Compare
|
The lag caused by blur has disappeared in the latest commit |
91a8fcd to
83244c3
Compare
| struct linked_node mask_source; | ||
| // store which node is stored with `mask_source` | ||
| // So we don't call `wlr_container_of` with the wrong type | ||
| enum wlr_scene_node_type mask_node_type; | ||
| enum blur_mask_type mask_type; |
There was a problem hiding this comment.
This should be wrapped in struct {...} WLR_PRIVATE;
| bool link_tex_program(struct tex_shader *shader, GLint client_version, enum fx_tex_shader_source source) { | ||
| GLchar frag_src_part[2048]; | ||
| GLchar frag_src[4096]; | ||
| bool link_tex_program(struct tex_shader *shader, GLint client_version, enum fx_tex_shader_source source, bool has_clip) { |
There was a problem hiding this comment.
Nit: Maybe shorten the line with a line break? (also make sure that you're using tabs as stated in the .editorconfig file 😄)
| blur->corners = CORNER_LOCATION_NONE; | ||
| blur->should_only_blur_bottom_layer = false; | ||
| blur->transparency_mask_source = linked_node_init();; | ||
| blur->mask_source = linked_node_init();; |
There was a problem hiding this comment.
Should probably initialize mask_type as well, and what's with the ;;?
| } | ||
|
|
||
| void wlr_scene_blur_set_mask_source(struct wlr_scene_blur *blur, | ||
| struct wlr_scene_node *source, enum blur_mask_type mask_type) { |
There was a problem hiding this comment.
Nit: Use tabs as specified in the .editorconfig
| /** | ||
| * Set the transparency mask source for the blur, only rendering blur where the | ||
| * Mask source is actually rendering (e.g. skip transparent spaces) | ||
| * Set the mask source for the blur, reducing rendering area based on mask type |
There was a problem hiding this comment.
You should document that only scene_buffers and rects are supported
| } | ||
| } | ||
|
|
||
| void wlr_scene_blur_set_mask_source(struct wlr_scene_blur *blur, |
There was a problem hiding this comment.
I'd split this up into two functions, one for setting mask_source and one for setting the mask type. Would really simplify the logic here :)
Something like this:
void wlr_scene_blur_set_mask_source(struct wlr_scene_blur *blur,
struct wlr_scene_node *source) {
struct linked_node *linked_node = get_blur_linked_node_for_node(source);
if (source && !linked_node) {
wlr_log(WLR_ERROR, "Masking blur is only supported for "
" wlr_scene_buffer and wlr_scene_rect sources. Keeping old source");
return;
}
// Already linked
if (linked_node && linked_nodes_are_linked(&blur->mask_source, linked_node)) {
return;
}
linked_node_destroy(&blur->mask_source);
if (linked_node != NULL) {
linked_node_destroy(linked_node);
blur->mask_node_type = source->type;
linked_node_init_link(&blur->mask_source, linked_node);
}
scene_node_update(&blur->node, NULL);
}
void wlr_scene_blur_set_mask_type(struct wlr_scene_blur *blur,
enum blur_mask_type mask_type) {
if (blur->mask_type == mask_type) {
return;
}
blur->mask_type = mask_type;
// Only update when the mask type is NONE, or when there's a mask
// source present
if (mask_type == BLUR_MASK_NONE
|| linked_nodes_get_sibling(&blur->mask_source)) {
scene_node_update(&blur->node, NULL);
}
}| enum blur_mask_type { | ||
| BLUR_MASK_NONE = 0, | ||
| BLUR_MASK_IGNORE_TRANSPARENCY = 1, | ||
| BLUR_MASK_OPAQUE_REGION = 2, | ||
| BLUR_MASK_ALL = INT_MAX, | ||
| }; | ||
|
|
| if (pixman_region32_empty(&blur_render_area)) { | ||
| pixman_region32_fini(&opaque_region); | ||
| pixman_region32_fini(&blur_render_area); | ||
| break; |
There was a problem hiding this comment.
This logic should also only be handled in the scene_node_opaque_region function to make our lives easier :)



Adds a few more API breaks but also should allow to get some performance time back by allowing sources to define the opaque region, allowing us to render, Less
most of it was recommended by @ErikReider, and it seems to work well