mirror of
https://bitbucket.org/smil3y/kde-workspace.git
synced 2025-02-23 18:32:50 +00:00
kwin: KWin::PaintData optimization
QGraphicsScale and QGraphicsRotation are for use with QGraphicsItem, have signals and more setters and getters than KWin::PaintData needs making its use in KWin::PaintData sub-optimal Signed-off-by: Ivailo Monev <xakepa10@gmail.com>
This commit is contained in:
parent
e51cf82b56
commit
4b3d2080e9
3 changed files with 46 additions and 39 deletions
|
@ -65,11 +65,23 @@ void WindowPrePaintData::setTransformed()
|
||||||
|
|
||||||
class PaintDataPrivate {
|
class PaintDataPrivate {
|
||||||
public:
|
public:
|
||||||
QGraphicsScale scale;
|
PaintDataPrivate();
|
||||||
|
|
||||||
|
qreal xScale;
|
||||||
|
qreal yScale;
|
||||||
|
qreal zScale;
|
||||||
QVector3D translation;
|
QVector3D translation;
|
||||||
QGraphicsRotation rotation;
|
QVector3D rotationOrigin;
|
||||||
|
qreal rotationAngle;
|
||||||
|
QVector3D rotationAxis;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
PaintDataPrivate::PaintDataPrivate()
|
||||||
|
: xScale(1.0), yScale(1.0), zScale(1.0),
|
||||||
|
rotationAngle(0), rotationAxis(0.0, 0.0, 1.0)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
PaintData::PaintData()
|
PaintData::PaintData()
|
||||||
: d(new PaintDataPrivate())
|
: d(new PaintDataPrivate())
|
||||||
{
|
{
|
||||||
|
@ -82,50 +94,44 @@ PaintData::~PaintData()
|
||||||
|
|
||||||
qreal PaintData::xScale() const
|
qreal PaintData::xScale() const
|
||||||
{
|
{
|
||||||
return d->scale.xScale();
|
return d->xScale;
|
||||||
}
|
}
|
||||||
|
|
||||||
qreal PaintData::yScale() const
|
qreal PaintData::yScale() const
|
||||||
{
|
{
|
||||||
return d->scale.yScale();
|
return d->yScale;
|
||||||
}
|
}
|
||||||
|
|
||||||
qreal PaintData::zScale() const
|
qreal PaintData::zScale() const
|
||||||
{
|
{
|
||||||
return d->scale.zScale();
|
return d->zScale;
|
||||||
}
|
|
||||||
|
|
||||||
void PaintData::setScale(const QVector2D &scale)
|
|
||||||
{
|
|
||||||
d->scale.setXScale(scale.x());
|
|
||||||
d->scale.setYScale(scale.y());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void PaintData::setScale(const QVector3D &scale)
|
void PaintData::setScale(const QVector3D &scale)
|
||||||
{
|
{
|
||||||
d->scale.setXScale(scale.x());
|
d->xScale = scale.x();
|
||||||
d->scale.setYScale(scale.y());
|
d->yScale = scale.y();
|
||||||
d->scale.setZScale(scale.z());
|
d->zScale = scale.z();
|
||||||
}
|
}
|
||||||
|
|
||||||
void PaintData::setXScale(qreal scale)
|
void PaintData::setXScale(qreal scale)
|
||||||
{
|
{
|
||||||
d->scale.setXScale(scale);
|
d->xScale = scale;
|
||||||
}
|
}
|
||||||
|
|
||||||
void PaintData::setYScale(qreal scale)
|
void PaintData::setYScale(qreal scale)
|
||||||
{
|
{
|
||||||
d->scale.setYScale(scale);
|
d->yScale = scale;
|
||||||
}
|
}
|
||||||
|
|
||||||
void PaintData::setZScale(qreal scale)
|
void PaintData::setZScale(qreal scale)
|
||||||
{
|
{
|
||||||
d->scale.setZScale(scale);
|
d->zScale = scale;
|
||||||
}
|
}
|
||||||
|
|
||||||
const QGraphicsScale &PaintData::scale() const
|
QVector3D PaintData::scale() const
|
||||||
{
|
{
|
||||||
return d->scale;
|
return QVector3D(d->xScale, d->yScale, d->zScale);
|
||||||
}
|
}
|
||||||
|
|
||||||
void PaintData::setXTranslation(qreal translate)
|
void PaintData::setXTranslation(qreal translate)
|
||||||
|
@ -175,37 +181,50 @@ const QVector3D &PaintData::translation() const
|
||||||
|
|
||||||
qreal PaintData::rotationAngle() const
|
qreal PaintData::rotationAngle() const
|
||||||
{
|
{
|
||||||
return d->rotation.angle();
|
return d->rotationAngle;
|
||||||
}
|
}
|
||||||
|
|
||||||
QVector3D PaintData::rotationAxis() const
|
QVector3D PaintData::rotationAxis() const
|
||||||
{
|
{
|
||||||
return d->rotation.axis();
|
return d->rotationAxis;
|
||||||
}
|
}
|
||||||
|
|
||||||
QVector3D PaintData::rotationOrigin() const
|
QVector3D PaintData::rotationOrigin() const
|
||||||
{
|
{
|
||||||
return d->rotation.origin();
|
return d->rotationOrigin;
|
||||||
}
|
}
|
||||||
|
|
||||||
void PaintData::setRotationAngle(qreal angle)
|
void PaintData::setRotationAngle(qreal angle)
|
||||||
{
|
{
|
||||||
d->rotation.setAngle(angle);
|
d->rotationAngle = angle;
|
||||||
}
|
}
|
||||||
|
|
||||||
void PaintData::setRotationAxis(Qt::Axis axis)
|
void PaintData::setRotationAxis(Qt::Axis axis)
|
||||||
{
|
{
|
||||||
d->rotation.setAxis(axis);
|
switch (axis) {
|
||||||
|
case Qt::XAxis: {
|
||||||
|
d->rotationAxis = QVector3D(1.0, 0.0, 0.0);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case Qt::YAxis: {
|
||||||
|
d->rotationAxis = QVector3D(0.0, 1.0, 0.0);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case Qt::ZAxis: {
|
||||||
|
d->rotationAxis = QVector3D(0.0, 0.0, 1.0);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void PaintData::setRotationAxis(const QVector3D &axis)
|
void PaintData::setRotationAxis(const QVector3D &axis)
|
||||||
{
|
{
|
||||||
d->rotation.setAxis(axis);
|
d->rotationAxis = axis;
|
||||||
}
|
}
|
||||||
|
|
||||||
void PaintData::setRotationOrigin(const QVector3D &origin)
|
void PaintData::setRotationOrigin(const QVector3D &origin)
|
||||||
{
|
{
|
||||||
d->rotation.setOrigin(origin);
|
d->rotationOrigin = origin;
|
||||||
}
|
}
|
||||||
|
|
||||||
class WindowPaintDataPrivate {
|
class WindowPaintDataPrivate {
|
||||||
|
|
|
@ -32,7 +32,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
#include <QVector2D>
|
#include <QVector2D>
|
||||||
#include <QVector3D>
|
#include <QVector3D>
|
||||||
#include <QFont>
|
#include <QFont>
|
||||||
#include <QGraphicsScale>
|
|
||||||
#include <QKeyEvent>
|
#include <QKeyEvent>
|
||||||
#include <QVector>
|
#include <QVector>
|
||||||
#include <QList>
|
#include <QList>
|
||||||
|
@ -1685,19 +1684,13 @@ public:
|
||||||
* @since 4.10
|
* @since 4.10
|
||||||
**/
|
**/
|
||||||
void setZScale(qreal scale);
|
void setZScale(qreal scale);
|
||||||
/**
|
|
||||||
* Sets the scale factor in X and Y direction.
|
|
||||||
* @param scale The scale factor for X and Y direction
|
|
||||||
* @since 4.10
|
|
||||||
**/
|
|
||||||
void setScale(const QVector2D &scale);
|
|
||||||
/**
|
/**
|
||||||
* Sets the scale factor in X, Y and Z direction
|
* Sets the scale factor in X, Y and Z direction
|
||||||
* @param scale The scale factor for X, Y and Z direction
|
* @param scale The scale factor for X, Y and Z direction
|
||||||
* @since 4.10
|
* @since 4.10
|
||||||
**/
|
**/
|
||||||
void setScale(const QVector3D &scale);
|
void setScale(const QVector3D &scale);
|
||||||
const QGraphicsScale &scale() const;
|
QVector3D scale() const;
|
||||||
const QVector3D &translation() const;
|
const QVector3D &translation() const;
|
||||||
/**
|
/**
|
||||||
* @returns the translation in X direction.
|
* @returns the translation in X direction.
|
||||||
|
|
|
@ -152,11 +152,6 @@ void TestScreenPaintData::testSetScale()
|
||||||
QCOMPARE(data.xScale(), 2.0);
|
QCOMPARE(data.xScale(), 2.0);
|
||||||
QCOMPARE(data.yScale(), 3.0);
|
QCOMPARE(data.yScale(), 3.0);
|
||||||
QCOMPARE(data.zScale(), 4.0);
|
QCOMPARE(data.zScale(), 4.0);
|
||||||
// setting a vector2d should affect x and y components
|
|
||||||
data.setScale(QVector2D(0.5, 2.0));
|
|
||||||
QCOMPARE(data.xScale(), 0.5);
|
|
||||||
QCOMPARE(data.yScale(), 2.0);
|
|
||||||
QCOMPARE(data.zScale(), 4.0);
|
|
||||||
// setting a vector3d should affect all components
|
// setting a vector3d should affect all components
|
||||||
data.setScale(QVector3D(1.5, 2.5, 3.5));
|
data.setScale(QVector3D(1.5, 2.5, 3.5));
|
||||||
QCOMPARE(data.xScale(), 1.5);
|
QCOMPARE(data.xScale(), 1.5);
|
||||||
|
|
Loading…
Add table
Reference in a new issue