Arghl. Again a stupid bug caused by float having poor precision.

Reverting r700026 and changing floats to doubles again. I'd probably like
to change even the ones interfacing with OpenGL which I've left for now.


svn path=/trunk/KDE/kdebase/workspace/; revision=707987
This commit is contained in:
Luboš Luňák 2007-09-03 15:00:43 +00:00
parent 228928d45e
commit e6069e9cf6
49 changed files with 232 additions and 232 deletions

View file

@ -35,7 +35,7 @@ class Deleted
void copyToDeleted( Toplevel* c );
virtual ~Deleted(); // deleted only using unrefWindow()
int delete_refcount;
float window_opacity;
double window_opacity;
int desk;
QRect contentsRect; // for clientPos()/clientSize()
};

View file

@ -172,7 +172,7 @@ void EffectsHandlerImpl::windowUserMovedResized( EffectWindow* c, bool first, bo
ep.second->windowUserMovedResized( c, first, last );
}
void EffectsHandlerImpl::windowOpacityChanged( EffectWindow* c, float old_opacity )
void EffectsHandlerImpl::windowOpacityChanged( EffectWindow* c, double old_opacity )
{
if( static_cast<EffectWindowImpl*>(c)->window()->opacity() == old_opacity )
return;
@ -853,7 +853,7 @@ bool EffectWindowImpl::isMinimized() const
return false;
}
float EffectWindowImpl::opacity() const
double EffectWindowImpl::opacity() const
{
return toplevel->opacity();
}

View file

@ -92,7 +92,7 @@ class EffectsHandlerImpl : public EffectsHandler
// internal (used by kwin core or compositing code)
void startPaint();
void windowUserMovedResized( EffectWindow* c, bool first, bool last );
void windowOpacityChanged( EffectWindow* c, float old_opacity );
void windowOpacityChanged( EffectWindow* c, double old_opacity );
void windowAdded( EffectWindow* c );
void windowClosed( EffectWindow* c );
void windowDeleted( EffectWindow* c );
@ -149,7 +149,7 @@ class EffectWindowImpl : public EffectWindow
virtual bool isOnAllDesktops() const;
virtual int desktop() const; // prefer isOnXXX()
virtual bool isMinimized() const;
virtual float opacity() const;
virtual double opacity() const;
virtual QString caption() const;
virtual QPixmap icon() const;
virtual QString windowClass() const;

View file

@ -528,8 +528,8 @@ void BoxSwitchEffect::paintDesktopThumbnail( int iDesktop )
QSize size = QSize( displayWidth(), displayHeight());
size.scale( r.size(), Qt::KeepAspectRatio );
data.xScale = size.width() / float( displayWidth());
data.yScale = size.height() / float( displayHeight());
data.xScale = size.width() / double( displayWidth());
data.yScale = size.height() / double( displayHeight());
int width = int( displayWidth() * data.xScale );
int height = int( displayHeight() * data.yScale );
int x = r.x() + ( r.width() - width ) / 2;

View file

@ -121,7 +121,7 @@ void LiquidEffect::postPaintScreen()
// Use the shader
mShader->bind();
mShader->setUniform("time", mTime);
mShader->setUniform("time", (float)mTime);
// Render fullscreen quad with screen contents
glBegin(GL_QUADS);

View file

@ -44,7 +44,7 @@ class LiquidEffect : public Effect
GLShader* mShader;
bool mValid;
float mTime;
double mTime;
};
} // namespace

View file

@ -59,8 +59,8 @@ void TaskbarThumbnailEffect::postPaintScreen()
WindowPaintData thumbdata( w );
thumbdata.xTranslate = thumb.x() - w->x();
thumbdata.yTranslate = thumb.y() - w->y();
thumbdata.xScale = thumb.width() / (float)w->width();
thumbdata.yScale = thumb.height() / (float)w->height();
thumbdata.xScale = thumb.width() / (double)w->width();
thumbdata.yScale = thumb.height() / (double)w->height();
// From Scene::Window::infiniteRegion()
QRegion infRegion = QRegion( INT_MIN / 2, INT_MIN / 2, INT_MAX, INT_MAX );
effects->paintWindow( w, PAINT_WINDOW_TRANSFORMED, infRegion, thumbdata );
@ -79,7 +79,7 @@ QRect TaskbarThumbnailEffect::getThumbnailPosition( EffectWindow* c, int* space
if( icon.right() < 40 || ( displayWidth() - icon.left()) < 40 )
{
// Vertical taskbar...
float scale = qMin(qMax(icon.height(), 100) / (float)c->height(), 200.0f / c->width());
double scale = qMin(qMax(icon.height(), 100) / (double)c->height(), 200.0 / c->width());
thumb.setSize( QSize( int(scale * c->width()),int(scale * c->height()) ));
if( icon.right() < 40 ) // ...on the left
thumb.moveTopLeft( QPoint( icon.right() + *space, icon.top() ));
@ -90,7 +90,7 @@ QRect TaskbarThumbnailEffect::getThumbnailPosition( EffectWindow* c, int* space
else
{
// Horizontal taskbar...
float scale = qMin(qMax(icon.width(), 75) / (float)c->width(), 200.0f / c->height());
double scale = qMin(qMax(icon.width(), 75) / (double)c->width(), 200.0 / c->height());
thumb.setSize( QSize( int(scale * c->width()),int(scale * c->height()) ));
if( icon.top() < ( displayHeight() - icon.bottom())) // ...at the top
thumb.moveTopLeft( QPoint( icon.left(), icon.bottom() + *space ));

View file

@ -32,7 +32,7 @@ class WavyWindowsEffect
virtual void postPaintScreen();
private:
float mTimeElapsed;
double mTimeElapsed;
};
} // namespace

View file

@ -46,7 +46,7 @@ void DesktopGridEffect::prePaintScreen( ScreenPrePaintData& data, int time )
{
if( slide )
{
progress = qMin( 1.0f, progress + time / float( PROGRESS_TIME ));
progress = qMin( 1.0, progress + time / double( PROGRESS_TIME ));
// PAINT_SCREEN_BACKGROUND_FIRST is needed because screen will be actually painted more than once,
// so with normal screen painting second screen paint would erase parts of the first paint
if( progress != 1 )
@ -60,9 +60,9 @@ void DesktopGridEffect::prePaintScreen( ScreenPrePaintData& data, int time )
else if( progress != 0 || activated )
{
if( activated )
progress = qMin( 1.0f, progress + time / float( PROGRESS_TIME ));
progress = qMin( 1.0, progress + time / double( PROGRESS_TIME ));
else
progress = qMax( 0.0f, progress - time / float( PROGRESS_TIME ));
progress = qMax( 0.0, progress - time / double( PROGRESS_TIME ));
// PAINT_SCREEN_BACKGROUND_FIRST is needed because screen will be actually painted more than once,
// so with normal screen painting second screen paint would erase parts of the first paint
if( progress != 0 )
@ -150,8 +150,8 @@ void DesktopGridEffect::paintScreenDesktop( int desktop, int mask, QRegion regio
QRect normal = desktopRect( effects->currentDesktop(), false );
d.xTranslate += rect.x(); // - normal.x();
d.yTranslate += rect.y(); // - normal.y();
d.xScale *= rect.width() / float( normal.width());
d.yScale *= rect.height() / float( normal.height());
d.xScale *= rect.width() / double( normal.width());
d.yScale *= rect.height() / double( normal.height());
// TODO mask parts that are not visible?
effects->paintScreen( mask, region, d );
}
@ -280,10 +280,10 @@ QRect DesktopGridEffect::desktopRect( int desktop, bool scaled ) const
if( !scaled )
return rect;
QRect current = desktopRect( effects->currentDesktop(), false );
rect = QRect( qRound( interpolate( rect.x() - current.x(), rect.x() / float( x ), progress )),
qRound( interpolate( rect.y() - current.y(), rect.y() / float( y ), progress )),
qRound( interpolate( rect.width(), displayWidth() / float( x ), progress )),
qRound( interpolate( rect.height(), displayHeight() / float( y ), progress )));
rect = QRect( qRound( interpolate( rect.x() - current.x(), rect.x() / double( x ), progress )),
qRound( interpolate( rect.y() - current.y(), rect.y() / double( y ), progress )),
qRound( interpolate( rect.width(), displayWidth() / double( x ), progress )),
qRound( interpolate( rect.height(), displayHeight() / double( y ), progress )));
return rect;
}
@ -395,9 +395,9 @@ void DesktopGridEffect::slideDesktopChanged( int old )
{ // current position is in new current desktop (e.g. quickly changing back),
// don't do full progress
if( abs( currentPos.x() - rect.x()) > abs( currentPos.y() - rect.y()))
progress = 1 - abs( currentPos.x() - rect.x()) / float( displayWidth());
progress = 1 - abs( currentPos.x() - rect.x()) / double( displayWidth());
else
progress = 1 - abs( currentPos.y() - rect.y()) / float( displayHeight());
progress = 1 - abs( currentPos.y() - rect.y()) / double( displayHeight());
}
else // current position is not on current desktop, do full progress
progress = 0;

View file

@ -45,7 +45,7 @@ class DesktopGridEffect
void paintSlide( int mask, QRegion region, const ScreenPaintData& data );
void paintScreenDesktop( int desktop, int mask, QRegion region, ScreenPaintData data );
void slideDesktopChanged( int old );
float progress;
double progress;
bool activated;
int painting_desktop;
int hover_desktop;

View file

@ -18,7 +18,7 @@ KWIN_EFFECT( dialogparent, DialogParentEffect )
void DialogParentEffect::prePaintWindow( EffectWindow* w, WindowPrePaintData& data, int time )
{
// How long does it take for the effect to get it's full strength (in ms)
const float changeTime = 200;
const double changeTime = 200;
// Check if this window has a modal dialog and change the window's
// effect's strength accordingly
@ -26,11 +26,11 @@ void DialogParentEffect::prePaintWindow( EffectWindow* w, WindowPrePaintData& da
if( hasDialog )
{
// Increase effect strength of this window
effectStrength[w] = qMin(1.0f, effectStrength[w] + time/changeTime);
effectStrength[w] = qMin(1.0, effectStrength[w] + time/changeTime);
}
else
{
effectStrength[w] = qMax(0.0f, effectStrength[w] - time/changeTime);
effectStrength[w] = qMax(0.0, effectStrength[w] - time/changeTime);
}
// Call the next effect
@ -39,7 +39,7 @@ void DialogParentEffect::prePaintWindow( EffectWindow* w, WindowPrePaintData& da
void DialogParentEffect::paintWindow( EffectWindow* w, int mask, QRegion region, WindowPaintData& data )
{
float s = effectStrength[w];
double s = effectStrength[w];
if(s > 0.0f)
{
// Brightness will be within [1.0; 0.6]
@ -54,7 +54,7 @@ void DialogParentEffect::paintWindow( EffectWindow* w, int mask, QRegion region,
void DialogParentEffect::postPaintWindow( EffectWindow* w )
{
float s = effectStrength[w];
double s = effectStrength[w];
// If strength is between 0 and 1, the effect is still in progress and the
// window has to be repainted during the next pass

View file

@ -39,7 +39,7 @@ class DialogParentEffect
bool hasModalWindow( EffectWindow* t );
private:
// The progress of the fading.
QHash<EffectWindow*, float> effectStrength;
QHash<EffectWindow*, double> effectStrength;
};
} // namespace

View file

@ -27,7 +27,7 @@ class DrunkenEffect
virtual void windowAdded( EffectWindow* w );
virtual void windowClosed( EffectWindow* w );
private:
QHash< EffectWindow*, float > windows; // progress
QHash< EffectWindow*, double > windows; // progress
};
} // namespace

View file

@ -144,8 +144,8 @@ void ExplosionEffect::paintWindow( EffectWindow* w, int mask, QRegion region, Wi
bool useshader = ( mValid && mWindows.contains( w ) );
if( useshader )
{
float maxscaleadd = 1.5f;
float scale = 1 + maxscaleadd*mWindows[w];
double maxscaleadd = 1.5f;
double scale = 1 + maxscaleadd*mWindows[w];
data.xScale = scale;
data.yScale = scale;
data.xTranslate += int( w->width() / 2 * ( 1 - scale ));
@ -153,7 +153,7 @@ void ExplosionEffect::paintWindow( EffectWindow* w, int mask, QRegion region, Wi
data.opacity *= 0.99; // Force blending
mShader->bind();
mShader->setUniform("factor", (float)mWindows[w]);
mShader->setUniform("scale", scale);
mShader->setUniform("scale", (float)scale);
glActiveTexture(GL_TEXTURE4);
mStartOffsetTex->bind();
glActiveTexture(GL_TEXTURE5);

View file

@ -50,7 +50,7 @@ class ExplosionEffect
GLShader* mShader;
GLTexture* mStartOffsetTex;
GLTexture* mEndOffsetTex;
QMap< const EffectWindow*, float > mWindows;
QMap< const EffectWindow*, double > mWindows;
int mActiveAnimations;
bool mValid;
bool mInited;

View file

@ -29,8 +29,8 @@ void FadeEffect::prePaintScreen( ScreenPrePaintData& data, int time )
{
if( !windows.isEmpty())
{
fadeInStep = time / float( fadeInTime );
fadeOutStep = time / float( fadeOutTime );
fadeInStep = time / double( fadeInTime );
fadeOutStep = time / double( fadeOutTime );
}
effects->prePaintScreen( data, time );
}
@ -95,28 +95,28 @@ void FadeEffect::paintWindow( EffectWindow* w, int mask, QRegion region, WindowP
if( new_data.saturation > windows[ w ].saturation )
{
windows[ w ].saturation = qMin( new_data.saturation,
windows[ w ].saturation + float( windows[ w ].fadeInStep ));
windows[ w ].saturation + windows[ w ].fadeInStep );
}
else if( new_data.saturation < windows[ w ].saturation )
{
windows[ w ].saturation = qMax( new_data.saturation,
windows[ w ].saturation - float( windows[ w ].fadeOutStep ));
windows[ w ].saturation - windows[ w ].fadeOutStep );
}
if( new_data.brightness > windows[ w ].brightness )
{
windows[ w ].brightness = qMin( new_data.brightness,
windows[ w ].brightness + float( windows[ w ].fadeInStep ));
windows[ w ].brightness + windows[ w ].fadeInStep );
}
else if( new_data.brightness < windows[ w ].brightness )
{
windows[ w ].brightness = qMax( new_data.brightness,
windows[ w ].brightness - float( windows[ w ].fadeOutStep ));
windows[ w ].brightness - windows[ w ].fadeOutStep );
}
windows[ w ].opacity = qBound( 0.0f, windows[ w ].opacity, 1.0f );
windows[ w ].saturation = qBound( 0.0f, windows[ w ].saturation, 1.0f );
windows[ w ].brightness = qBound( 0.0f, windows[ w ].brightness, 1.0f );
windows[ w ].opacity = qBound( 0.0, windows[ w ].opacity, 1.0 );
windows[ w ].saturation = qBound( 0.0, windows[ w ].saturation, 1.0 );
windows[ w ].brightness = qBound( 0.0, windows[ w ].brightness, 1.0 );
windows[ w ].fadeInStep = 0.0;
windows[ w ].fadeOutStep = 0.0;
@ -136,7 +136,7 @@ void FadeEffect::paintWindow( EffectWindow* w, int mask, QRegion region, WindowP
effects->paintWindow( w, mask, region, data );
}
void FadeEffect::windowOpacityChanged( EffectWindow* w, float old_opacity )
void FadeEffect::windowOpacityChanged( EffectWindow* w, double old_opacity )
{
if( !windows.contains( w ))
windows[ w ].opacity = old_opacity;

View file

@ -26,7 +26,7 @@ class FadeEffect
virtual void paintWindow( EffectWindow* w, int mask, QRegion region, WindowPaintData& data );
// TODO react also on virtual desktop changes
virtual void windowOpacityChanged( EffectWindow* c, float old_opacity );
virtual void windowOpacityChanged( EffectWindow* c, double old_opacity );
virtual void windowAdded( EffectWindow* c );
virtual void windowClosed( EffectWindow* c );
virtual void windowDeleted( EffectWindow* c );
@ -35,7 +35,7 @@ class FadeEffect
private:
class WindowInfo;
QHash< const EffectWindow*, WindowInfo > windows;
float fadeInStep, fadeOutStep;
double fadeInStep, fadeOutStep;
int fadeInTime, fadeOutTime;
bool fadeWindows;
};
@ -51,9 +51,9 @@ class FadeEffect::WindowInfo
, brightness( 1.0 )
, deleted( false )
{}
float fadeInStep, fadeOutStep;
float opacity;
float saturation, brightness;
double fadeInStep, fadeOutStep;
double opacity;
double saturation, brightness;
bool deleted;
};

View file

@ -57,17 +57,17 @@ void FallApartEffect::paintWindow( EffectWindow* w, int mask, QRegion region, Wi
// make fragments move in various directions, based on where
// they are (left pieces generally move to the left, etc.)
QPointF p1( quad[ 0 ].x(), quad[ 0 ].y());
float xdiff = 0;
double xdiff = 0;
if( p1.x() < w->width() / 2 )
xdiff = -( w->width() / 2 - p1.x()) / w->width() * 100;
if( p1.x() > w->width() / 2 )
xdiff = ( p1.x() - w->width() / 2 ) / w->width() * 100;
float ydiff = 0;
double ydiff = 0;
if( p1.y() < w->height() / 2 )
ydiff = -( w->height() / 2 - p1.y()) / w->height() * 100;
if( p1.y() > w->height() / 2 )
ydiff = ( p1.y() - w->height() / 2 ) / w->height() * 100;
float modif = windows[ w ] * windows[ w ] * 64;
double modif = windows[ w ] * windows[ w ] * 64;
srandom( cnt ); // change direction randomly but consistently
xdiff += ( rand() % 21 - 10 );
ydiff += ( rand() % 21 - 10 );
@ -80,16 +80,16 @@ void FallApartEffect::paintWindow( EffectWindow* w, int mask, QRegion region, Wi
// also make the fragments rotate around their center
QPointF center(( quad[ 0 ].x() + quad[ 1 ].x() + quad[ 2 ].x() + quad[ 3 ].x()) / 4,
( quad[ 0 ].y() + quad[ 1 ].y() + quad[ 2 ].y() + quad[ 3 ].y()) / 4 );
float adiff = ( rand() % 720 - 360 ) / 360. * 2 * M_PI; // spin randomly
double adiff = ( rand() % 720 - 360 ) / 360. * 2 * M_PI; // spin randomly
for( int j = 0;
j < 4;
++j )
{
float x = quad[ j ].x() - center.x();
float y = quad[ j ].y() - center.y();
float angle = atan2( y, x );
double x = quad[ j ].x() - center.x();
double y = quad[ j ].y() - center.y();
double angle = atan2( y, x );
angle += windows[ w ] * adiff;
float dist = sqrt( x * x + y * y );
double dist = sqrt( x * x + y * y );
x = dist * cos( angle );
y = dist * sin( angle );
quad[ j ].move( center.x() + x, center.y() + y );

View file

@ -27,7 +27,7 @@ class FallApartEffect
virtual void windowClosed( EffectWindow* c );
virtual void windowDeleted( EffectWindow* c );
private:
QHash< const EffectWindow*, float > windows;
QHash< const EffectWindow*, double > windows;
};
} // namespace

View file

@ -50,7 +50,7 @@ void FlameEffect::paintWindow( EffectWindow* w, int mask, QRegion region, Window
if( windows.contains( w ))
{
WindowQuadList new_quads;
float ylimit = windows[ w ] * w->height(); // parts above this are already away
double ylimit = windows[ w ] * w->height(); // parts above this are already away
foreach( WindowQuad quad, data.quads )
{
if( quad.bottom() <= ylimit )

View file

@ -27,7 +27,7 @@ class FlameEffect
virtual void windowClosed( EffectWindow* c );
virtual void windowDeleted( EffectWindow* c );
private:
QHash< const EffectWindow*, float > windows;
QHash< const EffectWindow*, double > windows;
};
} // namespace

View file

@ -53,7 +53,7 @@ void LookingGlassEffect::toggle()
void LookingGlassEffect::zoomIn()
{
target_zoom = qMin(7.0f, target_zoom + 0.5f);
target_zoom = qMin(7.0, target_zoom + 0.5);
setEnabled( true );
effects->addRepaint( cursorPos().x() - radius, cursorPos().y() - radius, 2*radius, 2*radius );
}
@ -73,18 +73,18 @@ void LookingGlassEffect::prePaintScreen( ScreenPrePaintData& data, int time )
{
if( zoom != target_zoom )
{
float diff = time / 500.0f;
double diff = time / 500.0;
if( target_zoom > zoom )
zoom = qMin( zoom * qMax( 1.0f + diff, 1.2f ), target_zoom );
zoom = qMin( zoom * qMax( 1.0 + diff, 1.2 ), target_zoom );
else
zoom = qMax( zoom * qMin( 1.0f - diff, 0.8f ), target_zoom );
zoom = qMax( zoom * qMin( 1.0 - diff, 0.8 ), target_zoom );
kDebug() << "zoom is now " << zoom;
radius = qBound(200.0f, 200.0f * zoom, 500.0f);
radius = qBound(200.0, 200.0 * zoom, 500.0);
if( zoom > 1.0f )
{
shader()->bind();
shader()->setUniform("zoom", zoom);
shader()->setUniform("zoom", (float)zoom);
shader()->setUniform("radius", (float)radius);
shader()->unbind();
}

View file

@ -36,8 +36,8 @@ class LookingGlassEffect : public QObject, public ShaderEffect
void zoomOut();
private:
float zoom;
float target_zoom;
double zoom;
double target_zoom;
int radius;
};

View file

@ -46,11 +46,11 @@ void MagnifierEffect::prePaintScreen( ScreenPrePaintData& data, int time )
{
if( zoom != target_zoom )
{
float diff = time / 500.0;
double diff = time / 500.0;
if( target_zoom > zoom )
zoom = qMin( zoom * qMax( 1 + diff, 1.2f ), target_zoom );
zoom = qMin( zoom * qMax( 1 + diff, 1.2 ), target_zoom );
else
zoom = qMax( zoom * qMin( 1 - diff, 0.8f ), target_zoom );
zoom = qMax( zoom * qMin( 1 - diff, 0.8 ), target_zoom );
}
effects->prePaintScreen( data, time );
if( zoom != 1.0 )

View file

@ -33,8 +33,8 @@ class MagnifierEffect
void toggle();
private:
QRect magnifierArea( QPoint pos = cursorPos()) const;
float zoom;
float target_zoom;
double zoom;
double target_zoom;
QSize magnifier_size;
};

View file

@ -25,9 +25,9 @@ class MakeTransparentEffect
virtual void prePaintWindow( EffectWindow* w, WindowPrePaintData& data, int time );
virtual void paintWindow( EffectWindow* w, int mask, QRegion region, WindowPaintData& data );
private:
float decoration;
float moveresize;
float dialogs;
double decoration;
double moveresize;
double dialogs;
};
} // namespace

View file

@ -34,7 +34,7 @@ void MinimizeAnimationEffect::prePaintScreen( ScreenPrePaintData& data, int time
void MinimizeAnimationEffect::prePaintWindow( EffectWindow* w, WindowPrePaintData& data, int time )
{
const float changeTime = 500;
const double changeTime = 500;
if( mAnimationProgress.contains( w ))
{
if( w->isMinimized() )
@ -71,7 +71,7 @@ void MinimizeAnimationEffect::paintWindow( EffectWindow* w, int mask, QRegion re
if( mAnimationProgress.contains( w ))
{
// 0 = not minimized, 1 = fully minimized
float progress = mAnimationProgress[w];
double progress = mAnimationProgress[w];
QRect geo = w->geometry();
QRect icon = w->iconGeometry();
@ -79,8 +79,8 @@ void MinimizeAnimationEffect::paintWindow( EffectWindow* w, int mask, QRegion re
if( !icon.isValid() )
icon = QRect( displayWidth() / 2, displayHeight() / 2, 0, 0 );
data.xScale *= interpolate(1.0, icon.width() / (float)geo.width(), progress);
data.yScale *= interpolate(1.0, icon.height() / (float)geo.height(), progress);
data.xScale *= interpolate(1.0, icon.width() / (double)geo.width(), progress);
data.yScale *= interpolate(1.0, icon.height() / (double)geo.height(), progress);
data.xTranslate = (int)interpolate(data.xTranslate, icon.x() - geo.x(), progress);
data.yTranslate = (int)interpolate(data.yTranslate, icon.y() - geo.y(), progress);
}

View file

@ -36,7 +36,7 @@ class MinimizeAnimationEffect
virtual void windowUnminimized( EffectWindow* c );
private:
QHash< EffectWindow*, float > mAnimationProgress;
QHash< EffectWindow*, double > mAnimationProgress;
int mActiveAnimations;
};

View file

@ -73,17 +73,17 @@ PresentWindowsEffect::~PresentWindowsEffect()
void PresentWindowsEffect::prePaintScreen( ScreenPrePaintData& data, int time )
{
// How long does it take for the effect to get it's full strength (in ms)
const float changeTime = 300;
const double changeTime = 300;
if(mActivated)
{
mActiveness = qMin(1.0f, mActiveness + time/changeTime);
mActiveness = qMin(1.0, mActiveness + time/changeTime);
if( mRearranging < 1 )
mRearranging = qMin(1.0f, mRearranging + time/changeTime);
mRearranging = qMin(1.0, mRearranging + time/changeTime);
}
else if(mActiveness > 0.0f)
else if(mActiveness > 0.0)
{
mActiveness = qMax(0.0f, mActiveness - time/changeTime);
if(mActiveness <= 0.0f)
mActiveness = qMax(0.0, mActiveness - time/changeTime);
if(mActiveness <= 0.0)
effectTerminated();
}
@ -111,11 +111,11 @@ void PresentWindowsEffect::prePaintWindow( EffectWindow* w, WindowPrePaintData&
data.setTranslucent();
// Change window's hover according to cursor pos
WindowData& windata = mWindowData[w];
const float hoverchangetime = 200;
const double hoverchangetime = 200;
if( windata.area.contains(cursorPos()) )
windata.hover = qMin(1.0f, windata.hover + time / hoverchangetime);
windata.hover = qMin(1.0, windata.hover + time / hoverchangetime);
else
windata.hover = qMax(0.0f, windata.hover - time / hoverchangetime);
windata.hover = qMax(0.0, windata.hover - time / hoverchangetime);
}
else if( !w->isDesktop())
w->disablePainting( EffectWindow::PAINT_DISABLED );
@ -195,10 +195,10 @@ void PresentWindowsEffect::paintWindow( EffectWindow* w, int mask, QRegion regio
paintWindowIcon( w, data );
QString text = w->caption();
float centerx = w->x() + data.xTranslate + w->width() * data.xScale * 0.5f;
float centery = w->y() + data.yTranslate + w->height() * data.yScale * 0.5f;
double centerx = w->x() + data.xTranslate + w->width() * data.xScale * 0.5f;
double centery = w->y() + data.yTranslate + w->height() * data.yScale * 0.5f;
int maxwidth = (int)(w->width() * data.xScale - 20);
float opacity = (0.7 + 0.2*windata.hover) * data.opacity;
double opacity = (0.7 + 0.2*windata.hover) * data.opacity;
QColor textcolor( 255, 255, 255, (int)(255*opacity) );
QColor bgcolor( 0, 0, 0, (int)(255*opacity) );
QFont f;
@ -421,7 +421,7 @@ void PresentWindowsEffect::calculateWindowTransformationsDumb(EffectWindowList w
int r = i / cols;
int c = i % cols;
mWindowData[window].hover = 0.0f;
mWindowData[window].scale = qMin(cellwidth / (float)window->width(), cellheight / (float)window->height());
mWindowData[window].scale = qMin(cellwidth / (double)window->width(), cellheight / (double)window->height());
mWindowData[window].area.setLeft(placementRect.left() + cellwidth * c);
mWindowData[window].area.setTop(placementRect.top() + cellheight * r);
mWindowData[window].area.setWidth((int)(window->width() * mWindowData[window].scale));
@ -434,19 +434,19 @@ void PresentWindowsEffect::calculateWindowTransformationsDumb(EffectWindowList w
}
}
float PresentWindowsEffect::windowAspectRatio(EffectWindow* c)
double PresentWindowsEffect::windowAspectRatio(EffectWindow* c)
{
return c->width() / (float)c->height();
return c->width() / (double)c->height();
}
int PresentWindowsEffect::windowWidthForHeight(EffectWindow* c, int h)
{
return (int)((h / (float)c->height()) * c->width());
return (int)((h / (double)c->height()) * c->width());
}
int PresentWindowsEffect::windowHeightForWidth(EffectWindow* c, int w)
{
return (int)((w / (float)c->width()) * c->height());
return (int)((w / (double)c->width()) * c->height());
}
void PresentWindowsEffect::calculateWindowTransformationsKompose(EffectWindowList windowlist)
@ -458,17 +458,17 @@ void PresentWindowsEffect::calculateWindowTransformationsKompose(EffectWindowLis
int spacing = 10;
int rows, columns;
float parentRatio = availRect.width() / (float)availRect.height();
double parentRatio = availRect.width() / (double)availRect.height();
// Use more columns than rows when parent's width > parent's height
if ( parentRatio > 1 )
{
columns = (int)ceil( sqrt(windowlist.count()) );
rows = (int)ceil( (float)windowlist.count() / (float)columns );
rows = (int)ceil( (double)windowlist.count() / (double)columns );
}
else
{
rows = (int)ceil( sqrt(windowlist.count()) );
columns = (int)ceil( (float)windowlist.count() / (float)rows );
columns = (int)ceil( (double)windowlist.count() / (double)rows );
}
kDebug() << "Using " << rows << " rows & " << columns << " columns for " << windowlist.count() << " clients";
@ -495,7 +495,7 @@ void PresentWindowsEffect::calculateWindowTransformationsKompose(EffectWindowLis
window = *it;
// Calculate width and height of widget
float ratio = windowAspectRatio(window);
double ratio = windowAspectRatio(window);
int widgetw = 100;
int widgeth = 100;
@ -525,8 +525,8 @@ void PresentWindowsEffect::calculateWindowTransformationsKompose(EffectWindowLis
}
else
{
float widthForHeight = windowWidthForHeight(window, usableH);
float heightForWidth = windowHeightForWidth(window, usableW);
double widthForHeight = windowWidthForHeight(window, usableH);
double heightForWidth = windowHeightForWidth(window, usableW);
if ( (ratio >= 1.0 && heightForWidth <= usableH) ||
(ratio < 1.0 && widthForHeight > usableW) )
{
@ -576,7 +576,7 @@ void PresentWindowsEffect::calculateWindowTransformationsKompose(EffectWindowLis
QRect geom = geometryRects[pos];
geom.setY( geom.y() + topOffset );
mWindowData[window].area = geom;
mWindowData[window].scale = geom.width() / (float)window->width();
mWindowData[window].scale = geom.width() / (double)window->width();
mWindowData[window].hover = 0.0f;
kDebug() << "Window '" << window->caption() << "' gets moved to (" <<
@ -592,7 +592,7 @@ void PresentWindowsEffect::calculateWindowTransformationsClosest(EffectWindowLis
{
QRect area = effects->clientArea( PlacementArea, QPoint( 0, 0 ), effects->currentDesktop());
int columns = int( ceil( sqrt( windowlist.count())));
int rows = int( ceil( windowlist.count() / float( columns )));
int rows = int( ceil( windowlist.count() / double( columns )));
foreach( EffectWindow* w, windowlist )
mWindowData[ w ].slot = -1;
for(;;)
@ -621,17 +621,17 @@ void PresentWindowsEffect::calculateWindowTransformationsClosest(EffectWindowLis
area.y() + ((*it).slot / columns ) * slotheight,
slotwidth, slotheight );
geom.adjust( 10, 10, -10, -10 ); // borders
float scale;
double scale;
EffectWindow* w = it.key();
if( geom.width() / float( w->width()) < geom.height() / float( w->height()))
if( geom.width() / double( w->width()) < geom.height() / double( w->height()))
{ // center vertically
scale = geom.width() / float( w->width());
scale = geom.width() / double( w->width());
geom.moveTop( geom.top() + ( geom.height() - int( w->height() * scale )) / 2 );
geom.setHeight( int( w->height() * scale ));
}
else
{ // center horizontally
scale = geom.height() / float( w->height());
scale = geom.height() / double( w->height());
geom.moveLeft( geom.left() + ( geom.width() - int( w->width() * scale )) / 2 );
geom.setWidth( int( w->width() * scale ));
}
@ -713,9 +713,9 @@ bool PresentWindowsEffect::canRearrangeClosest(EffectWindowList windowlist)
{
QRect area = effects->clientArea( PlacementArea, QPoint( 0, 0 ), effects->currentDesktop());
int columns = int( ceil( sqrt( windowlist.count())));
int rows = int( ceil( windowlist.count() / float( columns )));
int rows = int( ceil( windowlist.count() / double( columns )));
int old_columns = int( ceil( sqrt( mWindowData.count())));
int old_rows = int( ceil( mWindowData.count() / float( columns )));
int old_rows = int( ceil( mWindowData.count() / double( columns )));
return old_columns != columns || old_rows != rows;
}

View file

@ -61,7 +61,7 @@ class PresentWindowsEffect
bool canRearrangeClosest(EffectWindowList windowlist);
// Helper methods for layout calculation
float windowAspectRatio(EffectWindow* c);
double windowAspectRatio(EffectWindow* c);
int windowWidthForHeight(EffectWindow* c, int h);
int windowHeightForWidth(EffectWindow* c, int w);
@ -84,9 +84,9 @@ class PresentWindowsEffect
// Whether the effect is currently activated by the user
bool mActivated;
// 0 = not active, 1 = fully active
float mActiveness;
double mActiveness;
// 0 = start of rearranging (old_area), 1 = done
float mRearranging;
double mRearranging;
Window mInput;
bool hasKeyboardGrab;
@ -96,9 +96,9 @@ class PresentWindowsEffect
{
QRect area;
QRect old_area; // when rearranging, otherwise unset
float scale;
float old_scale; // when rearranging, otherwise unset
float hover;
double scale;
double old_scale; // when rearranging, otherwise unset
double hover;
int slot;
int slot_distance;
QPixmap icon;

View file

@ -28,7 +28,7 @@ class ScaleInEffect
virtual void windowAdded( EffectWindow* c );
virtual void windowClosed( EffectWindow* c );
private:
QHash< const EffectWindow*, float > windows;
QHash< const EffectWindow*, double > windows;
};
} // namespace

View file

@ -25,7 +25,7 @@ ShadowEffect::ShadowEffect()
KConfigGroup conf = effects->effectConfig("Shadow");
shadowXOffset = conf.readEntry( "XOffset", 10 );
shadowYOffset = conf.readEntry( "YOffset", 10 );
shadowOpacity = (float)conf.readEntry( "Opacity", 0.2 );
shadowOpacity = conf.readEntry( "Opacity", 0.2 );
shadowFuzzyness = conf.readEntry( "Fuzzyness", 10 );
QString shadowtexture = KGlobal::dirs()->findResource("data", "kwin/shadow-texture.png");
@ -125,7 +125,7 @@ void ShadowEffect::drawShadow( EffectWindow* window, int mask, QRegion region, W
mShadowTexture->bind();
// Take the transparency settings and window's transparency into account.
// Also make the shadow more transparent if we've made it bigger
glColor4f(0, 0, 0, shadowOpacity * data.opacity * (window->width() / (float)w) * (window->height() / (float)h));
glColor4f(0, 0, 0, shadowOpacity * data.opacity * (window->width() / (double)w) * (window->height() / (double)h));
glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
// We have two elements per vertex in the verts array
int verticesCount = verts.count() / 2;

View file

@ -35,7 +35,7 @@ class ShadowEffect
QRect shadowRectangle(const QRect& windowRectangle) const;
int shadowXOffset, shadowYOffset;
float shadowOpacity;
double shadowOpacity;
int shadowFuzzyness;
GLTexture* mShadowTexture;
};

View file

@ -36,7 +36,7 @@ class ShowFpsEffect
enum { MAX_FPS = 200 };
int frames[ MAX_FPS ]; // (sec*1000+msec) of the time the frame was done
int frames_pos; // position in the queue
float alpha;
double alpha;
int x;
int y;
};

View file

@ -41,7 +41,7 @@ class TestFBOEffect : public Effect
GLRenderTarget* mRenderTarget;
bool mValid;
float mRot;
double mRot;
};
} // namespace

View file

@ -127,8 +127,8 @@ void ThumbnailAsideEffect::arrange()
pos[ d.index ] = d.window->height();
}
QRect area = effects->clientArea( WorkArea, QPoint(), effects->currentDesktop());
float scale = area.height() / float( height );
scale = qMin( scale, maxwidth / float( mwidth )); // don't be wider than maxwidth pixels
double scale = area.height() / double( height );
scale = qMin( scale, maxwidth / double( mwidth )); // don't be wider than maxwidth pixels
int add = 0;
for( int i = 0;
i < windows.size();

View file

@ -51,7 +51,7 @@ class ThumbnailAsideEffect
QHash< EffectWindow*, Data > windows;
int maxwidth;
int spacing;
float opacity;
double opacity;
};
} // namespace

View file

@ -37,11 +37,11 @@ void ZoomEffect::prePaintScreen( ScreenPrePaintData& data, int time )
{
if( zoom != target_zoom )
{
float diff = time / 500.0;
double diff = time / 500.0;
if( target_zoom > zoom )
zoom = qMin( zoom * qMax( 1 + diff, 1.2f ), target_zoom );
zoom = qMin( zoom * qMax( 1 + diff, 1.2 ), target_zoom );
else
zoom = qMax( zoom * qMin( 1 - diff, 0.8f ), target_zoom );
zoom = qMax( zoom * qMin( 1 - diff, 0.8 ), target_zoom );
}
if( zoom != 1.0 )
data.mask |= PAINT_SCREEN_TRANSFORMED;

View file

@ -32,8 +32,8 @@ class ZoomEffect
void zoomOut();
void actualSize();
private:
float zoom;
float target_zoom;
double zoom;
double target_zoom;
};
} // namespace

View file

@ -84,7 +84,7 @@ void Effect::windowUserMovedResized( EffectWindow* , bool, bool )
{
}
void Effect::windowOpacityChanged( EffectWindow*, float )
void Effect::windowOpacityChanged( EffectWindow*, double )
{
}
@ -197,8 +197,8 @@ void Effect::setPositionTransformations( WindowPaintData& data, QRect& region, E
{
QSize size = w->size();
size.scale( r.size(), aspect );
data.xScale = size.width() / float( w->width());
data.yScale = size.height() / float( w->height());
data.xScale = size.width() / double( w->width());
data.yScale = size.height() / double( w->height());
int width = int( w->width() * data.xScale );
int height = int( w->height() * data.yScale );
int x = r.x() + ( r.width() - width ) / 2;
@ -425,7 +425,7 @@ EffectWindowGroup::~EffectWindowGroup()
WindowQuad
***************************************************************/
WindowQuad WindowQuad::makeSubQuad( float x1, float y1, float x2, float y2 ) const
WindowQuad WindowQuad::makeSubQuad( double x1, double y1, double x2, double y2 ) const
{
assert( x1 < x2 && y1 < y2 && x1 >= left() && x2 <= right() && y1 >= top() && y2 <= bottom());
#ifndef NDEBUG
@ -451,14 +451,14 @@ WindowQuad WindowQuad::makeSubQuad( float x1, float y1, float x2, float y2 ) con
ret.verts[ 1 ].oy = y1;
ret.verts[ 2 ].oy = y2;
ret.verts[ 3 ].oy = y2;
float my_tleft = verts[ 0 ].tx;
float my_tright = verts[ 2 ].tx;
float my_ttop = verts[ 0 ].ty;
float my_tbottom = verts[ 2 ].ty;
float tleft = ( x1 - left()) / ( right() - left()) * ( my_tright - my_tleft ) + my_tleft;
float tright = ( x2 - left()) / ( right() - left()) * ( my_tright - my_tleft ) + my_tleft;
float ttop = ( y1 - top()) / ( bottom() - top()) * ( my_tbottom - my_ttop ) + my_ttop;
float tbottom = ( y2 - top()) / ( bottom() - top()) * ( my_tbottom - my_ttop ) + my_ttop;
double my_tleft = verts[ 0 ].tx;
double my_tright = verts[ 2 ].tx;
double my_ttop = verts[ 0 ].ty;
double my_tbottom = verts[ 2 ].ty;
double tleft = ( x1 - left()) / ( right() - left()) * ( my_tright - my_tleft ) + my_tleft;
double tright = ( x2 - left()) / ( right() - left()) * ( my_tright - my_tleft ) + my_tleft;
double ttop = ( y1 - top()) / ( bottom() - top()) * ( my_tbottom - my_ttop ) + my_ttop;
double tbottom = ( y2 - top()) / ( bottom() - top()) * ( my_tbottom - my_ttop ) + my_ttop;
ret.verts[ 0 ].tx = tleft;
ret.verts[ 3 ].tx = tleft;
ret.verts[ 1 ].tx = tright;
@ -473,8 +473,8 @@ WindowQuad WindowQuad::makeSubQuad( float x1, float y1, float x2, float y2 ) con
bool WindowQuad::smoothNeeded() const
{
// smoothing is needed if the width or height of the quad does not match the original size
float width = verts[ 1 ].ox - verts[ 0 ].ox;
float height = verts[ 2 ].oy - verts[ 1 ].oy;
double width = verts[ 1 ].ox - verts[ 0 ].ox;
double height = verts[ 2 ].oy - verts[ 1 ].oy;
return( verts[ 1 ].px - verts[ 0 ].px != width || verts[ 2 ].px - verts[ 3 ].px != width
|| verts[ 2 ].py - verts[ 1 ].py != height || verts[ 3 ].py - verts[ 0 ].py != height );
}
@ -483,7 +483,7 @@ bool WindowQuad::smoothNeeded() const
WindowQuadList
***************************************************************/
WindowQuadList WindowQuadList::splitAtX( float x ) const
WindowQuadList WindowQuadList::splitAtX( double x ) const
{
WindowQuadList ret;
foreach( WindowQuad quad, *this )
@ -514,7 +514,7 @@ WindowQuadList WindowQuadList::splitAtX( float x ) const
return ret;
}
WindowQuadList WindowQuadList::splitAtY( float y ) const
WindowQuadList WindowQuadList::splitAtY( double y ) const
{
WindowQuadList ret;
foreach( WindowQuad quad, *this )
@ -550,10 +550,10 @@ WindowQuadList WindowQuadList::makeGrid( int maxquadsize ) const
if( empty())
return *this;
// find the bounding rectangle
float left = first().left();
float right = first().right();
float top = first().top();
float bottom = first().bottom();
double left = first().left();
double right = first().right();
double top = first().top();
double bottom = first().bottom();
foreach( WindowQuad quad, *this )
{
#ifndef NDEBUG
@ -566,11 +566,11 @@ WindowQuadList WindowQuadList::makeGrid( int maxquadsize ) const
bottom = qMax( bottom, quad.bottom());
}
WindowQuadList ret;
for( float x = left;
for( double x = left;
x < right;
x += maxquadsize )
{
for( float y = top;
for( double y = top;
y < bottom;
y += maxquadsize )
{

View file

@ -97,7 +97,7 @@ class KWIN_EXPORT Effect
// called when moved/resized or once after it's finished
virtual void windowUserMovedResized( EffectWindow* c, bool first, bool last );
virtual void windowOpacityChanged( EffectWindow* c, float old_opacity );
virtual void windowOpacityChanged( EffectWindow* c, double old_opacity );
virtual void windowAdded( EffectWindow* c );
virtual void windowClosed( EffectWindow* c );
virtual void windowDeleted( EffectWindow* c );
@ -122,7 +122,7 @@ class KWIN_EXPORT Effect
static QPoint cursorPos();
// Interpolates between x and y
static float interpolate(float x, float y, float a)
static double interpolate(double x, double y, double a)
{
return x * (1 - a) + y * a;
}
@ -309,7 +309,7 @@ class KWIN_EXPORT EffectWindow
virtual bool isDeleted() const = 0;
virtual bool isMinimized() const = 0;
virtual float opacity() const = 0;
virtual double opacity() const = 0;
virtual bool isOnDesktop( int d ) const;
virtual bool isOnCurrentDesktop() const;
@ -379,21 +379,21 @@ class KWIN_EXPORT EffectWindowGroup
class KWIN_EXPORT WindowVertex
{
public:
float x() const;
float y() const;
void move( float x, float y );
void setX( float x );
void setY( float y );
float originalX() const;
float originalY() const;
double x() const;
double y() const;
void move( double x, double y );
void setX( double x );
void setY( double y );
double originalX() const;
double originalY() const;
WindowVertex();
WindowVertex( float x, float y, float tx, float ty );
WindowVertex( double x, double y, double tx, double ty );
private:
friend class WindowQuad;
friend class WindowQuadList;
float px, py; // position
float ox, oy; // origional position
float tx, ty; // texture coords
double px, py; // position
double ox, oy; // origional position
double tx, ty; // texture coords
};
enum WindowQuadType
@ -412,18 +412,18 @@ class KWIN_EXPORT WindowQuad
{
public:
explicit WindowQuad( WindowQuadType type );
WindowQuad makeSubQuad( float x1, float y1, float x2, float y2 ) const;
WindowQuad makeSubQuad( double x1, double y1, double x2, double y2 ) const;
WindowVertex& operator[]( int index );
const WindowVertex& operator[]( int index ) const;
bool decoration() const;
float left() const;
float right() const;
float top() const;
float bottom() const;
float originalLeft() const;
float originalRight() const;
float originalTop() const;
float originalBottom() const;
double left() const;
double right() const;
double top() const;
double bottom() const;
double originalLeft() const;
double originalRight() const;
double originalTop() const;
double originalBottom() const;
bool smoothNeeded() const;
bool isTransformed() const;
private:
@ -436,8 +436,8 @@ class KWIN_EXPORT WindowQuadList
: public QList< WindowQuad >
{
public:
WindowQuadList splitAtX( float x ) const;
WindowQuadList splitAtY( float y ) const;
WindowQuadList splitAtX( double x ) const;
WindowQuadList splitAtY( double y ) const;
WindowQuadList makeGrid( int maxquadsize ) const;
WindowQuadList select( WindowQuadType type ) const;
WindowQuadList filterOut( WindowQuadType type ) const;
@ -472,11 +472,11 @@ class KWIN_EXPORT WindowPaintData
* Opacity for contents is opacity*contents_opacity, the same
* way for decoration.
*/
float opacity;
float contents_opacity;
float decoration_opacity;
float xScale;
float yScale;
double opacity;
double contents_opacity;
double decoration_opacity;
double xScale;
double yScale;
int xTranslate;
int yTranslate;
/**
@ -485,13 +485,13 @@ class KWIN_EXPORT WindowPaintData
* unsaturated (greyscale). 0.5 would make the colors less intense,
* but not completely grey
**/
float saturation;
double saturation;
/**
* Brightness of the window, in range [0; 1]
* 1 means that the window is unchanged, 0 means that it's completely
* black. 0.5 would make it 50% darker than usual
**/
float brightness;
double brightness;
WindowQuadList quads;
/**
* Shader to be used for rendering, if any.
@ -503,8 +503,8 @@ class KWIN_EXPORT ScreenPaintData
{
public:
ScreenPaintData();
float xScale;
float yScale;
double xScale;
double yScale;
int xTranslate;
int yTranslate;
};
@ -529,50 +529,50 @@ WindowVertex::WindowVertex()
}
inline
WindowVertex::WindowVertex( float _x, float _y, float _tx, float _ty )
WindowVertex::WindowVertex( double _x, double _y, double _tx, double _ty )
: px( _x ), py( _y ), ox( _x ), oy( _y ), tx( _tx ), ty( _ty )
{
}
inline
float WindowVertex::x() const
double WindowVertex::x() const
{
return px;
}
inline
float WindowVertex::y() const
double WindowVertex::y() const
{
return py;
}
inline
float WindowVertex::originalX() const
double WindowVertex::originalX() const
{
return ox;
}
inline
float WindowVertex::originalY() const
double WindowVertex::originalY() const
{
return oy;
}
inline
void WindowVertex::move( float x, float y )
void WindowVertex::move( double x, double y )
{
px = x;
py = y;
}
inline
void WindowVertex::setX( float x )
void WindowVertex::setX( double x )
{
px = x;
}
inline
void WindowVertex::setY( float y )
void WindowVertex::setY( double y )
{
py = y;
}
@ -618,49 +618,49 @@ bool WindowQuad::isTransformed() const
}
inline
float WindowQuad::left() const
double WindowQuad::left() const
{
return qMin( verts[ 0 ].px, qMin( verts[ 1 ].px, qMin( verts[ 2 ].px, verts[ 3 ].px )));
}
inline
float WindowQuad::right() const
double WindowQuad::right() const
{
return qMax( verts[ 0 ].px, qMax( verts[ 1 ].px, qMax( verts[ 2 ].px, verts[ 3 ].px )));
}
inline
float WindowQuad::top() const
double WindowQuad::top() const
{
return qMin( verts[ 0 ].py, qMin( verts[ 1 ].py, qMin( verts[ 2 ].py, verts[ 3 ].py )));
}
inline
float WindowQuad::bottom() const
double WindowQuad::bottom() const
{
return qMax( verts[ 0 ].py, qMax( verts[ 1 ].py, qMax( verts[ 2 ].py, verts[ 3 ].py )));
}
inline
float WindowQuad::originalLeft() const
double WindowQuad::originalLeft() const
{
return verts[ 0 ].ox;
}
inline
float WindowQuad::originalRight() const
double WindowQuad::originalRight() const
{
return verts[ 2 ].ox;
}
inline
float WindowQuad::originalTop() const
double WindowQuad::originalTop() const
{
return verts[ 0 ].oy;
}
inline
float WindowQuad::originalBottom() const
double WindowQuad::originalBottom() const
{
return verts[ 2 ].oy;
}

View file

@ -145,7 +145,7 @@ void ShaderEffect::postPaintScreen()
// Use the shader
mShader->bind();
mShader->setUniform("time", mTime);
mShader->setUniform("time", (float)mTime);
mShader->setUniform("cursorX", (float)cursorPos().x());
mShader->setUniform("cursorY", (float)cursorPos().y());

View file

@ -46,7 +46,7 @@ class KWIN_EXPORT ShaderEffect : public Effect
GLShader* mShader;
bool mValid;
float mTime;
double mTime;
bool mEnabled;
};

View file

@ -1177,7 +1177,7 @@ void SceneOpenGL::Window::renderQuads( int mask, const QRegion& region, const Wi
delete[] texcoords;
}
void SceneOpenGL::Window::prepareStates( float opacity, float brightness, float saturation, GLShader* shader )
void SceneOpenGL::Window::prepareStates( double opacity, double brightness, double saturation, GLShader* shader )
{
if(shader)
prepareShaderRenderStates( opacity, brightness, saturation, shader );
@ -1185,7 +1185,7 @@ void SceneOpenGL::Window::prepareStates( float opacity, float brightness, float
prepareRenderStates( opacity, brightness, saturation );
}
void SceneOpenGL::Window::prepareShaderRenderStates( float opacity, float brightness, float saturation, GLShader* shader )
void SceneOpenGL::Window::prepareShaderRenderStates( double opacity, double brightness, double saturation, GLShader* shader )
{
// setup blending of transparent windows
glPushAttrib( GL_ENABLE_BIT );
@ -1200,7 +1200,7 @@ void SceneOpenGL::Window::prepareShaderRenderStates( float opacity, float bright
shader->setUniform("brightness", (float)brightness);
}
void SceneOpenGL::Window::prepareRenderStates( float opacity, float brightness, float saturation )
void SceneOpenGL::Window::prepareRenderStates( double opacity, double brightness, double saturation )
{
// setup blending of transparent windows
glPushAttrib( GL_ENABLE_BIT );
@ -1325,7 +1325,7 @@ void SceneOpenGL::Window::prepareRenderStates( float opacity, float brightness,
}
}
void SceneOpenGL::Window::restoreStates( float opacity, float brightness, float saturation, GLShader* shader )
void SceneOpenGL::Window::restoreStates( double opacity, double brightness, double saturation, GLShader* shader )
{
if(shader)
restoreShaderRenderStates( opacity, brightness, saturation, shader );
@ -1333,7 +1333,7 @@ void SceneOpenGL::Window::restoreStates( float opacity, float brightness, float
restoreRenderStates( opacity, brightness, saturation );
}
void SceneOpenGL::Window::restoreShaderRenderStates( float opacity, float brightness, float saturation, GLShader* shader )
void SceneOpenGL::Window::restoreShaderRenderStates( double opacity, double brightness, double saturation, GLShader* shader )
{
Q_UNUSED( opacity );
Q_UNUSED( brightness );
@ -1342,7 +1342,7 @@ void SceneOpenGL::Window::restoreShaderRenderStates( float opacity, float bright
glPopAttrib(); // ENABLE_BIT
}
void SceneOpenGL::Window::restoreRenderStates( float opacity, float brightness, float saturation )
void SceneOpenGL::Window::restoreRenderStates( double opacity, double brightness, double saturation )
{
if( opacity != 1.0 || saturation != 1.0 || brightness != 1.0f )
{

View file

@ -125,12 +125,12 @@ class SceneOpenGL::Window
protected:
void renderQuads( int mask, const QRegion& region, const WindowQuadList& quads );
void prepareStates( float opacity, float brightness, float saturation, GLShader* shader );
void prepareRenderStates( float opacity, float brightness, float saturation );
void prepareShaderRenderStates( float opacity, float brightness, float saturation, GLShader* shader );
void restoreStates( float opacity, float brightness, float saturation, GLShader* shader );
void restoreRenderStates( float opacity, float brightness, float saturation );
void restoreShaderRenderStates( float opacity, float brightness, float saturation, GLShader* shader );
void prepareStates( double opacity, double brightness, double saturation, GLShader* shader );
void prepareRenderStates( double opacity, double brightness, double saturation );
void prepareShaderRenderStates( double opacity, double brightness, double saturation, GLShader* shader );
void restoreStates( double opacity, double brightness, double saturation, GLShader* shader );
void restoreRenderStates( double opacity, double brightness, double saturation );
void restoreShaderRenderStates( double opacity, double brightness, double saturation, GLShader* shader );
private:
Texture texture;

View file

@ -394,7 +394,7 @@ void SceneXrender::Window::discardAlpha()
}
// Create XRender picture for the alpha mask.
Picture SceneXrender::Window::alphaMask( float opacity )
Picture SceneXrender::Window::alphaMask( double opacity )
{
if( isOpaque() && opacity == 1.0 )
return None;
@ -469,8 +469,8 @@ void SceneXrender::Window::performPaint( int mask, QRegion region, WindowPaintDa
int y = toplevel->y();
int width = toplevel->width();
int height = toplevel->height();
float xscale = 1;
float yscale = 1;
double xscale = 1;
double yscale = 1;
transformed_shape = shape();
if( mask & PAINT_WINDOW_TRANSFORMED )
{

View file

@ -67,11 +67,11 @@ class SceneXrender::Window
void setTransformedShape( const QRegion& shape );
private:
Picture picture();
Picture alphaMask( float opacity );
Picture alphaMask( double opacity );
Picture _picture;
XRenderPictFormat* format;
Picture alpha;
float alpha_cached_opacity;
double alpha_cached_opacity;
QRegion transformed_shape;
};

View file

@ -294,17 +294,17 @@ void Toplevel::getResourceClass()
}
}
float Toplevel::opacity() const
double Toplevel::opacity() const
{
if( info->opacity() == 0xffffffff )
return 1.0;
return info->opacity() * 1.0 / 0xffffffff;
}
void Toplevel::setOpacity( float new_opacity )
void Toplevel::setOpacity( double new_opacity )
{
float old_opacity = opacity();
new_opacity = qBound( 0.0f, new_opacity, 1.0f );
double old_opacity = opacity();
new_opacity = qBound( 0.0, new_opacity, 1.0 );
if( old_opacity == new_opacity )
return;
info->setOpacity( static_cast< unsigned long >( new_opacity * 0xffffffff ));

View file

@ -90,8 +90,8 @@ class Toplevel
bool readyForPainting() const; // true if the window has been already painted its contents
Visual* visual() const;
bool shape() const;
void setOpacity( float opacity );
float opacity() const;
void setOpacity( double opacity );
double opacity() const;
int depth() const;
bool hasAlpha() const;
void setupCompositing();