Commit 00df0a70 authored by Vlad Zahorodnii's avatar Vlad Zahorodnii
Browse files

wayland: Explicitly initialize surface size to 0

QSize() will construct an invalid size. An invalid size has width and
height set to -1. In other words, QSize() != QSize(0, 0). This can create
issues when computing the bounding rect of a surface that has invisible
subsurfaces.

For example, if the subsurface rect is QRect(0,0 -1x-1), the top-left
corner of the bounding rect will be affected.

In order to make computation of the bounding rect robust, initialize the
surface size to 0 explicitly.

BUG: 454535
parent f9c20bb8
Pipeline #190305 passed with stage
in 22 minutes and 55 seconds
......@@ -763,7 +763,7 @@ void TestWaylandSurface::testScale()
// even though we've changed the scale, if we don't have a buffer we
// don't have a size. If we don't have a size it can't have changed
QCOMPARE(sizeChangedSpy.count(), 0);
QVERIFY(!serverSurface->size().isValid());
QCOMPARE(serverSurface->size(), QSize(0, 0));
// let's try changing to same factor, should not emit changed on server
s->setScale(2);
......
......@@ -628,9 +628,10 @@ void SurfaceInterfacePrivate::applyState(SurfaceState *next)
surfaceSize = surfaceSize / scaleOverride;
implicitSurfaceSize = implicitSurfaceSize / scaleOverride;
} else {
surfaceSize = QSize();
implicitSurfaceSize = QSize();
bufferSize = QSize();
// not QSize() because that will initialize width and height to -1
surfaceSize = QSize(0, 0);
implicitSurfaceSize = QSize(0, 0);
bufferSize = QSize(0, 0);
inputRegion = QRegion();
opaqueRegion = QRegion();
}
......
......@@ -112,9 +112,9 @@ public:
SubSurfaceInterface *subSurface = nullptr;
QMatrix4x4 surfaceToBufferMatrix;
QMatrix4x4 bufferToSurfaceMatrix;
QSize bufferSize;
QSize implicitSurfaceSize;
QSize surfaceSize;
QSize bufferSize = QSize(0, 0);
QSize implicitSurfaceSize = QSize(0, 0);
QSize surfaceSize = QSize(0, 0);
QRegion inputRegion;
QRegion opaqueRegion;
ClientBuffer *bufferRef = nullptr;
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment