From e6069e9cf6154da89ae7e027dc753bae0d2097a1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lubo=C5=A1=20Lu=C5=88=C3=A1k?= Date: Mon, 3 Sep 2007 15:00:43 +0000 Subject: [PATCH] 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 --- deleted.h | 2 +- effects.cpp | 4 +- effects.h | 4 +- effects/boxswitch.cpp | 4 +- effects/demo_liquid.cpp | 2 +- effects/demo_liquid.h | 2 +- effects/demo_taskbarthumbnail.cpp | 8 +-- effects/demo_wavywindows.h | 2 +- effects/desktopgrid.cpp | 22 +++---- effects/desktopgrid.h | 2 +- effects/dialogparent.cpp | 10 +-- effects/dialogparent.h | 2 +- effects/drunken.h | 2 +- effects/explosioneffect.cpp | 6 +- effects/explosioneffect.h | 2 +- effects/fade.cpp | 20 +++--- effects/fade.h | 10 +-- effects/fallapart.cpp | 16 ++--- effects/fallapart.h | 2 +- effects/flame.cpp | 2 +- effects/flame.h | 2 +- effects/lookingglass.cpp | 12 ++-- effects/lookingglass.h | 4 +- effects/magnifier.cpp | 6 +- effects/magnifier.h | 4 +- effects/maketransparent.h | 6 +- effects/minimizeanimation.cpp | 8 +-- effects/minimizeanimation.h | 2 +- effects/presentwindows.cpp | 62 +++++++++--------- effects/presentwindows.h | 12 ++-- effects/scalein.h | 2 +- effects/shadow.cpp | 4 +- effects/shadow.h | 2 +- effects/showfps.h | 2 +- effects/test_fbo.h | 2 +- effects/thumbnailaside.cpp | 4 +- effects/thumbnailaside.h | 2 +- effects/zoom.cpp | 6 +- effects/zoom.h | 4 +- lib/kwineffects.cpp | 44 ++++++------- lib/kwineffects.h | 100 +++++++++++++++--------------- lib/kwinshadereffect.cpp | 2 +- lib/kwinshadereffect.h | 2 +- scene_opengl.cpp | 12 ++-- scene_opengl.h | 12 ++-- scene_xrender.cpp | 6 +- scene_xrender.h | 4 +- toplevel.cpp | 8 +-- toplevel.h | 4 +- 49 files changed, 232 insertions(+), 232 deletions(-) diff --git a/deleted.h b/deleted.h index 5e2e38c380..269aef86ab 100644 --- a/deleted.h +++ b/deleted.h @@ -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() }; diff --git a/effects.cpp b/effects.cpp index 533c8f75bf..7ec7c56c33 100644 --- a/effects.cpp +++ b/effects.cpp @@ -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(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(); } diff --git a/effects.h b/effects.h index 647c0d0cea..bd1e51e247 100644 --- a/effects.h +++ b/effects.h @@ -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; diff --git a/effects/boxswitch.cpp b/effects/boxswitch.cpp index c9ce83e5d4..cac369221a 100644 --- a/effects/boxswitch.cpp +++ b/effects/boxswitch.cpp @@ -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; diff --git a/effects/demo_liquid.cpp b/effects/demo_liquid.cpp index eaf40f1ce0..54a9217ba8 100644 --- a/effects/demo_liquid.cpp +++ b/effects/demo_liquid.cpp @@ -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); diff --git a/effects/demo_liquid.h b/effects/demo_liquid.h index 9a078b2e8a..3450cd98ce 100644 --- a/effects/demo_liquid.h +++ b/effects/demo_liquid.h @@ -44,7 +44,7 @@ class LiquidEffect : public Effect GLShader* mShader; bool mValid; - float mTime; + double mTime; }; } // namespace diff --git a/effects/demo_taskbarthumbnail.cpp b/effects/demo_taskbarthumbnail.cpp index e1f2155a63..7b1f7b5873 100644 --- a/effects/demo_taskbarthumbnail.cpp +++ b/effects/demo_taskbarthumbnail.cpp @@ -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 )); diff --git a/effects/demo_wavywindows.h b/effects/demo_wavywindows.h index e060a76a1a..a9944e7d39 100644 --- a/effects/demo_wavywindows.h +++ b/effects/demo_wavywindows.h @@ -32,7 +32,7 @@ class WavyWindowsEffect virtual void postPaintScreen(); private: - float mTimeElapsed; + double mTimeElapsed; }; } // namespace diff --git a/effects/desktopgrid.cpp b/effects/desktopgrid.cpp index 52e9316490..2c87335b33 100644 --- a/effects/desktopgrid.cpp +++ b/effects/desktopgrid.cpp @@ -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; diff --git a/effects/desktopgrid.h b/effects/desktopgrid.h index dc13a1aeaa..86d4853f5c 100644 --- a/effects/desktopgrid.h +++ b/effects/desktopgrid.h @@ -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; diff --git a/effects/dialogparent.cpp b/effects/dialogparent.cpp index c683f642bb..e384337900 100644 --- a/effects/dialogparent.cpp +++ b/effects/dialogparent.cpp @@ -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 diff --git a/effects/dialogparent.h b/effects/dialogparent.h index 979dfafd48..3b33233d19 100644 --- a/effects/dialogparent.h +++ b/effects/dialogparent.h @@ -39,7 +39,7 @@ class DialogParentEffect bool hasModalWindow( EffectWindow* t ); private: // The progress of the fading. - QHash effectStrength; + QHash effectStrength; }; } // namespace diff --git a/effects/drunken.h b/effects/drunken.h index 85ac1a1b8c..2b665c4536 100644 --- a/effects/drunken.h +++ b/effects/drunken.h @@ -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 diff --git a/effects/explosioneffect.cpp b/effects/explosioneffect.cpp index 9b4ebacef8..f2e16372ce 100644 --- a/effects/explosioneffect.cpp +++ b/effects/explosioneffect.cpp @@ -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); diff --git a/effects/explosioneffect.h b/effects/explosioneffect.h index e570469cc7..b2846cd6aa 100644 --- a/effects/explosioneffect.h +++ b/effects/explosioneffect.h @@ -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; diff --git a/effects/fade.cpp b/effects/fade.cpp index cd5e2e0ecc..90853828a5 100644 --- a/effects/fade.cpp +++ b/effects/fade.cpp @@ -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; diff --git a/effects/fade.h b/effects/fade.h index f1f27ef226..0554e3b709 100644 --- a/effects/fade.h +++ b/effects/fade.h @@ -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; }; diff --git a/effects/fallapart.cpp b/effects/fallapart.cpp index cc4cbeba30..beee4717af 100644 --- a/effects/fallapart.cpp +++ b/effects/fallapart.cpp @@ -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 ); diff --git a/effects/fallapart.h b/effects/fallapart.h index f420f32907..90f399aace 100644 --- a/effects/fallapart.h +++ b/effects/fallapart.h @@ -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 diff --git a/effects/flame.cpp b/effects/flame.cpp index 5e2da48cc5..797293abed 100644 --- a/effects/flame.cpp +++ b/effects/flame.cpp @@ -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 ) diff --git a/effects/flame.h b/effects/flame.h index 861e755ad8..ee3ac7da53 100644 --- a/effects/flame.h +++ b/effects/flame.h @@ -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 diff --git a/effects/lookingglass.cpp b/effects/lookingglass.cpp index c2dbaa909a..7f2e08b0c8 100644 --- a/effects/lookingglass.cpp +++ b/effects/lookingglass.cpp @@ -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(); } diff --git a/effects/lookingglass.h b/effects/lookingglass.h index bbb6307186..086c63e919 100644 --- a/effects/lookingglass.h +++ b/effects/lookingglass.h @@ -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; }; diff --git a/effects/magnifier.cpp b/effects/magnifier.cpp index cb34f238d9..d8c9e6f5c8 100644 --- a/effects/magnifier.cpp +++ b/effects/magnifier.cpp @@ -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 ) diff --git a/effects/magnifier.h b/effects/magnifier.h index 8d08670fb1..548bbe7e12 100644 --- a/effects/magnifier.h +++ b/effects/magnifier.h @@ -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; }; diff --git a/effects/maketransparent.h b/effects/maketransparent.h index 36660542c2..88d04914e1 100644 --- a/effects/maketransparent.h +++ b/effects/maketransparent.h @@ -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 diff --git a/effects/minimizeanimation.cpp b/effects/minimizeanimation.cpp index 0862e4fab3..d59d649f61 100644 --- a/effects/minimizeanimation.cpp +++ b/effects/minimizeanimation.cpp @@ -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); } diff --git a/effects/minimizeanimation.h b/effects/minimizeanimation.h index 4e67e0f8aa..39cb7d3734 100644 --- a/effects/minimizeanimation.h +++ b/effects/minimizeanimation.h @@ -36,7 +36,7 @@ class MinimizeAnimationEffect virtual void windowUnminimized( EffectWindow* c ); private: - QHash< EffectWindow*, float > mAnimationProgress; + QHash< EffectWindow*, double > mAnimationProgress; int mActiveAnimations; }; diff --git a/effects/presentwindows.cpp b/effects/presentwindows.cpp index 85f79bad97..dfb52df50e 100644 --- a/effects/presentwindows.cpp +++ b/effects/presentwindows.cpp @@ -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; } diff --git a/effects/presentwindows.h b/effects/presentwindows.h index 62dbc6c2bf..08054938a4 100644 --- a/effects/presentwindows.h +++ b/effects/presentwindows.h @@ -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; diff --git a/effects/scalein.h b/effects/scalein.h index b1ea088b1d..a687043973 100644 --- a/effects/scalein.h +++ b/effects/scalein.h @@ -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 diff --git a/effects/shadow.cpp b/effects/shadow.cpp index 2ec061e9ea..005ab05366 100644 --- a/effects/shadow.cpp +++ b/effects/shadow.cpp @@ -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; diff --git a/effects/shadow.h b/effects/shadow.h index 85b0e38216..a2434f3440 100644 --- a/effects/shadow.h +++ b/effects/shadow.h @@ -35,7 +35,7 @@ class ShadowEffect QRect shadowRectangle(const QRect& windowRectangle) const; int shadowXOffset, shadowYOffset; - float shadowOpacity; + double shadowOpacity; int shadowFuzzyness; GLTexture* mShadowTexture; }; diff --git a/effects/showfps.h b/effects/showfps.h index cc58b80bd2..e85dc98381 100644 --- a/effects/showfps.h +++ b/effects/showfps.h @@ -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; }; diff --git a/effects/test_fbo.h b/effects/test_fbo.h index 9b7eff1c33..a0dee8a593 100644 --- a/effects/test_fbo.h +++ b/effects/test_fbo.h @@ -41,7 +41,7 @@ class TestFBOEffect : public Effect GLRenderTarget* mRenderTarget; bool mValid; - float mRot; + double mRot; }; } // namespace diff --git a/effects/thumbnailaside.cpp b/effects/thumbnailaside.cpp index 59f8d83d49..53f72a4e93 100644 --- a/effects/thumbnailaside.cpp +++ b/effects/thumbnailaside.cpp @@ -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(); diff --git a/effects/thumbnailaside.h b/effects/thumbnailaside.h index 2b632f3d0e..7c071fe1ca 100644 --- a/effects/thumbnailaside.h +++ b/effects/thumbnailaside.h @@ -51,7 +51,7 @@ class ThumbnailAsideEffect QHash< EffectWindow*, Data > windows; int maxwidth; int spacing; - float opacity; + double opacity; }; } // namespace diff --git a/effects/zoom.cpp b/effects/zoom.cpp index 5fbeefc52b..965fe776fe 100644 --- a/effects/zoom.cpp +++ b/effects/zoom.cpp @@ -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; diff --git a/effects/zoom.h b/effects/zoom.h index af54fe2ec5..f198b7391f 100644 --- a/effects/zoom.h +++ b/effects/zoom.h @@ -32,8 +32,8 @@ class ZoomEffect void zoomOut(); void actualSize(); private: - float zoom; - float target_zoom; + double zoom; + double target_zoom; }; } // namespace diff --git a/lib/kwineffects.cpp b/lib/kwineffects.cpp index 60c46b9235..60400e2f7e 100644 --- a/lib/kwineffects.cpp +++ b/lib/kwineffects.cpp @@ -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 ) { diff --git a/lib/kwineffects.h b/lib/kwineffects.h index ae608a8ca8..6553bc58a0 100644 --- a/lib/kwineffects.h +++ b/lib/kwineffects.h @@ -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; } diff --git a/lib/kwinshadereffect.cpp b/lib/kwinshadereffect.cpp index 98565afc3b..45f775a83f 100644 --- a/lib/kwinshadereffect.cpp +++ b/lib/kwinshadereffect.cpp @@ -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()); diff --git a/lib/kwinshadereffect.h b/lib/kwinshadereffect.h index 890d6bf1d9..639dd0de7a 100644 --- a/lib/kwinshadereffect.h +++ b/lib/kwinshadereffect.h @@ -46,7 +46,7 @@ class KWIN_EXPORT ShaderEffect : public Effect GLShader* mShader; bool mValid; - float mTime; + double mTime; bool mEnabled; }; diff --git a/scene_opengl.cpp b/scene_opengl.cpp index 77cbfdeb29..1820ea69bc 100644 --- a/scene_opengl.cpp +++ b/scene_opengl.cpp @@ -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 ) { diff --git a/scene_opengl.h b/scene_opengl.h index 71fc2a5ba5..92a4af89ce 100644 --- a/scene_opengl.h +++ b/scene_opengl.h @@ -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; diff --git a/scene_xrender.cpp b/scene_xrender.cpp index 0e7174c4aa..cf99e2a9c8 100644 --- a/scene_xrender.cpp +++ b/scene_xrender.cpp @@ -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 ) { diff --git a/scene_xrender.h b/scene_xrender.h index cefa27d4fa..ae1de60018 100644 --- a/scene_xrender.h +++ b/scene_xrender.h @@ -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; }; diff --git a/toplevel.cpp b/toplevel.cpp index a5d37e7b21..322836d97b 100644 --- a/toplevel.cpp +++ b/toplevel.cpp @@ -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 )); diff --git a/toplevel.h b/toplevel.h index 1b224297c7..b8cf559804 100644 --- a/toplevel.h +++ b/toplevel.h @@ -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();