Split out common part of ScreenPaintData and WindowPaintData

New common d-pointered class PaintData is added which cannot
be instantiated.
This commit is contained in:
Martin Gräßlin 2012-06-02 21:54:18 +02:00
parent a2b0d42916
commit dd067b075b
10 changed files with 412 additions and 467 deletions

View file

@ -700,7 +700,7 @@ void CoverSwitchEffect::paintWindowCover(EffectWindow* w, bool reflectedWindow,
}
}
}
data.rotation.setAngle(data.rotation.angle() * timeLine.currentValue());
data.setRotationAngle(data.rotationAngle() * timeLine.currentValue());
}
}
if (stop) {
@ -731,7 +731,7 @@ void CoverSwitchEffect::paintWindowCover(EffectWindow* w, bool reflectedWindow,
}
}
}
data.rotation.setAngle(data.rotation.angle() * (1.0 - timeLine.currentValue()));
data.setRotationAngle(data.rotationAngle() * (1.0 - timeLine.currentValue()));
}
}
@ -793,9 +793,9 @@ void CoverSwitchEffect::paintFrontWindow(EffectWindow* frontWindow, int width, i
distance = -frontWindow->geometry().width() * 0.5f + area.width() * 0.5f +
(((float)displayWidth() * 0.5 * scaleFactor) - (float)area.width() * 0.5f) / rightWindows;
data.translate(distance * timeLine.currentValue());
data.rotation.setAxis(Qt::YAxis);
data.rotation.setAngle(-angle * timeLine.currentValue());
data.rotation.setOrigin(QVector3D(frontWindow->geometry().width(), 0.0, 0.0));
data.setRotationAxis(Qt::YAxis);
data.setRotationAngle(-angle * timeLine.currentValue());
data.setRotationOrigin(QVector3D(frontWindow->geometry().width(), 0.0, 0.0));
} else {
// move to left
distance = frontWindow->geometry().width() * 0.5f - area.width() * 0.5f +
@ -804,8 +804,8 @@ void CoverSwitchEffect::paintFrontWindow(EffectWindow* frontWindow, int width, i
if (specialHandlingForward)
factor = 2.0;
data.translate(distance * timeLine.currentValue() * factor);
data.rotation.setAxis(Qt::YAxis);
data.rotation.setAngle(angle * timeLine.currentValue());
data.setRotationAxis(Qt::YAxis);
data.setRotationAngle(angle * timeLine.currentValue());
}
}
if (specialHandlingForward) {
@ -833,15 +833,15 @@ void CoverSwitchEffect::paintWindows(const EffectWindowList& windows, bool left,
// has to appear on this side after half of the time
if (animation && timeLine.currentValue() >= 0.5 && additionalWindow != NULL) {
WindowPaintData data(additionalWindow);
data.rotation.setAxis(Qt::YAxis);
data.rotation.setAngle(angle * rotateFactor);
data.setRotationAxis(Qt::YAxis);
data.setRotationAngle(angle * rotateFactor);
if (left) {
data.translate(-xTranslate - additionalWindow->geometry().x());
}
else {
data.translate(xTranslate + area.width() -
additionalWindow->geometry().x() - additionalWindow->geometry().width());
data.rotation.setOrigin(QVector3D(additionalWindow->geometry().width(), 0.0, 0.0));
data.setRotationOrigin(QVector3D(additionalWindow->geometry().width(), 0.0, 0.0));
}
data.opacity *= (timeLine.currentValue() - 0.5) * 2.0;
paintWindowCover(additionalWindow, reflectedWindows, data);
@ -853,8 +853,8 @@ void CoverSwitchEffect::paintWindows(const EffectWindowList& windows, bool left,
continue;
}
WindowPaintData data(window);
data.rotation.setAxis(Qt::YAxis);
data.rotation.setAngle(angle);
data.setRotationAxis(Qt::YAxis);
data.setRotationAngle(angle);
if (left)
data.translate(-xTranslate + xTranslate * i / windowCount - window->geometry().x());
else
@ -865,7 +865,7 @@ void CoverSwitchEffect::paintWindows(const EffectWindowList& windows, bool left,
// right most window on left side -> move to front
// have to move one window distance plus half the difference between the window and the desktop size
data.translate((xTranslate / windowCount + (width - window->geometry().width()) * 0.5f) * timeLine.currentValue());
data.rotation.setAngle(angle - angle * timeLine.currentValue());
data.setRotationAngle(angle - angle * timeLine.currentValue());
}
// right most window does not have to be moved
else if (!left && (i == 0)); // do nothing
@ -877,7 +877,7 @@ void CoverSwitchEffect::paintWindows(const EffectWindowList& windows, bool left,
if ((i == windowCount - 1) && !left) {
// left most window on right side -> move to front
data.translate(- (xTranslate / windowCount + (width - window->geometry().width()) * 0.5f) * timeLine.currentValue());
data.rotation.setAngle(angle - angle * timeLine.currentValue());
data.setRotationAngle(angle - angle * timeLine.currentValue());
}
// left most window does not have to be moved
else if (i == 0 && left); // do nothing
@ -888,8 +888,8 @@ void CoverSwitchEffect::paintWindows(const EffectWindowList& windows, bool left,
}
}
if (!left)
data.rotation.setOrigin(QVector3D(window->geometry().width(), 0.0, 0.0));
data.rotation.setAngle(data.rotation.angle() * rotateFactor);
data.setRotationOrigin(QVector3D(window->geometry().width(), 0.0, 0.0));
data.setRotationAngle(data.rotationAngle() * rotateFactor);
// make window most to edge transparent if animation
if (animation && i == 0 && ((direction == Left && left) || (direction == Right && !left))) {
// only for the first half of the animation

View file

@ -744,9 +744,9 @@ void CubeEffect::paintCube(int mask, QRegion region, ScreenPaintData& data)
painting_desktop = effects->numberOfDesktops();
}
ScreenPaintData newData = data;
newData.rotation.setAxis(Qt::YAxis);
newData.rotation.setAngle(internalCubeAngle * i);
newData.rotation.setOrigin(QVector3D(rect.width() / 2, 0.0, -point));
newData.setRotationAxis(Qt::YAxis);
newData.setRotationAngle(internalCubeAngle * i);
newData.setRotationOrigin(QVector3D(rect.width() / 2, 0.0, -point));
newData.setZTranslation(-zTranslate);
effects->paintScreen(mask, region, newData);
}
@ -1379,9 +1379,9 @@ void CubeEffect::paintWindow(EffectWindow* w, int mask, QRegion region, WindowPa
if (shader) {
data.setXTranslation(-rect.width());
} else {
data.rotation.setAxis(Qt::YAxis);
data.rotation.setOrigin(QVector3D(rect.width() - w->x(), 0.0, 0.0));
data.rotation.setAngle(-360.0f / effects->numberOfDesktops());
data.setRotationAxis(Qt::YAxis);
data.setRotationOrigin(QVector3D(rect.width() - w->x(), 0.0, 0.0));
data.setRotationAngle(-360.0f / effects->numberOfDesktops());
float cubeAngle = (float)((float)(effects->numberOfDesktops() - 2) / (float)effects->numberOfDesktops() * 180.0f);
float point = rect.width() / 2 * tan(cubeAngle * 0.5f * M_PI / 180.0f);
QMatrix4x4 matrix;
@ -1403,9 +1403,9 @@ void CubeEffect::paintWindow(EffectWindow* w, int mask, QRegion region, WindowPa
if (shader) {
data.setXTranslation(rect.width());
} else {
data.rotation.setAxis(Qt::YAxis);
data.rotation.setOrigin(QVector3D(-w->x(), 0.0, 0.0));
data.rotation.setAngle(-360.0f / effects->numberOfDesktops());
data.setRotationAxis(Qt::YAxis);
data.setRotationOrigin(QVector3D(-w->x(), 0.0, 0.0));
data.setRotationAngle(-360.0f / effects->numberOfDesktops());
float cubeAngle = (float)((float)(effects->numberOfDesktops() - 2) / (float)effects->numberOfDesktops() * 180.0f);
float point = rect.width() / 2 * tan(cubeAngle * 0.5f * M_PI / 180.0f);
QMatrix4x4 matrix;

View file

@ -122,8 +122,8 @@ void CubeSlideEffect::paintSlideCube(int mask, QRegion region, ScreenPaintData&
int secondDesktop;
switch(direction) {
case Left:
firstFaceData.rotation.setAxis(Qt::YAxis);
secondFaceData.rotation.setAxis(Qt::YAxis);
firstFaceData.setRotationAxis(Qt::YAxis);
secondFaceData.setRotationAxis(Qt::YAxis);
if (usePagerLayout)
secondDesktop = effects->desktopToLeft(front_desktop, true);
else {
@ -131,12 +131,12 @@ void CubeSlideEffect::paintSlideCube(int mask, QRegion region, ScreenPaintData&
if (secondDesktop == 0)
secondDesktop = effects->numberOfDesktops();
}
firstFaceData.rotation.setAngle(90.0f * timeLine.currentValue());
secondFaceData.rotation.setAngle(-90.0f * (1.0f - timeLine.currentValue()));
firstFaceData.setRotationAngle(90.0f * timeLine.currentValue());
secondFaceData.setRotationAngle(-90.0f * (1.0f - timeLine.currentValue()));
break;
case Right:
firstFaceData.rotation.setAxis(Qt::YAxis);
secondFaceData.rotation.setAxis(Qt::YAxis);
firstFaceData.setRotationAxis(Qt::YAxis);
secondFaceData.setRotationAxis(Qt::YAxis);
if (usePagerLayout)
secondDesktop = effects->desktopToRight(front_desktop, true);
else {
@ -144,23 +144,23 @@ void CubeSlideEffect::paintSlideCube(int mask, QRegion region, ScreenPaintData&
if (secondDesktop > effects->numberOfDesktops())
secondDesktop = 1;
}
firstFaceData.rotation.setAngle(-90.0f * timeLine.currentValue());
secondFaceData.rotation.setAngle(90.0f * (1.0f - timeLine.currentValue()));
firstFaceData.setRotationAngle(-90.0f * timeLine.currentValue());
secondFaceData.setRotationAngle(90.0f * (1.0f - timeLine.currentValue()));
break;
case Upwards:
firstFaceData.rotation.setAxis(Qt::XAxis);
secondFaceData.rotation.setAxis(Qt::XAxis);
firstFaceData.setRotationAxis(Qt::XAxis);
secondFaceData.setRotationAxis(Qt::XAxis);
secondDesktop = effects->desktopAbove(front_desktop, true);
firstFaceData.rotation.setAngle(-90.0f * timeLine.currentValue());
secondFaceData.rotation.setAngle(90.0f * (1.0f - timeLine.currentValue()));
firstFaceData.setRotationAngle(-90.0f * timeLine.currentValue());
secondFaceData.setRotationAngle(90.0f * (1.0f - timeLine.currentValue()));
point = rect.height() / 2 * tan(45.0f * M_PI / 180.0f);
break;
case Downwards:
firstFaceData.rotation.setAxis(Qt::XAxis);
secondFaceData.rotation.setAxis(Qt::XAxis);
firstFaceData.setRotationAxis(Qt::XAxis);
secondFaceData.setRotationAxis(Qt::XAxis);
secondDesktop = effects->desktopBelow(front_desktop, true);
firstFaceData.rotation.setAngle(90.0f * timeLine.currentValue());
secondFaceData.rotation.setAngle(-90.0f * (1.0f - timeLine.currentValue()));
firstFaceData.setRotationAngle(90.0f * timeLine.currentValue());
secondFaceData.setRotationAngle(-90.0f * (1.0f - timeLine.currentValue()));
point = rect.height() / 2 * tan(45.0f * M_PI / 180.0f);
break;
default:
@ -168,7 +168,7 @@ void CubeSlideEffect::paintSlideCube(int mask, QRegion region, ScreenPaintData&
return;
}
// front desktop
firstFaceData.rotation.setOrigin(QVector3D(rect.width() / 2, rect.height() / 2, -point));
firstFaceData.setRotationOrigin(QVector3D(rect.width() / 2, rect.height() / 2, -point));
other_desktop = secondDesktop;
firstDesktop = true;
effects->paintScreen(mask, region, firstFaceData);
@ -176,7 +176,7 @@ void CubeSlideEffect::paintSlideCube(int mask, QRegion region, ScreenPaintData&
other_desktop = painting_desktop;
painting_desktop = secondDesktop;
firstDesktop = false;
secondFaceData.rotation.setOrigin(QVector3D(rect.width() / 2, rect.height() / 2, -point));
secondFaceData.setRotationOrigin(QVector3D(rect.width() / 2, rect.height() / 2, -point));
effects->paintScreen(mask, region, secondFaceData);
cube_painting = false;
painting_desktop = effects->currentDesktop();

View file

@ -294,8 +294,8 @@ void FlipSwitchEffect::paintScreen(int mask, QRegion region, ScreenPaintData& da
EffectWindow* w = m_flipOrderedWindows.last();
if (ItemInfo *info = m_windows.value(w,0)) {
WindowPaintData data(w);
data.rotation.setAxis(Qt::YAxis);
data.rotation.setAngle(m_angle * m_startStopTimeLine.currentValue());
data.setRotationAxis(Qt::YAxis);
data.setRotationAngle(m_angle * m_startStopTimeLine.currentValue());
data.opacity = info->opacity;
data.brightness = info->brightness;
data.saturation = info->saturation;
@ -325,8 +325,8 @@ void FlipSwitchEffect::paintScreen(int mask, QRegion region, ScreenPaintData& da
if (!info)
continue;
WindowPaintData data(w);
data.rotation.setAxis(Qt::YAxis);
data.rotation.setAngle(m_angle * m_startStopTimeLine.currentValue());
data.setRotationAxis(Qt::YAxis);
data.setRotationAngle(m_angle * m_startStopTimeLine.currentValue());
data.opacity = info->opacity;
data.brightness = info->brightness;
data.saturation = info->saturation;

View file

@ -98,8 +98,8 @@ void GlideEffect::paintWindow(EffectWindow* w, int mask, QRegion region, WindowP
InfoHash::const_iterator info = windows.constFind(w);
if (info != windows.constEnd()) {
const double progress = info->timeLine->currentValue();
data.rotation.setAxis(Qt::XAxis);
data.rotation.setAngle(angle * (1 - progress));
data.setRotationAxis(Qt::XAxis);
data.setRotationAngle(angle * (1 - progress));
data.opacity *= progress;
switch(effect) {
default:

View file

@ -90,8 +90,8 @@ void SheetEffect::paintWindow(EffectWindow* w, int mask, QRegion region, WindowP
if (info != windows.constEnd()) {
const double progress = info->timeLine->currentValue();
QGraphicsRotation rot;
data.rotation.setAxis(Qt::XAxis);
data.rotation.setAngle(60.0 * (1.0 - progress));
data.setRotationAxis(Qt::XAxis);
data.setRotationAngle(60.0 * (1.0 - progress));
data *= QVector3D(1.0, progress, progress);
data.translate(0.0, - (w->y() - info->parentY) * (1.0 - progress));
}

View file

@ -462,9 +462,9 @@ void AnimationEffect::paintWindow( EffectWindow* w, int mask, QRegion region, Wi
break;
}
case Rotation: {
data.rotation.setAxis((Qt::Axis)metaData(Axis, anim->meta));
data.setRotationAxis((Qt::Axis)metaData(Axis, anim->meta));
const float prgrs = progress(*anim);
data.rotation.setAngle(anim->from[0] + prgrs*(anim->to[0] - anim->from[0]));
data.setRotationAngle(anim->from[0] + prgrs*(anim->to[0] - anim->from[0]));
const QRect geo = w->rect();
const uint sAnchor = metaData(SourceAnchor, anim->meta),
@ -475,7 +475,7 @@ void AnimationEffect::paintWindow( EffectWindow* w, int mask, QRegion region, Wi
QPointF pt2(xCoord(geo, tAnchor), yCoord(geo, tAnchor));
pt += static_cast<qreal>(prgrs)*(pt2 - pt);
}
data.rotation.setOrigin(QVector3D(pt));
data.setRotationOrigin(QVector3D(pt));
break;
}
case Generic:

View file

@ -60,9 +60,154 @@ void WindowPrePaintData::setTransformed()
mask |= Effect::PAINT_WINDOW_TRANSFORMED;
}
class PaintDataPrivate {
public:
QGraphicsScale scale;
QVector3D translation;
QGraphicsRotation rotation;
};
PaintData::PaintData()
: d(new PaintDataPrivate())
{
}
PaintData::~PaintData()
{
delete d;
}
qreal PaintData::xScale() const
{
return d->scale.xScale();
}
qreal PaintData::yScale() const
{
return d->scale.yScale();
}
qreal PaintData::zScale() const
{
return d->scale.zScale();
}
void PaintData::setScale(const QVector2D &scale)
{
d->scale.setXScale(scale.x());
d->scale.setYScale(scale.y());
}
void PaintData::setScale(const QVector3D &scale)
{
d->scale.setXScale(scale.x());
d->scale.setYScale(scale.y());
d->scale.setZScale(scale.z());
}
void PaintData::setXScale(qreal scale)
{
d->scale.setXScale(scale);
}
void PaintData::setYScale(qreal scale)
{
d->scale.setYScale(scale);
}
void PaintData::setZScale(qreal scale)
{
d->scale.setZScale(scale);
}
const QGraphicsScale &PaintData::scale() const
{
return d->scale;
}
void PaintData::setXTranslation(qreal translate)
{
d->translation.setX(translate);
}
void PaintData::setYTranslation(qreal translate)
{
d->translation.setY(translate);
}
void PaintData::setZTranslation(qreal translate)
{
d->translation.setZ(translate);
}
void PaintData::translate(qreal x, qreal y, qreal z)
{
translate(QVector3D(x, y, z));
}
void PaintData::translate(const QVector3D &t)
{
d->translation += t;
}
qreal PaintData::xTranslation() const
{
return d->translation.x();
}
qreal PaintData::yTranslation() const
{
return d->translation.y();
}
qreal PaintData::zTranslation() const
{
return d->translation.z();
}
const QVector3D &PaintData::translation() const
{
return d->translation;
}
qreal PaintData::rotationAngle() const
{
return d->rotation.angle();
}
QVector3D PaintData::rotationAxis() const
{
return d->rotation.axis();
}
QVector3D PaintData::rotationOrigin() const
{
return d->rotation.origin();
}
void PaintData::setRotationAngle(qreal angle)
{
d->rotation.setAngle(angle);
}
void PaintData::setRotationAxis(Qt::Axis axis)
{
d->rotation.setAxis(axis);
}
void PaintData::setRotationAxis(const QVector3D &axis)
{
d->rotation.setAxis(axis);
}
void PaintData::setRotationOrigin(const QVector3D &origin)
{
d->rotation.setOrigin(origin);
}
WindowPaintData::WindowPaintData(EffectWindow* w)
: opacity(w->opacity())
: PaintData()
, opacity(w->opacity())
, contents_opacity(1.0)
, decoration_opacity(1.0)
, saturation(1)
@ -73,21 +218,22 @@ WindowPaintData::WindowPaintData(EffectWindow* w)
}
WindowPaintData::WindowPaintData(const WindowPaintData &other)
: opacity(other.opacity)
: PaintData()
, opacity(other.opacity)
, contents_opacity(other.contents_opacity)
, decoration_opacity(other.decoration_opacity)
, saturation(other.saturation)
, brightness(other.brightness)
, quads(other.quads)
, shader(other.shader)
, m_translation(other.translation())
{
m_scale.setXScale(other.xScale());
m_scale.setYScale(other.yScale());
m_scale.setZScale(other.zScale());
rotation.setOrigin(other.rotation.origin());
rotation.setAxis(other.rotation.axis());
rotation.setAngle(other.rotation.angle());
setXScale(other.xScale());
setYScale(other.yScale());
setZScale(other.zScale());
translate(other.translation());
setRotationOrigin(other.rotationOrigin());
setRotationAxis(other.rotationAxis());
setRotationAngle(other.rotationAngle());
}
WindowPaintData &WindowPaintData::operator*=(qreal scale)
@ -130,152 +276,61 @@ WindowPaintData &WindowPaintData::operator+=(const QVector2D &translation)
WindowPaintData &WindowPaintData::operator+=(const QVector3D &translation)
{
this->m_translation += translation;
translate(translation);
return *this;
}
qreal WindowPaintData::xScale() const
{
return this->m_scale.xScale();
}
qreal WindowPaintData::yScale() const
{
return this->m_scale.yScale();
}
qreal WindowPaintData::zScale() const
{
return this->m_scale.zScale();
}
void WindowPaintData::setXScale(qreal scale)
{
this->m_scale.setXScale(scale);
}
void WindowPaintData::setYScale(qreal scale)
{
this->m_scale.setYScale(scale);
}
void WindowPaintData::setZScale(qreal scale)
{
this->m_scale.setZScale(scale);
}
void WindowPaintData::setScale(const QVector2D &scale)
{
this->setXScale(scale.x());
this->setYScale(scale.y());
}
void WindowPaintData::setScale(const QVector3D &scale)
{
this->setXScale(scale.x());
this->setYScale(scale.y());
this->setZScale(scale.z());
}
const QGraphicsScale &WindowPaintData::scale() const
{
return m_scale;
}
void WindowPaintData::setXTranslation(qreal translate)
{
this->m_translation.setX(translate);
}
void WindowPaintData::setYTranslation(qreal translate)
{
this->m_translation.setY(translate);
}
void WindowPaintData::setZTranslation(qreal translate)
{
this->m_translation.setZ(translate);
}
void WindowPaintData::translate(qreal x, qreal y, qreal z)
{
this->operator+=(QVector3D(x, y, z));
}
void WindowPaintData::translate(const QVector3D &translate)
{
this->operator+=(translate);
}
qreal WindowPaintData::xTranslation() const
{
return m_translation.x();
}
qreal WindowPaintData::yTranslation() const
{
return m_translation.y();
}
qreal WindowPaintData::zTranslation() const
{
return m_translation.z();
}
const QVector3D &WindowPaintData::translation() const
{
return m_translation;
}
ScreenPaintData::ScreenPaintData()
: PaintData()
{
}
ScreenPaintData::ScreenPaintData(const ScreenPaintData &other)
: m_translation(other.translation())
: PaintData()
{
m_scale.setXScale(other.xScale());
m_scale.setYScale(other.yScale());
m_scale.setZScale(other.zScale());
rotation.setOrigin(other.rotation.origin());
rotation.setAxis(other.rotation.axis());
rotation.setAngle(other.rotation.angle());
translate(other.translation());
setXScale(other.xScale());
setYScale(other.yScale());
setZScale(other.zScale());
setRotationOrigin(other.rotationOrigin());
setRotationAxis(other.rotationAxis());
setRotationAngle(other.rotationAngle());
}
ScreenPaintData &ScreenPaintData::operator=(const ScreenPaintData &rhs)
{
this->m_scale.setXScale(rhs.xScale());
this->m_scale.setYScale(rhs.yScale());
this->m_scale.setZScale(rhs.zScale());
this->m_translation.setX(rhs.xTranslation());
this->m_translation.setY(rhs.yTranslation());
this->m_translation.setZ(rhs.zTranslation());
this->rotation.setOrigin(rhs.rotation.origin());
this->rotation.setAxis(rhs.rotation.axis());
this->rotation.setAngle(rhs.rotation.angle());
setXScale(rhs.xScale());
setYScale(rhs.yScale());
setZScale(rhs.zScale());
setXTranslation(rhs.xTranslation());
setYTranslation(rhs.yTranslation());
setZTranslation(rhs.zTranslation());
setRotationOrigin(rhs.rotationOrigin());
setRotationAxis(rhs.rotationAxis());
setRotationAngle(rhs.rotationAngle());
return *this;
}
ScreenPaintData &ScreenPaintData::operator*=(qreal scale)
{
this->m_scale.setXScale(this->xScale() * scale);
this->m_scale.setYScale(this->yScale() * scale);
this->m_scale.setZScale(this->zScale() * scale);
setXScale(this->xScale() * scale);
setYScale(this->yScale() * scale);
setZScale(this->zScale() * scale);
return *this;
}
ScreenPaintData &ScreenPaintData::operator*=(const QVector2D &scale)
{
this->m_scale.setXScale(this->xScale() * scale.x());
this->m_scale.setYScale(this->yScale() * scale.y());
setXScale(this->xScale() * scale.x());
setYScale(this->yScale() * scale.y());
return *this;
}
ScreenPaintData &ScreenPaintData::operator*=(const QVector3D &scale)
{
this->m_scale.setXScale(this->xScale() * scale.x());
this->m_scale.setYScale(this->yScale() * scale.y());
this->m_scale.setZScale(this->zScale() * scale.z());
setXScale(this->xScale() * scale.x());
setYScale(this->yScale() * scale.y());
setZScale(this->zScale() * scale.z());
return *this;
}
@ -296,98 +351,10 @@ ScreenPaintData &ScreenPaintData::operator+=(const QVector2D &translation)
ScreenPaintData &ScreenPaintData::operator+=(const QVector3D &translation)
{
m_translation += translation;
translate(translation);
return *this;
}
qreal ScreenPaintData::xScale() const
{
return m_scale.xScale();
}
qreal ScreenPaintData::yScale() const
{
return m_scale.yScale();
}
qreal ScreenPaintData::zScale() const
{
return m_scale.zScale();
}
void ScreenPaintData::setScale(const QVector2D &scale)
{
this->m_scale.setXScale(scale.x());
this->m_scale.setYScale(scale.y());
}
void ScreenPaintData::setScale(const QVector3D &scale)
{
this->m_scale.setXScale(scale.x());
this->m_scale.setYScale(scale.y());
this->m_scale.setZScale(scale.z());
}
void ScreenPaintData::setXScale(qreal scale)
{
this->m_scale.setXScale(scale);
}
void ScreenPaintData::setYScale(qreal scale)
{
this->m_scale.setYScale(scale);
}
void ScreenPaintData::setZScale(qreal scale)
{
this->m_scale.setZScale(scale);
}
const QGraphicsScale &ScreenPaintData::scale() const
{
return this->m_scale;
}
void ScreenPaintData::setXTranslation(qreal translate)
{
m_translation.setX(translate);
}
void ScreenPaintData::setYTranslation(qreal translate)
{
m_translation.setY(translate);
}
void ScreenPaintData::setZTranslation(qreal translate)
{
m_translation.setZ(translate);
}
void ScreenPaintData::translate(qreal x, qreal y, qreal z)
{
this->operator+=(QVector3D(x, y, z));
}
qreal ScreenPaintData::xTranslation() const
{
return m_translation.x();
}
qreal ScreenPaintData::yTranslation() const
{
return m_translation.y();
}
qreal ScreenPaintData::zTranslation() const
{
return m_translation.z();
}
const QVector3D &ScreenPaintData::translation() const
{
return m_translation;
}
//****************************************
// Effect
//****************************************

View file

@ -54,6 +54,8 @@ class QVector2D;
namespace KWin
{
class PaintDataPrivate;
class EffectWindow;
class EffectWindowGroup;
class EffectFrame;
@ -1649,7 +1651,168 @@ public:
void setTransformed();
};
class KWIN_EXPORT WindowPaintData
class KWIN_EXPORT PaintData
{
public:
virtual ~PaintData();
/**
* @returns scale factor in X direction.
* @since 4.10
**/
qreal xScale() const;
/**
* @returns scale factor in Y direction.
* @since 4.10
**/
qreal yScale() const;
/**
* @returns scale factor in Z direction.
* @since 4.10
**/
qreal zScale() const;
/**
* Sets the scale factor in X direction to @p scale
* @param scale The scale factor in X direction
* @since 4.10
**/
void setXScale(qreal scale);
/**
* Sets the scale factor in Y direction to @p scale
* @param scale The scale factor in Y direction
* @since 4.10
**/
void setYScale(qreal scale);
/**
* Sets the scale factor in Z direction to @p scale
* @param scale The scale factor in Z direction
* @since 4.10
**/
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
* @param scale The scale factor for X, Y and Z direction
* @since 4.10
**/
void setScale(const QVector3D &scale);
const QGraphicsScale &scale() const;
const QVector3D &translation() const;
/**
* @returns the translation in X direction.
* @since 4.10
**/
qreal xTranslation() const;
/**
* @returns the translation in Y direction.
* @since 4.10
**/
qreal yTranslation() const;
/**
* @returns the translation in Z direction.
* @since 4.10
**/
qreal zTranslation() const;
/**
* Sets the translation in X direction to @p translate.
* @since 4.10
**/
void setXTranslation(qreal translate);
/**
* Sets the translation in Y direction to @p translate.
* @since 4.10
**/
void setYTranslation(qreal translate);
/**
* Sets the translation in Z direction to @p translate.
* @since 4.10
**/
void setZTranslation(qreal translate);
/**
* Performs a translation by adding the values component wise.
* @param x Translation in X direction
* @param y Translation in Y direction
* @param z Translation in Z direction
* @since 4.10
**/
void translate(qreal x, qreal y = 0.0, qreal z = 0.0);
/**
* Performs a translation by adding the values component wise.
* Overloaded method for convenience.
* @param translate The translation
* @since 4.10
**/
void translate(const QVector3D &translate);
/**
* Sets the rotation angle.
* @param angle The new rotation angle.
* @since 4.10
* @see rotationAngle()
**/
void setRotationAngle(qreal angle);
/**
* Returns the rotation angle.
* Initially 0.0.
* @returns The current rotation angle.
* @since 4.10
* @see setRotationAngle
**/
qreal rotationAngle() const;
/**
* Sets the rotation origin.
* @param origin The new rotation origin.
* @since 4.10
* @see rotationOrigin()
**/
void setRotationOrigin(const QVector3D &origin);
/**
* Returns the rotation origin. That is the point in space which is fixed during the rotation.
* Initially this is 0/0/0.
* @returns The rotation's origin
* @since 4.10
* @see setRotationOrigin()
**/
QVector3D rotationOrigin() const;
/**
* Sets the rotation axis.
* Set a component to 1.0 to rotate around this axis and to 0.0 to disable rotation around the
* axis.
* @param axis A vector holding information on which axis to rotate
* @since 4.10
* @see rotationAxis()
**/
void setRotationAxis(const QVector3D &axis);
/**
* Sets the rotation axis.
* Overloaded method for convenience.
* @param axis The axis around which should be rotated.
* @since 4.10
* @see rotationAxis()
**/
void setRotationAxis(Qt::Axis axis);
/**
* The current rotation axis.
* By default the rotation is (0/0/1) which means a rotation around the z axis.
* @returns The current rotation axis.
* @since 4.10
* @see setRotationAxis
**/
QVector3D rotationAxis() const;
protected:
PaintData();
PaintData(const PaintData &other);
private:
PaintDataPrivate * const d;
};
class KWIN_EXPORT WindowPaintData : public PaintData
{
public:
WindowPaintData(EffectWindow* w);
@ -1695,98 +1858,6 @@ public:
* @since 4.10
**/
WindowPaintData& operator+=(const QVector3D &translation);
/**
* @returns scale factor in X direction.
* @since 4.10
**/
qreal xScale() const;
/**
* @returns scale factor in Y direction.
* @since 4.10
**/
qreal yScale() const;
/**
* @returns scale factor in Z direction.
* @since 4.10
**/
qreal zScale() const;
/**
* Sets the scale factor in X direction to @p scale
* @param scale The scale factor in X direction
* @since 4.10
**/
void setXScale(qreal scale);
/**
* Sets the scale factor in Y direction to @p scale
* @param scale The scale factor in Y direction
* @since 4.10
**/
void setYScale(qreal scale);
/**
* Sets the scale factor in Z direction to @p scale
* @param scale The scale factor in Z direction
* @since 4.10
**/
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
* @param scale The scale factor for X, Y and Z direction
* @since 4.10
**/
void setScale(const QVector3D &scale);
const QGraphicsScale &scale() const;
const QVector3D &translation() const;
/**
* @returns the translation in X direction.
* @since 4.10
**/
qreal xTranslation() const;
/**
* @returns the translation in Y direction.
* @since 4.10
**/
qreal yTranslation() const;
/**
* @returns the translation in Z direction.
* @since 4.10
**/
qreal zTranslation() const;
/**
* Sets the translation in X direction to @p translate.
* @since 4.10
**/
void setXTranslation(qreal translate);
/**
* Sets the translation in Y direction to @p translate.
* @since 4.10
**/
void setYTranslation(qreal translate);
/**
* Sets the translation in Z direction to @p translate.
* @since 4.10
**/
void setZTranslation(qreal translate);
/**
* Translates the window.
* @param x Translation in X direction
* @param y Translation in Y direction
* @param z Translation in Z direction
* @since 4.10
**/
void translate(qreal x, qreal y = 0.0, qreal z = 0.0);
/**
* Translates the window.
* Overloaded method for convenience.
* @param translate The translation
* @since 4.10
**/
void translate(const QVector3D &translate);
/**
* Window opacity, in range 0 = transparent to 1 = fully opaque
* Opacity for contents is opacity*contents_opacity, the same
@ -1815,13 +1886,9 @@ public:
* Shader to be used for rendering, if any.
*/
GLShader* shader;
QGraphicsRotation rotation;
private:
QGraphicsScale m_scale;
QVector3D m_translation;
};
class KWIN_EXPORT ScreenPaintData
class KWIN_EXPORT ScreenPaintData : public PaintData
{
public:
ScreenPaintData();
@ -1867,96 +1934,7 @@ public:
* @since 4.10
**/
ScreenPaintData& operator+=(const QVector3D &translation);
/**
* @returns scale factor in X direction.
* @since 4.10
**/
qreal xScale() const;
/**
* @returns scale factor in Y direction.
* @since 4.10
**/
qreal yScale() const;
/**
* @returns scale factor in Z direction.
* @since 4.10
**/
qreal zScale() const;
/**
* Sets the scale factor in X direction to @p scale
* @param scale The scale factor in X direction
* @since 4.10
**/
void setXScale(qreal scale);
/**
* Sets the scale factor in Y direction to @p scale
* @param scale The scale factor in Y direction
* @since 4.10
**/
void setYScale(qreal scale);
/**
* Sets the scale factor in Z direction to @p scale
* @param scale The scale factor in Z direction
* @since 4.10
**/
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
* @param scale The scale factor for X, Y and Z direction
* @since 4.10
**/
void setScale(const QVector3D &scale);
const QGraphicsScale &scale() const;
const QVector3D &translation() const;
/**
* @returns the translation in X direction.
* @since 4.10
**/
qreal xTranslation() const;
/**
* @returns the translation in Y direction.
* @since 4.10
**/
qreal yTranslation() const;
/**
* @returns the translation in Z direction.
* @since 4.10
**/
qreal zTranslation() const;
/**
* Sets the translation in X direction to @p translate.
* @since 4.10
**/
void setXTranslation(qreal translate);
/**
* Sets the translation in Y direction to @p translate.
* @since 4.10
**/
void setYTranslation(qreal translate);
/**
* Sets the translation in Z direction to @p translate.
* @since 4.10
**/
void setZTranslation(qreal translate);
/**
* Translates the screen.
* @param x Translation in X direction
* @param y Translation in Y direction
* @param z Translation in Z direction
* @since 4.10
**/
void translate(qreal x, qreal y = 0.0, qreal z = 0.0);
QGraphicsRotation rotation;
ScreenPaintData& operator=(const ScreenPaintData &rhs);
private:
QGraphicsScale m_scale;
QVector3D m_translation;
};
class KWIN_EXPORT ScreenPrePaintData

View file

@ -136,15 +136,15 @@ QMatrix4x4 SceneOpenGL::transformation(int mask, const ScreenPaintData &data) co
matrix.translate(data.translation());
data.scale().applyTo(&matrix);
if (data.rotation.angle() == 0.0)
if (data.rotationAngle() == 0.0)
return matrix;
// Apply the rotation
// cannot use data.rotation->applyTo(&matrix) as QGraphicsRotation uses projectedRotate to map back to 2D
matrix.translate(data.rotation.origin());
const QVector3D axis = data.rotation.axis();
matrix.rotate(data.rotation.angle(), axis.x(), axis.y(), axis.z());
matrix.translate(-data.rotation.origin());
matrix.translate(data.rotationOrigin());
const QVector3D axis = data.rotationAxis();
matrix.rotate(data.rotationAngle(), axis.x(), axis.y(), axis.z());
matrix.translate(-data.rotationOrigin());
return matrix;
}
@ -419,15 +419,15 @@ QMatrix4x4 SceneOpenGL::Window::transformation(int mask, const WindowPaintData &
matrix.translate(data.translation());
data.scale().applyTo(&matrix);
if (data.rotation.angle() == 0.0)
if (data.rotationAngle() == 0.0)
return matrix;
// Apply the rotation
// cannot use data.rotation.applyTo(&matrix) as QGraphicsRotation uses projectedRotate to map back to 2D
matrix.translate(data.rotation.origin());
const QVector3D axis = data.rotation.axis();
matrix.rotate(data.rotation.angle(), axis.x(), axis.y(), axis.z());
matrix.translate(-data.rotation.origin());
matrix.translate(data.rotationOrigin());
const QVector3D axis = data.rotationAxis();
matrix.rotate(data.rotationAngle(), axis.x(), axis.y(), axis.z());
matrix.translate(-data.rotationOrigin());
return matrix;
}