summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDanny Baumann <dannybaumann@web.de>2007-06-27 15:29:18 +0200
committerDanny Baumann <dannybaumann@web.de>2007-06-27 15:29:18 +0200
commit7bc0e685440908879784f00850ecd7c5443d29ac (patch)
treec61b74dd942c76d405fa47a90560f1ea5a554594
parent7752de34707d9cdee8ecbe7c8a68625e5a7b7709 (diff)
download3d-7bc0e685440908879784f00850ecd7c5443d29ac.tar.gz
3d-7bc0e685440908879784f00850ecd7c5443d29ac.tar.bz2
More cleanup.
-rw-r--r--3d.c95
1 files changed, 46 insertions, 49 deletions
diff --git a/3d.c b/3d.c
index 0169db7..86ca62e 100644
--- a/3d.c
+++ b/3d.c
@@ -57,6 +57,16 @@ typedef struct _tdDisplay
FiniPluginForDisplayProc finiPluginForDisplay;
} tdDisplay;
+typedef struct _tdWindow
+{
+ float z;
+ float currentZ;
+ Bool ftb;
+
+ CompWindow *next;
+ CompWindow *prev;
+} tdWindow;
+
typedef struct _tdScreen
{
int windowPrivateIndex;
@@ -86,23 +96,15 @@ typedef struct _tdScreen
int currentScreenNum;
+ tdWindow **lastInViewportList;
+ int lastInViewportListSize;
+
Bool active;
CompWindow *first;
CompWindow *last;
} tdScreen;
-typedef struct _tdWindow
-{
- float z;
- float currentZ;
- Bool ftb;
-
- CompWindow *next;
- CompWindow *prev;
-} tdWindow;
-
-
#define GET_TD_DISPLAY(d) \
((tdDisplay *) (d)->privates[displayPrivateIndex].ptr)
@@ -123,10 +125,6 @@ typedef struct _tdWindow
GET_TD_SCREEN (w->screen, \
GET_TD_DISPLAY (w->screen->display)))
-
-
-#define NUM_OPTIONS(s) (sizeof ((s)->opt) / sizeof (CompOption))
-
static Bool windowIs3D(CompWindow * w)
{
if (w->attrib.override_redirect)
@@ -205,14 +203,10 @@ static Bool differentResolutions(CompScreen * s)
static void tdPreparePaintScreen(CompScreen * screen, int msSinceLastPaint)
{
- tdWindow **lastInViewport;
-
CompWindow *w;
-
tdWindow *tdw;
int i;
-
float maxZoom;
TD_SCREEN(screen);
@@ -238,49 +232,46 @@ static void tdPreparePaintScreen(CompScreen * screen, int msSinceLastPaint)
tds->xMove = 0.0f;
}
- if (!tds->active)
+ if (tds->active)
{
- UNWRAP(tds, screen, preparePaintScreen);
- (*screen->preparePaintScreen) (screen, msSinceLastPaint);
- WRAP(tds, screen, preparePaintScreen, tdPreparePaintScreen);
-
- return;
- }
-
- lastInViewport = (tdWindow **) malloc(sizeof(tdWindow *) * screen->hsize);
+ if (tds->lastInViewportListSize < screen->hsize)
+ {
+ tds->lastInViewportList =
+ (tdWindow **) realloc(tds->lastInViewportList, sizeof(tdWindow *) * screen->hsize);
+ tds->lastInViewportListSize = screen->hsize;
+ }
- for (i = 0; i < screen->hsize; i++)
- lastInViewport[i] = NULL;
+ for (i = 0; i < screen->hsize; i++)
+ tds->lastInViewportList[i] = NULL;
- tds->maxZ = 0.0f;
+ tds->maxZ = 0.0f;
- for (w = screen->windows; w; w = w->next)
- {
- if (!windowIs3D(w))
- continue;
+ for (w = screen->windows; w; w = w->next)
+ {
+ if (!windowIs3D(w))
+ continue;
- tdw = GET_TD_WINDOW(w, tds);
- maxZoom = 0.0f;
+ tdw = GET_TD_WINDOW(w, tds);
+ maxZoom = 0.0f;
- for (i = 0; i < screen->hsize; i++)
- {
- if (IS_IN_VIEWPORT(w, i))
+ for (i = 0; i < screen->hsize; i++)
{
- if (lastInViewport[i] && lastInViewport[i]->z > maxZoom)
- maxZoom = lastInViewport[i]->z;
+ if (IS_IN_VIEWPORT(w, i))
+ {
+ if (tds->lastInViewportList[i] && tds->lastInViewportList[i]->z > maxZoom)
+ maxZoom = tds->lastInViewportList[i]->z;
- lastInViewport[i] = tdw;
+ tds->lastInViewportList[i] = tdw;
+ }
}
- }
- tdw->z = maxZoom + tdGetSpace(screen);
+ tdw->z = maxZoom + tdGetSpace(screen);
- if (tdw->z > tds->maxZ)
- tds->maxZ = tdw->z;
+ if (tdw->z > tds->maxZ)
+ tds->maxZ = tdw->z;
+ }
}
- free(lastInViewport);
-
UNWRAP(tds, screen, preparePaintScreen);
(*screen->preparePaintScreen) (screen, msSinceLastPaint);
WRAP(tds, screen, preparePaintScreen, tdPreparePaintScreen);
@@ -1008,6 +999,9 @@ static Bool tdInitScreen(CompPlugin * p, CompScreen * s)
tds->currentDifferentResolutions = differentResolutions(s);
tds->xMove = 0.0f;
+
+ tds->lastInViewportList = NULL;
+ tds->lastInViewportListSize = 0;
s->privates[tdd->screenPrivateIndex].ptr = tds;
@@ -1026,6 +1020,9 @@ static void tdFiniScreen(CompPlugin * p, CompScreen * s)
freeWindowPrivateIndex(s, tds->windowPrivateIndex);
+ if (tds->lastInViewportList)
+ free (tds->lastInViewportList);
+
UNWRAP (tds, s, initPluginForScreen);
UNWRAP (tds, s, finiPluginForScreen);