Esempio n. 1
0
void
ExpandAnim::applyTransform ()
{
    GLMatrix *transform = &mTransform;
    float defaultXScale = 0.3f;
    float forwardProgress;
    float expandProgress;
    const float expandPhaseEnd = 0.5f;

    forwardProgress = getProgress ();

    if ((1 - forwardProgress) < expandPhaseEnd)
	expandProgress = (1 - forwardProgress) / expandPhaseEnd;
    else
	expandProgress = 1.0f;

    // animation movement
    transform->translate (WIN_X (mWindow) + WIN_W (mWindow) / 2.0f,
			  WIN_Y (mWindow) + WIN_H (mWindow) / 2.0f,
			  0.0f); 

    transform->scale (defaultXScale + (1.0f - defaultXScale) *
		      expandProgress,
		      (1 - forwardProgress), 0.0f);

    transform->translate (-(WIN_X (mWindow) + WIN_W (mWindow) / 2.0f),
		      	  -(WIN_Y (mWindow) + WIN_H (mWindow) / 2.0f),
		      	  0.0f);

}
Esempio n. 2
0
bool
ResizeWindow::glPaint (const GLWindowPaintAttrib &attrib,
		       const GLMatrix            &transform,
		       const CompRegion          &region,
		       unsigned int              mask)
{
    bool       status;

    if (window == static_cast<resize::CompWindowImpl*>(rScreen->logic.w)->impl ()
	&& rScreen->logic.mode == ResizeOptions::ModeStretch)
    {
	GLMatrix       wTransform (transform);
	BoxRec	       box;
	float	       xOrigin, yOrigin;
	float	       xScale, yScale;
	int            x, y;

	if (mask & PAINT_WINDOW_OCCLUSION_DETECTION_MASK)
	    return false;

	status = gWindow->glPaint (attrib, transform, region,
				   mask | PAINT_WINDOW_NO_CORE_INSTANCE_MASK);

	GLWindowPaintAttrib lastAttrib (gWindow->lastPaintAttrib ());

	if (window->alpha () || lastAttrib.opacity != OPAQUE)
	    mask |= PAINT_WINDOW_TRANSLUCENT_MASK;

	rScreen->logic.getPaintRectangle (&box);
	getStretchScale (&box, &xScale, &yScale);

	x = window->geometry (). x ();
	y = window->geometry (). y ();

	xOrigin = x - window->border ().left;
	yOrigin = y - window->border ().top;

	wTransform.translate (xOrigin, yOrigin, 0.0f);
	wTransform.scale (xScale, yScale, 1.0f);
	wTransform.translate ((rScreen->logic.geometry.x - x) / xScale - xOrigin,
			      (rScreen->logic.geometry.y - y) / yScale - yOrigin,
			      0.0f);

	gWindow->glDraw (wTransform, lastAttrib, region,
			 mask | PAINT_WINDOW_TRANSFORMED_MASK);
    }
    else
    {
	status = gWindow->glPaint (attrib, transform, region, mask);
    }

    return status;
}
Esempio n. 3
0
void MythRenderOpenGL2::PushTransformation(const UIEffects &fx, QPointF &center)
{
    GLMatrix newtop = m_transforms.top();
    if (fx.hzoom != 1.0 || fx.vzoom != 1.0 || fx.angle != 0.0)
    {
        newtop.translate(-center.x(), -center.y());
        newtop.scale(fx.hzoom, fx.vzoom);
        newtop.rotate(fx.angle);
        newtop.translate(center.x(), center.y());
    }
    m_transforms.push(newtop);
}
Esempio n. 4
0
bool
CubeScreen::cubeCheckOrientation (const GLScreenPaintAttrib &sAttrib,
				  const GLMatrix            &transform,
				  CompOutput                *output,
				  std::vector<GLVector>     &points)
{
    WRAPABLE_HND_FUNCTN_RETURN (bool, cubeCheckOrientation, sAttrib, transform, output, points)
    GLMatrix sTransform = transform;
    GLMatrix mvp, pm (priv->gScreen->projectionMatrix ()->getMatrix ());
    GLVector pntA, pntB, pntC;
    GLVector vecA, vecB, ortho;
    bool     rv = false;

    priv->gScreen->glApplyTransform (sAttrib, output, &sTransform);
    sTransform.translate (priv->mOutputXOffset, -priv->mOutputYOffset, 0.0f);
    sTransform.scale (priv->mOutputXScale, priv->mOutputYScale, 1.0f);

    mvp = pm * sTransform;

    pntA = mvp * points[0];

    if (pntA[3] < 0.0f)
	rv = !rv;

    pntA.homogenize ();

    pntB = mvp * points[1];

    if (pntB[3] < 0.0f)
	rv = !rv;

    pntB.homogenize ();

    pntC = mvp * points[2];
    pntC.homogenize ();

    vecA = pntC - pntA;
    vecB = pntC - pntB;

    ortho = vecA ^ vecB;

    if (ortho[2] > 0.0f)
	rv = !rv;

    return rv;
}
Esempio n. 5
0
bool 
RotateScreen::glPaintOutput (const GLScreenPaintAttrib &sAttrib,
			     const GLMatrix            &transform, 
			     const CompRegion          &region, 
			     CompOutput                *output,
			     unsigned int              mask)
{
    if (mGrabIndex || mMoving || mProgress != 0.0f)
    {
	GLMatrix sTransform = transform;

	sTransform.translate (0.0f, 0.0f, -mZoomTranslate);

	mask &= ~PAINT_SCREEN_REGION_MASK;
	mask |= PAINT_SCREEN_TRANSFORMED_MASK;
	
	return gScreen->glPaintOutput (sAttrib, sTransform, region, output, mask);
    }

    return gScreen->glPaintOutput (sAttrib, transform, region, output, mask);
}
Esempio n. 6
0
/* This function currently always performs occlusion detection to
   minimize paint regions. OpenGL precision requirements are no good
   enough to guarantee that the results from using occlusion detection
   is the same as without. It's likely not possible to see any
   difference with most hardware but occlusion detection in the
   transformed screen case should be made optional for those who do
   see a difference. */
