mirroring added
This commit is contained in:
parent
86e438a0ed
commit
a35cc9936a
@ -64,6 +64,20 @@ static GLuint qskTakeTexture( QOpenGLFramebufferObject& fbo )
|
||||
return textureId;
|
||||
}
|
||||
|
||||
static inline QSGImageNode::TextureCoordinatesTransformMode
|
||||
qskEffectiveTransformMode( const Qt::Orientations mirrored )
|
||||
{
|
||||
QSGImageNode::TextureCoordinatesTransformMode mode;
|
||||
|
||||
if ( mirrored & Qt::Vertical )
|
||||
mode |= QSGImageNode::MirrorVertically;
|
||||
|
||||
if ( mirrored & Qt::Horizontal )
|
||||
mode |= QSGImageNode::MirrorHorizontally;
|
||||
|
||||
return mode;
|
||||
}
|
||||
|
||||
namespace
|
||||
{
|
||||
const quint8 imageRole = 250; // reserved for internal use
|
||||
@ -104,6 +118,25 @@ QskPaintedNode::RenderHint QskPaintedNode::renderHint() const
|
||||
return m_renderHint;
|
||||
}
|
||||
|
||||
void QskPaintedNode::setMirrored( Qt::Orientations orientations )
|
||||
{
|
||||
if ( orientations != m_mirrored )
|
||||
{
|
||||
m_mirrored == orientations;
|
||||
|
||||
if ( auto imageNode = findImageNode( this ) )
|
||||
{
|
||||
imageNode->setTextureCoordinatesTransform(
|
||||
qskEffectiveTransformMode( orientations ) );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Qt::Orientations QskPaintedNode::mirrored() const
|
||||
{
|
||||
return m_mirrored;
|
||||
}
|
||||
|
||||
QRectF QskPaintedNode::rect() const
|
||||
{
|
||||
const auto imageNode = findImageNode( this );
|
||||
@ -145,6 +178,14 @@ void QskPaintedNode::update( QQuickWindow* window,
|
||||
else
|
||||
updateImageNode( window, rect, nodeData );
|
||||
}
|
||||
|
||||
imageNode = findImageNode( this );
|
||||
if ( imageNode )
|
||||
{
|
||||
imageNode->setRect( rect );
|
||||
imageNode->setTextureCoordinatesTransform(
|
||||
qskEffectiveTransformMode( m_mirrored ) );
|
||||
}
|
||||
}
|
||||
|
||||
void QskPaintedNode::updateImageNode(
|
||||
@ -183,8 +224,6 @@ void QskPaintedNode::updateImageNode(
|
||||
texture->setImage( image );
|
||||
else
|
||||
imageNode->setTexture( window->createTextureFromImage( image ) );
|
||||
|
||||
imageNode->setRect( rect );
|
||||
}
|
||||
|
||||
void QskPaintedNode::updateImageNodeGL(
|
||||
@ -240,8 +279,6 @@ void QskPaintedNode::updateImageNodeGL(
|
||||
texture->setTextureSize( size );
|
||||
}
|
||||
#endif
|
||||
|
||||
imageNode->setRect( rect );
|
||||
}
|
||||
|
||||
uint32_t QskPaintedNode::createTexture(
|
||||
|
@ -38,6 +38,9 @@ class QSK_EXPORT QskPaintedNode : public QSGNode
|
||||
void setRenderHint( RenderHint );
|
||||
RenderHint renderHint() const;
|
||||
|
||||
void setMirrored( Qt::Orientations );
|
||||
Qt::Orientations mirrored() const;
|
||||
|
||||
QRectF rect() const;
|
||||
|
||||
protected:
|
||||
@ -55,6 +58,7 @@ class QSK_EXPORT QskPaintedNode : public QSGNode
|
||||
uint32_t createTexture( QQuickWindow*, const QSize&, const void* nodeData );
|
||||
|
||||
RenderHint m_renderHint = OpenGL;
|
||||
Qt::Orientations m_mirrored;
|
||||
QskHashValue m_hash = 0;
|
||||
};
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user