summaryrefslogtreecommitdiffstats
path: root/opengl.c
diff options
context:
space:
mode:
authorRichard Grenville <[email protected]>2013-03-18 19:01:18 +0800
committerRichard Grenville <[email protected]>2013-03-18 19:01:18 +0800
commit69c3579a24635e9504bceabc1c76dfe96342c3b0 (patch)
tree037aed0ddfaafdc80c85ef19fde30ffbddea6457 /opengl.c
parent848103bc3447f814c51cb818836533e18e018bf5 (diff)
downloadtdebase-69c3579a24635e9504bceabc1c76dfe96342c3b0.tar.gz
tdebase-69c3579a24635e9504bceabc1c76dfe96342c3b0.zip
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)
Diffstat (limited to 'opengl.c')
-rw-r--r--opengl.c37
1 files changed, 28 insertions, 9 deletions
diff --git a/opengl.c b/opengl.c
index 21b3c181f..92b0292b0 100644
--- a/opengl.c
+++ b/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);
}
/**