From f002e20354cb95dd315ed99a6aa4b2848a86c068 Mon Sep 17 00:00:00 2001 From: Vlad Zahorodnii Date: Sun, 11 Aug 2024 19:51:03 +0300 Subject: [PATCH] scene: Make SurfaceItem provide device texture coordinates The main motivation behind this change is to make the ItemRendererOpenGL use a homogeneous coordinate space for texture coordinates in order to simplify rendering code. The device pixels have been chosen because they are more agnostic about the graphics api. --- src/scene/itemrenderer_opengl.cpp | 2 +- src/scene/surfaceitem.cpp | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/scene/itemrenderer_opengl.cpp b/src/scene/itemrenderer_opengl.cpp index a4b605ae98..94dbcbba6c 100644 --- a/src/scene/itemrenderer_opengl.cpp +++ b/src/scene/itemrenderer_opengl.cpp @@ -195,7 +195,7 @@ void ItemRendererOpenGL::createRenderNode(Item *item, RenderContext *context) .transformMatrix = context->transformStack.top(), .opacity = context->opacityStack.top(), .hasAlpha = pixmap->hasAlphaChannel(), - .coordinateType = NormalizedCoordinates, + .coordinateType = UnnormalizedCoordinates, .colorDescription = item->colorDescription(), .renderingIntent = item->renderingIntent(), .bufferReleasePoint = surfaceItem->bufferReleasePoint(), diff --git a/src/scene/surfaceitem.cpp b/src/scene/surfaceitem.cpp index ddb63913e3..86e1340b8a 100644 --- a/src/scene/surfaceitem.cpp +++ b/src/scene/surfaceitem.cpp @@ -255,10 +255,10 @@ WindowQuadList SurfaceItem::buildQuads() const const QPointF bufferBottomRight = snapToPixelGridF(m_bufferSourceBox.topLeft() + m_surfaceToBufferTransform.map(QPointF(rect.right() * xScale, rect.bottom() * yScale), sourceBox.size())); const QPointF bufferBottomLeft = snapToPixelGridF(m_bufferSourceBox.topLeft() + m_surfaceToBufferTransform.map(QPointF(rect.left() * xScale, rect.bottom() * yScale), sourceBox.size())); - quad[0] = WindowVertex(rect.topLeft(), QPointF{bufferTopLeft.x() / m_bufferSize.width(), bufferTopLeft.y() / m_bufferSize.height()}); - quad[1] = WindowVertex(rect.topRight(), QPointF{bufferTopRight.x() / m_bufferSize.width(), bufferTopRight.y() / m_bufferSize.height()}); - quad[2] = WindowVertex(rect.bottomRight(), QPointF{bufferBottomRight.x() / m_bufferSize.width(), bufferBottomRight.y() / m_bufferSize.height()}); - quad[3] = WindowVertex(rect.bottomLeft(), QPointF{bufferBottomLeft.x() / m_bufferSize.width(), bufferBottomLeft.y() / m_bufferSize.height()}); + quad[0] = WindowVertex(rect.topLeft(), bufferTopLeft); + quad[1] = WindowVertex(rect.topRight(), bufferTopRight); + quad[2] = WindowVertex(rect.bottomRight(), bufferBottomRight); + quad[3] = WindowVertex(rect.bottomLeft(), bufferBottomLeft); quads << quad; }