wayland: Use correct bounds size when computing the source box

The buffer transform specifies a transform from the buffer coordinate
space to the surface coordinate space.

The inverse buffer transform specifies a transform from the surface
coordinate space to the buffer coordinate space.

OutputTransform::map(QRect, QSizeF) expects both arguments to be in the
same coordinate space.

In case of SurfaceInterfacePrivate::computeSourceBox(), both should be
scaled surface coordinates so bufferTransform.inverted() maps the source
rect to the proper buffer coordinate space.
This commit is contained in:
Vlad Zahorodnii 2023-08-20 14:10:48 +03:00
parent 7582d72eac
commit 54e2a5761c
3 changed files with 20 additions and 1 deletions

View file

@ -142,6 +142,19 @@ QRectF OutputTransform::map(const QRectF &rect, const QSizeF &bounds) const
return dest;
}
QSizeF OutputTransform::map(const QSizeF &size) const
{
switch (m_kind) {
case Kind::Normal:
case Kind::Rotated180:
case Kind::Flipped:
case Kind::Flipped180:
return size;
default:
return size.transposed();
}
}
Output::Output(QObject *parent)
: QObject(parent)
{

View file

@ -75,6 +75,11 @@ public:
*/
OutputTransform inverted() const;
/**
* Applies the output transform to the given @a size.
*/
QSizeF map(const QSizeF &size) const;
/**
* Applies the output transform to the given @a rect within a buffer with dimensions @a bounds.
*/

View file

@ -486,12 +486,13 @@ QRectF SurfaceInterfacePrivate::computeBufferSourceBox() const
return QRectF(0, 0, bufferSize.width(), bufferSize.height());
}
const QSizeF bounds = current.bufferTransform.map(bufferSize);
const QRectF box(current.viewport.sourceGeometry.x() * current.bufferScale,
current.viewport.sourceGeometry.y() * current.bufferScale,
current.viewport.sourceGeometry.width() * current.bufferScale,
current.viewport.sourceGeometry.height() * current.bufferScale);
return current.bufferTransform.inverted().map(box, bufferSize);
return current.bufferTransform.inverted().map(box, bounds);
}
void SurfaceState::mergeInto(SurfaceState *target)