From 3c1e003830fe4066c4ccca4f75abf381a5cb70c3 Mon Sep 17 00:00:00 2001 From: Richard Grenville Date: Sun, 21 Oct 2012 20:44:24 +0800 Subject: Improvement: Stop painting on regions of higher windows Sort of reverts cdf7db750d, but implements in a different way. (Well, maybe the pre-cdf7db750d way is actually better, if I'm willing to sacrifice some precious code reusability.) Basically, trading CPU for GPU, in an attempt to solve farseerfc and ichi-no-eda's problems. Highly experimental, could be revoked at any moment. --- compton.h | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) (limited to 'compton.h') diff --git a/compton.h b/compton.h index 56a397668..56c580993 100644 --- a/compton.h +++ b/compton.h @@ -276,6 +276,11 @@ typedef struct _win { Bool need_configure; XConfigureEvent queue_configure; + /// Region to be ignored when painting. Basically the region where + /// higher opaque windows will paint upon. Depends on window frame + /// opacity state, window geometry, window mapped/unmapped state, + /// window mode, of this and all higher windows. + XserverRegion reg_ignore; struct _win *prev_trans; } win; @@ -1038,6 +1043,39 @@ copy_region(Display *dpy, XserverRegion oldregion) { return region; } +/** + * Dump a region. + */ +static inline void +dump_region(Display *dpy, XserverRegion region) { + int nrects = 0, i; + XRectangle *rects = XFixesFetchRegion(dpy, region, &nrects); + if (!rects) + return; + + for (i = 0; i < nrects; ++i) + printf("Rect #%d: %8d, %8d, %8d, %8d\n", i, rects[i].x, rects[i].y, + rects[i].width, rects[i].height); + + XFree(rects); +} + +/** + * Check if a region is empty. + * + * Keith Packard said this is slow: + * http://lists.freedesktop.org/archives/xorg/2007-November/030467.html + */ +static inline Bool +is_region_empty(Display *dpy, XserverRegion region) { + int nrects = 0; + XRectangle *rects = XFixesFetchRegion(dpy, region, &nrects); + + XFree(rects); + + return !nrects; +} + /** * Add a window to damaged area. * -- cgit v1.2.1