[prev in list] [next in list] [prev in thread] [next in thread] 

List:       freedesktop-compiz
Subject:    Re: [compiz] window walking interface
From:       Dennis Kasprzyk <onestone () opencompositing ! org>
Date:       2007-06-12 19:16:48
Message-ID: 200706122116.48750.onestone () opencompositing ! org
[Download RAW message or body]

Am Dienstag 12 Juni 2007 19:27:41 schrieb Dennis Kasprzyk:
> Am Dienstag 12 Juni 2007 14:52:53 schrieb Danny Baumann:
> > Hi,
> >
> > > > Thanks for putting these changes in git, it indeed makes more sense
> > > > than the way I did it first.
> > > > I re-made the transparent cube patches to work now with this new
> > > > interface. Tell me what you think about it.
> >
> > I re-did Roi's patches for latest cube plugin changes and coding style.
> >
> > Attached are the following:
> > > 0001-cube-painting-order.txt:
> > >
> > > This is good to go in if you're able to help fix any regressions that
> > > may appear. There's some coding style changes that need to be made
> > > before I can let this go in, though.
> > >
> > > Please replace all C++ comments with C comments, keep declarations at
> > > the beginning of each scope and make sure lines are no longer than 80
> > > columns.
> >
> > This one is replaced by
> > 0001-Improve-cube-paint-order-calculations.patch.
> >
> > > 0002-plugin-events.txt:
> > >
> > > This is not OK. Plugin events should not be used at all now that 3d and
> > > rotate plugins can hook into the cube plugin directly. Just add
> > > whatever hooks that are appropriate to the cube plugin.
> >
> > Replaced by 0002-Added-rotation-state.patch. With that patch, there is a
> > rotation state variable in CubeScreen that is written by the plugin
> > rotating it, rotate in the current case.
> >
> > > 0003-transparent-cube.txt:
> > >
> > > Looks OK. The same coding style changes need to be made here too,
> > > though.
> >
> > Replaced by 0003-Add-cube-transparency.patch (which adds the cube
> > transparency) and
> > 0004-Added-option-to-enable-cube-transparency-only-on-but.patch (option
> > to enable transparency only on 'manual' rotation).
> >
> > Are these patches ok to go in?
> >
> > Regards,
> >
> > Danny
>
> Hi,
>
> here are some additional transcube patches.
>
> 0005:
> Fixes the FrontToBack calculation for inside cube mode.
>
> 0006:
> Makes the checkFTB function wrapable to allow other plugins like cubereflex
> to change the result of this function.
>
> 0007:
> Separates paintTopBottom into individual functions and fixes normals and
> painting order of the top and bottom caps.
>
> 0008:
> Adds a wrapable paintInside function to allow other plugins to render
> something inside of the transparent cube.
>
> Regards,
> Dennis

This is an additional patch that compines the two orientation checking 
function into one. It also disables the orientation checking functions for 
the "inside" cube mode. In inside cube mode some points of the orientation 
checking function get projected outside of the visible range and this 
produces wrong results.

Dennis

["0009-Combined-checkFTB-and-capDirection-into-one-checkOri.patch" (text/x-diff)]

From dbca3cff69a75c1951e6629630ce420ef7f59e1d Mon Sep 17 00:00:00 2001
From: Dennis Kasprzyk <onestone@beryl-project.org>
Date: Tue, 12 Jun 2007 21:10:26 +0200
Subject: [PATCH] Combined checkFTB and capDirection into one checkOrientation function.

---
 include/cube.h |   18 +++------
 plugins/cube.c |  120 +++++++++++++++++--------------------------------------
 2 files changed, 43 insertions(+), 95 deletions(-)

diff --git a/include/cube.h b/include/cube.h
index 0a87626..293bad1 100644
--- a/include/cube.h
+++ b/include/cube.h
@@ -87,16 +87,11 @@ typedef void (*CubePaintInsideProc) (CompScreen			*s,
 				     CompOutput			*output,
 				     int			size);
 
