All pastes #618552 Raw Edit

Anonymous

public text v1 · immutable
·published 2007-07-14 01:04 UTC
rendered paste body
From fddfe5ea71143eec148071737879ff1e1403e9c2 Mon Sep 17 00:00:00 2001
From: Roi Cohen <roico@roico-desktop.(none)>
Date: Tue, 3 Jul 2007 14:13:52 +0300
Subject: [PATCH] add setClipPlanes wrappable function

---
 include/compiz.h |   11 ++++++++++-
 src/paint.c      |   48 ++++++++++++++++++++++++++++--------------------
 src/screen.c     |    1 +
 3 files changed, 39 insertions(+), 21 deletions(-)

diff --git a/include/compiz.h b/include/compiz.h
index dd34f00..3d37309 100644
--- a/include/compiz.h
+++ b/include/compiz.h
@@ -26,7 +26,7 @@
 #ifndef _COMPIZ_H
 #define _COMPIZ_H
 
-#define ABIVERSION 20070606
+#define ABIVERSION 20070703
 
 #include <stdio.h>
 #include <sys/time.h>
@@ -1320,6 +1320,10 @@ typedef void (*PaintBackgroundProc) (CompScreen   *screen,
 				     Region	  region,
 				     unsigned int mask);
 
+typedef void (*SetClipPlanesProc) (CompScreen	*screen,
+				   Region	region,
+				   CompOutput	*output);
+
 void
 preparePaintScreen (CompScreen *screen,
 		    int	       msSinceLastPaint);
@@ -1414,6 +1418,10 @@ paintBackground (CompScreen   *screen,
 		 Region	      region,
 		 unsigned int mask);
 
+void
+setClipPlanes (CompScreen   *screen,
+	       Region	    region,
+	       CompOutput   *output);
 
 /* texture.c */
 
@@ -2003,6 +2011,7 @@ struct _CompScreen {
     PaintTransformedOutputProc	   paintTransformedOutput;
     ApplyScreenTransformProc	   applyScreenTransform;
     PaintBackgroundProc		   paintBackground;
+    SetClipPlanesProc		   setClipPlanes;
     PaintWindowProc		   paintWindow;
     DrawWindowProc		   drawWindow;
     AddWindowGeometryProc	   addWindowGeometry;
diff --git a/src/paint.c b/src/paint.c
index 00cbf73..08456b2 100644
--- a/src/paint.c
+++ b/src/paint.c
@@ -272,29 +272,10 @@ paintTransformedOutput (CompScreen		*screen,
 
     if ((mask & CLIP_PLANE_MASK) == CLIP_PLANE_MASK)
     {
-	GLdouble h = screen->height;
-
-	GLdouble p1[2] = { region->extents.x1, h - region->extents.y2 };
-	GLdouble p2[2] = { region->extents.x2, h - region->extents.y1 };
-
-	GLdouble halfW = output->width / 2.0;
-	GLdouble halfH = output->height / 2.0;
-
-	GLdouble cx = output->region.extents.x1 + halfW;
-	GLdouble cy = (h - output->region.extents.y2) + halfH;
-
-	GLdouble top[4]    = { 0.0, halfH / (cy - p1[1]), 0.0, 0.5 };
-	GLdouble bottom[4] = { 0.0, halfH / (cy - p2[1]), 0.0, 0.5 };
-	GLdouble left[4]   = { halfW / (cx - p1[0]), 0.0, 0.0, 0.5 };
-	GLdouble right[4]  = { halfW / (cx - p2[0]), 0.0, 0.0, 0.5 };
-
 	glPushMatrix ();
 	glLoadMatrixf (sTransform.m);
 
-	glClipPlane (GL_CLIP_PLANE0, top);
-	glClipPlane (GL_CLIP_PLANE1, bottom);
-	glClipPlane (GL_CLIP_PLANE2, left);
-	glClipPlane (GL_CLIP_PLANE3, right);
+	(*screen->setClipPlanes) (screen, region, output);
 
 	glEnable (GL_CLIP_PLANE0);
 	glEnable (GL_CLIP_PLANE1);
@@ -1167,3 +1148,30 @@ paintBackground (CompScreen   *s,
 
     free (data);
 }
+
+void
+setClipPlanes (CompScreen   *screen,
+	       Region	    region,
+	       CompOutput   *output)
+{
+    GLdouble h = screen->height;
+
+    GLdouble p1[2] = { region->extents.x1, h - region->extents.y2 };
+    GLdouble p2[2] = { region->extents.x2, h - region->extents.y1 };
+
+    GLdouble halfW = output->width / 2.0;
+    GLdouble halfH = output->height / 2.0;
+
+    GLdouble cx = output->region.extents.x1 + halfW;
+    GLdouble cy = (h - output->region.extents.y2) + halfH;
+
+    GLdouble top[4]    = { 0.0, halfH / (cy - p1[1]), 0.0, 0.5 };
+    GLdouble bottom[4] = { 0.0, halfH / (cy - p2[1]), 0.0, 0.5 };
+    GLdouble left[4]   = { halfW / (cx - p1[0]), 0.0, 0.0, 0.5 };
+    GLdouble right[4]  = { halfW / (cx - p2[0]), 0.0, 0.0, 0.5 };
+
+    glClipPlane (GL_CLIP_PLANE0, top);
+    glClipPlane (GL_CLIP_PLANE1, bottom);
+    glClipPlane (GL_CLIP_PLANE2, left);
+    glClipPlane (GL_CLIP_PLANE3, right);
+}
diff --git a/src/screen.c b/src/screen.c
index 9c69c79..46a58b8 100644
--- a/src/screen.c
+++ b/src/screen.c
@@ -1565,6 +1565,7 @@ addScreen (CompDisplay *display,
     s->applyScreenTransform	  = applyScreenTransform;
     s->paintBackground		  = paintBackground;
     s->paintWindow		  = paintWindow;
+    s->setClipPlanes		  = setClipPlanes;
     s->drawWindow		  = drawWindow;
     s->addWindowGeometry	  = addWindowGeometry;
     s->drawWindowTexture	  = drawWindowTexture;
-- 
1.5.2.1.280.g38570