Replace translation by QVector3D in Screen/Window PaintData

This commit is contained in:
Martin Gräßlin 2012-05-28 14:45:46 +02:00
parent 0eff12eb92
commit a2b0d42916
26 changed files with 387 additions and 154 deletions

View file

@ -365,7 +365,7 @@ bool BlurEffect::shouldBlur(const EffectWindow *w, int mask, const WindowPaintDa
return false; return false;
bool scaled = !qFuzzyCompare(data.xScale(), 1.0) && !qFuzzyCompare(data.yScale(), 1.0); bool scaled = !qFuzzyCompare(data.xScale(), 1.0) && !qFuzzyCompare(data.yScale(), 1.0);
bool translated = data.xTranslate || data.yTranslate; bool translated = data.xTranslation() || data.yTranslation();
if (scaled || ((translated || (mask & PAINT_WINDOW_TRANSFORMED)) && !w->data(WindowForceBlurRole).toBool())) if (scaled || ((translated || (mask & PAINT_WINDOW_TRANSFORMED)) && !w->data(WindowForceBlurRole).toBool()))
return false; return false;
@ -385,10 +385,10 @@ void BlurEffect::drawWindow(EffectWindow *w, int mask, QRegion region, WindowPai
if (shouldBlur(w, mask, data)) { if (shouldBlur(w, mask, data)) {
QRegion shape = region & blurRegion(w).translated(w->pos()) & screen; QRegion shape = region & blurRegion(w).translated(w->pos()) & screen;
const bool translated = data.xTranslate || data.yTranslate; const bool translated = data.xTranslation() || data.yTranslation();
// let's do the evil parts - someone wants to blur behind a transformed window // let's do the evil parts - someone wants to blur behind a transformed window
if (translated) { if (translated) {
shape = shape.translated(data.xTranslate, data.yTranslate); shape = shape.translated(data.xTranslation(), data.yTranslation());
shape = shape & region; shape = shape & region;
} }

View file

@ -850,8 +850,8 @@ void BoxSwitchEffect::paintDesktopThumbnail(int iDesktop)
int x = r.x() + (r.width() - width) / 2; int x = r.x() + (r.width() - width) / 2;
int y = r.y() + (r.height() - height) / 2; int y = r.y() + (r.height() - height) / 2;
region = QRect(x, y, width, height); region = QRect(x, y, width, height);
data.xTranslate = x; data.setXTranslation(x);
data.yTranslate = y; data.setYTranslation(y);
effects->paintScreen(PAINT_SCREEN_TRANSFORMED | PAINT_SCREEN_BACKGROUND_FIRST, effects->paintScreen(PAINT_SCREEN_TRANSFORMED | PAINT_SCREEN_BACKGROUND_FIRST,
region, data); region, data);

View file

@ -671,34 +671,35 @@ void CoverSwitchEffect::slotTabBoxUpdated()
void CoverSwitchEffect::paintWindowCover(EffectWindow* w, bool reflectedWindow, WindowPaintData& data) void CoverSwitchEffect::paintWindowCover(EffectWindow* w, bool reflectedWindow, WindowPaintData& data)
{ {
QRect windowRect = w->geometry(); QRect windowRect = w->geometry();
data.yTranslate = area.height() - windowRect.y() - windowRect.height(); data.setYTranslation(area.height() - windowRect.y() - windowRect.height());
data.zTranslate = -zPosition; data.setZTranslation(-zPosition);
if (start) { if (start) {
if (w->isMinimized()) { if (w->isMinimized()) {
data.opacity *= timeLine.currentValue(); data.opacity *= timeLine.currentValue();
} else { } else {
data.xTranslate *= timeLine.currentValue(); const QVector3D translation = data.translation() * timeLine.currentValue();
data.yTranslate *= timeLine.currentValue(); data.setXTranslation(translation.x());
data.setYTranslation(translation.y());
data.setZTranslation(translation.z());
if (effects->numScreens() > 1) { if (effects->numScreens() > 1) {
QRect clientRect = effects->clientArea(FullScreenArea, w->screen(), effects->currentDesktop()); QRect clientRect = effects->clientArea(FullScreenArea, w->screen(), effects->currentDesktop());
QRect fullRect = effects->clientArea(FullArea, activeScreen, effects->currentDesktop()); QRect fullRect = effects->clientArea(FullArea, activeScreen, effects->currentDesktop());
if (w->screen() == activeScreen) { if (w->screen() == activeScreen) {
if (clientRect.width() != fullRect.width() && clientRect.x() != fullRect.x()) { if (clientRect.width() != fullRect.width() && clientRect.x() != fullRect.x()) {
data.xTranslate -= clientRect.x() * (1.0f - timeLine.currentValue()); data.translate(- clientRect.x() * (1.0f - timeLine.currentValue()));
} }
if (clientRect.height() != fullRect.height() && clientRect.y() != fullRect.y()) { if (clientRect.height() != fullRect.height() && clientRect.y() != fullRect.y()) {
data.yTranslate -= clientRect.y() * (1.0f - timeLine.currentValue()); data.translate(0.0, - clientRect.y() * (1.0f - timeLine.currentValue()));
} }
} else { } else {
if (clientRect.width() != fullRect.width() && clientRect.x() < area.x()) { if (clientRect.width() != fullRect.width() && clientRect.x() < area.x()) {
data.xTranslate -= clientRect.width() * (1.0f - timeLine.currentValue()); data.translate(- clientRect.width() * (1.0f - timeLine.currentValue()));
} }
if (clientRect.height() != fullRect.height() && clientRect.y() < area.y()) { if (clientRect.height() != fullRect.height() && clientRect.y() < area.y()) {
data.yTranslate -= clientRect.height() * (1.0f - timeLine.currentValue()); data.translate(0.0, - clientRect.height() * (1.0f - timeLine.currentValue()));
} }
} }
} }
data.zTranslate *= timeLine.currentValue();
data.rotation.setAngle(data.rotation.angle() * timeLine.currentValue()); data.rotation.setAngle(data.rotation.angle() * timeLine.currentValue());
} }
} }
@ -706,29 +707,30 @@ void CoverSwitchEffect::paintWindowCover(EffectWindow* w, bool reflectedWindow,
if (w->isMinimized() && w != effects->activeWindow()) { if (w->isMinimized() && w != effects->activeWindow()) {
data.opacity *= (1.0 - timeLine.currentValue()); data.opacity *= (1.0 - timeLine.currentValue());
} else { } else {
data.xTranslate *= (1.0 - timeLine.currentValue()); const QVector3D translation = data.translation() * (1.0 - timeLine.currentValue());
data.yTranslate *= (1.0 - timeLine.currentValue()); data.setXTranslation(translation.x());
data.setYTranslation(translation.y());
data.setZTranslation(translation.z());
if (effects->numScreens() > 1) { if (effects->numScreens() > 1) {
QRect clientRect = effects->clientArea(FullScreenArea, w->screen(), effects->currentDesktop()); QRect clientRect = effects->clientArea(FullScreenArea, w->screen(), effects->currentDesktop());
QRect rect = effects->clientArea(FullScreenArea, activeScreen, effects->currentDesktop()); QRect rect = effects->clientArea(FullScreenArea, activeScreen, effects->currentDesktop());
QRect fullRect = effects->clientArea(FullArea, activeScreen, effects->currentDesktop()); QRect fullRect = effects->clientArea(FullArea, activeScreen, effects->currentDesktop());
if (w->screen() == activeScreen) { if (w->screen() == activeScreen) {
if (clientRect.width() != fullRect.width() && clientRect.x() != fullRect.x()) { if (clientRect.width() != fullRect.width() && clientRect.x() != fullRect.x()) {
data.xTranslate -= clientRect.x() * timeLine.currentValue(); data.translate(- clientRect.x() * timeLine.currentValue());
} }
if (clientRect.height() != fullRect.height() && clientRect.y() != fullRect.y()) { if (clientRect.height() != fullRect.height() && clientRect.y() != fullRect.y()) {
data.yTranslate -= clientRect.y() * timeLine.currentValue(); data.translate(0.0, - clientRect.y() * timeLine.currentValue());
} }
} else { } else {
if (clientRect.width() != fullRect.width() && clientRect.x() < rect.x()) { if (clientRect.width() != fullRect.width() && clientRect.x() < rect.x()) {
data.xTranslate -= clientRect.width() * timeLine.currentValue(); data.translate(- clientRect.width() * timeLine.currentValue());
} }
if (clientRect.height() != fullRect.height() && clientRect.y() < area.y()) { if (clientRect.height() != fullRect.height() && clientRect.y() < area.y()) {
data.yTranslate -= clientRect.height() * timeLine.currentValue(); data.translate(0.0, - clientRect.height() * timeLine.currentValue());
} }
} }
} }
data.zTranslate *= (1.0 - timeLine.currentValue());
data.rotation.setAngle(data.rotation.angle() * (1.0 - timeLine.currentValue())); data.rotation.setAngle(data.rotation.angle() * (1.0 - timeLine.currentValue()));
} }
} }
@ -740,7 +742,7 @@ void CoverSwitchEffect::paintWindowCover(EffectWindow* w, bool reflectedWindow,
QMatrix4x4 reflectionMatrix; QMatrix4x4 reflectionMatrix;
reflectionMatrix.scale(1.0, -1.0, 1.0); reflectionMatrix.scale(1.0, -1.0, 1.0);
shader->setUniform("screenTransformation", origMatrix * reflectionMatrix); shader->setUniform("screenTransformation", origMatrix * reflectionMatrix);
data.yTranslate = - area.height() - windowRect.y() - windowRect.height(); data.setYTranslation(- area.height() - windowRect.y() - windowRect.height());
if (start) { if (start) {
data.opacity *= timeLine.currentValue(); data.opacity *= timeLine.currentValue();
} else if (stop) { } else if (stop) {
@ -755,7 +757,7 @@ void CoverSwitchEffect::paintWindowCover(EffectWindow* w, bool reflectedWindow,
#ifndef KWIN_HAVE_OPENGLES #ifndef KWIN_HAVE_OPENGLES
glPushMatrix(); glPushMatrix();
glScalef(1.0, -1.0, 1.0); glScalef(1.0, -1.0, 1.0);
data.yTranslate = - area.height() - windowRect.y() - windowRect.height(); data.setYTranslation(- area.height() - windowRect.y() - windowRect.height());
effects->paintWindow(w, effects->paintWindow(w,
PAINT_WINDOW_TRANSFORMED, PAINT_WINDOW_TRANSFORMED,
infiniteRegion(), data); infiniteRegion(), data);
@ -775,7 +777,7 @@ void CoverSwitchEffect::paintFrontWindow(EffectWindow* frontWindow, int width, i
return; return;
bool specialHandlingForward = false; bool specialHandlingForward = false;
WindowPaintData data(frontWindow); WindowPaintData data(frontWindow);
data.xTranslate = area.width() * 0.5 - frontWindow->geometry().x() - frontWindow->geometry().width() * 0.5; data.setXTranslation(area.width() * 0.5 - frontWindow->geometry().x() - frontWindow->geometry().width() * 0.5);
if (leftWindows == 0) { if (leftWindows == 0) {
leftWindows = 1; leftWindows = 1;
if (!start && !stop) if (!start && !stop)
@ -790,7 +792,7 @@ void CoverSwitchEffect::paintFrontWindow(EffectWindow* frontWindow, int width, i
// move to right // move to right
distance = -frontWindow->geometry().width() * 0.5f + area.width() * 0.5f + distance = -frontWindow->geometry().width() * 0.5f + area.width() * 0.5f +
(((float)displayWidth() * 0.5 * scaleFactor) - (float)area.width() * 0.5f) / rightWindows; (((float)displayWidth() * 0.5 * scaleFactor) - (float)area.width() * 0.5f) / rightWindows;
data.xTranslate += distance * timeLine.currentValue(); data.translate(distance * timeLine.currentValue());
data.rotation.setAxis(Qt::YAxis); data.rotation.setAxis(Qt::YAxis);
data.rotation.setAngle(-angle * timeLine.currentValue()); data.rotation.setAngle(-angle * timeLine.currentValue());
data.rotation.setOrigin(QVector3D(frontWindow->geometry().width(), 0.0, 0.0)); data.rotation.setOrigin(QVector3D(frontWindow->geometry().width(), 0.0, 0.0));
@ -801,7 +803,7 @@ void CoverSwitchEffect::paintFrontWindow(EffectWindow* frontWindow, int width, i
float factor = 1.0; float factor = 1.0;
if (specialHandlingForward) if (specialHandlingForward)
factor = 2.0; factor = 2.0;
data.xTranslate += distance * timeLine.currentValue() * factor; data.translate(distance * timeLine.currentValue() * factor);
data.rotation.setAxis(Qt::YAxis); data.rotation.setAxis(Qt::YAxis);
data.rotation.setAngle(angle * timeLine.currentValue()); data.rotation.setAngle(angle * timeLine.currentValue());
} }
@ -834,11 +836,11 @@ void CoverSwitchEffect::paintWindows(const EffectWindowList& windows, bool left,
data.rotation.setAxis(Qt::YAxis); data.rotation.setAxis(Qt::YAxis);
data.rotation.setAngle(angle * rotateFactor); data.rotation.setAngle(angle * rotateFactor);
if (left) { if (left) {
data.xTranslate += -xTranslate - additionalWindow->geometry().x(); data.translate(-xTranslate - additionalWindow->geometry().x());
} }
else { else {
data.xTranslate += xTranslate + area.width() - data.translate(xTranslate + area.width() -
additionalWindow->geometry().x() - additionalWindow->geometry().width(); additionalWindow->geometry().x() - additionalWindow->geometry().width());
data.rotation.setOrigin(QVector3D(additionalWindow->geometry().width(), 0.0, 0.0)); data.rotation.setOrigin(QVector3D(additionalWindow->geometry().width(), 0.0, 0.0));
} }
data.opacity *= (timeLine.currentValue() - 0.5) * 2.0; data.opacity *= (timeLine.currentValue() - 0.5) * 2.0;
@ -854,34 +856,34 @@ void CoverSwitchEffect::paintWindows(const EffectWindowList& windows, bool left,
data.rotation.setAxis(Qt::YAxis); data.rotation.setAxis(Qt::YAxis);
data.rotation.setAngle(angle); data.rotation.setAngle(angle);
if (left) if (left)
data.xTranslate += -xTranslate + xTranslate * i / windowCount - window->geometry().x(); data.translate(-xTranslate + xTranslate * i / windowCount - window->geometry().x());
else else
data.xTranslate += xTranslate + width - xTranslate * i / windowCount - window->geometry().x() - window->geometry().width(); data.translate(xTranslate + width - xTranslate * i / windowCount - window->geometry().x() - window->geometry().width());
if (animation) { if (animation) {
if (direction == Right) { if (direction == Right) {
if ((i == windowCount - 1) && left) { if ((i == windowCount - 1) && left) {
// right most window on left side -> move to front // 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 // have to move one window distance plus half the difference between the window and the desktop size
data.xTranslate += (xTranslate / windowCount + (width - window->geometry().width()) * 0.5f) * timeLine.currentValue(); data.translate((xTranslate / windowCount + (width - window->geometry().width()) * 0.5f) * timeLine.currentValue());
data.rotation.setAngle(angle - angle * timeLine.currentValue()); data.rotation.setAngle(angle - angle * timeLine.currentValue());
} }
// right most window does not have to be moved // right most window does not have to be moved
else if (!left && (i == 0)); // do nothing else if (!left && (i == 0)); // do nothing
else { else {
// all other windows - move to next position // all other windows - move to next position
data.xTranslate += xTranslate / windowCount * timeLine.currentValue(); data.translate(xTranslate / windowCount * timeLine.currentValue());
} }
} else { } else {
if ((i == windowCount - 1) && !left) { if ((i == windowCount - 1) && !left) {
// left most window on right side -> move to front // left most window on right side -> move to front
data.xTranslate -= (xTranslate / windowCount + (width - window->geometry().width()) * 0.5f) * timeLine.currentValue(); data.translate(- (xTranslate / windowCount + (width - window->geometry().width()) * 0.5f) * timeLine.currentValue());
data.rotation.setAngle(angle - angle * timeLine.currentValue()); data.rotation.setAngle(angle - angle * timeLine.currentValue());
} }
// left most window does not have to be moved // left most window does not have to be moved
else if (i == 0 && left); // do nothing else if (i == 0 && left); // do nothing
else { else {
// all other windows - move to next position // all other windows - move to next position
data.xTranslate -= xTranslate / windowCount * timeLine.currentValue(); data.translate(- xTranslate / windowCount * timeLine.currentValue());
} }
} }
} }

View file

@ -747,7 +747,7 @@ void CubeEffect::paintCube(int mask, QRegion region, ScreenPaintData& data)
newData.rotation.setAxis(Qt::YAxis); newData.rotation.setAxis(Qt::YAxis);
newData.rotation.setAngle(internalCubeAngle * i); newData.rotation.setAngle(internalCubeAngle * i);
newData.rotation.setOrigin(QVector3D(rect.width() / 2, 0.0, -point)); newData.rotation.setOrigin(QVector3D(rect.width() / 2, 0.0, -point));
newData.zTranslate = -zTranslate; newData.setZTranslation(-zTranslate);
effects->paintScreen(mask, region, newData); effects->paintScreen(mask, region, newData);
} }
cube_painting = false; cube_painting = false;
@ -1355,7 +1355,7 @@ void CubeEffect::paintWindow(EffectWindow* w, int mask, QRegion region, WindowPa
zOrdering *= timeLine.currentValue(); zOrdering *= timeLine.currentValue();
if (stop) if (stop)
zOrdering *= (1.0 - timeLine.currentValue()); zOrdering *= (1.0 - timeLine.currentValue());
data.zTranslate += zOrdering; data.translate(0.0, 0.0, zOrdering);
} }
// check for windows belonging to the previous desktop // check for windows belonging to the previous desktop
int prev_desktop = painting_desktop - 1; int prev_desktop = painting_desktop - 1;
@ -1377,7 +1377,7 @@ void CubeEffect::paintWindow(EffectWindow* w, int mask, QRegion region, WindowPa
} }
data.quads = new_quads; data.quads = new_quads;
if (shader) { if (shader) {
data.xTranslate = -rect.width(); data.setXTranslation(-rect.width());
} else { } else {
data.rotation.setAxis(Qt::YAxis); data.rotation.setAxis(Qt::YAxis);
data.rotation.setOrigin(QVector3D(rect.width() - w->x(), 0.0, 0.0)); data.rotation.setOrigin(QVector3D(rect.width() - w->x(), 0.0, 0.0));
@ -1401,7 +1401,7 @@ void CubeEffect::paintWindow(EffectWindow* w, int mask, QRegion region, WindowPa
} }
data.quads = new_quads; data.quads = new_quads;
if (shader) { if (shader) {
data.xTranslate = rect.width(); data.setXTranslation(rect.width());
} else { } else {
data.rotation.setAxis(Qt::YAxis); data.rotation.setAxis(Qt::YAxis);
data.rotation.setOrigin(QVector3D(-w->x(), 0.0, 0.0)); data.rotation.setOrigin(QVector3D(-w->x(), 0.0, 0.0));

View file

@ -301,7 +301,7 @@ void CubeSlideEffect::paintWindow(EffectWindow* w, int mask, QRegion region, Win
if (w->x() < rect.x() && if (w->x() < rect.x() &&
(direction == Left || direction == Right)) { (direction == Left || direction == Right)) {
WindowQuadList new_quads; WindowQuadList new_quads;
data.xTranslate = rect.width(); data.setXTranslation(rect.width());
foreach (const WindowQuad & quad, data.quads) { foreach (const WindowQuad & quad, data.quads) {
if (quad.right() <= -w->x()) { if (quad.right() <= -w->x()) {
new_quads.append(quad); new_quads.append(quad);
@ -312,7 +312,7 @@ void CubeSlideEffect::paintWindow(EffectWindow* w, int mask, QRegion region, Win
if (w->x() + w->width() > rect.x() + rect.width() && if (w->x() + w->width() > rect.x() + rect.width() &&
(direction == Left || direction == Right)) { (direction == Left || direction == Right)) {
WindowQuadList new_quads; WindowQuadList new_quads;
data.xTranslate = -rect.width(); data.setXTranslation(-rect.width());
foreach (const WindowQuad & quad, data.quads) { foreach (const WindowQuad & quad, data.quads) {
if (quad.right() > rect.width() - w->x()) { if (quad.right() > rect.width() - w->x()) {
new_quads.append(quad); new_quads.append(quad);
@ -323,7 +323,7 @@ void CubeSlideEffect::paintWindow(EffectWindow* w, int mask, QRegion region, Win
if (w->y() < rect.y() && if (w->y() < rect.y() &&
(direction == Upwards || direction == Downwards)) { (direction == Upwards || direction == Downwards)) {
WindowQuadList new_quads; WindowQuadList new_quads;
data.yTranslate = rect.height(); data.setYTranslation(rect.height());
foreach (const WindowQuad & quad, data.quads) { foreach (const WindowQuad & quad, data.quads) {
if (quad.bottom() <= -w->y()) { if (quad.bottom() <= -w->y()) {
new_quads.append(quad); new_quads.append(quad);
@ -334,7 +334,7 @@ void CubeSlideEffect::paintWindow(EffectWindow* w, int mask, QRegion region, Win
if (w->y() + w->height() > rect.y() + rect.height() && if (w->y() + w->height() > rect.y() + rect.height() &&
(direction == Upwards || direction == Downwards)) { (direction == Upwards || direction == Downwards)) {
WindowQuadList new_quads; WindowQuadList new_quads;
data.yTranslate = -rect.height(); data.setYTranslation(-rect.height());
foreach (const WindowQuad & quad, data.quads) { foreach (const WindowQuad & quad, data.quads) {
if (quad.bottom() > rect.height() - w->y()) { if (quad.bottom() > rect.height() - w->y()) {
new_quads.append(quad); new_quads.append(quad);

View file

@ -192,8 +192,7 @@ void DesktopGridEffect::paintScreen(int mask, QRegion region, ScreenPaintData& d
QRect geo = m_windowMoveGeometry.translated(diff); QRect geo = m_windowMoveGeometry.translated(diff);
WindowPaintData d(windowMove); WindowPaintData d(windowMove);
d *= QVector2D((qreal)geo.width() / (qreal)windowMove->width(), (qreal)geo.height() / (qreal)windowMove->height()); d *= QVector2D((qreal)geo.width() / (qreal)windowMove->width(), (qreal)geo.height() / (qreal)windowMove->height());
d.xTranslate += qRound(geo.left() - windowMove->x()); d += QPoint(qRound(geo.left() - windowMove->x()), qRound(geo.top() - windowMove->y()));
d.yTranslate += qRound(geo.top() - windowMove->y());
effects->drawWindow(windowMove, PAINT_WINDOW_TRANSFORMED | PAINT_WINDOW_LANCZOS, infiniteRegion(), d); effects->drawWindow(windowMove, PAINT_WINDOW_TRANSFORMED | PAINT_WINDOW_LANCZOS, infiniteRegion(), d);
} }
@ -335,8 +334,7 @@ void DesktopGridEffect::paintWindow(EffectWindow* w, int mask, QRegion region, W
double progress = timeline.currentValue(); double progress = timeline.currentValue();
d.setXScale(interpolate(1, xScale * scale[screen] * (float)transformedGeo.width() / (float)w->geometry().width(), progress)); d.setXScale(interpolate(1, xScale * scale[screen] * (float)transformedGeo.width() / (float)w->geometry().width(), progress));
d.setYScale(interpolate(1, yScale * scale[screen] * (float)transformedGeo.height() / (float)w->geometry().height(), progress)); d.setYScale(interpolate(1, yScale * scale[screen] * (float)transformedGeo.height() / (float)w->geometry().height(), progress));
d.xTranslate += qRound(newPos.x() - w->x()); d += QPoint(qRound(newPos.x() - w->x()), qRound(newPos.y() - w->y()));
d.yTranslate += qRound(newPos.y() - w->y());
if (isUsingPresentWindows() && (w->isDock() || w->isSkipSwitcher())) { if (isUsingPresentWindows() && (w->isDock() || w->isSkipSwitcher())) {
// fade out panels if present windows is used // fade out panels if present windows is used

View file

@ -146,8 +146,7 @@ void ExplosionEffect::paintWindow(EffectWindow* w, int mask, QRegion region, Win
double scale = 1 + maxscaleadd * mWindows[w]; double scale = 1 + maxscaleadd * mWindows[w];
data.setXScale(scale); data.setXScale(scale);
data.setYScale(scale); data.setYScale(scale);
data.xTranslate += int(w->width() / 2 * (1 - scale)); data.translate(int(w->width() / 2 * (1 - scale)), int(w->height() / 2 * (1 - scale)));
data.yTranslate += int(w->height() / 2 * (1 - scale));
data.opacity *= 0.99; // Force blending data.opacity *= 0.99; // Force blending
ShaderManager *manager = ShaderManager::instance(); ShaderManager *manager = ShaderManager::instance();
GLShader *shader = manager->pushShader(ShaderManager::GenericShader); GLShader *shader = manager->pushShader(ShaderManager::GenericShader);

View file

@ -301,13 +301,13 @@ void FlipSwitchEffect::paintScreen(int mask, QRegion region, ScreenPaintData& da
data.saturation = info->saturation; data.saturation = info->saturation;
int distance = tempList.count() - 1; int distance = tempList.count() - 1;
float zDistance = 500.0f; float zDistance = 500.0f;
data.xTranslate -= (w->x() - m_screenArea.x() + data.xTranslate) * m_startStopTimeLine.currentValue(); data.translate(- (w->x() - m_screenArea.x() + data.xTranslation()) * m_startStopTimeLine.currentValue());
data.xTranslate += m_screenArea.width() * m_xPosition * m_startStopTimeLine.currentValue();
data.yTranslate += (m_screenArea.y() + m_screenArea.height() * m_yPosition - (w->y() + w->height() + data.yTranslate)) * m_startStopTimeLine.currentValue();
data.xTranslate -= (m_screenArea.width() * 0.25f) * distance * m_startStopTimeLine.currentValue(); data.translate(m_screenArea.width() * m_xPosition * m_startStopTimeLine.currentValue(),
data.yTranslate -= (m_screenArea.height() * 0.10f) * distance * m_startStopTimeLine.currentValue(); (m_screenArea.y() + m_screenArea.height() * m_yPosition - (w->y() + w->height() + data.yTranslation())) * m_startStopTimeLine.currentValue());
data.zTranslate -= (zDistance * distance) * m_startStopTimeLine.currentValue(); data.translate(- (m_screenArea.width() * 0.25f) * distance * m_startStopTimeLine.currentValue(),
- (m_screenArea.height() * 0.10f) * distance * m_startStopTimeLine.currentValue(),
- (zDistance * distance) * m_startStopTimeLine.currentValue());
if (m_scheduledDirections.head() == DirectionForward) if (m_scheduledDirections.head() == DirectionForward)
data.opacity *= 0.8 * m_timeLine.currentValue(); data.opacity *= 0.8 * m_timeLine.currentValue();
else else
@ -353,24 +353,24 @@ void FlipSwitchEffect::paintScreen(int mask, QRegion region, ScreenPaintData& da
} }
} }
float zDistance = 500.0f; float zDistance = 500.0f;
data.xTranslate -= (w->x() - m_screenArea.x() + data.xTranslate) * m_startStopTimeLine.currentValue(); data.translate(- (w->x() - m_screenArea.x() + data.xTranslation()) * m_startStopTimeLine.currentValue());
data.xTranslate += m_screenArea.width() * m_xPosition * m_startStopTimeLine.currentValue(); data.translate(m_screenArea.width() * m_xPosition * m_startStopTimeLine.currentValue(),
data.yTranslate += (m_screenArea.y() + m_screenArea.height() * m_yPosition - (w->y() + w->height() + data.yTranslate)) * m_startStopTimeLine.currentValue(); (m_screenArea.y() + m_screenArea.height() * m_yPosition - (w->y() + w->height() + data.yTranslation())) * m_startStopTimeLine.currentValue());
data.xTranslate -= (m_screenArea.width() * 0.25f) * distance * m_startStopTimeLine.currentValue(); data.translate(-(m_screenArea.width() * 0.25f) * distance * m_startStopTimeLine.currentValue(),
data.yTranslate -= (m_screenArea.height() * 0.10f) * distance * m_startStopTimeLine.currentValue(); -(m_screenArea.height() * 0.10f) * distance * m_startStopTimeLine.currentValue(),
data.zTranslate -= (zDistance * distance) * m_startStopTimeLine.currentValue(); -(zDistance * distance) * m_startStopTimeLine.currentValue());
if (m_animation && !m_scheduledDirections.isEmpty()) { if (m_animation && !m_scheduledDirections.isEmpty()) {
if (m_scheduledDirections.head() == DirectionForward) { if (m_scheduledDirections.head() == DirectionForward) {
data.xTranslate += (m_screenArea.width() * 0.25f) * m_timeLine.currentValue(); data.translate((m_screenArea.width() * 0.25f) * m_timeLine.currentValue(),
data.yTranslate += (m_screenArea.height() * 0.10f) * m_timeLine.currentValue(); (m_screenArea.height() * 0.10f) * m_timeLine.currentValue(),
data.zTranslate += zDistance * m_timeLine.currentValue(); zDistance * m_timeLine.currentValue());
if (distance == 0) if (distance == 0)
data.opacity *= (1.0 - m_timeLine.currentValue()); data.opacity *= (1.0 - m_timeLine.currentValue());
} else { } else {
data.xTranslate -= (m_screenArea.width() * 0.25f) * m_timeLine.currentValue(); data.translate(- (m_screenArea.width() * 0.25f) * m_timeLine.currentValue(),
data.yTranslate -= (m_screenArea.height() * 0.10f) * m_timeLine.currentValue(); - (m_screenArea.height() * 0.10f) * m_timeLine.currentValue(),
data.zTranslate -= zDistance * m_timeLine.currentValue(); - zDistance * m_timeLine.currentValue());
} }
} }
data.opacity *= (0.8 + 0.2 * (1.0 - m_startStopTimeLine.currentValue())); data.opacity *= (0.8 + 0.2 * (1.0 - m_startStopTimeLine.currentValue()));
@ -820,17 +820,17 @@ void FlipSwitchEffect::adjustWindowMultiScreen(const KWin::EffectWindow* w, Wind
QRect fullRect = effects->clientArea(FullArea, m_activeScreen, effects->currentDesktop()); QRect fullRect = effects->clientArea(FullArea, m_activeScreen, effects->currentDesktop());
if (w->screen() == m_activeScreen) { if (w->screen() == m_activeScreen) {
if (clientRect.width() != fullRect.width() && clientRect.x() != fullRect.x()) { if (clientRect.width() != fullRect.width() && clientRect.x() != fullRect.x()) {
data.xTranslate -= clientRect.x(); data.translate(- clientRect.x());
} }
if (clientRect.height() != fullRect.height() && clientRect.y() != fullRect.y()) { if (clientRect.height() != fullRect.height() && clientRect.y() != fullRect.y()) {
data.yTranslate -= clientRect.y(); data.translate(0.0, - clientRect.y());
} }
} else { } else {
if (clientRect.width() != fullRect.width() && clientRect.x() < rect.x()) { if (clientRect.width() != fullRect.width() && clientRect.x() < rect.x()) {
data.xTranslate -= clientRect.width(); data.translate(- clientRect.width());
} }
if (clientRect.height() != fullRect.height() && clientRect.y() < m_screenArea.y()) { if (clientRect.height() != fullRect.height() && clientRect.y() < m_screenArea.y()) {
data.yTranslate -= clientRect.height(); data.translate(0.0, - clientRect.height());
} }
} }
} }

View file

@ -129,8 +129,7 @@ void GlideEffect::glideIn(EffectWindow* w, WindowPaintData& data)
return; return;
const double progress = info->timeLine->currentValue(); const double progress = info->timeLine->currentValue();
data *= progress; data *= progress;
data.xTranslate += int(w->width() / 2 * (1 - progress)); data.translate(int(w->width() / 2 * (1 - progress)), int(w->height() / 2 * (1 - progress)));
data.yTranslate += int(w->height() / 2 * (1 - progress));
} }
void GlideEffect::glideOut(EffectWindow* w, WindowPaintData& data) void GlideEffect::glideOut(EffectWindow* w, WindowPaintData& data)
@ -140,8 +139,7 @@ void GlideEffect::glideOut(EffectWindow* w, WindowPaintData& data)
return; return;
const double progress = info->timeLine->currentValue(); const double progress = info->timeLine->currentValue();
data *= (2 - progress); data *= (2 - progress);
data.xTranslate -= int(w->width() / 2 * (1 - progress)); data.translate(- int(w->width() / 2 * (1 - progress)), - int(w->height() / 2 * (1 - progress)));
data.yTranslate -= int(w->height() / 2 * (1 - progress));
} }
void GlideEffect::postPaintWindow(EffectWindow* w) void GlideEffect::postPaintWindow(EffectWindow* w)

View file

@ -94,8 +94,8 @@ void MinimizeAnimationEffect::paintWindow(EffectWindow* w, int mask, QRegion reg
data *= QVector2D(interpolate(1.0, icon.width() / (double)geo.width(), progress), data *= QVector2D(interpolate(1.0, icon.width() / (double)geo.width(), progress),
interpolate(1.0, icon.height() / (double)geo.height(), progress)); interpolate(1.0, icon.height() / (double)geo.height(), progress));
data.xTranslate = (int)interpolate(data.xTranslate, icon.x() - geo.x(), progress); data.setXTranslation((int)interpolate(data.xTranslation(), icon.x() - geo.x(), progress));
data.yTranslate = (int)interpolate(data.yTranslate, icon.y() - geo.y(), progress); data.setYTranslation((int)interpolate(data.yTranslation(), icon.y() - geo.y(), progress));
data.opacity *= 0.1 + (1 - progress) * 0.9; data.opacity *= 0.1 + (1 - progress) * 0.9;
} }

View file

@ -379,8 +379,7 @@ void PresentWindowsEffect::paintWindow(EffectWindow *w, int mask, QRegion region
rect.setHeight(rect.height()*scale); rect.setHeight(rect.height()*scale);
data *= QVector2D(scale, scale); data *= QVector2D(scale, scale);
data.xTranslate += tx; data += QPoint(tx, ty);
data.yTranslate += ty;
} }
} }
@ -388,9 +387,7 @@ void PresentWindowsEffect::paintWindow(EffectWindow *w, int mask, QRegion region
mask &= ~PAINT_WINDOW_LANCZOS; mask &= ~PAINT_WINDOW_LANCZOS;
} }
if (m_dragInProgress && m_dragWindow == w) { if (m_dragInProgress && m_dragWindow == w) {
QPoint diff = cursorPos() - m_dragStart; data += (cursorPos() - m_dragStart);
data.xTranslate += diff.x();
data.yTranslate += diff.y();
} }
effects->paintWindow(w, mask, region, data); effects->paintWindow(w, mask, region, data);

View file

@ -69,8 +69,7 @@ void ResizeEffect::paintWindow(EffectWindow* w, int mask, QRegion region, Window
{ {
if (m_active && w == m_resizeWindow) { if (m_active && w == m_resizeWindow) {
if (m_features & TextureScale) { if (m_features & TextureScale) {
data.xTranslate += m_currentGeometry.x() - m_originalGeometry.x(); data += (m_currentGeometry.topLeft() - m_originalGeometry.topLeft());
data.yTranslate += m_currentGeometry.y() - m_originalGeometry.y();
data *= QVector2D(m_currentGeometry.width()/m_originalGeometry.width(), data *= QVector2D(m_currentGeometry.width()/m_originalGeometry.width(),
m_currentGeometry.height()/m_originalGeometry.height()); m_currentGeometry.height()/m_originalGeometry.height());
} }

View file

@ -60,8 +60,7 @@ void ScaleInEffect::paintWindow(EffectWindow* w, int mask, QRegion region, Windo
const qreal value = mTimeLineWindows[ w ]->currentValue(); const qreal value = mTimeLineWindows[ w ]->currentValue();
data.opacity *= value; data.opacity *= value;
data *= QVector2D(value, value); data *= QVector2D(value, value);
data.xTranslate += int(w->width() / 2 * (1 - value)); data += QPoint(int(w->width() / 2 * (1 - value)), int(w->height() / 2 * (1 - value)));
data.yTranslate += int(w->height() / 2 * (1 - value));
} }
effects->paintWindow(w, mask, region, data); effects->paintWindow(w, mask, region, data);
} }

View file

@ -108,8 +108,8 @@ void ScreenShotEffect::postPaintScreen()
} }
int width = right - left; int width = right - left;
int height = bottom - top; int height = bottom - top;
d.xTranslate = -m_scheduledScreenshot->x() - left; d.setXTranslation(-m_scheduledScreenshot->x() - left);
d.yTranslate = -m_scheduledScreenshot->y() - top; d.setYTranslation(-m_scheduledScreenshot->y() - top);
// render window into offscreen texture // render window into offscreen texture
int mask = PAINT_WINDOW_TRANSFORMED | PAINT_WINDOW_TRANSLUCENT; int mask = PAINT_WINDOW_TRANSFORMED | PAINT_WINDOW_TRANSLUCENT;

View file

@ -93,7 +93,7 @@ void SheetEffect::paintWindow(EffectWindow* w, int mask, QRegion region, WindowP
data.rotation.setAxis(Qt::XAxis); data.rotation.setAxis(Qt::XAxis);
data.rotation.setAngle(60.0 * (1.0 - progress)); data.rotation.setAngle(60.0 * (1.0 - progress));
data *= QVector3D(1.0, progress, progress); data *= QVector3D(1.0, progress, progress);
data.yTranslate -= (w->y() - info->parentY) * (1.0 - progress); data.translate(0.0, - (w->y() - info->parentY) * (1.0 - progress));
} }
effects->paintWindow(w, mask, region, data); effects->paintWindow(w, mask, region, data);
} }

View file

@ -166,8 +166,7 @@ void SlideEffect::paintWindow(EffectWindow* w, int mask, QRegion region, WindowP
if (slide) { if (slide) {
// don't move windows on all desktops (compensate screen transformation) // don't move windows on all desktops (compensate screen transformation)
if (!w->isOnAllDesktops()) { // TODO also fix 'Workspace::movingClient' if (!w->isOnAllDesktops()) { // TODO also fix 'Workspace::movingClient'
data.xTranslate += slide_painting_diff.x(); data += slide_painting_diff;
data.yTranslate += slide_painting_diff.y();
} }
} }
effects->paintWindow(w, mask, region, data); effects->paintWindow(w, mask, region, data);

View file

@ -195,23 +195,23 @@ void SlidingPopupsEffect::paintWindow(EffectWindow* w, int mask, QRegion region,
int splitPoint = 0; int splitPoint = 0;
switch(mWindowsData[ w ].from) { switch(mWindowsData[ w ].from) {
case West: case West:
data.xTranslate -= w->width() * progress; data.translate(- w->width() * progress);
splitPoint = w->width() - (w->x() + w->width() - screenRect.x() - start); splitPoint = w->width() - (w->x() + w->width() - screenRect.x() - start);
region = QRegion(w->x() + splitPoint, w->y(), w->width() - splitPoint, w->height()); region = QRegion(w->x() + splitPoint, w->y(), w->width() - splitPoint, w->height());
break; break;
case North: case North:
data.yTranslate -= w->height() * progress; data.translate(0.0, - w->height() * progress);
splitPoint = w->height() - (w->y() + w->height() - screenRect.y() - start); splitPoint = w->height() - (w->y() + w->height() - screenRect.y() - start);
region = QRegion(w->x(), w->y() + splitPoint, w->width(), w->height() - splitPoint); region = QRegion(w->x(), w->y() + splitPoint, w->width(), w->height() - splitPoint);
break; break;
case East: case East:
data.xTranslate += w->width() * progress; data.translate(w->width() * progress);
splitPoint = screenRect.x() + screenRect.width() - w->x() - start; splitPoint = screenRect.x() + screenRect.width() - w->x() - start;
region = QRegion(w->x(), w->y(), splitPoint, w->height()); region = QRegion(w->x(), w->y(), splitPoint, w->height());
break; break;
case South: case South:
default: default:
data.yTranslate += w->height() * progress; data.translate(0.0, w->height() * progress);
splitPoint = screenRect.y() + screenRect.height() - w->y() - start; splitPoint = screenRect.y() + screenRect.height() - w->y() - start;
region = QRegion(w->x(), w->y(), w->width(), splitPoint); region = QRegion(w->x(), w->y(), w->width(), splitPoint);
} }

View file

@ -82,7 +82,7 @@ void TaskbarThumbnailEffect::paintWindow(EffectWindow* w, int mask, QRegion regi
WindowPaintData thumbData(thumbw); WindowPaintData thumbData(thumbw);
thumbData.opacity *= data.opacity; thumbData.opacity *= data.opacity;
QRect r, thumbRect(thumb.rect); QRect r, thumbRect(thumb.rect);
thumbRect.translate(w->pos() + QPoint(data.xTranslate, data.yTranslate)); thumbRect.translate(w->pos() + QPoint(data.xTranslation(), data.yTranslation()));
thumbRect.setSize(QSize(thumbRect.width() * data.xScale(), thumbRect.height() * data.yScale())); // QSize has no vector multiplicator... :-( thumbRect.setSize(QSize(thumbRect.width() * data.xScale(), thumbRect.height() * data.yScale())); // QSize has no vector multiplicator... :-(
if (effects->compositingType() == KWin::OpenGLCompositing) { if (effects->compositingType() == KWin::OpenGLCompositing) {

View file

@ -269,16 +269,16 @@ void ZoomEffect::paintScreen(int mask, QRegion region, ScreenPaintData& data)
// mouse-tracking allows navigation of the zoom-area using the mouse. // mouse-tracking allows navigation of the zoom-area using the mouse.
switch(mouseTracking) { switch(mouseTracking) {
case MouseTrackingProportional: case MouseTrackingProportional:
data.xTranslate = - int(cursorPoint.x() * (zoom - 1.0)); data.setXTranslation(- int(cursorPoint.x() * (zoom - 1.0)));
data.yTranslate = - int(cursorPoint.y() * (zoom - 1.0)); data.setYTranslation(- int(cursorPoint.y() * (zoom - 1.0)));
prevPoint = cursorPoint; prevPoint = cursorPoint;
break; break;
case MouseTrackingCentred: case MouseTrackingCentred:
prevPoint = cursorPoint; prevPoint = cursorPoint;
// fall through // fall through
case MouseTrackingDisabled: case MouseTrackingDisabled:
data.xTranslate = qMin(0, qMax(int(displayWidth() - displayWidth() * zoom), int(displayWidth() / 2 - prevPoint.x() * zoom))); data.setXTranslation(qMin(0, qMax(int(displayWidth() - displayWidth() * zoom), int(displayWidth() / 2 - prevPoint.x() * zoom))));
data.yTranslate = qMin(0, qMax(int(displayHeight() - displayHeight() * zoom), int(displayHeight() / 2 - prevPoint.y() * zoom))); data.setYTranslation(qMin(0, qMax(int(displayHeight() - displayHeight() * zoom), int(displayHeight() / 2 - prevPoint.y() * zoom))));
break; break;
case MouseTrackingPush: case MouseTrackingPush:
if (timeline.state() != QTimeLine::Running) { if (timeline.state() != QTimeLine::Running) {
@ -301,8 +301,8 @@ void ZoomEffect::paintScreen(int mask, QRegion region, ScreenPaintData& data)
timeline.start(); timeline.start();
} }
} }
data.xTranslate = - int(prevPoint.x() * (zoom - 1.0)); data.setXTranslation(- int(prevPoint.x() * (zoom - 1.0)));
data.yTranslate = - int(prevPoint.y() * (zoom - 1.0)); data.setYTranslation(- int(prevPoint.y() * (zoom - 1.0)));
break; break;
} }
@ -316,8 +316,8 @@ void ZoomEffect::paintScreen(int mask, QRegion region, ScreenPaintData& data)
acceptFocus = msecs > focusDelay; acceptFocus = msecs > focusDelay;
} }
if (acceptFocus) { if (acceptFocus) {
data.xTranslate = - int(focusPoint.x() * (zoom - 1.0)); data.setXTranslation(- int(focusPoint.x() * (zoom - 1.0)));
data.yTranslate = - int(focusPoint.y() * (zoom - 1.0)); data.setYTranslation(- int(focusPoint.y() * (zoom - 1.0)));
prevPoint = focusPoint; prevPoint = focusPoint;
} }
} }
@ -336,7 +336,7 @@ void ZoomEffect::paintScreen(int mask, QRegion region, ScreenPaintData& data)
h *= zoom; h *= zoom;
} }
QPoint p = QCursor::pos(); QPoint p = QCursor::pos();
QRect rect(p.x() * zoom + data.xTranslate, p.y() * zoom + data.yTranslate, w, h); QRect rect(p.x() * zoom + data.xTranslation(), p.y() * zoom + data.yTranslation(), w, h);
if (texture) { if (texture) {
texture->bind(); texture->bind();

View file

@ -186,8 +186,8 @@ void LanczosFilter::performPaint(EffectWindowImpl* w, int mask, QRegion region,
width = w->width(); width = w->width();
height = w->height(); height = w->height();
} }
int tx = data.xTranslate + w->x() + left * data.xScale(); int tx = data.xTranslation() + w->x() + left * data.xScale();
int ty = data.yTranslate + w->y() + top * data.yScale(); int ty = data.yTranslation() + w->y() + top * data.yScale();
int tw = width * data.xScale(); int tw = width * data.xScale();
int th = height * data.yScale(); int th = height * data.yScale();
const QRect textureRect(tx, ty, tw, th); const QRect textureRect(tx, ty, tw, th);
@ -242,8 +242,8 @@ void LanczosFilter::performPaint(EffectWindowImpl* w, int mask, QRegion region,
WindowPaintData thumbData = data; WindowPaintData thumbData = data;
thumbData.setXScale(1.0); thumbData.setXScale(1.0);
thumbData.setYScale(1.0); thumbData.setYScale(1.0);
thumbData.xTranslate = -w->x() - left; thumbData.setXTranslation(-w->x() - left);
thumbData.yTranslate = -w->y() - top; thumbData.setYTranslation(-w->y() - top);
thumbData.brightness = 1.0; thumbData.brightness = 1.0;
thumbData.opacity = 1.0; thumbData.opacity = 1.0;
thumbData.saturation = 1.0; thumbData.saturation = 1.0;

View file

@ -407,7 +407,7 @@ void AnimationEffect::paintWindow( EffectWindow* w, int mask, QRegion region, Wi
if (anim->from[0] >= 0.0 && anim->to[0] >= 0.0) { // scale x if (anim->from[0] >= 0.0 && anim->to[0] >= 0.0) { // scale x
f1 = interpolated(*anim, 0); f1 = interpolated(*anim, 0);
f2 = geometryCompensation( anim->meta & AnimationEffect::Horizontal, f1 ); f2 = geometryCompensation( anim->meta & AnimationEffect::Horizontal, f1 );
data.xTranslate += f2 * sz.width(); data.translate(f2 * sz.width());
data.setXScale(data.xScale() * f1); data.setXScale(data.xScale() * f1);
} }
if (anim->from[1] >= 0.0 && anim->to[1] >= 0.0) { // scale y if (anim->from[1] >= 0.0 && anim->to[1] >= 0.0) { // scale y
@ -417,7 +417,7 @@ void AnimationEffect::paintWindow( EffectWindow* w, int mask, QRegion region, Wi
} }
else if ( ((anim->meta & AnimationEffect::Vertical)>>1) != (anim->meta & AnimationEffect::Horizontal) ) else if ( ((anim->meta & AnimationEffect::Vertical)>>1) != (anim->meta & AnimationEffect::Horizontal) )
f2 = geometryCompensation( anim->meta & AnimationEffect::Vertical, f1 ); f2 = geometryCompensation( anim->meta & AnimationEffect::Vertical, f1 );
data.yTranslate += f2 * sz.height(); data.translate(0.0, f2 * sz.height());
data.setYScale(data.yScale() * f1); data.setYScale(data.yScale() * f1);
} }
break; break;
@ -426,8 +426,7 @@ void AnimationEffect::paintWindow( EffectWindow* w, int mask, QRegion region, Wi
region = clipRect(w->expandedGeometry(), *anim); region = clipRect(w->expandedGeometry(), *anim);
break; break;
case Translation: case Translation:
data.xTranslate += interpolated(*anim, 0); data += QPointF(interpolated(*anim, 0), interpolated(*anim, 1));
data.yTranslate += interpolated(*anim, 1);
break; break;
case Size: { case Size: {
FPx2 dest = anim->from + progress(*anim) * (anim->to - anim->from); FPx2 dest = anim->from + progress(*anim) * (anim->to - anim->from);
@ -435,12 +434,12 @@ void AnimationEffect::paintWindow( EffectWindow* w, int mask, QRegion region, Wi
float f; float f;
if (anim->from[0] >= 0.0 && anim->to[0] >= 0.0) { // resize x if (anim->from[0] >= 0.0 && anim->to[0] >= 0.0) { // resize x
f = dest[0]/sz.width(); f = dest[0]/sz.width();
data.xTranslate += geometryCompensation( anim->meta & AnimationEffect::Horizontal, f ) * sz.width(); data.translate(geometryCompensation( anim->meta & AnimationEffect::Horizontal, f ) * sz.width());
data.setXScale(data.xScale() * f); data.setXScale(data.xScale() * f);
} }
if (anim->from[1] >= 0.0 && anim->to[1] >= 0.0) { // resize y if (anim->from[1] >= 0.0 && anim->to[1] >= 0.0) { // resize y
f = dest[1]/sz.height(); f = dest[1]/sz.height();
data.yTranslate += geometryCompensation( anim->meta & AnimationEffect::Vertical, f ) * sz.height(); data.translate(0.0, geometryCompensation( anim->meta & AnimationEffect::Vertical, f ) * sz.height());
data.setYScale(data.yScale() * f); data.setYScale(data.yScale() * f);
} }
break; break;
@ -452,13 +451,13 @@ void AnimationEffect::paintWindow( EffectWindow* w, int mask, QRegion region, Wi
float dest = interpolated(*anim, 0); float dest = interpolated(*anim, 0);
const int x[2] = { xCoord(geo, metaData(SourceAnchor, anim->meta)), const int x[2] = { xCoord(geo, metaData(SourceAnchor, anim->meta)),
xCoord(geo, metaData(TargetAnchor, anim->meta)) }; xCoord(geo, metaData(TargetAnchor, anim->meta)) };
data.xTranslate += dest - (x[0] + prgrs*(x[1] - x[0])); data.translate(dest - (x[0] + prgrs*(x[1] - x[0])));
} }
if ( anim->from[1] >= 0.0 && anim->to[1] >= 0.0 ) { if ( anim->from[1] >= 0.0 && anim->to[1] >= 0.0 ) {
float dest = interpolated(*anim, 1); float dest = interpolated(*anim, 1);
const int y[2] = { yCoord(geo, metaData(SourceAnchor, anim->meta)), const int y[2] = { yCoord(geo, metaData(SourceAnchor, anim->meta)),
yCoord(geo, metaData(TargetAnchor, anim->meta)) }; yCoord(geo, metaData(TargetAnchor, anim->meta)) };
data.yTranslate += dest - (y[0] + prgrs*(y[1] - y[0])); data.translate(0.0, dest - (y[0] + prgrs*(y[1] - y[0])));
} }
break; break;
} }

View file

@ -65,9 +65,6 @@ WindowPaintData::WindowPaintData(EffectWindow* w)
: opacity(w->opacity()) : opacity(w->opacity())
, contents_opacity(1.0) , contents_opacity(1.0)
, decoration_opacity(1.0) , decoration_opacity(1.0)
, xTranslate(0)
, yTranslate(0)
, zTranslate(0)
, saturation(1) , saturation(1)
, brightness(1) , brightness(1)
, shader(NULL) , shader(NULL)
@ -79,13 +76,11 @@ WindowPaintData::WindowPaintData(const WindowPaintData &other)
: opacity(other.opacity) : opacity(other.opacity)
, contents_opacity(other.contents_opacity) , contents_opacity(other.contents_opacity)
, decoration_opacity(other.decoration_opacity) , decoration_opacity(other.decoration_opacity)
, xTranslate(other.xTranslate)
, yTranslate(other.yTranslate)
, zTranslate(other.zTranslate)
, saturation(other.saturation) , saturation(other.saturation)
, brightness(other.brightness) , brightness(other.brightness)
, quads(other.quads) , quads(other.quads)
, shader(other.shader) , shader(other.shader)
, m_translation(other.translation())
{ {
m_scale.setXScale(other.xScale()); m_scale.setXScale(other.xScale());
m_scale.setYScale(other.yScale()); m_scale.setYScale(other.yScale());
@ -118,6 +113,27 @@ WindowPaintData &WindowPaintData::operator*=(const QVector3D &scale)
return *this; return *this;
} }
WindowPaintData &WindowPaintData::operator+=(const QPointF &translation)
{
return this->operator+=(QVector3D(translation));
}
WindowPaintData &WindowPaintData::operator+=(const QPoint &translation)
{
return this->operator+=(QVector3D(translation));
}
WindowPaintData &WindowPaintData::operator+=(const QVector2D &translation)
{
return this->operator+=(QVector3D(translation));
}
WindowPaintData &WindowPaintData::operator+=(const QVector3D &translation)
{
this->m_translation += translation;
return *this;
}
qreal WindowPaintData::xScale() const qreal WindowPaintData::xScale() const
{ {
return this->m_scale.xScale(); return this->m_scale.xScale();
@ -166,17 +182,57 @@ const QGraphicsScale &WindowPaintData::scale() const
return m_scale; 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() ScreenPaintData::ScreenPaintData()
: xTranslate(0)
, yTranslate(0)
, zTranslate(0)
{ {
} }
ScreenPaintData::ScreenPaintData(const ScreenPaintData &other) ScreenPaintData::ScreenPaintData(const ScreenPaintData &other)
: xTranslate(other.xTranslate) : m_translation(other.translation())
, yTranslate(other.yTranslate)
, zTranslate(other.zTranslate)
{ {
m_scale.setXScale(other.xScale()); m_scale.setXScale(other.xScale());
m_scale.setYScale(other.yScale()); m_scale.setYScale(other.yScale());
@ -191,9 +247,9 @@ ScreenPaintData &ScreenPaintData::operator=(const ScreenPaintData &rhs)
this->m_scale.setXScale(rhs.xScale()); this->m_scale.setXScale(rhs.xScale());
this->m_scale.setYScale(rhs.yScale()); this->m_scale.setYScale(rhs.yScale());
this->m_scale.setZScale(rhs.zScale()); this->m_scale.setZScale(rhs.zScale());
this->xTranslate = rhs.xTranslate; this->m_translation.setX(rhs.xTranslation());
this->yTranslate = rhs.yTranslate; this->m_translation.setY(rhs.yTranslation());
this->zTranslate = rhs.zTranslate; this->m_translation.setZ(rhs.zTranslation());
this->rotation.setOrigin(rhs.rotation.origin()); this->rotation.setOrigin(rhs.rotation.origin());
this->rotation.setAxis(rhs.rotation.axis()); this->rotation.setAxis(rhs.rotation.axis());
this->rotation.setAngle(rhs.rotation.angle()); this->rotation.setAngle(rhs.rotation.angle());
@ -223,6 +279,27 @@ ScreenPaintData &ScreenPaintData::operator*=(const QVector3D &scale)
return *this; return *this;
} }
ScreenPaintData &ScreenPaintData::operator+=(const QPointF &translation)
{
return this->operator+=(QVector3D(translation));
}
ScreenPaintData &ScreenPaintData::operator+=(const QPoint &translation)
{
return this->operator+=(QVector3D(translation));
}
ScreenPaintData &ScreenPaintData::operator+=(const QVector2D &translation)
{
return this->operator+=(QVector3D(translation));
}
ScreenPaintData &ScreenPaintData::operator+=(const QVector3D &translation)
{
m_translation += translation;
return *this;
}
qreal ScreenPaintData::xScale() const qreal ScreenPaintData::xScale() const
{ {
return m_scale.xScale(); return m_scale.xScale();
@ -271,6 +348,46 @@ const QGraphicsScale &ScreenPaintData::scale() const
return this->m_scale; 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 // Effect
//**************************************** //****************************************
@ -372,8 +489,8 @@ void Effect::setPositionTransformations(WindowPaintData& data, QRect& region, Ef
int x = r.x() + (r.width() - width) / 2; int x = r.x() + (r.width() - width) / 2;
int y = r.y() + (r.height() - height) / 2; int y = r.y() + (r.height() - height) / 2;
region = QRect(x, y, width, height); region = QRect(x, y, width, height);
data.xTranslate = x - w->x(); data.setXTranslation(x - w->x());
data.yTranslate = y - w->y(); data.setYTranslation(y - w->y());
} }
int Effect::displayWidth() int Effect::displayWidth()
@ -1255,8 +1372,7 @@ void WindowMotionManager::apply(EffectWindow *w, WindowPaintData &data)
// TODO: Take into account existing scale so that we can work with multiple managers (E.g. Present windows + grid) // TODO: Take into account existing scale so that we can work with multiple managers (E.g. Present windows + grid)
WindowMotion *motion = &it.value(); WindowMotion *motion = &it.value();
data.xTranslate += motion->translation.value().x() - w->x(); data += (motion->translation.value() - QPointF(w->x(), w->y()));
data.yTranslate += motion->translation.value().y() - w->y();
data *= QVector2D(motion->scale.value()); data *= QVector2D(motion->scale.value());
} }

View file

@ -1672,6 +1672,29 @@ public:
* @since 4.10 * @since 4.10
**/ **/
WindowPaintData& operator*=(const QVector3D &scale); WindowPaintData& operator*=(const QVector3D &scale);
/**
* Translates the window by the given @p translation and returns a reference to the ScreenPaintData.
* @since 4.10
**/
WindowPaintData& operator+=(const QPointF &translation);
/**
* Translates the window by the given @p translation and returns a reference to the ScreenPaintData.
* Overloaded method for convenience.
* @since 4.10
**/
WindowPaintData& operator+=(const QPoint &translation);
/**
* Translates the window by the given @p translation and returns a reference to the ScreenPaintData.
* Overloaded method for convenience.
* @since 4.10
**/
WindowPaintData& operator+=(const QVector2D &translation);
/**
* Translates the window by the given @p translation and returns a reference to the ScreenPaintData.
* Overloaded method for convenience.
* @since 4.10
**/
WindowPaintData& operator+=(const QVector3D &translation);
/** /**
* @returns scale factor in X direction. * @returns scale factor in X direction.
* @since 4.10 * @since 4.10
@ -1718,6 +1741,52 @@ public:
**/ **/
void setScale(const QVector3D &scale); void setScale(const QVector3D &scale);
const QGraphicsScale &scale() const; 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 * Window opacity, in range 0 = transparent to 1 = fully opaque
* Opacity for contents is opacity*contents_opacity, the same * Opacity for contents is opacity*contents_opacity, the same
@ -1726,9 +1795,6 @@ public:
double opacity; double opacity;
double contents_opacity; double contents_opacity;
double decoration_opacity; double decoration_opacity;
int xTranslate;
int yTranslate;
double zTranslate;
/** /**
* Saturation of the window, in range [0; 1] * Saturation of the window, in range [0; 1]
* 1 means that the window is unchanged, 0 means that it's completely * 1 means that the window is unchanged, 0 means that it's completely
@ -1752,6 +1818,7 @@ public:
QGraphicsRotation rotation; QGraphicsRotation rotation;
private: private:
QGraphicsScale m_scale; QGraphicsScale m_scale;
QVector3D m_translation;
}; };
class KWIN_EXPORT ScreenPaintData class KWIN_EXPORT ScreenPaintData
@ -1777,6 +1844,29 @@ public:
* @since 4.10 * @since 4.10
**/ **/
ScreenPaintData& operator*=(const QVector3D &scale); ScreenPaintData& operator*=(const QVector3D &scale);
/**
* Translates the screen by the given @p translation and returns a reference to the ScreenPaintData.
* @since 4.10
**/
ScreenPaintData& operator+=(const QPointF &translation);
/**
* Translates the screen by the given @p translation and returns a reference to the ScreenPaintData.
* Overloaded method for convenience.
* @since 4.10
**/
ScreenPaintData& operator+=(const QPoint &translation);
/**
* Translates the screen by the given @p translation and returns a reference to the ScreenPaintData.
* Overloaded method for convenience.
* @since 4.10
**/
ScreenPaintData& operator+=(const QVector2D &translation);
/**
* Translates the screen by the given @p translation and returns a reference to the ScreenPaintData.
* Overloaded method for convenience.
* @since 4.10
**/
ScreenPaintData& operator+=(const QVector3D &translation);
/** /**
* @returns scale factor in X direction. * @returns scale factor in X direction.
* @since 4.10 * @since 4.10
@ -1823,13 +1913,50 @@ public:
**/ **/
void setScale(const QVector3D &scale); void setScale(const QVector3D &scale);
const QGraphicsScale &scale() const; const QGraphicsScale &scale() const;
int xTranslate; const QVector3D &translation() const;
int yTranslate; /**
double zTranslate; * @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; QGraphicsRotation rotation;
ScreenPaintData& operator=(const ScreenPaintData &rhs); ScreenPaintData& operator=(const ScreenPaintData &rhs);
private: private:
QGraphicsScale m_scale; QGraphicsScale m_scale;
QVector3D m_translation;
}; };
class KWIN_EXPORT ScreenPrePaintData class KWIN_EXPORT ScreenPrePaintData

View file

@ -406,8 +406,8 @@ void Scene::paintWindow(Window* w, int mask, QRegion region, WindowQuadList quad
const QPoint point = viewPos + declview->mapFromScene(item->scenePos()); const QPoint point = viewPos + declview->mapFromScene(item->scenePos());
const qreal x = point.x() + w->x() + (item->width() - size.width())/2; const qreal x = point.x() + w->x() + (item->width() - size.width())/2;
const qreal y = point.y() + w->y() + (item->height() - size.height()) / 2; const qreal y = point.y() + w->y() + (item->height() - size.height()) / 2;
thumbData.xTranslate = x - thumb->x(); thumbData.setXTranslation(x - thumb->x());
thumbData.yTranslate = y - thumb->y(); thumbData.setYTranslation(y - thumb->y());
int thumbMask = PAINT_WINDOW_TRANSFORMED | PAINT_WINDOW_LANCZOS; int thumbMask = PAINT_WINDOW_TRANSFORMED | PAINT_WINDOW_LANCZOS;
if (thumbData.opacity == 1.0) { if (thumbData.opacity == 1.0) {
thumbMask |= PAINT_WINDOW_OPAQUE; thumbMask |= PAINT_WINDOW_OPAQUE;

View file

@ -133,7 +133,7 @@ QMatrix4x4 SceneOpenGL::transformation(int mask, const ScreenPaintData &data) co
if (!(mask & PAINT_SCREEN_TRANSFORMED)) if (!(mask & PAINT_SCREEN_TRANSFORMED))
return matrix; return matrix;
matrix.translate(data.xTranslate, data.yTranslate, data.zTranslate); matrix.translate(data.translation());
data.scale().applyTo(&matrix); data.scale().applyTo(&matrix);
if (data.rotation.angle() == 0.0) if (data.rotation.angle() == 0.0)
@ -416,7 +416,7 @@ QMatrix4x4 SceneOpenGL::Window::transformation(int mask, const WindowPaintData &
if (!(mask & PAINT_WINDOW_TRANSFORMED)) if (!(mask & PAINT_WINDOW_TRANSFORMED))
return matrix; return matrix;
matrix.translate(data.xTranslate, data.yTranslate, data.zTranslate); matrix.translate(data.translation());
data.scale().applyTo(&matrix); data.scale().applyTo(&matrix);
if (data.rotation.angle() == 0.0) if (data.rotation.angle() == 0.0)

View file

@ -373,8 +373,8 @@ QRect SceneXrender::Window::mapToScreen(int mask, const WindowPaintData &data, c
if (mask & PAINT_WINDOW_TRANSFORMED) { if (mask & PAINT_WINDOW_TRANSFORMED) {
// Apply the window transformation // Apply the window transformation
r.moveTo(r.x() * data.xScale() + data.xTranslate, r.moveTo(r.x() * data.xScale() + data.xTranslation(),
r.y() * data.yScale() + data.yTranslate); r.y() * data.yScale() + data.yTranslation());
r.setWidth(r.width() * data.xScale()); r.setWidth(r.width() * data.xScale());
r.setHeight(r.height() * data.yScale()); r.setHeight(r.height() * data.yScale());
} }
@ -384,8 +384,8 @@ QRect SceneXrender::Window::mapToScreen(int mask, const WindowPaintData &data, c
if (mask & PAINT_SCREEN_TRANSFORMED) { if (mask & PAINT_SCREEN_TRANSFORMED) {
// Apply the screen transformation // Apply the screen transformation
r.moveTo(r.x() * screen_paint.xScale() + screen_paint.xTranslate, r.moveTo(r.x() * screen_paint.xScale() + screen_paint.xTranslation(),
r.y() * screen_paint.yScale() + screen_paint.yTranslate); r.y() * screen_paint.yScale() + screen_paint.yTranslation());
r.setWidth(r.width() * screen_paint.xScale()); r.setWidth(r.width() * screen_paint.xScale());
r.setHeight(r.height() * screen_paint.yScale()); r.setHeight(r.height() * screen_paint.yScale());
} }
@ -400,8 +400,8 @@ QPoint SceneXrender::Window::mapToScreen(int mask, const WindowPaintData &data,
if (mask & PAINT_WINDOW_TRANSFORMED) { if (mask & PAINT_WINDOW_TRANSFORMED) {
// Apply the window transformation // Apply the window transformation
pt.rx() = pt.x() * data.xScale() + data.xTranslate; pt.rx() = pt.x() * data.xScale() + data.xTranslation();
pt.ry() = pt.y() * data.yScale() + data.yTranslate; pt.ry() = pt.y() * data.yScale() + data.yTranslation();
} }
// Move the point to the screen position // Move the point to the screen position
@ -409,8 +409,8 @@ QPoint SceneXrender::Window::mapToScreen(int mask, const WindowPaintData &data,
if (mask & PAINT_SCREEN_TRANSFORMED) { if (mask & PAINT_SCREEN_TRANSFORMED) {
// Apply the screen transformation // Apply the screen transformation
pt.rx() = pt.x() * screen_paint.xScale() + screen_paint.xTranslate; pt.rx() = pt.x() * screen_paint.xScale() + screen_paint.xTranslation();
pt.ry() = pt.y() * screen_paint.yScale() + screen_paint.yTranslate; pt.ry() = pt.y() * screen_paint.yScale() + screen_paint.yTranslation();
} }
return pt; return pt;