Improvement: --resize-damage
- Add --resize-damage to enlarge/shrink repaint region by a specific number of pixels, used for solving the line corruption issue with blur. Thanks to Nuck and jerri in #104 for reporting. - Fix the memory leak of blur shader string.
This commit is contained in:
parent
c93d8830ff
commit
8113e4e3b4
|
@ -403,6 +403,8 @@ typedef struct {
|
||||||
/// Whether to paint on X Composite overlay window instead of root
|
/// Whether to paint on X Composite overlay window instead of root
|
||||||
/// window.
|
/// window.
|
||||||
bool paint_on_overlay;
|
bool paint_on_overlay;
|
||||||
|
/// Resize damage for a specific number of pixels.
|
||||||
|
int resize_damage;
|
||||||
/// Whether to unredirect all windows if a full-screen opaque window
|
/// Whether to unredirect all windows if a full-screen opaque window
|
||||||
/// is detected.
|
/// is detected.
|
||||||
bool unredir_if_possible;
|
bool unredir_if_possible;
|
||||||
|
|
|
@ -4235,6 +4235,11 @@ usage(void) {
|
||||||
" --blur-kern '7,7,0.000003,0.000102,0.000849,0.001723,0.000849,0.000102,0.000003,0.000102,0.003494,0.029143,0.059106,0.029143,0.003494,0.000102,0.000849,0.029143,0.243117,0.493069,0.243117,0.029143,0.000849,0.001723,0.059106,0.493069,0.493069,0.059106,0.001723,0.000849,0.029143,0.243117,0.493069,0.243117,0.029143,0.000849,0.000102,0.003494,0.029143,0.059106,0.029143,0.003494,0.000102,0.000003,0.000102,0.000849,0.001723,0.000849,0.000102,0.000003'\n"
|
" --blur-kern '7,7,0.000003,0.000102,0.000849,0.001723,0.000849,0.000102,0.000003,0.000102,0.003494,0.029143,0.059106,0.029143,0.003494,0.000102,0.000849,0.029143,0.243117,0.493069,0.243117,0.029143,0.000849,0.001723,0.059106,0.493069,0.493069,0.059106,0.001723,0.000849,0.029143,0.243117,0.493069,0.243117,0.029143,0.000849,0.000102,0.003494,0.029143,0.059106,0.029143,0.003494,0.000102,0.000003,0.000102,0.000849,0.001723,0.000849,0.000102,0.000003'\n"
|
||||||
"--blur-background-exclude condition\n"
|
"--blur-background-exclude condition\n"
|
||||||
" Exclude conditions for background blur.\n"
|
" Exclude conditions for background blur.\n"
|
||||||
|
"--resize-damage integer\n"
|
||||||
|
" Resize damaged region by a specific number of pixels. A positive\n"
|
||||||
|
" value enlarges it while a negative one shrinks it. Useful for\n"
|
||||||
|
" fixing the line corruption issues of blur. May or may not\n"
|
||||||
|
" work with --glx-no-stencil. Shrinking doesn't function correctly.\n"
|
||||||
"--invert-color-include condition\n"
|
"--invert-color-include condition\n"
|
||||||
" Specify a list of conditions of windows that should be painted with\n"
|
" Specify a list of conditions of windows that should be painted with\n"
|
||||||
" inverted color. Resource-hogging, and is not well tested.\n"
|
" inverted color. Resource-hogging, and is not well tested.\n"
|
||||||
|
@ -4861,6 +4866,7 @@ get_cfg(session_t *ps, int argc, char *const *argv, bool first_pass) {
|
||||||
{ "glx-swap-method", required_argument, NULL, 299 },
|
{ "glx-swap-method", required_argument, NULL, 299 },
|
||||||
{ "fade-exclude", required_argument, NULL, 300 },
|
{ "fade-exclude", required_argument, NULL, 300 },
|
||||||
{ "blur-kern", required_argument, NULL, 301 },
|
{ "blur-kern", required_argument, NULL, 301 },
|
||||||
|
{ "resize-damage", required_argument, NULL, 302 },
|
||||||
// Must terminate with a NULL entry
|
// Must terminate with a NULL entry
|
||||||
{ NULL, 0, NULL, 0 },
|
{ NULL, 0, NULL, 0 },
|
||||||
};
|
};
|
||||||
|
@ -5089,6 +5095,9 @@ get_cfg(session_t *ps, int argc, char *const *argv, bool first_pass) {
|
||||||
free(ps->o.blur_kern);
|
free(ps->o.blur_kern);
|
||||||
if (!(ps->o.blur_kern = parse_matrix(ps, optarg)))
|
if (!(ps->o.blur_kern = parse_matrix(ps, optarg)))
|
||||||
exit(1);
|
exit(1);
|
||||||
|
case 302:
|
||||||
|
// --resize-damage
|
||||||
|
ps->o.resize_damage = atoi(optarg);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
usage();
|
usage();
|
||||||
|
@ -5952,6 +5961,7 @@ session_init(session_t *ps_old, int argc, char **argv) {
|
||||||
.synchronize = false,
|
.synchronize = false,
|
||||||
.detect_rounded_corners = false,
|
.detect_rounded_corners = false,
|
||||||
.paint_on_overlay = false,
|
.paint_on_overlay = false,
|
||||||
|
.resize_damage = 0,
|
||||||
.unredir_if_possible = false,
|
.unredir_if_possible = false,
|
||||||
.dbus = false,
|
.dbus = false,
|
||||||
.benchmark = 0,
|
.benchmark = 0,
|
||||||
|
@ -6577,6 +6587,7 @@ session_run(session_t *ps) {
|
||||||
if (!ps->redirected)
|
if (!ps->redirected)
|
||||||
free_region(ps, &ps->all_damage);
|
free_region(ps, &ps->all_damage);
|
||||||
|
|
||||||
|
resize_region(ps, ps->all_damage, ps->o.resize_damage);
|
||||||
if (ps->all_damage && !is_region_empty(ps, ps->all_damage, NULL)) {
|
if (ps->all_damage && !is_region_empty(ps, ps->all_damage, NULL)) {
|
||||||
static int paint = 0;
|
static int paint = 0;
|
||||||
paint_all(ps, ps->all_damage, t);
|
paint_all(ps, ps->all_damage, t);
|
||||||
|
|
|
@ -850,19 +850,69 @@ get_screen_region(session_t *ps) {
|
||||||
return XFixesCreateRegion(ps->dpy, &r, 1);
|
return XFixesCreateRegion(ps->dpy, &r, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Resize a region.
|
||||||
|
*/
|
||||||
|
static inline void
|
||||||
|
resize_region(session_t *ps, XserverRegion region, short mod) {
|
||||||
|
if (!mod || !region) return;
|
||||||
|
|
||||||
|
int nrects = 0, nnewrects = 0;
|
||||||
|
XRectangle *newrects = NULL;
|
||||||
|
XRectangle *rects = XFixesFetchRegion(ps->dpy, region, &nrects);
|
||||||
|
if (!rects || !nrects)
|
||||||
|
goto resize_region_end;
|
||||||
|
|
||||||
|
// Allocate memory for new rectangle list, because I don't know if it's
|
||||||
|
// safe to write in the memory Xlib allocates
|
||||||
|
newrects = calloc(nrects, sizeof(XRectangle));
|
||||||
|
if (!newrects) {
|
||||||
|
printf_errf("(): Failed to allocate memory.");
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Loop through all rectangles
|
||||||
|
for (int i = 0; i < nrects; ++i) {
|
||||||
|
int x1 = max_i(rects[i].x - mod, 0);
|
||||||
|
int y1 = max_i(rects[i].y - mod, 0);
|
||||||
|
int x2 = min_i(rects[i].x + rects[i].width + mod, ps->root_width);
|
||||||
|
int y2 = min_i(rects[i].y + rects[i].height + mod, ps->root_height);
|
||||||
|
int wid = x2 - x1;
|
||||||
|
int hei = y2 - y1;
|
||||||
|
if (wid <= 0 || hei <= 0)
|
||||||
|
continue;
|
||||||
|
newrects[nnewrects].x = x1;
|
||||||
|
newrects[nnewrects].y = y1;
|
||||||
|
newrects[nnewrects].width = wid;
|
||||||
|
newrects[nnewrects].height = hei;
|
||||||
|
++nnewrects;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Set region
|
||||||
|
XFixesSetRegion(ps->dpy, region, newrects, nnewrects);
|
||||||
|
|
||||||
|
resize_region_end:
|
||||||
|
cxfree(rects);
|
||||||
|
free(newrects);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Dump a region.
|
* Dump a region.
|
||||||
*/
|
*/
|
||||||
static inline void
|
static inline void
|
||||||
dump_region(const session_t *ps, XserverRegion region) {
|
dump_region(const session_t *ps, XserverRegion region) {
|
||||||
int nrects = 0, i;
|
int nrects = 0;
|
||||||
XRectangle *rects = XFixesFetchRegion(ps->dpy, region, &nrects);
|
XRectangle *rects = NULL;
|
||||||
if (!rects)
|
if (!rects && region)
|
||||||
return;
|
rects = XFixesFetchRegion(ps->dpy, region, &nrects);
|
||||||
|
|
||||||
for (i = 0; i < nrects; ++i)
|
printf_dbgf("(%#010lx): %d rects\n", region, nrects);
|
||||||
|
if (!rects) return;
|
||||||
|
for (int i = 0; i < nrects; ++i)
|
||||||
printf("Rect #%d: %8d, %8d, %8d, %8d\n", i, rects[i].x, rects[i].y,
|
printf("Rect #%d: %8d, %8d, %8d, %8d\n", i, rects[i].x, rects[i].y,
|
||||||
rects[i].width, rects[i].height);
|
rects[i].width, rects[i].height);
|
||||||
|
putchar('\n');
|
||||||
|
fflush(stdout);
|
||||||
|
|
||||||
cxfree(rects);
|
cxfree(rects);
|
||||||
}
|
}
|
||||||
|
|
|
@ -246,6 +246,7 @@ glx_init_blur(session_t *ps) {
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
ps->glx_frag_shader_blur = glx_create_shader(GL_FRAGMENT_SHADER, shader_str);
|
ps->glx_frag_shader_blur = glx_create_shader(GL_FRAGMENT_SHADER, shader_str);
|
||||||
|
free(shader_str);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!ps->glx_frag_shader_blur) {
|
if (!ps->glx_frag_shader_blur) {
|
||||||
|
|
Loading…
Reference in New Issue