-typedef Bool (*CubeCheckFTBProc) (CompScreen              *s,
-				  const ScreenPaintAttrib *sAttrib,
-				  const CompTransform     *transform,
-				  CompOutput              *output);
-
-typedef Bool (*CubeCapDirectionProc) (CompScreen              *s,
-				      const ScreenPaintAttrib *sAttrib,
-				      const CompTransform     *transform,
-				      CompOutput              *output,
-				      float                   y);
+typedef Bool (*CubeCheckOrientationProc) (CompScreen              *s,
+					  const ScreenPaintAttrib *sAttrib,
+					  const CompTransform     *transform,
+					  CompOutput              *output,
+					  const float             points[3][3]);
 
 typedef enum _PaintOrder
 {
@@ -128,8 +123,7 @@ typedef struct _CubeScreen {
     CubePaintTopProc          paintTop;
     CubePaintBottomProc       paintBottom;
     CubePaintInsideProc       paintInside;
-    CubeCheckFTBProc          checkFTB;
-    CubeCapDirectionProc      capDirection;
+    CubeCheckOrientationProc  checkOrientation;
 
     CompOption opt[CUBE_SCREEN_OPTION_NUM];
 
diff --git a/plugins/cube.c b/plugins/cube.c
index dda6ea8..7d29ede 100644
--- a/plugins/cube.c
+++ b/plugins/cube.c
@@ -921,10 +921,11 @@ cubeDonePaintScreen (CompScreen *s)
 }
 
 static Bool
-cubeCheckFTB (CompScreen              *s,
-              const ScreenPaintAttrib *sAttrib,
-              const CompTransform     *transform,
-              CompOutput              *outputPtr)
+cubeCheckOrientation (CompScreen              *s,
+        	      const ScreenPaintAttrib *sAttrib,
+        	      const CompTransform     *transform,
+		      CompOutput              *outputPtr,
+		      const float             points[3][3])
 {
     CompTransform sTransform = *transform;
     float         mvp[16];
@@ -932,90 +933,27 @@ cubeCheckFTB (CompScreen              *s,
     float         vecA[3], vecB[3];
     float         ortho[3];
 
-    (*s->applyScreenTransform) (s, sAttrib, outputPtr, &sTransform);
-    transformToScreenSpace (s, outputPtr, -sAttrib->zTranslate, &sTransform);
-
-    MULTM (s->projection, sTransform.m, mvp);
-
-    pntA[0] = outputPtr->region.extents.x1;
-    pntA[1] = outputPtr->region.extents.y1,
-    pntA[2] = 0.0f;
-    pntA[3] = 1.0f;
-
-    pntB[0] = outputPtr->region.extents.x2;
-    pntB[1] = outputPtr->region.extents.y1;
-    pntB[2] = 0.0f;
-    pntB[3] = 1.0f;
-
-    pntC[0] = outputPtr->region.extents.x1 + outputPtr->width / 2.0f;
-    pntC[1] = outputPtr->region.extents.y1 + outputPtr->height / 2.0f;
-    pntC[2] = 0.0f;
-    pntC[3] = 1.0f;
-
-    MULTMV (mvp, pntA);
-    DIVV (pntA);
-
-    MULTMV (mvp, pntB);
-    DIVV (pntB);
-
-    MULTMV (mvp, pntC);
-    DIVV (pntC);
-
-    vecA[0] = pntC[0] - pntA[0];
-    vecA[1] = pntC[1] - pntA[1];
-    vecA[2] = pntC[2] - pntA[2];
-
-    vecB[0] = pntC[0] - pntB[0];
-    vecB[1] = pntC[1] - pntB[1];
-    vecB[2] = pntC[2] - pntB[2];
-
-    ortho[0] = vecA[1] * vecB[2] - vecA[2] * vecB[1];
-    ortho[1] = vecA[2] * vecB[0] - vecA[0] * vecB[2];
-    ortho[2] = vecA[0] * vecB[1] - vecA[1] * vecB[0];
-
-    if (ortho[2] > 0.0f && pntC[2] > DEFAULT_Z_CAMERA)
-    {
-	/* The viewport is reversed, should be painted front to back. */
-	return TRUE;
-    }
-
-    return FALSE;
-}
-
-static Bool
-cubeCapDirection (CompScreen              *s,
-        	  const ScreenPaintAttrib *sAttrib,
-        	  const CompTransform     *transform,
-        	  CompOutput              *outputPtr,
-		  float                   y)
-{
-    CompTransform sTransform = *transform;
-    float         mvp[16];
-    float         pntA[4], pntB[4], pntC[4];
-    float         vecA[3], vecB[3];
-    float         ortho[3];
+	CUBE_SCREEN (s);
 
-    CUBE_SCREEN (s);
-    
     (*s->applyScreenTransform) (s, sAttrib, outputPtr, &sTransform);
     matrixTranslate (&sTransform, cs->outputXOffset, -cs->outputYOffset, 0.0f);
     matrixScale (&sTransform, cs->outputXScale, cs->outputYScale, 1.0f);
 
     MULTM (s->projection, sTransform.m, mvp);
 
-    pntA[0] = -0.5f;
-    pntA[1] = y,
-    pntA[2] = 0.0f;
+    pntA[0] = points[0][0];
+    pntA[1] = points[0][1];
+    pntA[2] = points[0][2];
     pntA[3] = 1.0f;
 
-    pntB[0] = 0.0f;
-    pntB[1] = y;
-    pntB[2] = 0.5f;
+    pntB[0] = points[1][0];
+    pntB[1] = points[1][1];
+    pntB[2] = points[1][2];
     pntB[3] = 1.0f;
 
-    pntC[0] = 0.0f;
-    pntC[1] = y;
-    pntC[2] = 0.0f;
+    pntC[0] = points[2][0];
+    pntC[1] = points[2][1];
+    pntC[2] = points[2][2];
     pntC[3] = 1.0f;
 
     MULTMV (mvp, pntA);
@@ -1039,9 +977,10 @@ cubeCapDirection (CompScreen              *s,
     ortho[1] = vecA[2] * vecB[0] - vecA[0] * vecB[2];
     ortho[2] = vecA[0] * vecB[1] - vecA[1] * vecB[0];
 
+	
     if (ortho[2] > 0.0f)
     {
-	/* We see the top face of the cap */
+	/* The viewport is reversed, should be painted front to back. */
 	return TRUE;
     }
 
@@ -1062,7 +1001,17 @@ cubeMoveViewportAndPaint (CompScreen		  *s,
 
     CUBE_SCREEN (s);
 
-    ftb = cs->checkFTB (s, sAttrib, transform, outputPtr);
+    float vPoints[3][3] = { { -0.5, 0.0, cs->distance},
+			    { 0.0, 0.5, cs->distance},
+			    { 0.0, 0.0, cs->distance}};
+			    
+    /* Special handling for inside cube mode. Orientation calculation
+       doesn't work right because some points are transformed outside
+       the visible range. */
+    if (cs->invert == 1)
+	ftb = cs->checkOrientation (s, sAttrib, transform, outputPtr, vPoints);
+    else
+	ftb = FALSE;
 
     if ((paintOrder == FTB && !ftb) ||
         (paintOrder == BTF && ftb))
@@ -1508,8 +1457,14 @@ cubePaintTransformedOutput (CompScreen		    *s,
 	(cs->invert != 1 || cs->desktopOpacity != OPAQUE ||
 	 sa.vRotate != 0.0f || sa.yTranslate != 0.0f))
     {
-	topDir    = cs->capDirection(s, &sa, transform, outputPtr, 0.5f);
-	bottomDir = cs->capDirection(s, &sa, transform, outputPtr, -0.5f);
+	static float top[3][3] = { { 0.5, 0.5, 0.0},
+				   { 0.0, 0.5, -0.5},
+				   { 0.0, 0.5, 0.0}};
+	static float bottom[3][3] = { { 0.5, 0.5, 0.0},
+				      { 0.0, 0.5, -0.5},
+				      { 0.0, 0.5, 0.0}};
+	topDir    = cs->checkOrientation(s, &sa, transform, outputPtr, top);
+	bottomDir = cs->checkOrientation(s, &sa, transform, outputPtr, bottom);
 
 	if (topDir && bottomDir)
 	{
@@ -2128,8 +2083,7 @@ cubeInitScreen (CompPlugin *p,
     cs->paintTop          = cubePaintTop;
     cs->paintBottom       = cubePaintBottom;
     cs->paintInside       = cubePaintInside;
-    cs->checkFTB          = cubeCheckFTB;
-    cs->capDirection      = cubeCapDirection;
+    cs->checkOrientation  = cubeCheckOrientation;
 
     s->privates[cd->screenPrivateIndex].ptr = cs;
 
-- 
1.5.0.5-dirty



_______________________________________________
compiz mailing list
compiz@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/compiz


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic