SurfaceItem: Use pixmap() for quad generation

This uses the previous pixmap if the current one is invalid,
which ensures the generated quads have sane coordinates.

The issue caused flickering while resizing Chrome after
2f4fa23e61

While at it, move `size` out of the loop as it doesn't change.

Signed-off-by: Victoria Fischer <victoria.fischer@mbition.io>
This commit is contained in:
Kai Uwe Broulik 2022-07-27 13:10:02 +02:00 committed by Kai Uwe Broulik
parent 259f4d7838
commit 1e3a81249c

View file

@ -128,6 +128,7 @@ void SurfaceItem::preprocess()
WindowQuadList SurfaceItem::buildQuads() const
{
const QRegion region = shape();
const auto size = pixmap()->size();
WindowQuadList quads;
quads.reserve(region.rectCount());
@ -140,8 +141,6 @@ WindowQuadList SurfaceItem::buildQuads() const
const QPointF bufferBottomRight = m_surfaceToBufferMatrix.map(rect.bottomRight());
const QPointF bufferBottomLeft = m_surfaceToBufferMatrix.map(rect.bottomLeft());
const auto size = m_pixmap->size();
quad[0] = WindowVertex(rect.topLeft(), QPointF{bufferTopLeft.x() / size.width(), bufferTopLeft.y() / size.height()});
quad[1] = WindowVertex(rect.topRight(), QPointF{bufferTopRight.x() / size.width(), bufferTopRight.y() / size.height()});
quad[2] = WindowVertex(rect.bottomRight(), QPointF{bufferBottomRight.x() / size.width(), bufferBottomRight.y() / size.height()});