diff options
author | Richard Grenville <[email protected]> | 2013-04-05 21:05:19 +0800 |
---|---|---|
committer | Richard Grenville <[email protected]> | 2013-04-05 21:05:19 +0800 |
commit | 53870fb7fe83f5ab54a0e37a553f3dd769e2fbbf (patch) | |
tree | 570c68806c57c2a5dd76f398bcb4d519f527fcb3 /compton.h | |
parent | ab53e73ce77aa44458de55f62abf6273ac44d540 (diff) | |
download | tdebase-53870fb7fe83f5ab54a0e37a553f3dd769e2fbbf.tar.gz tdebase-53870fb7fe83f5ab54a0e37a553f3dd769e2fbbf.zip |
Improvement: GLX: Cache region contents & --glx-no-rebind-pixmap
- Cache region contents in is_region_empty(), mostly useful only for GLX
backend to save one roundtrip to X.
- GLX backend: Add --glx-no-rebind-pixmap, which prevents rebinding of
GLX texture to pixmap on content change. It doesn't work on some
drivers, but it saves some CPU on those where it does.
- Wrap XFree() with a new function cxfree() since its man page claims
NULL pointers are not acceptable (although in fact it does...).
- Use macro to save some code in get_cfg(). Code clean-up.
Diffstat (limited to 'compton.h')
-rw-r--r-- | compton.h | 23 |
1 files changed, 16 insertions, 7 deletions
@@ -269,8 +269,7 @@ make_text_prop(session_t *ps, char *str) { printf_errfq(1, "(): Failed to allocate memory."); if (XmbTextListToTextProperty(ps->dpy, &str, 1, XStringStyle, pprop)) { - if (pprop->value) - XFree(pprop->value); + cxfree(pprop->value); free(pprop); pprop = NULL; } @@ -547,14 +546,15 @@ win_render(session_t *ps, win *w, int x, int y, int wid, int hei, double opacity } static inline void -set_tgt_clip(session_t *ps, XserverRegion reg) { +set_tgt_clip(session_t *ps, XserverRegion reg, + const XRectangle * const cache_rects, const int cache_nrects) { switch (ps->o.backend) { case BKEND_XRENDER: XFixesSetPictureClipRegion(ps->dpy, ps->tgt_buffer, 0, 0, reg); break; #ifdef CONFIG_VSYNC_OPENGL case BKEND_GLX: - glx_set_clip(ps, reg); + glx_set_clip(ps, reg, cache_rects, cache_nrects); break; #endif } @@ -854,7 +854,7 @@ dump_region(const session_t *ps, XserverRegion region) { printf("Rect #%d: %8d, %8d, %8d, %8d\n", i, rects[i].x, rects[i].y, rects[i].width, rects[i].height); - XFree(rects); + cxfree(rects); } /** @@ -865,13 +865,22 @@ dump_region(const session_t *ps, XserverRegion region) { * * @param ps current session * @param region region to check for + * @param pcache_rects a place to cache the dumped rectangles + * @param ncache_nrects a place to cache the number of dumped rectangles */ static inline bool -is_region_empty(const session_t *ps, XserverRegion region) { +is_region_empty(const session_t *ps, XserverRegion region, + XRectangle **pcache_rects, int *pcache_nrects) { int nrects = 0; XRectangle *rects = XFixesFetchRegion(ps->dpy, region, &nrects); - XFree(rects); + if (pcache_rects) + *pcache_rects = rects; + else + cxfree(rects); + + if (pcache_nrects) + *pcache_nrects = nrects; return !nrects; } |