Use always float as the floating point type for compositing

(http://lists.kde.org/?l=kwin&m=118493073424327&w=2).


svn path=/trunk/KDE/kdebase/workspace/; revision=700026
This commit is contained in:
Luboš Luňák 2007-08-14 15:22:23 +00:00
parent 32506e3aa7
commit d846a1e8a9
28 changed files with 86 additions and 86 deletions

View file

@ -35,7 +35,7 @@ class Deleted
void copyToDeleted( Toplevel* c ); void copyToDeleted( Toplevel* c );
virtual ~Deleted(); // deleted only using unrefWindow() virtual ~Deleted(); // deleted only using unrefWindow()
int delete_refcount; int delete_refcount;
double window_opacity; float window_opacity;
int desk; int desk;
QRect contentsRect; // for clientPos()/clientSize() 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 ); ep.second->windowUserMovedResized( c, first, last );
} }
void EffectsHandlerImpl::windowOpacityChanged( EffectWindow* c, double old_opacity ) void EffectsHandlerImpl::windowOpacityChanged( EffectWindow* c, float old_opacity )
{ {
if( static_cast<EffectWindowImpl*>(c)->window()->opacity() == old_opacity ) if( static_cast<EffectWindowImpl*>(c)->window()->opacity() == old_opacity )
return; return;
@ -853,7 +853,7 @@ bool EffectWindowImpl::isMinimized() const
return false; return false;
} }
double EffectWindowImpl::opacity() const float EffectWindowImpl::opacity() const
{ {
return toplevel->opacity(); return toplevel->opacity();
} }

View file

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

View file

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

View file

