scene: Store renderTargetRect as QRectF

This allows the projection matrix calculation to properly calculate the
screen edges without losing bits due to earlier rounding.
This commit is contained in:
Arjen Hiemstra 2022-11-10 16:43:57 +01:00
parent 69feee0ce6
commit cd65515ea6
2 changed files with 6 additions and 6 deletions

View file

@ -260,7 +260,7 @@ void Scene::prePaint(Output *output)
setRenderTargetScale(1);
} else {
painted_screen = output;
setRenderTargetRect(painted_screen->geometry());
setRenderTargetRect(painted_screen->fractionalGeometry());
setRenderTargetScale(painted_screen->scale());
}
@ -409,7 +409,7 @@ void Scene::postPaint()
clearStackingOrder();
}
static QMatrix4x4 createProjectionMatrix(const QRect &rect, qreal scale)
static QMatrix4x4 createProjectionMatrix(const QRectF &rect, qreal scale)
{
QMatrix4x4 ret;
ret.ortho(QRectF(rect.left() * scale, rect.top() * scale, rect.width() * scale, rect.height() * scale));
@ -423,10 +423,10 @@ QMatrix4x4 Scene::renderTargetProjectionMatrix() const
QRect Scene::renderTargetRect() const
{
return m_renderTargetRect;
return m_renderTargetRect.toRect();
}
void Scene::setRenderTargetRect(const QRect &rect)
void Scene::setRenderTargetRect(const QRectF &rect)
{
if (rect == m_renderTargetRect) {
return;

View file

@ -168,7 +168,7 @@ public:
QMatrix4x4 renderTargetProjectionMatrix() const;
QRect renderTargetRect() const;
void setRenderTargetRect(const QRect &rect);
void setRenderTargetRect(const QRectF &rect);
qreal renderTargetScale() const;
void setRenderTargetScale(qreal scale);
@ -233,7 +233,7 @@ private:
QList<SceneDelegate *> m_delegates;
QRect m_geometry;
QMatrix4x4 m_renderTargetProjectionMatrix;
QRect m_renderTargetRect;
QRectF m_renderTargetRect;
qreal m_renderTargetScale = 1;
// how many times finalPaintScreen() has been called
int m_paintScreenCount = 0;