[beryl-commits] compiz mirror: Changes to 'master' (9685bac85cdc2d688f4f7f5b58ebb86c6c9513aa)
compiz at server.beryl-project.org
compiz at server.beryl-project.org
Thu Jun 21 18:24:12 CEST 2007
New commits:
commit 9685bac85cdc2d688f4f7f5b58ebb86c6c9513aa
Merge: a069bdaaf72e38da871681b70a6e92982a79f80f 7f4ef98d5920c67408775c6ea332102ea062b562
Author: Dennis Kasprzyk <onestone at opencompositing.org>
Date: Thu Jun 21 18:23:48 2007 +0200
Merge branch 'master' of git+ssh://onestone@git.freedesktop.org/git/xorg/app/compiz
commit a069bdaaf72e38da871681b70a6e92982a79f80f
Author: Dennis Kasprzyk <onestone at opencompositing.org>
Date: Thu Jun 21 18:23:19 2007 +0200
Bump cube ABI version.
commit ba7f99423ea384192a5f239bd7831607e31fd81c
Author: Dennis Kasprzyk <onestone at opencompositing.org>
Date: Thu Jun 21 18:22:43 2007 +0200
Combined checkFTB and capDirection into one checkOrientation function.
commit aac553781eac7218e0ec42e69b55a5fbb0f0868a
Author: Dennis Kasprzyk <onestone at opencompositing.org>
Date: Thu Jun 21 18:21:57 2007 +0200
Added a wrapabble paintInside function to allow plugins to render something inside of the transparent cube.
commit 30e16ec87ce3922290e394ccd482f62f559037e2
Author: Dennis Kasprzyk <onestone at opencompositing.org>
Date: Thu Jun 21 18:21:24 2007 +0200
Separated paintTopBottom into individual paintTop and paintBottom functions.
commit 50a1415209475394fc8cbc488e9b4e2b637d97b9
Author: Dennis Kasprzyk <onestone at opencompositing.org>
Date: Thu Jun 21 18:20:31 2007 +0200
Made chackFTB wrapable.
commit 04731b119e1fd67aefe52abe7e4cddabfbe34087
Author: Dennis Kasprzyk <onestone at opencompositing.org>
Date: Thu Jun 21 18:20:00 2007 +0200
Fixed FTB calculation for inside cube mode.
include/cube.h | 35 ++++++++--
plugins/cube.c | 199 ++++++++++++++++++++++++++++++++++++++++++--------------
2 files changed, 178 insertions(+), 56 deletions(-)
Modified: compiz/include/cube.h
===================================================================
--- compiz/include/cube.h
+++ compiz/include/cube.h
@@ -25,7 +25,7 @@
#include <compiz.h>
-#define CUBE_ABIVERSION 20070612
+#define CUBE_ABIVERSION 20070621
#define CUBE_DISPLAY_OPTION_ABI 0
#define CUBE_DISPLAY_OPTION_INDEX 1
@@ -69,11 +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 void (*CubePaintInsideProc) (CompScreen *s,
+ const ScreenPaintAttrib *sAttrib,
+ const CompTransform *transform,
+ CompOutput *output,
+ int size);
+
+typedef Bool (*CubeCheckOrientationProc) (CompScreen *s,
+ const ScreenPaintAttrib *sAttrib,
+ const CompTransform *transform,
+ CompOutput *output,
+ float points[3][3]);
typedef enum _PaintOrder
{
@@ -102,7 +120,10 @@ typedef struct _CubeScreen {
CubeGetRotationProc getRotation;
CubeClearTargetOutputProc clearTargetOutput;
- CubePaintTopBottomProc paintTopBottom;
+ CubePaintTopProc paintTop;
+ CubePaintBottomProc paintBottom;
+ CubePaintInsideProc paintInside;
+ CubeCheckOrientationProc checkOrientation;
CompOption opt[CUBE_SCREEN_OPTION_NUM];
Modified: compiz/plugins/cube.c
===================================================================
--- compiz/plugins/cube.c
+++ compiz/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,
+ float points[3][3])
{
CompTransform sTransform = *transform;
float mvp[16];
@@ -932,24 +933,27 @@ cubeCheckFTB (CompScreen *s,
float vecA[3], vecB[3];
float ortho[3];
+ CUBE_SCREEN (s);
+
(*s->applyScreenTransform) (s, sAttrib, outputPtr, &sTransform);
- transformToScreenSpace (s, outputPtr, -sAttrib->zTranslate, &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] = outputPtr->region.extents.x1;
- pntA[1] = outputPtr->region.extents.y1,
- 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] = outputPtr->region.extents.x2;
- pntB[1] = outputPtr->region.extents.y1;
- pntB[2] = 0.0f;
+ pntB[0] = points[1][0];
+ pntB[1] = points[1][1];
+ pntB[2] = points[1][2];
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[0] = points[2][0];
+ pntC[1] = points[2][1];
+ pntC[2] = points[2][2];
pntC[3] = 1.0f;
MULTMV (mvp, pntA);
@@ -973,6 +977,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)
{
/* The viewport is reversed, should be painted front to back. */
@@ -996,7 +1001,17 @@ cubeMoveViewportAndPaint (CompScreen *s,
CUBE_SCREEN (s);
- ftb = cubeCheckFTB (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))
@@ -1190,15 +1205,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 +1241,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 ();
@@ -1268,6 +1316,13 @@ cubePaintTopBottom (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,
@@ -1283,6 +1338,7 @@ cubePaintTransformedOutput (CompScreen *s,
PaintOrder paintOrder;
Bool clear;
Bool wasCulled = FALSE;
+ Bool topDir, bottomDir;
int output = 0;
CUBE_SCREEN (s);
@@ -1401,7 +1457,49 @@ cubePaintTransformedOutput (CompScreen *s,
(cs->invert != 1 || cs->desktopOpacity != OPAQUE ||
sa.vRotate != 0.0f || sa.yTranslate != 0.0f))
{
- (*cs->paintTopBottom) (s, &sa, transform, outputPtr, hsize);
+ 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)
+ {
+ 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)
+ {
+ 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);
+ (*cs->paintInside) (s, &sa, transform, outputPtr, hsize);
+ }
+ glNormal3f (0.0f, 0.0f, -1.0f);
}
if (cs->invert == 1)
@@ -1982,7 +2080,10 @@ cubeInitScreen (CompPlugin *p,
cs->getRotation = cubeGetRotation;
cs->clearTargetOutput = cubeClearTargetOutput;
- cs->paintTopBottom = cubePaintTopBottom;
+ cs->paintTop = cubePaintTop;
+ cs->paintBottom = cubePaintBottom;
+ cs->paintInside = cubePaintInside;
+ cs->checkOrientation = cubeCheckOrientation;
s->privates[cd->screenPrivateIndex].ptr = cs;
More information about the commits
mailing list