diff options
author | Friedemann Kleint <Friedemann.Kleint@qt.io> | 2016-11-22 13:29:55 +0100 |
---|---|---|
committer | Friedemann Kleint <Friedemann.Kleint@qt.io> | 2016-11-22 22:29:16 +0000 |
commit | 07cde200e55ee03bf9e2f9af89c20f91072deccc (patch) | |
tree | a59282f7fa93a57e60d4f9e66b29535d64864c39 /src/quick/scenegraph/util/qsgimagenode.cpp | |
parent | 39bed6135cd08b346866bb35ac95eaaf6f69b95c (diff) |
Move rebuildGeometry() functions of nodes
Move QSGDefaultImageNode::rebuildGeometry(),
QSGDefaultNinePatchNode::rebuildGeometry() to
QSGImageNode::rebuildGeometry(),
QSGNinePatchNode::rebuildGeometry()
respectively.
This makes it possible to use then from the D3D12 plugin
when built without OpenGL support.
Task-number: QTBUG-57185
Change-Id: Ib88c5622f7048618151a63d7536d76296a25842e
Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io>
Diffstat (limited to 'src/quick/scenegraph/util/qsgimagenode.cpp')
-rw-r--r-- | src/quick/scenegraph/util/qsgimagenode.cpp | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/src/quick/scenegraph/util/qsgimagenode.cpp b/src/quick/scenegraph/util/qsgimagenode.cpp index a78bfc1c66..c03c91d1cb 100644 --- a/src/quick/scenegraph/util/qsgimagenode.cpp +++ b/src/quick/scenegraph/util/qsgimagenode.cpp @@ -187,4 +187,33 @@ QT_BEGIN_NAMESPACE \return \c true if the node takes ownership of the texture; otherwise \c false. */ +void QSGImageNode::rebuildGeometry(QSGGeometry *g, + QSGTexture *texture, + const QRectF &rect, + QRectF sourceRect, + TextureCoordinatesTransformMode texCoordMode) +{ + if (!texture) + return; + + if (!sourceRect.width() || !sourceRect.height()) { + QSize ts = texture->textureSize(); + sourceRect = QRectF(0, 0, ts.width(), ts.height()); + } + + // Maybe transform the texture coordinates + if (texCoordMode.testFlag(QSGImageNode::MirrorHorizontally)) { + float tmp = sourceRect.left(); + sourceRect.setLeft(sourceRect.right()); + sourceRect.setRight(tmp); + } + if (texCoordMode.testFlag(QSGImageNode::MirrorVertically)) { + float tmp = sourceRect.top(); + sourceRect.setTop(sourceRect.bottom()); + sourceRect.setBottom(tmp); + } + + QSGGeometry::updateTexturedRectGeometry(g, rect, texture->convertToNormalizedSourceRect(sourceRect)); +} + QT_END_NAMESPACE |