diff --git a/3d.c b/3d.c index 9c339b4..d770019 100644 --- a/3d.c +++ b/3d.c @@ -81,6 +81,7 @@ typedef struct _tdScreen PaintOutputProc paintOutput; DonePaintScreenProc donePaintScreen; InitWindowWalkerProc initWindowWalker; + ApplyScreenTransformProc applyScreenTransform; CubePaintTopProc paintTop; CubePaintBottomProc paintBottom; @@ -107,6 +108,8 @@ typedef struct _tdScreen CompWindow *first; CompWindow *last; + + Bool test; } tdScreen; #define GET_TD_DISPLAY(d) \ @@ -290,10 +293,12 @@ tdPaintWindow(CompWindow * w, Region region, unsigned int mask) { Bool status; + Bool wasCulled; + wasCulled = glIsEnabled(GL_CULL_FACE); TD_SCREEN(w->screen); TD_WINDOW(w); - +#if 0 if (tdw->currentZ != 0.0f) { Bool wasCulled; @@ -308,7 +313,7 @@ tdPaintWindow(CompWindow * w, mask |= PAINT_WINDOW_TRANSFORMED_MASK; - wasCulled = glIsEnabled(GL_CULL_FACE); + matrixTranslate(&wTransform, 0.0f, 0.0f, tdw->currentZ); @@ -556,15 +561,76 @@ tdPaintWindow(CompWindow * w, WRAP(tds, w->screen, paintWindow, tdPaintWindow); } else +#endif + + if (tdw->currentZ != 0.0f && !tds->test) + mask |= PAINT_WINDOW_NO_CORE_INSTANCE_MASK; + + + if (tds->test) + { + + + if (tdw->ftb) + { + glEnable(GL_CULL_FACE); // Re-enable culling. + glCullFace(GL_FRONT); + + + UNWRAP(tds, w->screen, paintWindow); + status = (*w->screen->paintWindow) (w, attrib, transform, region, mask); + WRAP(tds, w->screen, paintWindow, tdPaintWindow); + +} + else + { + glEnable(GL_CULL_FACE); // Re-enable culling. + glCullFace(GL_BACK); + + UNWRAP(tds, w->screen, paintWindow); + status = (*w->screen->paintWindow) (w, attrib, transform, region, mask); + WRAP(tds, w->screen, paintWindow, tdPaintWindow); + } + + glCullFace(GL_BACK); + + if (!wasCulled) + glDisable(GL_CULL_FACE); + + } + else { UNWRAP(tds, w->screen, paintWindow); status = (*w->screen->paintWindow) (w, attrib, transform, region, mask); WRAP(tds, w->screen, paintWindow, tdPaintWindow); } + return status; } + +static void +tdApplyScreenTransform (CompScreen *s, + const ScreenPaintAttrib *sAttrib, + CompOutput *output, + CompTransform *transform) +{ + TD_SCREEN (s); + + UNWRAP (tds, s, applyScreenTransform); + (*s->applyScreenTransform) (s, sAttrib, output, transform); + WRAP (tds, s, applyScreenTransform, tdApplyScreenTransform); + + /* + if (!tds->test) + { + matrixScale(transform, 0.5, 0.5, 0.5); + } + */ + +} + static void tdAddWindow(CompScreen *s, CompWindow *w) { TD_SCREEN(s); @@ -653,9 +719,75 @@ tdPaintTransformedOutput(CompScreen * s, } } + UNWRAP(tds, s, paintTransformedOutput); (*s->paintTransformedOutput) (s, sAttrib, transform, region, output, mask); WRAP(tds, s, paintTransformedOutput, tdPaintTransformedOutput); + tds->test = TRUE; + + { + CompTransform sTransform = *transform; + screenLighting (s, TRUE); + + (*s->applyScreenTransform) (s, sAttrib, output, &sTransform); + + + + + + CompWindow *w; + CompWalker walk; + + + + + (*s->initWindowWalker) (s, &walk); + + + /* paint all windows from bottom to top */ + for (w = (*walk.first) (s); w; w = (*walk.next) (w)) + { + CompTransform mTransform = sTransform; + + TD_WINDOW (w); + if (w->destroyed) + continue; + + if (!w->shaded) + { + if (w->attrib.map_state != IsViewable || !w->damaged) + continue; + } + if (tdw->currentZ != 0.0f) + { + matrixScale(&mTransform,1.0 + tdw->currentZ,1.0 + tdw->currentZ,1.0 + tdw->currentZ); + s->enableOutputClipping (s, &mTransform, region, output); + + transformToScreenSpace (s, output, -sAttrib->zTranslate, + &mTransform); + + glPushMatrix (); + glLoadMatrixf (mTransform.m); + + + (*s->paintWindow) (w, &w->paint, &mTransform, w->clip, PAINT_WINDOW_ON_TRANSFORMED_SCREEN_MASK); + glPopMatrix (); + s->disableOutputClipping (s); + } + } + + + + + + + + } +tds->test = FALSE; + /* + UNWRAP(tds, s, paintTransformedOutput); + (*s->paintTransformedOutput) (s, sAttrib, transform, region, output, mask); + WRAP(tds, s, paintTransformedOutput, tdPaintTransformedOutput);*/ } static Bool @@ -808,7 +940,7 @@ tdInitWindowWalker (CompScreen *s, CompWalker* walker) WRAP (tds, s, initWindowWalker, tdInitWindowWalker); if ((tds->active || tds->tdWindowExists) && - cs->paintOrder == BTF) + cs->paintOrder == BTF && tds->test) { walker->first = tdWalkFirst; walker->last = tdWalkLast; @@ -816,6 +948,7 @@ tdInitWindowWalker (CompScreen *s, CompWalker* walker) walker->prev = tdWalkPrev; } + } static Bool tdInitPluginForDisplay (CompPlugin *p, CompDisplay *d) @@ -864,6 +997,8 @@ static Bool tdInitPluginForDisplay (CompPlugin *p, CompDisplay *d) WRAP(tds, s, donePaintScreen, tdDonePaintScreen); WRAP(tds, s, preparePaintScreen, tdPreparePaintScreen); WRAP(tds, s, initWindowWalker, tdInitWindowWalker); + + WRAP (tds, s, applyScreenTransform, tdApplyScreenTransform); } } } @@ -895,6 +1030,9 @@ static void tdFiniPluginForDisplay (CompPlugin *p, CompDisplay *d) UNWRAP(tds, s, donePaintScreen); UNWRAP(tds, s, preparePaintScreen); UNWRAP(tds, s, initWindowWalker); + + UNWRAP (tds, s, applyScreenTransform); + } cubeDisplayPrivateIndex = -1;