void
PrivateGLScreen::paintOutputRegion (const GLMatrix   &transform,
				    const CompRegion &region,
				    CompOutput       *output,
				    unsigned int     mask)
{
    CompRegion    tmpRegion (region);
    CompWindow    *w;
    GLWindow      *gw;
    int           windowMask, odMask;
    bool          status, unredirectFS;
    bool          withOffset = false;
    GLMatrix      vTransform;
    CompPoint     offXY;
    std::set<CompWindow*> unredirected;

    CompWindowList                   pl;
    CompWindowList::reverse_iterator rit;

    unredirectFS = CompositeScreen::get (screen)->
	getOption ("unredirect_fullscreen_windows")->value ().b ();

    const CompMatch &unredirectable = CompositeScreen::get (screen)->
	getOption ("unredirect_match")->value ().match ();

    const CompString &blacklist =
	getOption ("unredirect_driver_blacklist")->value ().s ();

    bool blacklisted = driverIsBlacklisted (blacklist.c_str ());

    if (mask & PAINT_SCREEN_TRANSFORMED_MASK)
    {
	windowMask     = PAINT_WINDOW_ON_TRANSFORMED_SCREEN_MASK;
    }
    else
    {
	windowMask     = 0;
    }

    /*
     * We need to COPY the PaintList for now because there seem to be some
     * odd cases where the master list might change during the below loops.
     * (LP: #958540)
     */
    pl = cScreen->getWindowPaintList ();

    if (!(mask & PAINT_SCREEN_NO_OCCLUSION_DETECTION_MASK))
    {
	FullscreenRegion fs (*output, screen->region ());

	/* detect occlusions */
	for (rit = pl.rbegin (); rit != pl.rend (); ++rit)
	{
	    w = (*rit);
	    gw = GLWindow::get (w);

	    if (w->destroyed ())
		continue;

	    if (!w->shaded ())
	    {
		/* Non-damaged windows don't have valid pixmap
		 * contents and we aren't displaying them yet
		 * so don't factor them into occlusion detection */
		if (!gw->priv->cWindow->damaged ())
		{
		    gw->priv->clip = region;
		    continue;
		}
		if (!w->isViewable ())
		    continue;
	    }

	    /* copy region */
	    gw->priv->clip = tmpRegion;

	    odMask = PAINT_WINDOW_OCCLUSION_DETECTION_MASK;

	    if ((cScreen->windowPaintOffset ().x () != 0 ||
		 cScreen->windowPaintOffset ().y () != 0) &&
		!w->onAllViewports ())
	    {
		withOffset = true;

		offXY = w->getMovementForOffset (cScreen->windowPaintOffset ());

		vTransform = transform;
		vTransform.translate (offXY.x (), offXY.y (), 0);

		gw->priv->clip.translate (-offXY.x (), -offXY. y ());

		odMask |= PAINT_WINDOW_WITH_OFFSET_MASK;
		status = gw->glPaint (gw->paintAttrib (), vTransform,
				      tmpRegion, odMask);
	    }
	    else
	    {
		withOffset = false;
		status = gw->glPaint (gw->paintAttrib (), transform, tmpRegion,
				      odMask);
	    }

	    if (status)
	    {
		if (withOffset)
		{
		    tmpRegion -= w->region ().translated (offXY);
		}
		else
		    tmpRegion -= w->region ();
	    }

	    FullscreenRegion::WinFlags flags = 0;
	    if (w->type () & CompWindowTypeDesktopMask)
	        flags |= FullscreenRegion::Desktop;
	    if (w->alpha ())
		flags |= FullscreenRegion::Alpha;
	    
	    /* Anything which was not occlusion detected is not a suitable
	     * candidate for unredirection either */
	    if (!status)
		flags |= FullscreenRegion::NoOcclusionDetection;

	    CompositeWindow *cw = CompositeWindow::get (w);

	    /*
	     * Windows with alpha channels can partially occlude windows
	     * beneath them and so neither should be unredirected in that case.
	     *
	     * Performance note:  unredirectable.evaluate is SLOW because it
	     * involves regex matching. Too slow to do on every window for
	     * every frame. So we only call it if a window is redirected AND
	     * potentially needs unredirecting. This means changes to
	     * unredirect_match while a window is unredirected already may not
	     * take effect until it is un-fullscreened again. But that's better
	     * than the high price of regex matching on every frame.
	     */
	    if (unredirectFS &&
		!blacklisted &&
		!(mask & PAINT_SCREEN_TRANSFORMED_MASK) &&
		!(mask & PAINT_SCREEN_WITH_TRANSFORMED_WINDOWS_MASK) &&
		fs.isCoveredBy (w->region (), flags) &&
		(!cw->redirected () || unredirectable.evaluate (w)))
	    {
		unredirected.insert (w);
	    }
	    else
	    {
		if (!cw->redirected ())
		{
		    if (fs.allowRedirection (w->region ()))
		    {
			// 1. GLWindow::release to force gw->priv->needsRebind
			gw->release ();

			// 2. GLWindow::bind, which redirects the window,
			//    rebinds the pixmap, and then rebinds the pixmap
			//    to a texture.
			gw->bind ();

			// 3. Your window is now redirected again with the
			//    latest pixmap contents.
		    }
		    else
		    {
			unredirected.insert (w);
		    }
		}
	    }
	}
    }

    /* Unredirect any redirected fullscreen windows */
    foreach (CompWindow *fullscreenWindow, unredirected)
	CompositeWindow::get (fullscreenWindow)->unredirect ();

    if (!(mask & PAINT_SCREEN_NO_BACKGROUND_MASK))
	paintBackground (transform,
	                 tmpRegion,
	                 (mask & PAINT_SCREEN_TRANSFORMED_MASK));

    /* paint all windows from bottom to top */
    foreach (w, pl)
    {
	if (w->destroyed ())
	    continue;

        gw = GLWindow::get (w);

        /* Release any queued ConfigureWindow requests now */
	gw->priv->configureLock->release ();

	if (unredirected.find (w) != unredirected.end ())
	    continue;

	if (!w->shaded ())
	{
	    if (!w->isViewable ())
		continue;
	}

	const CompRegion &clip =
	    (!(mask & PAINT_SCREEN_NO_OCCLUSION_DETECTION_MASK)) ?
	    gw->clip () : region;

	if ((cScreen->windowPaintOffset ().x () != 0 ||
	     cScreen->windowPaintOffset ().y () != 0) &&
	    !w->onAllViewports ())
	{
	    offXY = w->getMovementForOffset (cScreen->windowPaintOffset ());

	    vTransform = transform;
	    vTransform.translate (offXY.x (), offXY.y (), 0);
	    gw->glPaint (gw->paintAttrib (), vTransform, clip,
		         windowMask | PAINT_WINDOW_WITH_OFFSET_MASK);
	}
	else
	{
	    gw->glPaint (gw->paintAttrib (), transform, clip, windowMask);
	}
    }
}