Skip to content

Commit 3bf8724

Browse files
committed
Render smart shadow behind blur
1 parent f97cfd0 commit 3bf8724

1 file changed

Lines changed: 44 additions & 40 deletions

File tree

types/scene/wlr_scene.c

Lines changed: 44 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -2027,6 +2027,50 @@ static void scene_entry_render(struct render_list_entry *entry, const struct ren
20272027
transform = wlr_output_transform_compose(transform, data->transform);
20282028
corner_location_transform(transform, &buffer_corners);
20292029

2030+
// Base texture rendering options
2031+
struct fx_render_texture_options tex_options = {
2032+
.base = (struct wlr_render_texture_options){
2033+
.texture = texture,
2034+
.src_box = scene_buffer->src_box,
2035+
.dst_box = dst_box,
2036+
.transform = transform,
2037+
.clip = &render_region, // Render with the smaller region, clipping CSD
2038+
.alpha = &scene_buffer->opacity,
2039+
.filter_mode = scene_buffer->filter_mode,
2040+
.blend_mode = !data->output->scene->calculate_visibility ||
2041+
!pixman_region32_empty(&opaque) ?
2042+
WLR_RENDER_BLEND_MODE_PREMULTIPLIED : WLR_RENDER_BLEND_MODE_NONE,
2043+
.wait_timeline = scene_buffer->wait_timeline,
2044+
.wait_point = scene_buffer->wait_point,
2045+
},
2046+
.clip_box = &dst_box,
2047+
.corners = buffer_corners,
2048+
.corner_radius = scene_buffer->corner_radius * data->scale,
2049+
};
2050+
2051+
// Smart shadow
2052+
// TODO: Place in shadow_node instead?
2053+
if (SCENE_BUFFER_SHOULD_SMART_SHADOW(scene_buffer)) {
2054+
// const float alpha = 0.5;
2055+
const float alpha = 1.0;
2056+
struct fx_render_smart_shadow_options shadow_options = {
2057+
.tex_options = tex_options,
2058+
2059+
// TODO:
2060+
.blur_sigma = scene_buffer->smart_shadow.blur_radius,
2061+
.color = {
2062+
// TODO: Fix weak colors
2063+
.r = 0 * alpha,
2064+
.g = 1 * alpha,
2065+
.b = 0 * alpha,
2066+
.a = alpha,
2067+
},
2068+
.x_offset = 0,
2069+
.y_offset = 0,
2070+
};
2071+
fx_render_pass_add_smart_shadow(data->render_pass, &shadow_options);
2072+
}
2073+
20302074
// Blur
20312075
if (SCENE_BUFFER_SHOULD_BLUR(scene_buffer, &scene->blur_data)) {
20322076
pixman_region32_t opaque_region;
@@ -2072,46 +2116,6 @@ static void scene_entry_render(struct render_list_entry *entry, const struct ren
20722116
pixman_region32_fini(&opaque_region);
20732117
}
20742118

2075-
struct fx_render_texture_options tex_options = {
2076-
.base = (struct wlr_render_texture_options){
2077-
.texture = texture,
2078-
.src_box = scene_buffer->src_box,
2079-
.dst_box = dst_box,
2080-
.transform = transform,
2081-
.clip = &render_region, // Render with the smaller region, clipping CSD
2082-
.alpha = &scene_buffer->opacity,
2083-
.filter_mode = scene_buffer->filter_mode,
2084-
.blend_mode = !data->output->scene->calculate_visibility ||
2085-
!pixman_region32_empty(&opaque) ?
2086-
WLR_RENDER_BLEND_MODE_PREMULTIPLIED : WLR_RENDER_BLEND_MODE_NONE,
2087-
.wait_timeline = scene_buffer->wait_timeline,
2088-
.wait_point = scene_buffer->wait_point,
2089-
},
2090-
.clip_box = &dst_box,
2091-
.corners = buffer_corners,
2092-
.corner_radius = scene_buffer->corner_radius * data->scale,
2093-
};
2094-
2095-
// TODO: Render before blur
2096-
if (SCENE_BUFFER_SHOULD_SMART_SHADOW(scene_buffer)) {
2097-
const float alpha = 1.0;
2098-
struct fx_render_smart_shadow_options shadow_options = {
2099-
.tex_options = tex_options,
2100-
2101-
// TODO:
2102-
.blur_sigma = scene_buffer->smart_shadow.blur_radius,
2103-
.color = {
2104-
// TODO: Fix weak colors
2105-
.r = 0 * alpha,
2106-
.g = 1 * alpha,
2107-
.b = 0 * alpha,
2108-
.a = alpha,
2109-
},
2110-
.x_offset = 0,
2111-
.y_offset = 0,
2112-
};
2113-
fx_render_pass_add_smart_shadow(data->render_pass, &shadow_options);
2114-
}
21152119
fx_render_pass_add_texture(data->render_pass, &tex_options);
21162120

21172121
struct wlr_scene_output_sample_event sample_event = {

0 commit comments

Comments
 (0)