@ -46,7 +46,7 @@ void DesktopGridEffect::prePaintScreen( ScreenPrePaintData& data, int time )
{ {
if( slide ) if( slide )
{ {
progress = qMin( 1.0, progress + time / double( PROGRESS_TIME )); progress = qMin( 1.0f, progress + time / float( PROGRESS_TIME ));
// PAINT_SCREEN_BACKGROUND_FIRST is needed because screen will be actually painted more than once, // 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 // so with normal screen painting second screen paint would erase parts of the first paint
if( progress != 1 ) if( progress != 1 )
@ -60,9 +60,9 @@ void DesktopGridEffect::prePaintScreen( ScreenPrePaintData& data, int time )
else if( progress != 0 || activated ) else if( progress != 0 || activated )
{ {
if( activated ) if( activated )
progress = qMin( 1.0, progress + time / double( PROGRESS_TIME )); progress = qMin( 1.0f, progress + time / float( PROGRESS_TIME ));
else else
progress = qMax( 0.0, progress - time / double( PROGRESS_TIME )); progress = qMax( 0.0f, progress - time / float( PROGRESS_TIME ));
// PAINT_SCREEN_BACKGROUND_FIRST is needed because screen will be actually painted more than once, // 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 // so with normal screen painting second screen paint would erase parts of the first paint
if( progress != 0 ) if( progress != 0 )

View file

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

View file

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

View file

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

View file

@ -26,7 +26,7 @@ class FadeEffect
virtual void paintWindow( EffectWindow* w, int mask, QRegion region, WindowPaintData& data ); virtual void paintWindow( EffectWindow* w, int mask, QRegion region, WindowPaintData& data );
// TODO react also on virtual desktop changes // TODO react also on virtual desktop changes
virtual void windowOpacityChanged( EffectWindow* c, double old_opacity ); virtual void windowOpacityChanged( EffectWindow* c, float old_opacity );
virtual void windowAdded( EffectWindow* c ); virtual void windowAdded( EffectWindow* c );
virtual void windowClosed( EffectWindow* c ); virtual void windowClosed( EffectWindow* c );
virtual void windowDeleted( EffectWindow* c ); virtual void windowDeleted( EffectWindow* c );
@ -35,7 +35,7 @@ class FadeEffect
private: private:
class WindowInfo; class WindowInfo;
QHash< const EffectWindow*, WindowInfo > windows; QHash< const EffectWindow*, WindowInfo > windows;
double fadeInStep, fadeOutStep; float fadeInStep, fadeOutStep;
int fadeInTime, fadeOutTime; int fadeInTime, fadeOutTime;
bool fadeWindows; bool fadeWindows;
}; };
@ -51,8 +51,8 @@ class FadeEffect::WindowInfo
, brightness( 1.0 ) , brightness( 1.0 )
, deleted( false ) , deleted( false )
{} {}
double fadeInStep, fadeOutStep; float fadeInStep, fadeOutStep;
double opacity; float opacity;
float saturation, brightness; float saturation, brightness;
bool deleted; 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 // make fragments move in various directions, based on where
// they are (left pieces generally move to the left, etc.) // they are (left pieces generally move to the left, etc.)
QPointF p1( quad[ 0 ].x(), quad[ 0 ].y()); QPointF p1( quad[ 0 ].x(), quad[ 0 ].y());
double xdiff = 0; float xdiff = 0;
if( p1.x() < w->width() / 2 ) if( p1.x() < w->width() / 2 )
xdiff = -( w->width() / 2 - p1.x()) / w->width() * 100; xdiff = -( w->width() / 2 - p1.x()) / w->width() * 100;
if( p1.x() > w->width() / 2 ) if( p1.x() > w->width() / 2 )
xdiff = ( p1.x() - w->width() / 2 ) / w->width() * 100; xdiff = ( p1.x() - w->width() / 2 ) / w->width() * 100;
double ydiff = 0; float ydiff = 0;
if( p1.y() < w->height() / 2 ) if( p1.y() < w->height() / 2 )
ydiff = -( w->height() / 2 - p1.y()) / w->height() * 100; ydiff = -( w->height() / 2 - p1.y()) / w->height() * 100;
if( p1.y() > w->height() / 2 ) if( p1.y() > w->height() / 2 )
ydiff = ( p1.y() - w->height() / 2 ) / w->height() * 100; ydiff = ( p1.y() - w->height() / 2 ) / w->height() * 100;
double modif = windows[ w ] * windows[ w ] * 64; float modif = windows[ w ] * windows[ w ] * 64;
srandom( cnt ); // change direction randomly but consistently srandom( cnt ); // change direction randomly but consistently
xdiff += ( rand() % 21 - 10 ); xdiff += ( rand() % 21 - 10 );
ydiff += ( 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 // also make the fragments rotate around their center
QPointF center(( quad[ 0 ].x() + quad[ 1 ].x() + quad[ 2 ].x() + quad[ 3 ].x()) / 4, 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 ); ( quad[ 0 ].y() + quad[ 1 ].y() + quad[ 2 ].y() + quad[ 3 ].y()) / 4 );
double adiff = ( rand() % 720 - 360 ) / 360. * 2 * M_PI; // spin randomly float adiff = ( rand() % 720 - 360 ) / 360. * 2 * M_PI; // spin randomly
for( int j = 0; for( int j = 0;
j < 4; j < 4;
++j ) ++j )
{ {
double x = quad[ j ].x() - center.x(); float x = quad[ j ].x() - center.x();
double y = quad[ j ].y() - center.y(); float y = quad[ j ].y() - center.y();
double angle = atan2( y, x ); float angle = atan2( y, x );
angle += windows[ w ] * adiff; angle += windows[ w ] * adiff;
double dist = sqrt( x * x + y * y ); float dist = sqrt( x * x + y * y );
x = dist * cos( angle ); x = dist * cos( angle );
y = dist * sin( angle ); y = dist * sin( angle );
quad[ j ].move( center.x() + x, center.y() + y ); quad[ j ].move( center.x() + x, center.y() + y );

View file

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

View file

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

View file

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

View file

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

View file

@ -443,12 +443,12 @@ void PresentWindowsEffect::calculateWindowTransformationsKompose(EffectWindowLis
if ( parentRatio > 1 ) if ( parentRatio > 1 )
{ {
columns = (int)ceil( sqrt(windowlist.count()) ); columns = (int)ceil( sqrt(windowlist.count()) );
rows = (int)ceil( (double)windowlist.count() / (double)columns ); rows = (int)ceil( (float)windowlist.count() / (float)columns );
} }
else else
{ {
rows = (int)ceil( sqrt(windowlist.count()) ); rows = (int)ceil( sqrt(windowlist.count()) );
columns = (int)ceil( (double)windowlist.count() / (double)rows ); columns = (int)ceil( (float)windowlist.count() / (float)rows );
} }
kDebug() << k_funcinfo << "Using " << rows << " rows & " << columns << " columns for " << windowlist.count() << " clients"; kDebug() << k_funcinfo << "Using " << rows << " rows & " << columns << " columns for " << windowlist.count() << " clients";
@ -505,8 +505,8 @@ void PresentWindowsEffect::calculateWindowTransformationsKompose(EffectWindowLis
} }
else else
{ {
double widthForHeight = windowWidthForHeight(window, usableH); float widthForHeight = windowWidthForHeight(window, usableH);
double heightForWidth = windowHeightForWidth(window, usableW); float heightForWidth = windowHeightForWidth(window, usableW);
if ( (ratio >= 1.0 && heightForWidth <= usableH) || if ( (ratio >= 1.0 && heightForWidth <= usableH) ||
(ratio < 1.0 && widthForHeight > usableW) ) (ratio < 1.0 && widthForHeight > usableW) )
{ {
@ -572,7 +572,7 @@ void PresentWindowsEffect::calculateWindowTransformationsClosest(EffectWindowLis
{ {
QRect area = effects->clientArea( PlacementArea, QPoint( 0, 0 ), effects->currentDesktop()); QRect area = effects->clientArea( PlacementArea, QPoint( 0, 0 ), effects->currentDesktop());
int columns = int( ceil( sqrt( windowlist.count()))); int columns = int( ceil( sqrt( windowlist.count())));
int rows = int( ceil( windowlist.count() / double( columns ))); int rows = int( ceil( windowlist.count() / float( columns )));
foreach( EffectWindow* w, windowlist ) foreach( EffectWindow* w, windowlist )
mWindowData[ w ].slot = -1; mWindowData[ w ].slot = -1;
for(;;) for(;;)
@ -693,9 +693,9 @@ bool PresentWindowsEffect::canRearrangeClosest(EffectWindowList windowlist)
{ {
QRect area = effects->clientArea( PlacementArea, QPoint( 0, 0 ), effects->currentDesktop()); QRect area = effects->clientArea( PlacementArea, QPoint( 0, 0 ), effects->currentDesktop());
int columns = int( ceil( sqrt( windowlist.count()))); int columns = int( ceil( sqrt( windowlist.count())));
int rows = int( ceil( windowlist.count() / double( columns ))); int rows = int( ceil( windowlist.count() / float( columns )));
int old_columns = int( ceil( sqrt( mWindowData.count()))); int old_columns = int( ceil( sqrt( mWindowData.count())));
int old_rows = int( ceil( mWindowData.count() / double( columns ))); int old_rows = int( ceil( mWindowData.count() / float( columns )));
return old_columns != columns || old_rows != rows; return old_columns != columns || old_rows != rows;
} }

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -74,7 +74,7 @@ void Effect::windowUserMovedResized( EffectWindow* , bool, bool )
{ {
} }
void Effect::windowOpacityChanged( EffectWindow*, double ) void Effect::windowOpacityChanged( EffectWindow*, float )
{ {
} }
@ -187,8 +187,8 @@ void Effect::setPositionTransformations( WindowPaintData& data, QRect& region, E
{ {
QSize size = w->size(); QSize size = w->size();
size.scale( r.size(), aspect ); size.scale( r.size(), aspect );
data.xScale = size.width() / double( w->width()); data.xScale = size.width() / float( w->width());
data.yScale = size.height() / double( w->height()); data.yScale = size.height() / float( w->height());
int width = int( w->width() * data.xScale ); int width = int( w->width() * data.xScale );
int height = int( w->height() * data.yScale ); int height = int( w->height() * data.yScale );
int x = r.x() + ( r.width() - width ) / 2; int x = r.x() + ( r.width() - width ) / 2;

View file

@ -96,7 +96,7 @@ class KWIN_EXPORT Effect
// called when moved/resized or once after it's finished // called when moved/resized or once after it's finished
virtual void windowUserMovedResized( EffectWindow* c, bool first, bool last ); virtual void windowUserMovedResized( EffectWindow* c, bool first, bool last );
virtual void windowOpacityChanged( EffectWindow* c, double old_opacity ); virtual void windowOpacityChanged( EffectWindow* c, float old_opacity );
virtual void windowAdded( EffectWindow* c ); virtual void windowAdded( EffectWindow* c );
virtual void windowClosed( EffectWindow* c ); virtual void windowClosed( EffectWindow* c );
virtual void windowDeleted( EffectWindow* c ); virtual void windowDeleted( EffectWindow* c );
@ -294,7 +294,7 @@ class KWIN_EXPORT EffectWindow
virtual bool isDeleted() const = 0; virtual bool isDeleted() const = 0;
virtual bool isMinimized() const = 0; virtual bool isMinimized() const = 0;
virtual double opacity() const = 0; virtual float opacity() const = 0;
virtual bool isOnDesktop( int d ) const; virtual bool isOnDesktop( int d ) const;
virtual bool isOnCurrentDesktop() const; virtual bool isOnCurrentDesktop() const;
@ -457,11 +457,11 @@ class KWIN_EXPORT WindowPaintData
* Opacity for contents is opacity*contents_opacity, the same * Opacity for contents is opacity*contents_opacity, the same
* way for decoration. * way for decoration.
*/ */
double opacity; float opacity;
double contents_opacity; float contents_opacity;
double decoration_opacity; float decoration_opacity;
double xScale; float xScale;
double yScale; float yScale;
int xTranslate; int xTranslate;
int yTranslate; int yTranslate;
/** /**
@ -488,8 +488,8 @@ class KWIN_EXPORT ScreenPaintData
{ {
public: public:
ScreenPaintData(); ScreenPaintData();
double xScale; float xScale;
double yScale; float yScale;
int xTranslate; int xTranslate;
int yTranslate; int yTranslate;
}; };

View file

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

View file

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

View file

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

View file

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

View file

@ -294,17 +294,17 @@ void Toplevel::getResourceClass()
} }
} }
double Toplevel::opacity() const float Toplevel::opacity() const
{ {
if( info->opacity() == 0xffffffff ) if( info->opacity() == 0xffffffff )
return 1.0; return 1.0;
return info->opacity() * 1.0 / 0xffffffff; return info->opacity() * 1.0 / 0xffffffff;
} }
void Toplevel::setOpacity( double new_opacity ) void Toplevel::setOpacity( float new_opacity )
{ {
double old_opacity = opacity(); float old_opacity = opacity();
new_opacity = qBound( 0.0, new_opacity, 1.0 ); new_opacity = qBound( 0.0f, new_opacity, 1.0f );
if( old_opacity == new_opacity ) if( old_opacity == new_opacity )
return; return;
info->setOpacity( static_cast< unsigned long >( new_opacity * 0xffffffff )); 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 bool readyForPainting() const; // true if the window has been already painted its contents
Visual* visual() const; Visual* visual() const;
bool shape() const; bool shape() const;
void setOpacity( double opacity ); void setOpacity( float opacity );
double opacity() const; float opacity() const;
int depth() const; int depth() const;
bool hasAlpha() const; bool hasAlpha() const;
void setupCompositing(); void setupCompositing();