Fix matrix multiplication, add transform function.
svn path=/branches/work/kwin_composite/; revision=559061
This commit is contained in:
parent
0516e1e73b
commit
a9cec042cb
2 changed files with 23 additions and 3 deletions
20
effects.cpp
20
effects.cpp
|
@ -55,7 +55,7 @@ Matrix operator*( const Matrix& m1, const Matrix& m2 )
|
|||
for( int k = 0;
|
||||
k < 4;
|
||||
++k )
|
||||
s += m1.m[ i ][ k ] * m2.m[ k ][ j ];
|
||||
s += m1.m[ k ][ j ] * m2.m[ i ][ k ];
|
||||
r.m[ i ][ j ] = s;
|
||||
}
|
||||
return r;
|
||||
|
@ -102,6 +102,24 @@ bool Matrix::isOnlyTranslate() const
|
|||
&& m[ 3 ][ 3 ] == 1;
|
||||
}
|
||||
|
||||
QPoint Matrix::transform( const QPoint& p ) const
|
||||
{
|
||||
int vec[ 4 ] = { p.x(), p.y(), 0, 1 };
|
||||
int res[ 4 ];
|
||||
for( int i = 0;
|
||||
i < 4;
|
||||
++i )
|
||||
{
|
||||
double s = 0;
|
||||
for( int j = 0;
|
||||
j < 4;
|
||||
++j )
|
||||
s += m[ i ][ j ] * vec[ j ];
|
||||
res[ i ] = int( s );
|
||||
}
|
||||
return QPoint( res[ 0 ], res[ 1 ] );
|
||||
}
|
||||
|
||||
//****************************************
|
||||
// Effect
|
||||
//****************************************
|
||||
|
|
|
@ -13,8 +13,9 @@ License. See the file "COPYING" for the exact licensing terms.
|
|||
#ifndef KWIN_EFFECTS_H
|
||||
#define KWIN_EFFECTS_H
|
||||
|
||||
#include <QMap>
|
||||
#include <QTimer>
|
||||
#include <qmap.h>
|
||||
#include <qpoint.h>
|
||||
#include <qtimer.h>
|
||||
|
||||
namespace KWinInternal
|
||||
{
|
||||
|
@ -32,6 +33,7 @@ class Matrix
|
|||
double xTranslate() const;
|
||||
double yTranslate() const;
|
||||
double zTranslate() const;
|
||||
QPoint transform( const QPoint& p ) const;
|
||||
double m[ 4 ][ 4 ];
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in a new issue