summaryrefslogtreecommitdiff
path: root/beryl-plugins/src/cube.c
diff options
context:
space:
mode:
authoronestone <onestone@d7aaf104-2d23-0410-ae22-9d23157bf5a3>2007-01-29 00:39:31 +0000
committeronestone <onestone@d7aaf104-2d23-0410-ae22-9d23157bf5a3>2007-01-29 00:39:31 +0000
commit61b0b2a0bf964a43f7a8e11578053e7ce90aa9bd (patch)
tree50ca7fda262ba2cbe4de0dc56aabdd9aa3fdd295 /beryl-plugins/src/cube.c
parentf4e2d8a5450c799e95a940a97bc9dba63ecd29d8 (diff)
downloadmarex-dev-61b0b2a0bf964a43f7a8e11578053e7ce90aa9bd.tar.gz
marex-dev-61b0b2a0bf964a43f7a8e11578053e7ce90aa9bd.tar.bz2
beryl-plugins/beryl-core: compiz stencil replacement patch addopted for beryl
git-svn-id: file:///beryl/trunk@3335 d7aaf104-2d23-0410-ae22-9d23157bf5a3
Diffstat (limited to 'beryl-plugins/src/cube.c')
-rw-r--r--beryl-plugins/src/cube.c93
1 files changed, 73 insertions, 20 deletions
diff --git a/beryl-plugins/src/cube.c b/beryl-plugins/src/cube.c
index c8912f5..96eccf3 100644
--- a/beryl-plugins/src/cube.c
+++ b/beryl-plugins/src/cube.c
@@ -213,6 +213,7 @@ typedef struct _CubeScreen
PaintWindowProc paintWindow;
SetScreenOptionProc setScreenOption;
OutputChangeNotifyProc outputChangeNotify;
+ SetClipPlanesProc setClipPlanes;
CompOption opt[CUBE_SCREEN_OPTION_NUM];
@@ -352,6 +353,73 @@ cubeInitTextureCoords(CompScreen * s, CubeCapInfo * cubeCap,
cubeCap->tc[11] = COMP_TEX_COORD_Y(matrix, y1);
}
+static void cubeSetClipPlanes (CompScreen *s, int output)
+{
+ CUBE_SCREEN(s);
+
+ if (cs->mmMode == Multiple || s->nOutputDev == 1)
+ {
+ if (cs->invert != 1)
+ {
+ UNWRAP(cs, s, setClipPlanes);
+ (*s->setClipPlanes) (s, output);
+ WRAP(cs, s, setClipPlanes, cubeSetClipPlanes);
+ return;
+ }
+ GLdouble clipPlane0[] = { 1.0, 0.0, 0.5 / cs->distance, 0.0 };
+ GLdouble clipPlane1[] = { -1.0, 0.0, 0.5 / cs->distance, 0.0 };
+ GLdouble clipPlane2[] = { 0.0, -1.0, 0.5 / cs->distance, 0.0 };
+ GLdouble clipPlane3[] = { 0.0, 1.0, 0.5 / cs->distance, 0.0 };
+
+ glClipPlane (GL_CLIP_PLANE0, clipPlane0);
+ glClipPlane (GL_CLIP_PLANE1, clipPlane1);
+ glClipPlane (GL_CLIP_PLANE2, clipPlane2);
+ glClipPlane (GL_CLIP_PLANE3, clipPlane3);
+ return;
+ }
+
+ float left = s->outputDev[output].region.extents.x1 /
+ s->outputDev[output].width;
+ float top = s->outputDev[output].region.extents.y1 /
+ s->outputDev[output].height;
+
+ float right = (s->width - s->outputDev[output].region.extents.x2) /
+ s->outputDev[output].width;
+ float bottom = (s->height - s->outputDev[output].region.extents.y2) /
+ s->outputDev[output].height;
+
+
+ if (cs->invert != 1)
+ {
+ GLdouble clipPlane0[] = { 0.0, -1.0, 0.0, 0.5 + top};
+ GLdouble clipPlane1[] = { 0.0, 1.0, 0.0, 0.5 + bottom };
+ GLdouble clipPlane2[] = { 1.0, 0.0, 0.0, 0.5 + left};
+ GLdouble clipPlane3[] = { -1.0, 0.0, 0.0, 0.5 + right};
+
+ glClipPlane (GL_CLIP_PLANE0, clipPlane0);
+ glClipPlane (GL_CLIP_PLANE1, clipPlane1);
+ glClipPlane (GL_CLIP_PLANE2, clipPlane2);
+ glClipPlane (GL_CLIP_PLANE3, clipPlane3);
+ return;
+ }
+
+
+ float w = (float)(s->width - s->outputDev[output].width) /
+ s->outputDev[output].width;
+
+ float h = (float)(s->height - s->outputDev[output].height) /
+ s->outputDev[output].height;
+
+ GLdouble clipPlane0[] = { 1.0, 0.0, (0.5 + w) / cs->distance, 0.0 };
+ GLdouble clipPlane1[] = { -1.0, 0.0, (0.5 + w) / cs->distance, 0.0 };
+ GLdouble clipPlane2[] = { 0.0, -1.0, (0.5 + h) / cs->distance, 0.0 };
+ GLdouble clipPlane3[] = { 0.0, 1.0, (0.5 + h) / cs->distance, 0.0 };
+
+ glClipPlane (GL_CLIP_PLANE0, clipPlane0);
+ glClipPlane (GL_CLIP_PLANE1, clipPlane1);
+ glClipPlane (GL_CLIP_PLANE2, clipPlane2);
+ glClipPlane (GL_CLIP_PLANE3, clipPlane3);
+}
static void cubeLoadImg(CompScreen * s, CubeCapInfo * cubeCap, int n)
{
@@ -466,6 +534,8 @@ static Bool cubeUpdateGeometry(CompScreen * s, int sides, Bool invert)
cs->invert = invert;
cs->distance = distance;
+
+
return TRUE;
}
@@ -1619,9 +1689,6 @@ cubePaintScreen(CompScreen * s,
cs->finalPaint=!(cs->opt[CUBE_SCREEN_OPTION_STUCK_TO_SCREEN].value.b);
if (cs->sky.name)
{
- if (mask & PAINT_SCREEN_WITH_TRANSFORMED_WINDOWS_MASK)
- glClear(GL_STENCIL_BUFFER_BIT);
-
screenLighting(s, FALSE);
glPushMatrix();
@@ -1648,9 +1715,6 @@ cubePaintScreen(CompScreen * s,
}
else
{
- if (mask & PAINT_SCREEN_WITH_TRANSFORMED_WINDOWS_MASK)
- glClear(GL_COLOR_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);
- else
glClear(GL_COLOR_BUFFER_BIT);
}
mask &= ~PAINT_SCREEN_CLEAR_MASK;
@@ -1953,9 +2017,6 @@ cubePaintTransformedScreen(CompScreen * s,
if (cs->sky.name)
{
- if (mask & PAINT_SCREEN_WITH_TRANSFORMED_WINDOWS_MASK)
- clearTargetOutput(s->display, GL_STENCIL_BUFFER_BIT);
-
screenLighting(s, FALSE);
glPushMatrix();
@@ -1989,11 +2050,7 @@ cubePaintTransformedScreen(CompScreen * s,
}
else
{
- if (mask & PAINT_SCREEN_WITH_TRANSFORMED_WINDOWS_MASK)
- clearTargetOutput(s->display,
- GL_COLOR_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);
- else
- clearTargetOutput(s->display, GL_COLOR_BUFFER_BIT);
+ clearTargetOutput(s->display, GL_COLOR_BUFFER_BIT);
}
mask &= ~PAINT_SCREEN_CLEAR_MASK;
@@ -2464,12 +2521,6 @@ cubePaintBackground(CompScreen * s, Region region, unsigned int mask)
{
CUBE_SCREEN(s);
- s->stencilRef++;
-
- if (cs->desktopOpacity == 0
- && !(mask & PAINT_BACKGROUND_WITH_STENCIL_MASK))
- return;
-
if ((cs->desktopOpacity != OPAQUE || s->berylDesktopManaged))
{
if (s->desktopWindowCount)
@@ -2968,6 +3019,7 @@ static Bool cubeInitScreen(CompPlugin * p, CompScreen * s)
WRAP(cs, s, paintWindow, cubePaintWindow);
WRAP(cs, s, setScreenOption, cubeSetGlobalScreenOption);
WRAP(cs, s, outputChangeNotify, cubeOutputChangeNotify);
+ WRAP(cs, s, setClipPlanes, cubeSetClipPlanes);
cubeUpdateOutputs(s);
@@ -2999,6 +3051,7 @@ static void cubeFiniScreen(CompPlugin * p, CompScreen * s)
UNWRAP(cs, s, paintWindow);
UNWRAP(cs, s, setScreenOption);
UNWRAP(cs, s, outputChangeNotify);
+ UNWRAP(cs, s, setClipPlanes);
removeScreenAction(s, &cd->opt[CUBE_DISPLAY_OPTION_UNFOLD].value.action);