Commit 2f4fa23e authored by Arjen Hiemstra's avatar Arjen Hiemstra
Browse files

Use normalized UV coordinates for SurfaceItem

Relying on the texture matrix to normalize means we multiply every UV
coordinate with 1/scale, which leads to floating point errors and thus
errors in the UV coordinates. Instead, if we calculate normalized
coordinates directly we avoid floating point error and get proper UV

Longer term the plan is to make all UV coordinates normalized and get
rid of the CoordinateType altogether.
parent 7292af3d
......@@ -376,7 +376,7 @@ void SceneOpenGL::createRenderNode(Item *item, RenderContext *context)
.transformMatrix = context->,
.opacity = context->,
.hasAlpha = hasAlpha,
.coordinateType = UnnormalizedCoordinates,
.coordinateType = NormalizedCoordinates,
......@@ -140,10 +140,12 @@ WindowQuadList SurfaceItem::buildQuads() const
const QPointF bufferBottomRight =;
const QPointF bufferBottomLeft =;
quad[0] = WindowVertex(rect.topLeft(), bufferTopLeft);
quad[1] = WindowVertex(rect.topRight(), bufferTopRight);
quad[2] = WindowVertex(rect.bottomRight(), bufferBottomRight);
quad[3] = WindowVertex(rect.bottomLeft(), bufferBottomLeft);
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()});
quad[3] = WindowVertex(rect.bottomLeft(), QPointF{bufferBottomLeft.x() / size.width(), bufferBottomLeft.y() / size.height()});
quads << quad;
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