[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 17:27:41
Message-ID: 200706121927.41698.onestone () opencompositing ! org
[Download RAW message or body]
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
["0005-Fixed-FTB-calculation-for-inside-cube-mode.patch" (text/x-diff)]
From dbdda65693a002017eec3e058d45c9a56b2d2f90 Mon Sep 17 00:00:00 2001
From: Dennis Kasprzyk <onestone@opencompositing.org>
Date: Tue, 12 Jun 2007 17:59:28 +0200
Subject: [PATCH] Fixed FTB calculation for inside cube mode.
---
plugins/cube.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/plugins/cube.c b/plugins/cube.c
index 5e5eab3..ae3bf31 100644
--- a/plugins/cube.c
+++ b/plugins/cube.c
@@ -973,7 +973,7 @@ cubeCheckFTB (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)
+ if (ortho[2] > 0.0f && pntC[2] > DEFAULT_Z_CAMERA)
{
/* The viewport is reversed, should be painted front to back. */
return TRUE;
--
1.5.0.5-dirty
["0008-Added-a-wrapabble-paintInside-function-to-allow-plug.patch" (text/x-diff)]
From 2c707d7bb1746ec7c856c2f7967a3e5f6000dd6b Mon Sep 17 00:00:00 2001
From: Dennis Kasprzyk <onestone@opencompositing.org>
Date: Tue, 12 Jun 2007 19:19:47 +0200
Subject: [PATCH] Added a wrapabble paintInside function to allow plugins to render \
something inside of the transparent cube.
---
include/cube.h | 7 +++++++
plugins/cube.c | 20 ++++++++++++++++++++
2 files changed, 27 insertions(+), 0 deletions(-)
diff --git a/include/cube.h b/include/cube.h
index 74cb360..0a87626 100644
--- a/include/cube.h
+++ b/include/cube.h
@@ -81,6 +81,12 @@ typedef void (*CubePaintBottomProc) (CompScreen *s,
CompOutput *output,
int size);
+typedef void (*CubePaintInsideProc) (CompScreen *s,
+ const ScreenPaintAttrib *sAttrib,
+ const CompTransform *transform,
+ CompOutput *output,
+ int size);
+
typedef Bool (*CubeCheckFTBProc) (CompScreen *s,
const ScreenPaintAttrib *sAttrib,
const CompTransform *transform,
@@ -121,6 +127,7 @@ typedef struct _CubeScreen {
CubeClearTargetOutputProc clearTargetOutput;
CubePaintTopProc paintTop;
CubePaintBottomProc paintBottom;
+ CubePaintInsideProc paintInside;
CubeCheckFTBProc checkFTB;
CubeCapDirectionProc capDirection;
diff --git a/plugins/cube.c b/plugins/cube.c
index 5e3e8c5..dda6ea8 100644
--- a/plugins/cube.c
+++ b/plugins/cube.c
@@ -1367,6 +1367,13 @@ cubePaintBottom (CompScreen *s,
}
static void
+cubePaintInside (CompScreen *s,
+ const ScreenPaintAttrib *sAttrib,
+ const CompTransform *transform,
+ CompOutput *output,
+ int size) {}
+
+static void
cubePaintTransformedOutput (CompScreen *s,
const ScreenPaintAttrib *sAttrib,
const CompTransform *transform,
@@ -1508,14 +1515,24 @@ cubePaintTransformedOutput (CompScreen *s,
{
glNormal3f (0.0f, -1.0f, 0.0f);
if (cs->desktopOpacity != OPAQUE)
+ {
(*cs->paintBottom) (s, &sa, transform, outputPtr, hsize);
+ glNormal3f (0.0f, 0.0f, -1.0f);
+ (*cs->paintInside) (s, &sa, transform, outputPtr, hsize);
+ glNormal3f (0.0f, -1.0f, 0.0f);
+ }
(*cs->paintTop) (s, &sa, transform, outputPtr, hsize);
}
else if (!topDir && !bottomDir)
{
glNormal3f (0.0f, 1.0f, 0.0f);
if (cs->desktopOpacity != OPAQUE)
+ {
(*cs->paintTop) (s, &sa, transform, outputPtr, hsize);
+ glNormal3f (0.0f, 0.0f, -1.0f);
+ (*cs->paintInside) (s, &sa, transform, outputPtr, hsize);
+ glNormal3f (0.0f, 1.0f, 0.0f);
+ }
(*cs->paintBottom) (s, &sa, transform, outputPtr, hsize);
}
else if (cs->desktopOpacity != OPAQUE)
@@ -1524,6 +1541,8 @@ cubePaintTransformedOutput (CompScreen *s,
(*cs->paintTop) (s, &sa, transform, outputPtr, hsize);
glNormal3f (0.0f, -1.0f, 0.0f);
(*cs->paintBottom) (s, &sa, transform, outputPtr, hsize);
+ glNormal3f (0.0f, 0.0f, -1.0f);
+ (*cs->paintInside) (s, &sa, transform, outputPtr, hsize);
}
glNormal3f (0.0f, 0.0f, -1.0f);
}
@@ -2108,6 +2127,7 @@ cubeInitScreen (CompPlugin *p,
cs->clearTargetOutput = cubeClearTargetOutput;
cs->paintTop = cubePaintTop;
cs->paintBottom = cubePaintBottom;
+ cs->paintInside = cubePaintInside;
cs->checkFTB = cubeCheckFTB;
cs->capDirection = cubeCapDirection;
--
1.5.0.5-dirty
["0006-Made-checkFTB-wrapable-needed-by-cubereflex-plugin.patch" (text/x-diff)]
From b3c15af3360c8373ba26425f1194ce6db99d32d9 Mon Sep 17 00:00:00 2001
From: Dennis Kasprzyk <onestone@opencompositing.org>
Date: Tue, 12 Jun 2007 18:07:41 +0200
Subject: [PATCH] Made checkFTB wrapable (needed by cubereflex plugin).
---
include/cube.h | 6 ++++++
plugins/cube.c | 3 ++-
2 files changed, 8 insertions(+), 1 deletions(-)
diff --git a/include/cube.h b/include/cube.h
index a8baf1f..c360a73 100644
--- a/include/cube.h
+++ b/include/cube.h
@@ -75,6 +75,11 @@ typedef void (*CubePaintTopBottomProc) (CompScreen *s,
CompOutput *output,
int size);
+typedef Bool (*CubeCheckFTBProc) (CompScreen *s,
+ const ScreenPaintAttrib *sAttrib,
+ const CompTransform *transform,
+ CompOutput *output);
+
typedef enum _PaintOrder
{
BTF = 0,
@@ -103,6 +108,7 @@ typedef struct _CubeScreen {
CubeGetRotationProc getRotation;
CubeClearTargetOutputProc clearTargetOutput;
CubePaintTopBottomProc paintTopBottom;
+ CubeCheckFTBProc checkFTB;
CompOption opt[CUBE_SCREEN_OPTION_NUM];
diff --git a/plugins/cube.c b/plugins/cube.c
index ae3bf31..2376760 100644
--- a/plugins/cube.c
+++ b/plugins/cube.c
@@ -996,7 +996,7 @@ cubeMoveViewportAndPaint (CompScreen *s,
CUBE_SCREEN (s);
- ftb = cubeCheckFTB (s, sAttrib, transform, outputPtr);
+ ftb = cs->checkFTB (s, sAttrib, transform, outputPtr);
if ((paintOrder == FTB && !ftb) ||
(paintOrder == BTF && ftb))
@@ -1983,6 +1983,7 @@ cubeInitScreen (CompPlugin *p,
cs->getRotation = cubeGetRotation;
cs->clearTargetOutput = cubeClearTargetOutput;
cs->paintTopBottom = cubePaintTopBottom;
+ cs->checkFTB = cubeCheckFTB;
s->privates[cd->screenPrivateIndex].ptr = cs;
--
1.5.0.5-dirty
["0007-Separated-paintTopBottom-into-individual-paintTop-an.patch" (text/x-diff)]
From 5e8900621b35a77f55730c67e1212df6f9447e71 Mon Sep 17 00:00:00 2001
From: Dennis Kasprzyk <onestone@opencompositing.org>
Date: Tue, 12 Jun 2007 19:11:22 +0200
Subject: [PATCH] Separated paintTopBottom into individual paintTop and paintBottom functions.
---
include/cube.h | 26 ++++++--
plugins/cube.c | 194 ++++++++++++++++++++++++++++++++++++++++++++++----------
2 files changed, 180 insertions(+), 40 deletions(-)
diff --git a/include/cube.h b/include/cube.h
index c360a73..74cb360 100644
--- a/include/cube.h
+++ b/include/cube.h
@@ -69,17 +69,29 @@ typedef void (*CubeClearTargetOutputProc) (CompScreen *s,
float xRotate,
float vRotate);
-typedef void (*CubePaintTopBottomProc) (CompScreen *s,
- const ScreenPaintAttrib *sAttrib,
- const CompTransform *transform,
- CompOutput *output,
- int size);
+typedef void (*CubePaintTopProc) (CompScreen *s,
+ const ScreenPaintAttrib *sAttrib,
+ const CompTransform *transform,
+ CompOutput *output,
+ int size);
+
+typedef void (*CubePaintBottomProc) (CompScreen *s,
+ const ScreenPaintAttrib *sAttrib,
+ const CompTransform *transform,
+ 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 enum _PaintOrder
{
BTF = 0,
@@ -107,8 +119,10 @@ typedef struct _CubeScreen {
CubeGetRotationProc getRotation;
CubeClearTargetOutputProc clearTargetOutput;
- CubePaintTopBottomProc paintTopBottom;
+ CubePaintTopProc paintTop;
+ CubePaintBottomProc paintBottom;
CubeCheckFTBProc checkFTB;
+ CubeCapDirectionProc capDirection;
CompOption opt[CUBE_SCREEN_OPTION_NUM];
diff --git a/plugins/cube.c b/plugins/cube.c
index 2376760..5e3e8c5 100644
--- a/plugins/cube.c
+++ b/plugins/cube.c
@@ -982,6 +982,72 @@ cubeCheckFTB (CompScreen *s,
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);
+
+ (*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[3] = 1.0f;
+
+ pntB[0] = 0.0f;
+ pntB[1] = y;
+ pntB[2] = 0.5f;
+ pntB[3] = 1.0f;
+
+ pntC[0] = 0.0f;
+ pntC[1] = y;
+ 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)
+ {
+ /* We see the top face of the cap */
+ return TRUE;
+ }
+
+ return FALSE;
+}
+
static void
cubeMoveViewportAndPaint (CompScreen *s,
const ScreenPaintAttrib *sAttrib,
@@ -1190,15 +1256,14 @@ cubeClearTargetOutput (CompScreen *s,
}
static void
-cubePaintTopBottom (CompScreen *s,
- const ScreenPaintAttrib *sAttrib,
- const CompTransform *transform,
- CompOutput *output,
- int size)
+cubePaintTop (CompScreen *s,
+ const ScreenPaintAttrib *sAttrib,
+ const CompTransform *transform,
+ CompOutput *output,
+ int size)
{
ScreenPaintAttrib sa = *sAttrib;
CompTransform sTransform = *transform;
- int i;
CUBE_SCREEN (s);
@@ -1227,35 +1292,69 @@ cubePaintTopBottom (CompScreen *s,
glVertexPointer (3, GL_FLOAT, 0, cs->vertices);
- for (i = 0; i < 2; i++)
+ if (cs->invert == 1 && size == 4 && cs->texture.name)
{
- if ((i == 0 && sAttrib->vRotate <= 0.0f) ||
- (i == 1 && sAttrib->vRotate > 0.0f))
- {
- glNormal3f (0.0f, -1.0f, 0.0f);
- if (cs->invert == 1 && size == 4 && cs->texture.name)
- {
- enableTexture (s, &cs->texture, COMP_TEXTURE_FILTER_GOOD);
- glTexCoordPointer (2, GL_FLOAT, 0, cs->tc);
- glDrawArrays (GL_TRIANGLE_FAN, 0, cs->nVertices >> 1);
- disableTexture (s, &cs->texture);
- glDisableClientState (GL_TEXTURE_COORD_ARRAY);
- }
- else
- {
- glDisableClientState (GL_TEXTURE_COORD_ARRAY);
- glDrawArrays (GL_TRIANGLE_FAN, 0, cs->nVertices >> 1);
- }
- }
- else
- {
- glNormal3f (0.0f, 1.0f, 0.0f);
- glDrawArrays (GL_TRIANGLE_FAN, cs->nVertices >> 1,
- cs->nVertices >> 1);
- }
+ enableTexture (s, &cs->texture, COMP_TEXTURE_FILTER_GOOD);
+ glTexCoordPointer (2, GL_FLOAT, 0, cs->tc);
+ glDrawArrays (GL_TRIANGLE_FAN, 0, cs->nVertices >> 1);
+ disableTexture (s, &cs->texture);
+ glDisableClientState (GL_TEXTURE_COORD_ARRAY);
+ }
+ else
+ {
+ glDisableClientState (GL_TEXTURE_COORD_ARRAY);
+ glDrawArrays (GL_TRIANGLE_FAN, 0, cs->nVertices >> 1);
+ }
+
+ glPopMatrix ();
+
+ glColor4usv (defaultColor);
+ glEnableClientState (GL_TEXTURE_COORD_ARRAY);
+
+ screenTexEnvMode (s, GL_REPLACE);
+ glDisable (GL_BLEND);
+ glBlendFunc (GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
+}
+
+static void
+cubePaintBottom (CompScreen *s,
+ const ScreenPaintAttrib *sAttrib,
+ const CompTransform *transform,
+ CompOutput *output,
+ int size)
+{
+ ScreenPaintAttrib sa = *sAttrib;
+ CompTransform sTransform = *transform;
+
+ CUBE_SCREEN (s);
+
+ screenLighting (s, TRUE);
+
+ glColor4us (cs->color[0], cs->color[1], cs->color[2], cs->desktopOpacity);
+
+ glPushMatrix ();
+
+ sa.yRotate += (360.0f / size) * (cs->xRotations + 1);
+ if (!cs->opt[CUBE_SCREEN_OPTION_ADJUST_IMAGE].value.b)
+ sa.yRotate -= (360.0f / size) * s->x;
+
+ (*s->applyScreenTransform) (s, &sa, output, &sTransform);
+
+ glLoadMatrixf (sTransform.m);
+ glTranslatef (cs->outputXOffset, -cs->outputYOffset, 0.0f);
+ glScalef (cs->outputXScale, cs->outputYScale, 1.0f);
+
+ if (cs->desktopOpacity != OPAQUE)
+ {
+ screenTexEnvMode (s, GL_MODULATE);
+ glEnable (GL_BLEND);
+ glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
}
- glNormal3f (0.0f, 0.0f, -1.0f);
+ glVertexPointer (3, GL_FLOAT, 0, cs->vertices);
+
+ glDrawArrays (GL_TRIANGLE_FAN, cs->nVertices >> 1,
+ cs->nVertices >> 1);
glPopMatrix ();
@@ -1283,6 +1382,7 @@ cubePaintTransformedOutput (CompScreen *s,
PaintOrder paintOrder;
Bool clear;
Bool wasCulled = FALSE;
+ Bool topDir, bottomDir;
int output = 0;
CUBE_SCREEN (s);
@@ -1401,7 +1501,31 @@ cubePaintTransformedOutput (CompScreen *s,
(cs->invert != 1 || cs->desktopOpacity != OPAQUE ||
sa.vRotate != 0.0f || sa.yTranslate != 0.0f))
{
- (*cs->paintTopBottom) (s, &sa, transform, outputPtr, hsize);
+ topDir = cs->capDirection(s, &sa, transform, outputPtr, 0.5f);
+ bottomDir = cs->capDirection(s, &sa, transform, outputPtr, -0.5f);
+
+ if (topDir && bottomDir)
+ {
+ glNormal3f (0.0f, -1.0f, 0.0f);
+ if (cs->desktopOpacity != OPAQUE)
+ (*cs->paintBottom) (s, &sa, transform, outputPtr, hsize);
+ (*cs->paintTop) (s, &sa, transform, outputPtr, hsize);
+ }
+ else if (!topDir && !bottomDir)
+ {
+ glNormal3f (0.0f, 1.0f, 0.0f);
+ if (cs->desktopOpacity != OPAQUE)
+ (*cs->paintTop) (s, &sa, transform, outputPtr, hsize);
+ (*cs->paintBottom) (s, &sa, transform, outputPtr, hsize);
+ }
+ else if (cs->desktopOpacity != OPAQUE)
+ {
+ glNormal3f (0.0f, 1.0f, 0.0f);
+ (*cs->paintTop) (s, &sa, transform, outputPtr, hsize);
+ glNormal3f (0.0f, -1.0f, 0.0f);
+ (*cs->paintBottom) (s, &sa, transform, outputPtr, hsize);
+ }
+ glNormal3f (0.0f, 0.0f, -1.0f);
}
if (cs->invert == 1)
@@ -1982,8 +2106,10 @@ cubeInitScreen (CompPlugin *p,
cs->getRotation = cubeGetRotation;
cs->clearTargetOutput = cubeClearTargetOutput;
- cs->paintTopBottom = cubePaintTopBottom;
+ cs->paintTop = cubePaintTop;
+ cs->paintBottom = cubePaintBottom;
cs->checkFTB = cubeCheckFTB;
+ cs->capDirection = cubeCapDirection;
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