mirror of https://github.com/yshui/picom.git
backend: gl: use gaussian blur for shadow
dual kawase is fast but its blur size is coarse grained, which sometimes makes the shadow ugly. Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
This commit is contained in:
parent
f2970bc697
commit
5ac8b7fc56
|
@ -1174,11 +1174,11 @@ struct backend_shadow_context *gl_create_shadow_context(backend_t *base, double
|
||||||
auto ctx = ccalloc(1, struct gl_shadow_context);
|
auto ctx = ccalloc(1, struct gl_shadow_context);
|
||||||
ctx->radius = radius;
|
ctx->radius = radius;
|
||||||
|
|
||||||
struct dual_kawase_blur_args args = {
|
struct gaussian_blur_args args = {
|
||||||
.size = (int)radius,
|
.size = (int)radius,
|
||||||
.strength = 0,
|
.deviation = gaussian_kernel_std_for_size(radius, 0.5 / 256.0),
|
||||||
};
|
};
|
||||||
ctx->blur_context = gl_create_blur_context(base, BLUR_METHOD_DUAL_KAWASE, &args);
|
ctx->blur_context = gl_create_blur_context(base, BLUR_METHOD_GAUSSIAN, &args);
|
||||||
return (struct backend_shadow_context *)ctx;
|
return (struct backend_shadow_context *)ctx;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -103,7 +103,7 @@ static inline double estimate_first_row_sum(double size, double r) {
|
||||||
/// Pick a suitable gaussian kernel standard deviation for a given kernel size. The
|
/// Pick a suitable gaussian kernel standard deviation for a given kernel size. The
|
||||||
/// returned radius is the maximum possible radius (<= size*2) that satisfies no sum of
|
/// returned radius is the maximum possible radius (<= size*2) that satisfies no sum of
|
||||||
/// the rows in the kernel are less than `row_limit` (up to certain precision).
|
/// the rows in the kernel are less than `row_limit` (up to certain precision).
|
||||||
static inline double gaussian_kernel_std_for_size(double size, double row_limit) {
|
double gaussian_kernel_std_for_size(double size, double row_limit) {
|
||||||
assert(size > 0);
|
assert(size > 0);
|
||||||
if (row_limit >= 1.0 / 2.0 / size) {
|
if (row_limit >= 1.0 / 2.0 / size) {
|
||||||
return size * 2;
|
return size * 2;
|
||||||
|
|
|
@ -22,6 +22,9 @@ double attr_pure sum_kernel_normalized(const conv *map, int x, int y, int width,
|
||||||
/// `size`.
|
/// `size`.
|
||||||
conv *gaussian_kernel(double r, int size);
|
conv *gaussian_kernel(double r, int size);
|
||||||
|
|
||||||
|
/// Estimate the best standard deviation for a give kernel size.
|
||||||
|
double gaussian_kernel_std_for_size(double size, double row_limit);
|
||||||
|
|
||||||
/// Create a gaussian kernel with auto detected standard deviation. The choosen standard
|
/// Create a gaussian kernel with auto detected standard deviation. The choosen standard
|
||||||
/// deviation tries to make sure the outer most pixels of the shadow are completely
|
/// deviation tries to make sure the outer most pixels of the shadow are completely
|
||||||
/// transparent.
|
/// transparent.
|
||||||
|
|
Loading…
Reference in New Issue