Bug fix: A XserverRegion leak
- Fix a XserverRegion leak introduced in b78ab316fd
. I hope this is the
reason of the slowdowns many users reported. Thanks to xrestop!
- Cache the screen region as a variable.
- Add debugging code for region allocation.
This commit is contained in:
parent
a0b0ff5d0a
commit
9fb62874c1
|
@ -69,6 +69,8 @@ Picture root_tile;
|
||||||
XserverRegion all_damage;
|
XserverRegion all_damage;
|
||||||
Bool has_name_pixmap;
|
Bool has_name_pixmap;
|
||||||
int root_height, root_width;
|
int root_height, root_width;
|
||||||
|
/// A region of the size of the screen.
|
||||||
|
XserverRegion screen_reg = None;
|
||||||
|
|
||||||
/// Pregenerated alpha pictures.
|
/// Pregenerated alpha pictures.
|
||||||
Picture *alpha_picts = NULL;
|
Picture *alpha_picts = NULL;
|
||||||
|
@ -1638,6 +1640,16 @@ win_paint_win(Display *dpy, win *w, Picture tgt_buffer) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Rebuild cached <code>screen_reg</code>.
|
||||||
|
*/
|
||||||
|
static void
|
||||||
|
rebuild_screen_reg(Display *dpy) {
|
||||||
|
if (screen_reg)
|
||||||
|
XFixesDestroyRegion(dpy, screen_reg);
|
||||||
|
screen_reg = get_screen_region(dpy);
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
paint_all(Display *dpy, XserverRegion region, win *t) {
|
paint_all(Display *dpy, XserverRegion region, win *t) {
|
||||||
#ifdef DEBUG_REPAINT
|
#ifdef DEBUG_REPAINT
|
||||||
|
@ -1652,7 +1664,7 @@ paint_all(Display *dpy, XserverRegion region, win *t) {
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
// Remove the damaged area out of screen
|
// Remove the damaged area out of screen
|
||||||
XFixesIntersectRegion(dpy, region, region, get_screen_region(dpy));
|
XFixesIntersectRegion(dpy, region, region, screen_reg);
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef MONITOR_REPAINT
|
#ifdef MONITOR_REPAINT
|
||||||
|
@ -2483,6 +2495,8 @@ configure_win(Display *dpy, XConfigureEvent *ce) {
|
||||||
root_width = ce->width;
|
root_width = ce->width;
|
||||||
root_height = ce->height;
|
root_height = ce->height;
|
||||||
|
|
||||||
|
rebuild_screen_reg(dpy);
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2995,6 +3009,7 @@ ev_focus_out(XFocusChangeEvent *ev) {
|
||||||
|
|
||||||
inline static void
|
inline static void
|
||||||
ev_create_notify(XCreateWindowEvent *ev) {
|
ev_create_notify(XCreateWindowEvent *ev) {
|
||||||
|
assert(ev->parent == root);
|
||||||
add_win(dpy, ev->window, 0, ev->override_redirect);
|
add_win(dpy, ev->window, 0, ev->override_redirect);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -4520,6 +4535,8 @@ main(int argc, char **argv) {
|
||||||
root_width = DisplayWidth(dpy, scr);
|
root_width = DisplayWidth(dpy, scr);
|
||||||
root_height = DisplayHeight(dpy, scr);
|
root_height = DisplayHeight(dpy, scr);
|
||||||
|
|
||||||
|
rebuild_screen_reg(dpy);
|
||||||
|
|
||||||
root_picture = XRenderCreatePicture(dpy, root,
|
root_picture = XRenderCreatePicture(dpy, root,
|
||||||
XRenderFindVisualFormat(dpy, DefaultVisual(dpy, scr)),
|
XRenderFindVisualFormat(dpy, DefaultVisual(dpy, scr)),
|
||||||
CPSubwindowMode, &pa);
|
CPSubwindowMode, &pa);
|
||||||
|
|
|
@ -89,6 +89,26 @@
|
||||||
#include <GL/glx.h>
|
#include <GL/glx.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef DEBUG_ALLOC_REG
|
||||||
|
static inline XserverRegion
|
||||||
|
XFixesCreateRegion_(Display *dpy, XRectangle *p, int n,
|
||||||
|
const char *func, int line) {
|
||||||
|
XserverRegion reg = XFixesCreateRegion(dpy, p, n);
|
||||||
|
printf("%#010lx: XFixesCreateRegion() in %s():%d\n", reg, func, line);
|
||||||
|
return reg;
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline void
|
||||||
|
XFixesDestroyRegion_(Display *dpy, XserverRegion reg,
|
||||||
|
const char *func, int line) {
|
||||||
|
XFixesDestroyRegion(dpy, reg);
|
||||||
|
printf("%#010lx: XFixesDestroyRegion() in %s():%d\n", reg, func, line);
|
||||||
|
}
|
||||||
|
|
||||||
|
#define XFixesCreateRegion(dpy, p, n) XFixesCreateRegion_(dpy, p, n, __func__, __LINE__)
|
||||||
|
#define XFixesDestroyRegion(dpy, reg) XFixesDestroyRegion_(dpy, reg, __func__, __LINE__)
|
||||||
|
#endif
|
||||||
|
|
||||||
// === Constants ===
|
// === Constants ===
|
||||||
#if !(COMPOSITE_MAJOR > 0 || COMPOSITE_MINOR >= 2)
|
#if !(COMPOSITE_MAJOR > 0 || COMPOSITE_MINOR >= 2)
|
||||||
#error libXcomposite version unsupported
|
#error libXcomposite version unsupported
|
||||||
|
|
Loading…
Reference in New Issue