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

Rounded corners and Kawase blur for glx, all in the same fork. #361

Closed
wants to merge 49 commits into from
Closed
Show file tree
Hide file tree
Changes from 24 commits
Commits
Show all changes
49 commits
Select commit Hold shift + click to select a range
1556fb5
patched with rounded-corners from https://github.com/sdhand/compton
ibhagwan Mar 24, 2020
9e2bfd1
added kawase blur to glx backend (from tryone144)
ibhagwan Mar 25, 2020
d2ec4ae
kawase blur working on glx backend, need to fix coredump
ibhagwan Mar 25, 2020
5d9771f
fixed memory fault due to free unallocated blur_kerns
ibhagwan Mar 25, 2020
4c3dfd0
added tryone144 dual_kawase branch to experimental-backends
ibhagwan Mar 25, 2020
187fe2d
renamed some functions to match tryone144 code
ibhagwan Mar 25, 2020
b3b6f13
rebased rounded_corners to experimental-backends
ibhagwan Mar 26, 2020
a6300c7
fixed leftover bug from testing
ibhagwan Mar 26, 2020
50693c7
WIP: added fragment shader skeleton for rounded corners on glx
ibhagwan Mar 27, 2020
528e21b
WIP: skeleton shader for rounded corners working (green mask)
ibhagwan Mar 27, 2020
d8c0110
wip: rounded corners shader test code semi-worikng?
ibhagwan Mar 28, 2020
868d396
wip: rounded corners frag shader works with green corners
ibhagwan Mar 28, 2020
b2d8e32
merged with yshui/picom commit 3ba7a2a [2020-03-28]
ibhagwan Mar 28, 2020
202d1b6
fixed dual_kawase on experimental, changed some variable names in rou…
ibhagwan Mar 28, 2020
8d84c3b
moved round_corners function to the right place
ibhagwan Mar 29, 2020
9073967
round_corners function moved again
ibhagwan Mar 30, 2020
4d01e1c
merged with yshui/compton up to commit 4c22d56
ibhagwan Mar 30, 2020
7b6caa9
rounded corners with glx: almost there...
ibhagwan Mar 30, 2020
484de46
rounded corners progress...
ibhagwan Mar 31, 2020
a3e27df
merged with yshui/picom up to commit b109526
ibhagwan Mar 31, 2020
8559732
temp commit before changing lots of code
ibhagwan Mar 31, 2020
84390f9
need cleanup now, but rounded corners are working with glx
ibhagwan Mar 31, 2020
23f1ce1
rounded corners code cleanup
ibhagwan Mar 31, 2020
10cdc03
updated README
ibhagwan Mar 31, 2020
aaf337e
init rounded corners shader only if glx backend is used
ibhagwan Apr 1, 2020
6ca1d01
rewrote shader code for better rounded corner rendering
ibhagwan Apr 2, 2020
2406418
wip: rounded borders almost working, need to add source alpha to pixel
ibhagwan Apr 2, 2020
16f4a26
wip: removed old shader, rounded borders almost perfect
ibhagwan Apr 2, 2020
375c5f7
rounded borders working with one-colored borders
ibhagwan Apr 4, 2020
fc5b941
merged with https://github.com/sdhand/picom/commit/e370ec2c0b5907020c…
ibhagwan Apr 4, 2020
8f9fb15
modified glx_read_border_pixel() logic
ibhagwan Apr 5, 2020
8051e23
fixed minor bug with kawase blur config
ibhagwan Apr 5, 2020
868a0b6
WIP: DO NOT USE, rounded corners almost working on new glx back
ibhagwan Apr 7, 2020
939a82e
wip: rounded corners new backend works sans borders
ibhagwan Apr 7, 2020
aad44d3
rounded corners on glx backend working
ibhagwan Apr 7, 2020
a607f8f
added vscode build|debug(gdb) tasks
ibhagwan Apr 16, 2020
4d4ec92
WIP: added tryone144 improved_fbo branch, need to fix flicker
ibhagwan Apr 17, 2020
6600d8b
WIP: minor modification, overlap alt_kawase blur still flicker...
ibhagwan Apr 18, 2020
6c3fcb5
added cfg options for disabling rounding of borders
ibhagwan Apr 24, 2020
89d42a1
fixed misc compile warnings
ibhagwan Apr 27, 2020
d10d4ea
fixed compile without CONFIG_OPENGL
ibhagwan Apr 27, 2020
25b94d3
hopefully last warning for tests to pass?
ibhagwan Apr 27, 2020
e24696d
last last warning?
ibhagwan Apr 27, 2020
68c8f1b
removed extra commas from picom.sample.conf
ibhagwan Apr 27, 2020
19e39e5
added 'corner_radius' and 'round_borders' to 'parse_wintype_config'
ibhagwan Jun 19, 2020
82ecc90
wintypes config bug fix
ibhagwan Jun 20, 2020
20c6412
added 'round_borders-rule' for manually overriding border width (work…
ibhagwan Aug 3, 2020
44b4970
round_borders_rule bugfix
ibhagwan Aug 4, 2020
0539616
Updated README, new fork, added screenshot
ibhagwan Feb 6, 2021
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
15 changes: 15 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,21 @@
picom
=======

## Why another picom fork?

TL;DR: rounded corners and dual_kawase blur on all backends.

This fork contains:

- Dual kawase blur method from [tryone144](https://github.com/tryone144/compton) as well as his new [feature/dual_kawase branch](https://github.com/tryone144/compton/tree/feature/dual_kawase) which implements the dual kawase blur method on the experimental glx backend.

- Rounded corners code from [sdhand](https://github.com/sdhand/picom) which is also ported to the experimetnal XRender backend.

- New code for rounded corners on the glx backend using GLSL frangment shader

For more information read [my reddit post](https://www.reddit.com/r/unixporn/comments/fs8trg/oc_comptonpicom_fork_with_both_tryone144s_dual/)


**This is a development branch, bugs to be expected**

This is forked from the original Compton because it seems to have become unmaintained.
Expand Down
11 changes: 10 additions & 1 deletion man/picom.1.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,12 @@ OPTIONS
*--inactive-dim* 'VALUE'::
Dim inactive windows. (0.0 - 1.0, defaults to 0.0)

*--corner-radius* 'VALUE'::
Round the corners of windows. (defaults to 0).

*--rounded-corners-exclude* 'CONDITION'::
Exclude conditions for rounded corners.

*--mark-wmwin-focused*::
Try to detect WM windows (a non-override-redirect window with no child that has 'WM_STATE') and mark them as active.

Expand Down Expand Up @@ -166,7 +172,7 @@ OPTIONS
*--detect-client-leader*::
Use 'WM_CLIENT_LEADER' to group windows, and consider windows in the same group focused at the same time. 'WM_TRANSIENT_FOR' has higher priority if *--detect-transient* is enabled, too.

*--blur-method*, *--blur-size*, *--blur-deviation*::
*--blur-method*, *--blur-size*, *--blur-deviation, *--blur-strength*::
Parameters for background blurring, see the *BLUR* section for more information.

*--blur-background*::
Expand Down Expand Up @@ -407,6 +413,9 @@ Available options of the 'blur' section are: ::
*deviation*:::
A floating point number. The standard deviation for the 'gaussian' blur method. Corresponds to the *--blur-deviation* command line option (default: 0.84089642).

*strength*:::
An integer in the range 1-20. The strength of the 'dual_kawase' blur method. Corresponds to the *--blur-strength* command line option. If not specified, the value requested by *--blur-size* is approximated.

*kernel*:::
A string. The kernel to use for the 'kernel' blur method, specified in the same format as the *--blur-kerns* option. Corresponds to the *--blur-kerns* command line option.

Expand Down
19 changes: 11 additions & 8 deletions src/backend/backend.c
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ void paint_all_new(session_t *ps, struct managed_win *t, bool ignore_damage) {
}

if (ps->root_image) {
ps->backend_data->ops->compose(ps->backend_data, ps->root_image, 0, 0,
ps->backend_data->ops->compose(ps->backend_data, t, ps->root_image, 0, 0,
&reg_paint, &reg_visible);
}

Expand All @@ -168,7 +168,7 @@ void paint_all_new(session_t *ps, struct managed_win *t, bool ignore_damage) {

// The bounding shape of the window, in global/target coordinates
// reminder: bounding shape contains the WM frame
auto reg_bound = win_get_bounding_shape_global_by_val(w);
auto reg_bound = win_get_bounding_shape_global_by_val(w, true);

// The clip region for the current window, in global/target coordinates
// reg_paint_in_bound \in reg_paint
Expand Down Expand Up @@ -211,6 +211,9 @@ void paint_all_new(session_t *ps, struct managed_win *t, bool ignore_damage) {
// fading out.
blur_opacity =
w->opacity / win_calc_opacity_target(ps, w, true);
} else if (!ps->o.blur_background_fixed) {
// Apply blur intensity depending on the window opacity.
blur_opacity = w->opacity;
}

if (real_win_mode == WMODE_TRANS || ps->o.force_win_blend) {
Expand All @@ -227,7 +230,7 @@ void paint_all_new(session_t *ps, struct managed_win *t, bool ignore_damage) {
assert(ps->o.blur_background_frame);
assert(real_win_mode == WMODE_FRAME_TRANS);

auto reg_blur = win_get_region_frame_local_by_val(w);
auto reg_blur = win_get_region_frame_local_by_val(w, true);
pixman_region32_translate(&reg_blur, w->g.x, w->g.y);
// make sure reg_blur \in reg_paint
pixman_region32_intersect(&reg_blur, &reg_blur, &reg_paint);
Expand Down Expand Up @@ -283,7 +286,7 @@ void paint_all_new(session_t *ps, struct managed_win *t, bool ignore_damage) {
assert(w->shadow_image);
if (w->opacity == 1) {
ps->backend_data->ops->compose(
ps->backend_data, w->shadow_image, w->g.x + w->shadow_dx,
ps->backend_data, w, w->shadow_image, w->g.x + w->shadow_dx,
w->g.y + w->shadow_dy, &reg_shadow, &reg_visible);
} else {
auto new_img = ps->backend_data->ops->copy(
Expand All @@ -292,7 +295,7 @@ void paint_all_new(session_t *ps, struct managed_win *t, bool ignore_damage) {
ps->backend_data, IMAGE_OP_APPLY_ALPHA_ALL, new_img,
NULL, &reg_visible, (double[]){w->opacity});
ps->backend_data->ops->compose(
ps->backend_data, new_img, w->g.x + w->shadow_dx,
ps->backend_data, w, new_img, w->g.x + w->shadow_dx,
w->g.y + w->shadow_dy, &reg_shadow, &reg_visible);
ps->backend_data->ops->release_image(ps->backend_data, new_img);
}
Expand All @@ -308,7 +311,7 @@ void paint_all_new(session_t *ps, struct managed_win *t, bool ignore_damage) {

// Draw window on target
if (!w->invert_color && !w->dim && w->frame_opacity == 1 && w->opacity == 1) {
ps->backend_data->ops->compose(ps->backend_data, w->win_image,
ps->backend_data->ops->compose(ps->backend_data, w, w->win_image,
w->g.x, w->g.y,
&reg_paint_in_bound, &reg_visible);
} else if (w->opacity * MAX_ALPHA >= 1) {
Expand Down Expand Up @@ -357,7 +360,7 @@ void paint_all_new(session_t *ps, struct managed_win *t, bool ignore_damage) {
&reg_visible_local, (double[]){dim_opacity});
}
if (w->frame_opacity != 1) {
auto reg_frame = win_get_region_frame_local_by_val(w);
auto reg_frame = win_get_region_frame_local_by_val(w, true);
ps->backend_data->ops->image_op(
ps->backend_data, IMAGE_OP_APPLY_ALPHA, new_img, &reg_frame,
&reg_visible_local, (double[]){w->frame_opacity});
Expand All @@ -368,7 +371,7 @@ void paint_all_new(session_t *ps, struct managed_win *t, bool ignore_damage) {
ps->backend_data, IMAGE_OP_APPLY_ALPHA_ALL, new_img,
NULL, &reg_visible_local, (double[]){w->opacity});
}
ps->backend_data->ops->compose(ps->backend_data, new_img, w->g.x,
ps->backend_data->ops->compose(ps->backend_data, w, new_img, w->g.x,
w->g.y, &reg_paint_in_bound,
&reg_visible);
ps->backend_data->ops->release_image(ps->backend_data, new_img);
Expand Down
10 changes: 9 additions & 1 deletion src/backend/backend.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@ typedef struct backend_base {
/// Whether the backend can accept new render request at the moment
bool busy;
// ...

// Session data
session_t *ps;
} backend_t;

typedef void (*backend_ready_callback_t)(void *);
Expand Down Expand Up @@ -56,6 +59,11 @@ struct gaussian_blur_args {
double deviation;
};

struct dual_kawase_blur_args {
int size;
blur_strength_t strength;
};

struct box_blur_args {
int size;
};
Expand Down Expand Up @@ -126,7 +134,7 @@ struct backend_operations {
* @param reg_paint the clip region, in target coordinates
* @param reg_visible the visible region, in target coordinates
*/
void (*compose)(backend_t *backend_data, void *image_data, int dst_x, int dst_y,
void (*compose)(backend_t *backend_data, struct managed_win *const w, void *image_data, int dst_x, int dst_y,
const region_t *reg_paint, const region_t *reg_visible);

/// Fill rectangle of the rendering buffer, mostly for debug purposes, optional.
Expand Down
97 changes: 97 additions & 0 deletions src/backend/backend_common.c
Original file line number Diff line number Diff line change
Expand Up @@ -362,10 +362,107 @@ struct conv **generate_blur_kernel(enum blur_method method, void *args, int *ker
return NULL;
}

/// Generate kernel parameters for dual-kawase blur method. Falls back on approximating
/// standard gauss radius if strength is not supplied
struct dual_kawase_params *generate_dual_kawase_params(void *args) {
struct dual_kawase_blur_args *blur_args = args;
static const struct {
int iterations;
float offset;
} strength_levels[20] = {
{.iterations = 1, .offset = 1.25f}, // LVL 1 => radius 4
{.iterations = 1, .offset = 2.25f}, // LVL 2 => radius 7
{.iterations = 2, .offset = 2.00f}, // LVL 3 => radius 14
{.iterations = 2, .offset = 3.00f}, // LVL 4 => radius 20
{.iterations = 2, .offset = 4.25f}, // LVL 5 => radius 28
{.iterations = 3, .offset = 2.50f}, // LVL 6 => radius 35
{.iterations = 3, .offset = 3.25f}, // LVL 7 => radius 45
{.iterations = 3, .offset = 4.25f}, // LVL 8 => radius 57
{.iterations = 3, .offset = 5.50f}, // LVL 9 => radius 74
{.iterations = 4, .offset = 3.25f}, // LVL 10 => radius 91
{.iterations = 4, .offset = 4.00f}, // LVL 11 => radius 110
{.iterations = 4, .offset = 5.00f}, // LVL 12 => radius 135
{.iterations = 4, .offset = 6.00f}, // LVL 13 => radius 161
{.iterations = 4, .offset = 7.25f}, // LVL 14 => radius 195
{.iterations = 4, .offset = 8.25f}, // LVL 15 => radius 221
{.iterations = 5, .offset = 4.50f}, // LVL 16 => radius 250
{.iterations = 5, .offset = 5.25f}, // LVL 17 => radius 287
{.iterations = 5, .offset = 6.25f}, // LVL 18 => radius 330
{.iterations = 5, .offset = 7.25f}, // LVL 19 => radius 383
{.iterations = 5, .offset = 8.50f}, // LVL 20 => radius >450
};

auto params = ccalloc(1, struct dual_kawase_params);
params->iterations = 0;
params->offset = 1.0f;

log_info("blur-strength: %d", blur_args->strength.strength);
if (blur_args->strength.strength <= 0 && blur_args->size) {
// approximate blur_strength with gaussian blur_radius
if (blur_args->size < 6) {
blur_args->strength.strength = 1;
} else if (blur_args->size < 11) {
blur_args->strength.strength = 2;
} else if (blur_args->size < 17) {
blur_args->strength.strength = 3;
} else if (blur_args->size < 24) {
blur_args->strength.strength = 4;
} else if (blur_args->size < 32) {
blur_args->strength.strength = 5;
} else if (blur_args->size < 40) {
blur_args->strength.strength = 6;
} else if (blur_args->size < 51) {
blur_args->strength.strength = 7;
} else if (blur_args->size < 67) {
blur_args->strength.strength = 8;
} else if (blur_args->size < 83) {
blur_args->strength.strength = 9;
} else if (blur_args->size < 101) {
blur_args->strength.strength = 10;
} else if (blur_args->size < 123) {
blur_args->strength.strength = 11;
} else if (blur_args->size < 148) {
blur_args->strength.strength = 12;
} else if (blur_args->size < 177) {
blur_args->strength.strength = 13;
} else if (blur_args->size < 208) {
blur_args->strength.strength = 14;
} else if (blur_args->size < 236) {
blur_args->strength.strength = 15;
} else if (blur_args->size < 269) {
blur_args->strength.strength = 16;
} else if (blur_args->size < 309) {
blur_args->strength.strength = 17;
} else if (blur_args->size < 357) {
blur_args->strength.strength = 18;
} else if (blur_args->size < 417) {
blur_args->strength.strength = 19;
} else {
blur_args->strength.strength = 20;
}
}

if (blur_args->strength.strength > 0) {
assert(blur_args->strength.strength <= 20);
params->iterations = strength_levels[blur_args->strength.strength - 1].iterations;
params->offset = strength_levels[blur_args->strength.strength - 1].offset;
}

params->expand = 2 * (int)exp2f((float)params->iterations) *
(256 - (int)(256.0f - params->offset)) +
1;

log_info("blur-strength: %d [.iter = %d, .offset = %f]",
blur_args->strength.strength, params->iterations, params->offset);

return params;
}

void init_backend_base(struct backend_base *base, session_t *ps) {
base->c = ps->c;
base->loop = ps->loop;
base->root = ps->root;
base->busy = false;
base->ops = NULL;
base->ps = ps;
}
11 changes: 11 additions & 0 deletions src/backend/backend_common.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,15 @@ typedef struct conv conv;
typedef struct backend_base backend_t;
struct backend_operations;

typedef struct dual_kawase_params {
/// Number of downsample passes
int iterations;
/// Pixel offset for down- and upsample
float offset;
/// Save area around blur target (@ref resize_width, @ref resize_height)
int expand;
} dual_kawase_params_t;

bool build_shadow(xcb_connection_t *, xcb_drawable_t, double opacity, int width,
int height, const conv *kernel, xcb_render_picture_t shadow_pixel,
xcb_pixmap_t *pixmap, xcb_render_picture_t *pict);
Expand All @@ -41,3 +50,5 @@ default_backend_render_shadow(backend_t *backend_data, int width, int height,
void init_backend_base(struct backend_base *base, session_t *ps);

struct conv **generate_blur_kernel(enum blur_method method, void *args, int *kernel_count);

struct dual_kawase_params *generate_dual_kawase_params(void *args);
2 changes: 1 addition & 1 deletion src/backend/dummy/dummy.c
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ static void dummy_check_image(struct backend_base *base, const struct dummy_imag
assert(*tmp->refcount > 0);
}

void dummy_compose(struct backend_base *base, void *image, int dst_x attr_unused,
void dummy_compose(struct backend_base *base, struct managed_win *w attr_unused, void *image, int dst_x attr_unused,
int dst_y attr_unused, const region_t *reg_paint attr_unused,
const region_t *reg_visible attr_unused) {
dummy_check_image(base, image);
Expand Down
Loading