scene: Make ImageItem 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.
This commit is contained in:
parent
f002e20354
commit
d12112b7a5
2 changed files with 8 additions and 5 deletions
|
@ -24,6 +24,7 @@ QImage ImageItem::image() const
|
||||||
void ImageItem::setImage(const QImage &image)
|
void ImageItem::setImage(const QImage &image)
|
||||||
{
|
{
|
||||||
m_image = image;
|
m_image = image;
|
||||||
|
discardQuads();
|
||||||
}
|
}
|
||||||
|
|
||||||
ImageItemOpenGL::ImageItemOpenGL(Item *parent)
|
ImageItemOpenGL::ImageItemOpenGL(Item *parent)
|
||||||
|
@ -68,11 +69,13 @@ WindowQuadList ImageItemOpenGL::buildQuads() const
|
||||||
return WindowQuadList{};
|
return WindowQuadList{};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const QRectF imageRect = m_image.rect();
|
||||||
|
|
||||||
WindowQuad quad;
|
WindowQuad quad;
|
||||||
quad[0] = WindowVertex(geometry.topLeft(), QPointF(0, 0));
|
quad[0] = WindowVertex(geometry.topLeft(), imageRect.topLeft());
|
||||||
quad[1] = WindowVertex(geometry.topRight(), QPointF(1, 0));
|
quad[1] = WindowVertex(geometry.topRight(), imageRect.topRight());
|
||||||
quad[2] = WindowVertex(geometry.bottomRight(), QPointF(1, 1));
|
quad[2] = WindowVertex(geometry.bottomRight(), imageRect.bottomRight());
|
||||||
quad[3] = WindowVertex(geometry.bottomLeft(), QPointF(0, 1));
|
quad[3] = WindowVertex(geometry.bottomLeft(), imageRect.bottomLeft());
|
||||||
|
|
||||||
WindowQuadList ret;
|
WindowQuadList ret;
|
||||||
ret.append(quad);
|
ret.append(quad);
|
||||||
|
|
|
@ -210,7 +210,7 @@ void ItemRendererOpenGL::createRenderNode(Item *item, RenderContext *context)
|
||||||
.transformMatrix = context->transformStack.top(),
|
.transformMatrix = context->transformStack.top(),
|
||||||
.opacity = context->opacityStack.top(),
|
.opacity = context->opacityStack.top(),
|
||||||
.hasAlpha = imageItem->image().hasAlphaChannel(),
|
.hasAlpha = imageItem->image().hasAlphaChannel(),
|
||||||
.coordinateType = NormalizedCoordinates,
|
.coordinateType = UnnormalizedCoordinates,
|
||||||
.colorDescription = item->colorDescription(),
|
.colorDescription = item->colorDescription(),
|
||||||
.renderingIntent = item->renderingIntent(),
|
.renderingIntent = item->renderingIntent(),
|
||||||
.bufferReleasePoint = nullptr,
|
.bufferReleasePoint = nullptr,
|
||||||
|
|
Loading…
Reference in a new issue