working towards Qt6
This commit is contained in:
parent
5e195a9743
commit
75cdda5f6a
@ -85,21 +85,19 @@ QSGNode* QskGraphicLabelSkinlet::updateGraphicNode(
|
|||||||
const auto colorFilter = label->graphicFilter();
|
const auto colorFilter = label->graphicFilter();
|
||||||
const auto rect = label->subControlRect( QskGraphicLabel::Graphic );
|
const auto rect = label->subControlRect( QskGraphicLabel::Graphic );
|
||||||
|
|
||||||
|
Qt::Orientations mirrored;
|
||||||
|
if ( label->mirror() )
|
||||||
|
mirrored = Qt::Horizontal;
|
||||||
|
|
||||||
if ( label->fillMode() == QskGraphicLabel::Stretch )
|
if ( label->fillMode() == QskGraphicLabel::Stretch )
|
||||||
{
|
{
|
||||||
node = QskSkinlet::updateGraphicNode( label, node,
|
node = QskSkinlet::updateGraphicNode( label, node,
|
||||||
label->graphic(), colorFilter, rect );
|
label->graphic(), colorFilter, rect, mirrored );
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
node = QskSkinlet::updateGraphicNode( label, node,
|
node = QskSkinlet::updateGraphicNode( label, node,
|
||||||
label->graphic(), colorFilter, rect, Qt::AlignCenter );
|
label->graphic(), colorFilter, rect, Qt::AlignCenter, mirrored );
|
||||||
}
|
|
||||||
|
|
||||||
if ( node && label->mirror() )
|
|
||||||
{
|
|
||||||
auto textureNode = static_cast< QskTextureNode* >( node );
|
|
||||||
textureNode->setMirrored( Qt::Horizontal );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return node;
|
return node;
|
||||||
|
@ -73,7 +73,7 @@ static inline QRectF qskSubControlRect( const QskSkinlet* skinlet,
|
|||||||
static inline QSGNode* qskUpdateGraphicNode(
|
static inline QSGNode* qskUpdateGraphicNode(
|
||||||
const QskSkinnable* skinnable, QSGNode* node,
|
const QskSkinnable* skinnable, QSGNode* node,
|
||||||
const QskGraphic& graphic, const QskColorFilter& colorFilter,
|
const QskGraphic& graphic, const QskColorFilter& colorFilter,
|
||||||
const QRectF& rect )
|
const QRectF& rect, Qt::Orientations mirrored )
|
||||||
{
|
{
|
||||||
if ( rect.isEmpty() )
|
if ( rect.isEmpty() )
|
||||||
return nullptr;
|
return nullptr;
|
||||||
@ -99,12 +99,13 @@ static inline QSGNode* qskUpdateGraphicNode(
|
|||||||
*/
|
*/
|
||||||
QRectF r(
|
QRectF r(
|
||||||
control->mapToScene( rect.topLeft() ),
|
control->mapToScene( rect.topLeft() ),
|
||||||
rect.size() * QskTextureRenderer::devicePixelRatio() );
|
rect.size() * control->window()->effectiveDevicePixelRatio() );
|
||||||
|
|
||||||
r = qskInnerRect( r );
|
r = qskInnerRect( r );
|
||||||
r.moveTopLeft( control->mapFromScene( r.topLeft() ) );
|
r.moveTopLeft( control->mapFromScene( r.topLeft() ) );
|
||||||
|
|
||||||
graphicNode->setGraphic( graphic, colorFilter, mode, r );
|
graphicNode->setGraphic( control->window(), graphic,
|
||||||
|
colorFilter, mode, r, mirrored );
|
||||||
|
|
||||||
return graphicNode;
|
return graphicNode;
|
||||||
}
|
}
|
||||||
@ -551,7 +552,8 @@ QSGNode* QskSkinlet::updateTextNode(
|
|||||||
|
|
||||||
QSGNode* QskSkinlet::updateGraphicNode(
|
QSGNode* QskSkinlet::updateGraphicNode(
|
||||||
const QskSkinnable* skinnable, QSGNode* node,
|
const QskSkinnable* skinnable, QSGNode* node,
|
||||||
const QskGraphic& graphic, QskAspect::Subcontrol subcontrol ) const
|
const QskGraphic& graphic, QskAspect::Subcontrol subcontrol,
|
||||||
|
Qt::Orientations mirrored ) const
|
||||||
{
|
{
|
||||||
const QRectF rect = qskSubControlRect( this, skinnable, subcontrol );
|
const QRectF rect = qskSubControlRect( this, skinnable, subcontrol );
|
||||||
|
|
||||||
@ -561,13 +563,13 @@ QSGNode* QskSkinlet::updateGraphicNode(
|
|||||||
const auto colorFilter = skinnable->effectiveGraphicFilter( subcontrol );
|
const auto colorFilter = skinnable->effectiveGraphicFilter( subcontrol );
|
||||||
|
|
||||||
return updateGraphicNode( skinnable, node,
|
return updateGraphicNode( skinnable, node,
|
||||||
graphic, colorFilter, rect, alignment );
|
graphic, colorFilter, rect, alignment, mirrored );
|
||||||
}
|
}
|
||||||
|
|
||||||
QSGNode* QskSkinlet::updateGraphicNode(
|
QSGNode* QskSkinlet::updateGraphicNode(
|
||||||
const QskSkinnable* skinnable, QSGNode* node,
|
const QskSkinnable* skinnable, QSGNode* node,
|
||||||
const QskGraphic& graphic, const QskColorFilter& colorFilter,
|
const QskGraphic& graphic, const QskColorFilter& colorFilter,
|
||||||
const QRectF& rect, Qt::Alignment alignment )
|
const QRectF& rect, Qt::Alignment alignment, Qt::Orientations mirrored )
|
||||||
{
|
{
|
||||||
if ( graphic.isNull() )
|
if ( graphic.isNull() )
|
||||||
return nullptr;
|
return nullptr;
|
||||||
@ -576,18 +578,18 @@ QSGNode* QskSkinlet::updateGraphicNode(
|
|||||||
rect.size(), Qt::KeepAspectRatio );
|
rect.size(), Qt::KeepAspectRatio );
|
||||||
|
|
||||||
const QRectF r = qskAlignedRectF( rect, size.width(), size.height(), alignment );
|
const QRectF r = qskAlignedRectF( rect, size.width(), size.height(), alignment );
|
||||||
return qskUpdateGraphicNode( skinnable, node, graphic, colorFilter, r );
|
return qskUpdateGraphicNode( skinnable, node, graphic, colorFilter, r, mirrored );
|
||||||
}
|
}
|
||||||
|
|
||||||
QSGNode* QskSkinlet::updateGraphicNode(
|
QSGNode* QskSkinlet::updateGraphicNode(
|
||||||
const QskSkinnable* skinnable, QSGNode* node,
|
const QskSkinnable* skinnable, QSGNode* node,
|
||||||
const QskGraphic& graphic, const QskColorFilter& colorFilter,
|
const QskGraphic& graphic, const QskColorFilter& colorFilter,
|
||||||
const QRectF& rect )
|
const QRectF& rect, Qt::Orientations mirrored )
|
||||||
{
|
{
|
||||||
if ( graphic.isNull() )
|
if ( graphic.isNull() )
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
|
||||||
return qskUpdateGraphicNode( skinnable, node, graphic, colorFilter, rect );
|
return qskUpdateGraphicNode( skinnable, node, graphic, colorFilter, rect, mirrored );
|
||||||
}
|
}
|
||||||
|
|
||||||
#include "moc_QskSkinlet.cpp"
|
#include "moc_QskSkinlet.cpp"
|
||||||
|
@ -66,11 +66,12 @@ class QSK_EXPORT QskSkinlet
|
|||||||
// keeping the aspect ratio
|
// keeping the aspect ratio
|
||||||
static QSGNode* updateGraphicNode( const QskSkinnable*, QSGNode*,
|
static QSGNode* updateGraphicNode( const QskSkinnable*, QSGNode*,
|
||||||
const QskGraphic&, const QskColorFilter&,
|
const QskGraphic&, const QskColorFilter&,
|
||||||
const QRectF&, Qt::Alignment );
|
const QRectF&, Qt::Alignment, Qt::Orientations mirrored = Qt::Orientations() );
|
||||||
|
|
||||||
// stretching to fit
|
// stretching to fit
|
||||||
static QSGNode* updateGraphicNode( const QskSkinnable*, QSGNode*,
|
static QSGNode* updateGraphicNode( const QskSkinnable*, QSGNode*,
|
||||||
const QskGraphic&, const QskColorFilter&, const QRectF& );
|
const QskGraphic&, const QskColorFilter&, const QRectF&,
|
||||||
|
Qt::Orientations mirrored = Qt::Orientations() );
|
||||||
|
|
||||||
static QSGNode* updateBoxClipNode( const QskSkinnable*, QSGNode*,
|
static QSGNode* updateBoxClipNode( const QskSkinnable*, QSGNode*,
|
||||||
const QRectF&, QskAspect::Subcontrol );
|
const QRectF&, QskAspect::Subcontrol );
|
||||||
@ -98,7 +99,8 @@ class QSK_EXPORT QskSkinlet
|
|||||||
const QString&, const QskTextOptions&, QskAspect::Subcontrol ) const;
|
const QString&, const QskTextOptions&, QskAspect::Subcontrol ) const;
|
||||||
|
|
||||||
QSGNode* updateGraphicNode( const QskSkinnable*, QSGNode*,
|
QSGNode* updateGraphicNode( const QskSkinnable*, QSGNode*,
|
||||||
const QskGraphic&, QskAspect::Subcontrol ) const;
|
const QskGraphic&, QskAspect::Subcontrol,
|
||||||
|
Qt::Orientations mirrored = Qt::Orientations() ) const;
|
||||||
|
|
||||||
void insertRemoveNodes( QSGNode* parentNode,
|
void insertRemoveNodes( QSGNode* parentNode,
|
||||||
QSGNode* oldNode, QSGNode* newNode, quint8 nodeRole ) const;
|
QSGNode* oldNode, QSGNode* newNode, quint8 nodeRole ) const;
|
||||||
|
@ -47,8 +47,9 @@ QskGraphicNode::~QskGraphicNode()
|
|||||||
}
|
}
|
||||||
|
|
||||||
void QskGraphicNode::setGraphic(
|
void QskGraphicNode::setGraphic(
|
||||||
const QskGraphic& graphic, const QskColorFilter& colorFilter,
|
QQuickWindow* window, const QskGraphic& graphic, const QskColorFilter& colorFilter,
|
||||||
QskTextureRenderer::RenderMode renderMode, const QRectF& rect )
|
QskTextureRenderer::RenderMode renderMode, const QRectF& rect,
|
||||||
|
Qt::Orientations mirrored )
|
||||||
{
|
{
|
||||||
bool isTextureDirty = isNull();
|
bool isTextureDirty = isNull();
|
||||||
|
|
||||||
@ -75,20 +76,20 @@ void QskGraphicNode::setGraphic(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
QskTextureNode::setRect( rect );
|
const auto hash = qskHash( graphic, colorFilter, renderMode );
|
||||||
|
|
||||||
const uint hash = qskHash( graphic, colorFilter, renderMode );
|
|
||||||
if ( hash != m_hash )
|
if ( hash != m_hash )
|
||||||
{
|
{
|
||||||
m_hash = hash;
|
m_hash = hash;
|
||||||
isTextureDirty = true;
|
isTextureDirty = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
auto textureId = QskTextureNode::textureId();
|
||||||
|
|
||||||
if ( isTextureDirty )
|
if ( isTextureDirty )
|
||||||
{
|
{
|
||||||
const uint textureId = QskTextureRenderer::createTextureFromGraphic(
|
textureId = QskTextureRenderer::createTextureFromGraphic(
|
||||||
renderMode, textureSize, graphic, colorFilter, Qt::IgnoreAspectRatio );
|
renderMode, textureSize, graphic, colorFilter, Qt::IgnoreAspectRatio );
|
||||||
|
|
||||||
QskTextureNode::setTextureId( textureId );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QskTextureNode::setTexture( window, rect, textureId, mirrored );
|
||||||
}
|
}
|
||||||
|
@ -11,6 +11,7 @@
|
|||||||
|
|
||||||
class QskGraphic;
|
class QskGraphic;
|
||||||
class QskColorFilter;
|
class QskColorFilter;
|
||||||
|
class QQuickWindow;
|
||||||
|
|
||||||
class QSK_EXPORT QskGraphicNode : public QskTextureNode
|
class QSK_EXPORT QskGraphicNode : public QskTextureNode
|
||||||
{
|
{
|
||||||
@ -18,12 +19,14 @@ class QSK_EXPORT QskGraphicNode : public QskTextureNode
|
|||||||
QskGraphicNode();
|
QskGraphicNode();
|
||||||
~QskGraphicNode() override;
|
~QskGraphicNode() override;
|
||||||
|
|
||||||
void setGraphic( const QskGraphic&, const QskColorFilter&,
|
void setGraphic( QQuickWindow*,
|
||||||
QskTextureRenderer::RenderMode, const QRectF& );
|
const QskGraphic&, const QskColorFilter&,
|
||||||
|
QskTextureRenderer::RenderMode, const QRectF&,
|
||||||
|
Qt::Orientations mirrored = Qt::Orientations() );
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void setTextureId( int ) = delete;
|
void setTexture( QQuickWindow*,
|
||||||
void setRect( const QRectF& ) = delete;
|
const QRectF&, uint id, Qt::Orientations ) = delete;
|
||||||
|
|
||||||
uint m_hash;
|
uint m_hash;
|
||||||
};
|
};
|
||||||
|
@ -31,7 +31,7 @@ QskPaintedNode::~QskPaintedNode()
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
void QskPaintedNode::update(
|
void QskPaintedNode::update( QQuickWindow* window,
|
||||||
QskTextureRenderer::RenderMode renderMode, const QRect& rect )
|
QskTextureRenderer::RenderMode renderMode, const QRect& rect )
|
||||||
{
|
{
|
||||||
bool isTextureDirty = isNull();
|
bool isTextureDirty = isNull();
|
||||||
@ -43,21 +43,21 @@ void QskPaintedNode::update(
|
|||||||
( rect.height() != static_cast< int >( oldRect.height() ) );
|
( rect.height() != static_cast< int >( oldRect.height() ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
QskTextureNode::setRect( rect );
|
const auto newHash = hash();
|
||||||
|
|
||||||
const uint newHash = hash();
|
|
||||||
if ( ( newHash == 0 ) || ( newHash != m_hash ) )
|
if ( ( newHash == 0 ) || ( newHash != m_hash ) )
|
||||||
{
|
{
|
||||||
m_hash = newHash;
|
m_hash = newHash;
|
||||||
isTextureDirty = true;
|
isTextureDirty = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
auto textureId = QskTextureNode::textureId();
|
||||||
|
|
||||||
if ( isTextureDirty )
|
if ( isTextureDirty )
|
||||||
{
|
{
|
||||||
PaintHelper helper( this );
|
PaintHelper helper( this );
|
||||||
const uint textureId =
|
textureId = QskTextureRenderer::createTexture(
|
||||||
QskTextureRenderer::createTexture( renderMode, rect.size(), &helper );
|
renderMode, rect.size(), &helper );
|
||||||
|
|
||||||
QskTextureNode::setTextureId( textureId );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QskTextureNode::setTexture( window, rect, textureId );
|
||||||
}
|
}
|
||||||
|
@ -15,7 +15,8 @@ class QSK_EXPORT QskPaintedNode : public QskTextureNode
|
|||||||
QskPaintedNode();
|
QskPaintedNode();
|
||||||
~QskPaintedNode() override;
|
~QskPaintedNode() override;
|
||||||
|
|
||||||
void update( QskTextureRenderer::RenderMode, const QRect& );
|
void update( QQuickWindow*,
|
||||||
|
QskTextureRenderer::RenderMode, const QRect& );
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual void paint( QPainter*, const QSizeF& ) = 0;
|
virtual void paint( QPainter*, const QSizeF& ) = 0;
|
||||||
@ -26,8 +27,8 @@ class QSK_EXPORT QskPaintedNode : public QskTextureNode
|
|||||||
private:
|
private:
|
||||||
class PaintHelper;
|
class PaintHelper;
|
||||||
|
|
||||||
void setTextureId( int ) = delete;
|
void setTexture( QQuickWindow*,
|
||||||
void setRect( const QRectF& ) = delete;
|
const QRectF&, uint id, Qt::Orientations ) = delete;
|
||||||
|
|
||||||
uint m_hash;
|
uint m_hash;
|
||||||
};
|
};
|
||||||
|
@ -4,8 +4,12 @@
|
|||||||
#include <qopenglfunctions.h>
|
#include <qopenglfunctions.h>
|
||||||
#include <qsggeometry.h>
|
#include <qsggeometry.h>
|
||||||
#include <qsgmaterial.h>
|
#include <qsgmaterial.h>
|
||||||
|
#include <qquickwindow.h>
|
||||||
|
|
||||||
|
QSK_QT_PRIVATE_BEGIN
|
||||||
#include <private/qsgnode_p.h>
|
#include <private/qsgnode_p.h>
|
||||||
|
QSK_QT_PRIVATE_END
|
||||||
|
|
||||||
|
|
||||||
namespace
|
namespace
|
||||||
{
|
{
|
||||||
@ -148,23 +152,25 @@ class QskTextureNodePrivate final : public QSGGeometryNodePrivate
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
void updateTextureGeometry()
|
void setTextureId( QQuickWindow*, uint id );
|
||||||
|
|
||||||
|
void updateTextureGeometry( const QQuickWindow* window )
|
||||||
{
|
{
|
||||||
QRectF r( 0, 0, 1, 1 );
|
QRectF r( 0, 0, 1, 1 );
|
||||||
|
|
||||||
if ( this->mirrorOrientations & Qt::Horizontal )
|
if ( this->mirrored & Qt::Horizontal )
|
||||||
{
|
{
|
||||||
r.setLeft( 1 );
|
r.setLeft( 1 );
|
||||||
r.setRight( 0 );
|
r.setRight( 0 );
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( mirrorOrientations & Qt::Vertical )
|
if ( mirrored & Qt::Vertical )
|
||||||
{
|
{
|
||||||
r.setTop( 1 );
|
r.setTop( 1 );
|
||||||
r.setBottom( 0 );
|
r.setBottom( 0 );
|
||||||
}
|
}
|
||||||
|
|
||||||
const qreal ratio = QskTextureRenderer::devicePixelRatio();
|
const qreal ratio = window->effectiveDevicePixelRatio();
|
||||||
|
|
||||||
const QRectF scaledRect( rect.x(), rect.y(),
|
const QRectF scaledRect( rect.x(), rect.y(),
|
||||||
rect.width() / ratio, rect.height() / ratio );
|
rect.width() / ratio, rect.height() / ratio );
|
||||||
@ -178,7 +184,7 @@ class QskTextureNodePrivate final : public QSGGeometryNodePrivate
|
|||||||
Material material;
|
Material material;
|
||||||
|
|
||||||
QRectF rect;
|
QRectF rect;
|
||||||
Qt::Orientations mirrorOrientations;
|
Qt::Orientations mirrored;
|
||||||
};
|
};
|
||||||
|
|
||||||
QskTextureNode::QskTextureNode()
|
QskTextureNode::QskTextureNode()
|
||||||
@ -212,63 +218,41 @@ QskTextureNode::~QskTextureNode()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void QskTextureNode::setRect( const QRectF& r )
|
void QskTextureNode::setTexture( QQuickWindow* window,
|
||||||
|
const QRectF& rect, uint textureId,
|
||||||
|
Qt::Orientations mirrored )
|
||||||
{
|
{
|
||||||
Q_D( QskTextureNode );
|
Q_D( QskTextureNode );
|
||||||
|
|
||||||
if ( d->rect != r )
|
if ( d->rect != rect || d->mirrored != mirrored )
|
||||||
{
|
{
|
||||||
d->rect = r;
|
d->rect = rect;
|
||||||
d->updateTextureGeometry();
|
d->mirrored = mirrored;
|
||||||
|
|
||||||
|
d->updateTextureGeometry( window );
|
||||||
|
|
||||||
markDirty( DirtyGeometry );
|
markDirty( DirtyGeometry );
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
QRectF QskTextureNode::rect() const
|
if ( textureId != this->textureId() )
|
||||||
{
|
|
||||||
Q_D( const QskTextureNode );
|
|
||||||
return d->rect;
|
|
||||||
}
|
|
||||||
|
|
||||||
void QskTextureNode::setMirrored( Qt::Orientations orientations )
|
|
||||||
{
|
|
||||||
Q_D( QskTextureNode );
|
|
||||||
|
|
||||||
if ( d->mirrorOrientations != orientations )
|
|
||||||
{
|
{
|
||||||
d->mirrorOrientations = orientations;
|
d->setTextureId( window, textureId );
|
||||||
d->updateTextureGeometry();
|
|
||||||
|
|
||||||
markDirty( DirtyMaterial );
|
markDirty( DirtyMaterial );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Qt::Orientations QskTextureNode::mirrored() const
|
void QskTextureNodePrivate::setTextureId( QQuickWindow*, uint textureId )
|
||||||
{
|
{
|
||||||
Q_D( const QskTextureNode );
|
if ( this->material.textureId() > 0 )
|
||||||
return d->mirrorOrientations;
|
|
||||||
}
|
|
||||||
|
|
||||||
void QskTextureNode::setTextureId( uint textureId )
|
|
||||||
{
|
|
||||||
Q_D( QskTextureNode );
|
|
||||||
|
|
||||||
if ( textureId == d->material.textureId() )
|
|
||||||
return;
|
|
||||||
|
|
||||||
if ( d->material.textureId() > 0 )
|
|
||||||
{
|
{
|
||||||
GLuint id = d->material.textureId();
|
GLuint id = this->material.textureId();
|
||||||
|
|
||||||
auto funcs = QOpenGLContext::currentContext()->functions();
|
auto funcs = QOpenGLContext::currentContext()->functions();
|
||||||
funcs->glDeleteTextures( 1, &id );
|
funcs->glDeleteTextures( 1, &id );
|
||||||
}
|
}
|
||||||
|
|
||||||
d->material.setTextureId( textureId );
|
this->material.setTextureId( textureId );
|
||||||
d->opaqueMaterial.setTextureId( textureId );
|
this->opaqueMaterial.setTextureId( textureId );
|
||||||
|
|
||||||
markDirty( DirtyMaterial );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
uint QskTextureNode::textureId() const
|
uint QskTextureNode::textureId() const
|
||||||
@ -277,9 +261,19 @@ uint QskTextureNode::textureId() const
|
|||||||
return d->material.textureId();
|
return d->material.textureId();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool QskTextureNode::isNull() const
|
bool QskTextureNode::isNull() const
|
||||||
{
|
{
|
||||||
Q_D( const QskTextureNode );
|
return textureId() == 0;
|
||||||
return d->material.textureId() == 0;
|
}
|
||||||
|
|
||||||
|
QRectF QskTextureNode::rect() const
|
||||||
|
{
|
||||||
|
Q_D( const QskTextureNode );
|
||||||
|
return d->rect;
|
||||||
|
}
|
||||||
|
|
||||||
|
Qt::Orientations QskTextureNode::mirrored() const
|
||||||
|
{
|
||||||
|
Q_D( const QskTextureNode );
|
||||||
|
return d->mirrored;
|
||||||
}
|
}
|
||||||
|
@ -11,6 +11,7 @@
|
|||||||
#include <qnamespace.h>
|
#include <qnamespace.h>
|
||||||
#include <qsgnode.h>
|
#include <qsgnode.h>
|
||||||
|
|
||||||
|
class QQuickWindow;
|
||||||
class QskTextureNodePrivate;
|
class QskTextureNodePrivate;
|
||||||
|
|
||||||
class QSK_EXPORT QskTextureNode : public QSGGeometryNode
|
class QSK_EXPORT QskTextureNode : public QSGGeometryNode
|
||||||
@ -21,13 +22,11 @@ class QSK_EXPORT QskTextureNode : public QSGGeometryNode
|
|||||||
|
|
||||||
bool isNull() const;
|
bool isNull() const;
|
||||||
|
|
||||||
void setRect( const QRectF& );
|
void setTexture( QQuickWindow*, const QRectF&, uint id,
|
||||||
QRectF rect() const;
|
Qt::Orientations mirrored = Qt::Orientations() );
|
||||||
|
|
||||||
void setTextureId( uint id );
|
|
||||||
uint textureId() const;
|
uint textureId() const;
|
||||||
|
QRectF rect() const;
|
||||||
void setMirrored( Qt::Orientations );
|
|
||||||
Qt::Orientations mirrored() const;
|
Qt::Orientations mirrored() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
@ -18,11 +18,7 @@
|
|||||||
#include <qimage.h>
|
#include <qimage.h>
|
||||||
#include <qpainter.h>
|
#include <qpainter.h>
|
||||||
|
|
||||||
#include <qguiapplication.h>
|
|
||||||
#include <qquickwindow.h>
|
#include <qquickwindow.h>
|
||||||
#include <qscreen.h>
|
|
||||||
#include <qsurface.h>
|
|
||||||
|
|
||||||
#include <qsgtexture.h>
|
#include <qsgtexture.h>
|
||||||
|
|
||||||
#if QT_VERSION >= QT_VERSION_CHECK( 6, 0, 0 )
|
#if QT_VERSION >= QT_VERSION_CHECK( 6, 0, 0 )
|
||||||
@ -220,36 +216,3 @@ uint QskTextureRenderer::createTextureFromGraphic(
|
|||||||
PaintHelper helper( graphic, colorFilter, aspectRatioMode );
|
PaintHelper helper( graphic, colorFilter, aspectRatioMode );
|
||||||
return createTexture( renderMode, size, &helper );
|
return createTexture( renderMode, size, &helper );
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline qreal qskOffscreenBufferRatio( const QOpenGLContext* context )
|
|
||||||
{
|
|
||||||
if ( context->screen() )
|
|
||||||
return context->screen()->devicePixelRatio();
|
|
||||||
|
|
||||||
return qGuiApp->devicePixelRatio();
|
|
||||||
}
|
|
||||||
|
|
||||||
qreal QskTextureRenderer::devicePixelRatio( const QOpenGLContext* context )
|
|
||||||
{
|
|
||||||
if ( context == nullptr )
|
|
||||||
context = QOpenGLContext::currentContext();
|
|
||||||
|
|
||||||
qreal ratio = 1.0;
|
|
||||||
|
|
||||||
if ( context->surface()->surfaceClass() == QSurface::Window )
|
|
||||||
{
|
|
||||||
auto* window = static_cast< QWindow* >( context->surface() );
|
|
||||||
|
|
||||||
if ( auto* quickWindow = qobject_cast< QQuickWindow* >( window ) )
|
|
||||||
ratio = quickWindow->effectiveDevicePixelRatio();
|
|
||||||
else
|
|
||||||
ratio = window->devicePixelRatio();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
ratio = qskOffscreenBufferRatio( context );
|
|
||||||
}
|
|
||||||
|
|
||||||
return ratio;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
@ -14,7 +14,6 @@ class QskColorFilter;
|
|||||||
|
|
||||||
class QPainter;
|
class QPainter;
|
||||||
class QSize;
|
class QSize;
|
||||||
class QOpenGLContext;
|
|
||||||
class QSGTexture;
|
class QSGTexture;
|
||||||
class QQuickWindow;
|
class QQuickWindow;
|
||||||
|
|
||||||
@ -52,8 +51,6 @@ namespace QskTextureRenderer
|
|||||||
|
|
||||||
QSK_EXPORT QSGTexture* textureFromId(
|
QSK_EXPORT QSGTexture* textureFromId(
|
||||||
QQuickWindow*, uint textureId, const QSize& );
|
QQuickWindow*, uint textureId, const QSize& );
|
||||||
|
|
||||||
QSK_EXPORT qreal devicePixelRatio( const QOpenGLContext* = nullptr );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
x
Reference in New Issue
Block a user