rendered paste bodyFrom 85f855b0a4972fd8d51b51bd3e77a6b68f964c1d Mon Sep 17 00:00:00 2001
From: Roi Cohen <roico@roico-desktop.(none)>
Date: Tue, 3 Jul 2007 14:16:51 +0300
Subject: [PATCH] fix cube's clip planes
---
include/cube.h | 3 ++-
plugins/cube.c | 42 ++++++++++++++++++++++++++++++++++++++++++
2 files changed, 44 insertions(+), 1 deletions(-)
diff --git a/include/cube.h b/include/cube.h
index b4670cb..c1dba8f 100644
--- a/include/cube.h
+++ b/include/cube.h
@@ -25,7 +25,7 @@
#include <compiz.h>
-#define CUBE_ABIVERSION 20070621
+#define CUBE_ABIVERSION 20070703
#define CUBE_DISPLAY_OPTION_ABI 0
#define CUBE_DISPLAY_OPTION_INDEX 1
@@ -112,6 +112,7 @@ typedef struct _CubeScreen {
PaintOutputProc paintOutput;
PaintTransformedOutputProc paintTransformedOutput;
PaintBackgroundProc paintBackground;
+ SetClipPlanesProc setClipPlanes;
PaintWindowProc paintWindow;
ApplyScreenTransformProc applyScreenTransform;
SetScreenOptionProc setScreenOption;
diff --git a/plugins/cube.c b/plugins/cube.c
index 63a428e..3523e7b 100644
--- a/plugins/cube.c
+++ b/plugins/cube.c
@@ -1681,6 +1681,46 @@ cubePaintBackground (CompScreen *s,
cubeUnSetBackgroundOpacity(s);
}
+static void
+cubeSetClipPlanes (CompScreen *s,
+ Region region,
+ CompOutput* output)
+{
+ CUBE_SCREEN(s);
+
+ glTranslatef(cs->outputXOffset, -cs->outputYOffset, 0.0f);
+ glScalef( cs->outputXScale, cs->outputYScale, 1.0f);
+
+ UNWRAP(cs, s, setClipPlanes);
+ (*s->setClipPlanes) (s, region, output);
+ WRAP(cs, s, setClipPlanes, cubeSetClipPlanes);
+
+ if (cs->invert == 1)
+ {
+ 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);
+ }
+ else
+ {
+ 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);
+ }
+}
+
static Bool
cubePaintWindow (CompWindow *w,
const WindowPaintAttrib *attrib,
@@ -2133,6 +2173,7 @@ cubeInitScreen (CompPlugin *p,
WRAP (cs, s, paintOutput, cubePaintOutput);
WRAP (cs, s, paintTransformedOutput, cubePaintTransformedOutput);
WRAP (cs, s, paintBackground, cubePaintBackground);
+ WRAP (cs, s, setClipPlanes, cubeSetClipPlanes);
WRAP (cs, s, paintWindow, cubePaintWindow);
WRAP (cs, s, applyScreenTransform, cubeApplyScreenTransform);
WRAP (cs, s, setScreenOption, cubeSetGlobalScreenOption);
@@ -2156,6 +2197,7 @@ cubeFiniScreen (CompPlugin *p,
UNWRAP (cs, s, paintOutput);
UNWRAP (cs, s, paintTransformedOutput);
UNWRAP (cs, s, paintBackground);
+ UNWRAP (cs, s, setClipPlanes);
UNWRAP (cs, s, paintWindow);
UNWRAP (cs, s, applyScreenTransform);
UNWRAP (cs, s, setScreenOption);
--
1.5.2.1.280.g38570