mirror of
https://github.com/yshui/picom.git
synced 2024-11-25 14:06:08 -05:00
Improvement: GLX: Use SCISSOR_TEST instead of STENCIL_TEST when possible
- GLX backend: Use GL_SCISSOR_TEST instead of STENCIL_TEST if there's only one rectangle in glx_set_clip(). Profiling with gDebugger shows a 10% performance improvement. - Add .desktop installation rules. (#97)
This commit is contained in:
parent
1a88e3d0c5
commit
a41f05ea92
3 changed files with 35 additions and 12 deletions
8
Makefile
8
Makefile
|
@ -6,6 +6,7 @@ CC ?= gcc
|
|||
PREFIX ?= /usr
|
||||
BINDIR ?= $(PREFIX)/bin
|
||||
MANDIR ?= $(PREFIX)/share/man/man1
|
||||
APPDIR ?= $(PREFIX)/share/applications
|
||||
|
||||
PACKAGES = x11 xcomposite xfixes xdamage xrender xext xrandr
|
||||
LIBS = -lm -lrt
|
||||
|
@ -79,7 +80,8 @@ else
|
|||
export LD_ALTEXEC = /usr/bin/ld.gold
|
||||
OBJS += backtrace-symbols.o
|
||||
LIBS += -lbfd
|
||||
CFLAGS += -ggdb -Weverything -Wno-disabled-macro-expansion -Wno-padded -Wno-gnu
|
||||
CFLAGS += -ggdb
|
||||
# CFLAGS += -Weverything -Wno-disabled-macro-expansion -Wno-padded -Wno-gnu
|
||||
endif
|
||||
|
||||
LIBS += $(shell pkg-config --libs $(PACKAGES))
|
||||
|
@ -112,9 +114,10 @@ man/%.1.html: man/%.1.asciidoc
|
|||
docs: $(MANPAGES) $(MANPAGES_HTML)
|
||||
|
||||
install: $(BINS) docs
|
||||
@install -d "$(DESTDIR)$(BINDIR)" "$(DESTDIR)$(MANDIR)"
|
||||
@install -d "$(DESTDIR)$(BINDIR)" "$(DESTDIR)$(MANDIR)" "$(DESTDIR)$(APPDIR)"
|
||||
@install -m755 $(BINS) "$(DESTDIR)$(BINDIR)"/
|
||||
@install -m644 $(MANPAGES) "$(DESTDIR)$(MANDIR)"/
|
||||
@install -m644 compton.desktop "$(DESTDIR)$(APPDIR)"/
|
||||
ifneq "$(DOCDIR)" ""
|
||||
@install -d "$(DESTDIR)$(DOCDIR)"
|
||||
@install -m644 README.md compton.sample.conf "$(DESTDIR)$(DOCDIR)"/
|
||||
|
@ -124,6 +127,7 @@ endif
|
|||
uninstall:
|
||||
@rm -f "$(DESTDIR)$(BINDIR)/compton" "$(DESTDIR)$(BINDIR)/compton-trans"
|
||||
@rm -f $(addprefix "$(DESTDIR)$(MANDIR)"/, compton.1 compton-trans.1)
|
||||
@rm -f "$(DESTDIR)$(APPDIR)/compton.desktop"
|
||||
ifneq "$(DOCDIR)" ""
|
||||
@rm -f $(addprefix "$(DESTDIR)$(DOCDIR)"/, README.md compton.sample.conf cdbus-driver.sh)
|
||||
endif
|
||||
|
|
|
@ -4136,7 +4136,7 @@ usage(void) {
|
|||
"--glx-no-stencil\n"
|
||||
" Avoid using stencil buffer under GLX backend. Might cause issues\n"
|
||||
" when rendering transparent content, may have a positive or\n"
|
||||
" negative effect on performance.\n"
|
||||
" negative effect on performance. (My test shows a 10% slowdown.)\n"
|
||||
#undef WARNING
|
||||
#ifndef CONFIG_DBUS
|
||||
#define WARNING WARNING_DISABLED
|
||||
|
|
37
src/opengl.c
37
src/opengl.c
|
@ -487,7 +487,31 @@ glx_set_clip(session_t *ps, XserverRegion reg) {
|
|||
if (ps->o.glx_no_stencil)
|
||||
return;
|
||||
|
||||
if (reg) {
|
||||
static XRectangle rect_blank = {
|
||||
.x = 0, .y = 0, .width = 0, .height = 0
|
||||
};
|
||||
|
||||
glDisable(GL_STENCIL_TEST);
|
||||
glDisable(GL_SCISSOR_TEST);
|
||||
|
||||
if (!reg)
|
||||
return;
|
||||
|
||||
int nrects = 0;
|
||||
XRectangle *rects = XFixesFetchRegion(ps->dpy, reg, &nrects);
|
||||
if (!nrects) {
|
||||
if (rects) XFree(rects);
|
||||
nrects = 1;
|
||||
rects = &rect_blank;
|
||||
}
|
||||
|
||||
assert(nrects);
|
||||
if (1 == nrects) {
|
||||
glEnable(GL_SCISSOR_TEST);
|
||||
glScissor(rects[0].x, ps->root_height - rects[0].y - rects[0].height,
|
||||
rects[0].width, rects[0].height);
|
||||
}
|
||||
else {
|
||||
glEnable(GL_STENCIL_TEST);
|
||||
glClear(GL_STENCIL_BUFFER_BIT);
|
||||
|
||||
|
@ -495,8 +519,6 @@ glx_set_clip(session_t *ps, XserverRegion reg) {
|
|||
glDepthMask(GL_FALSE);
|
||||
glStencilOp(GL_REPLACE, GL_KEEP, GL_KEEP);
|
||||
|
||||
int nrects = 0;
|
||||
XRectangle *rects = XFixesFetchRegion(ps->dpy, reg, &nrects);
|
||||
|
||||
glBegin(GL_QUADS);
|
||||
|
||||
|
@ -519,16 +541,13 @@ glx_set_clip(session_t *ps, XserverRegion reg) {
|
|||
|
||||
glEnd();
|
||||
|
||||
if (rects)
|
||||
XFree(rects);
|
||||
|
||||
glStencilOp(GL_KEEP, GL_KEEP, GL_KEEP);
|
||||
glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE);
|
||||
glDepthMask(GL_TRUE);
|
||||
}
|
||||
else {
|
||||
glDisable(GL_STENCIL_TEST);
|
||||
}
|
||||
|
||||
if (rects && &rect_blank != rects)
|
||||
XFree(rects);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in a new issue