introducing QskHashValue to work around Qt5/6 incompatibilities
This commit is contained in:
parent
04ec8b52a1
commit
55d5f99575
@ -34,7 +34,7 @@ void RadialTickmarksNode::update( const QColor& color, const QRectF& rect,
|
||||
markDirty( QSGNode::DirtyGeometry );
|
||||
}
|
||||
|
||||
const uint hash = tickmarks.hash( 17435 );
|
||||
const auto hash = tickmarks.hash( 17435 );
|
||||
|
||||
if( ( hash != m_hash ) || ( rect != m_rect ) )
|
||||
{
|
||||
|
@ -29,5 +29,5 @@ class RadialTickmarksNode : public QSGGeometryNode
|
||||
QRectF m_rect;
|
||||
int m_lineWidth = 0;
|
||||
|
||||
uint m_hash = 0;
|
||||
QskHashValue m_hash = 0;
|
||||
};
|
||||
|
@ -86,9 +86,9 @@ QskArcMetrics QskArcMetrics::toAbsolute( const QSizeF& size ) const noexcept
|
||||
return absoluted;
|
||||
}
|
||||
|
||||
uint QskArcMetrics::hash( uint seed ) const noexcept
|
||||
QskHashValue QskArcMetrics::hash( QskHashValue seed ) const noexcept
|
||||
{
|
||||
uint hash = qHash( m_width, seed );
|
||||
auto hash = qHash( m_width, seed );
|
||||
hash = qHash( m_startAngle, hash );
|
||||
hash = qHash( m_spanAngle, hash );
|
||||
|
||||
|
@ -50,7 +50,7 @@ class QSK_EXPORT QskArcMetrics
|
||||
|
||||
QskArcMetrics toAbsolute( const QSizeF& ) const noexcept;
|
||||
|
||||
uint hash( uint seed = 0 ) const noexcept;
|
||||
QskHashValue hash( QskHashValue seed = 0 ) const noexcept;
|
||||
|
||||
static QVariant interpolate( const QskArcMetrics&,
|
||||
const QskArcMetrics&, qreal progress );
|
||||
|
@ -185,9 +185,9 @@ QVariant QskBoxBorderColors::interpolate(
|
||||
return QVariant::fromValue( from.interpolated( to, ratio ) );
|
||||
}
|
||||
|
||||
uint QskBoxBorderColors::hash( uint seed ) const
|
||||
QskHashValue QskBoxBorderColors::hash( QskHashValue seed ) const
|
||||
{
|
||||
uint h = m_gradients[ 0 ].hash( seed );
|
||||
auto h = m_gradients[ 0 ].hash( seed );
|
||||
h = m_gradients[ 1 ].hash( h );
|
||||
h = m_gradients[ 2 ].hash( h );
|
||||
h = m_gradients[ 3 ].hash( h );
|
||||
|
@ -49,7 +49,7 @@ class QSK_EXPORT QskBoxBorderColors
|
||||
static QVariant interpolate( const QskBoxBorderColors&,
|
||||
const QskBoxBorderColors&, qreal ratio );
|
||||
|
||||
uint hash( uint seed = 0 ) const;
|
||||
QskHashValue hash( QskHashValue seed = 0 ) const;
|
||||
|
||||
bool isMonochrome() const;
|
||||
bool isVisible() const;
|
||||
|
@ -92,9 +92,9 @@ QVariant QskBoxBorderMetrics::interpolate(
|
||||
return QVariant::fromValue( from.interpolated( to, progress ) );
|
||||
}
|
||||
|
||||
uint QskBoxBorderMetrics::hash( uint seed ) const noexcept
|
||||
QskHashValue QskBoxBorderMetrics::hash( QskHashValue seed ) const noexcept
|
||||
{
|
||||
uint hash = qHashBits( &m_widths, sizeof( m_widths ), seed );
|
||||
auto hash = qHashBits( &m_widths, sizeof( m_widths ), seed );
|
||||
|
||||
const int mode = m_sizeMode;
|
||||
return qHashBits( &mode, sizeof( mode ), hash );
|
||||
|
@ -55,7 +55,7 @@ class QSK_EXPORT QskBoxBorderMetrics
|
||||
|
||||
QskBoxBorderMetrics toAbsolute( const QSizeF& ) const noexcept;
|
||||
|
||||
uint hash( uint seed = 0 ) const noexcept;
|
||||
QskHashValue hash( QskHashValue seed = 0 ) const noexcept;
|
||||
|
||||
static QVariant interpolate( const QskBoxBorderMetrics&,
|
||||
const QskBoxBorderMetrics&, qreal progress );
|
||||
|
@ -151,9 +151,9 @@ QVariant QskBoxShapeMetrics::interpolate(
|
||||
return QVariant::fromValue( from.interpolated( to, progress ) );
|
||||
}
|
||||
|
||||
uint QskBoxShapeMetrics::hash( uint seed ) const noexcept
|
||||
QskHashValue QskBoxShapeMetrics::hash( QskHashValue seed ) const noexcept
|
||||
{
|
||||
uint hash = qHash( static_cast< int >( m_sizeMode ), seed );
|
||||
auto hash = qHash( static_cast< int >( m_sizeMode ), seed );
|
||||
return qHashBits( m_radii, sizeof( m_radii ), hash );
|
||||
}
|
||||
|
||||
|
@ -93,7 +93,7 @@ class QSK_EXPORT QskBoxShapeMetrics
|
||||
|
||||
constexpr QskBoxShapeMetrics transposed() const noexcept;
|
||||
|
||||
uint hash( uint seed = 0 ) const noexcept;
|
||||
QskHashValue hash( QskHashValue seed = 0 ) const noexcept;
|
||||
|
||||
static QVariant interpolate( const QskBoxShapeMetrics&,
|
||||
const QskBoxShapeMetrics&, qreal progress ) noexcept;
|
||||
|
@ -39,4 +39,10 @@
|
||||
#define QSK_QT_PRIVATE_END \
|
||||
QT_WARNING_POP
|
||||
|
||||
#if QT_VERSION < QT_VERSION_CHECK( 6, 0, 0 )
|
||||
using QskHashValue = uint;
|
||||
#else
|
||||
using QskHashValue = size_t;
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
@ -412,14 +412,14 @@ bool QskGradient::hasStopAt( qreal value ) const
|
||||
return false;
|
||||
}
|
||||
|
||||
uint QskGradient::hash( uint seed ) const
|
||||
QskHashValue QskGradient::hash( QskHashValue seed ) const
|
||||
{
|
||||
if ( m_stops.isEmpty() )
|
||||
return seed;
|
||||
|
||||
const auto o = orientation();
|
||||
|
||||
uint hash = qHashBits( &o, sizeof( o ), seed );
|
||||
auto hash = qHashBits( &o, sizeof( o ), seed );
|
||||
for ( const auto& stop : m_stops )
|
||||
hash = stop.hash( hash );
|
||||
|
||||
|
@ -96,7 +96,7 @@ class QSK_EXPORT QskGradient
|
||||
static QVariant interpolate( const QskGradient&,
|
||||
const QskGradient&, qreal progress );
|
||||
|
||||
uint hash( uint seed ) const;
|
||||
QskHashValue hash( QskHashValue seed ) const;
|
||||
|
||||
Q_INVOKABLE qreal stopAt( int index ) const;
|
||||
Q_INVOKABLE QColor colorAt( int index ) const;
|
||||
|
@ -44,9 +44,9 @@ void QskGradientStop::setStop( qreal position, const QColor& color ) noexcept
|
||||
m_color = color;
|
||||
}
|
||||
|
||||
uint QskGradientStop::hash( uint seed ) const noexcept
|
||||
QskHashValue QskGradientStop::hash( QskHashValue seed ) const noexcept
|
||||
{
|
||||
uint hash = qHashBits( &m_position, sizeof( m_position ), seed );
|
||||
auto hash = qHashBits( &m_position, sizeof( m_position ), seed );
|
||||
return qHashBits( &m_color, sizeof( m_color ), hash );
|
||||
}
|
||||
|
||||
|
@ -41,7 +41,7 @@ class QSK_EXPORT QskGradientStop
|
||||
static QColor interpolated(
|
||||
const QskGradientStop&, const QskGradientStop&, qreal position ) noexcept;
|
||||
|
||||
uint hash( uint seed ) const noexcept;
|
||||
QskHashValue hash( QskHashValue seed ) const noexcept;
|
||||
|
||||
private:
|
||||
qreal m_position;
|
||||
|
@ -63,7 +63,7 @@ void QskScaleTickmarks::invert()
|
||||
std::reverse( m_ticks[ 2 ].begin(), m_ticks[ 2 ].end() );
|
||||
}
|
||||
|
||||
uint QskScaleTickmarks::hash( uint seed ) const
|
||||
QskHashValue QskScaleTickmarks::hash( QskHashValue seed ) const
|
||||
{
|
||||
seed = qHash( m_ticks[0], seed );
|
||||
seed = qHash( m_ticks[1], seed );
|
||||
|
@ -53,7 +53,7 @@ class QSK_EXPORT QskScaleTickmarks
|
||||
void invert();
|
||||
void reset();
|
||||
|
||||
uint hash( uint seed = 0 ) const;
|
||||
QskHashValue hash( QskHashValue seed = 0 ) const;
|
||||
|
||||
private:
|
||||
QVector< qreal > m_ticks[ 3 ];
|
||||
|
@ -83,9 +83,9 @@ QRectF QskShadowMetrics::shadowRect( const QRectF& sourceRect ) const
|
||||
sourceRect.height() + 2 * extent );
|
||||
}
|
||||
|
||||
uint QskShadowMetrics::hash( uint seed ) const noexcept
|
||||
QskHashValue QskShadowMetrics::hash( QskHashValue seed ) const noexcept
|
||||
{
|
||||
uint hash;
|
||||
QskHashValue hash;
|
||||
|
||||
hash = qHash( m_offset.x(), seed );
|
||||
hash = qHash( m_offset.y(), seed );
|
||||
|
@ -56,7 +56,7 @@ class QSK_EXPORT QskShadowMetrics
|
||||
|
||||
QRectF shadowRect( const QRectF& sourceRect ) const;
|
||||
|
||||
uint hash( uint seed = 0 ) const noexcept;
|
||||
QskHashValue hash( QskHashValue seed = 0 ) const noexcept;
|
||||
|
||||
static QVariant interpolate( const QskShadowMetrics&,
|
||||
const QskShadowMetrics&, qreal progress );
|
||||
|
@ -9,7 +9,7 @@
|
||||
#include <qhashfunctions.h>
|
||||
#include <qvariant.h>
|
||||
|
||||
uint QskTextColors::hash( uint seed ) const
|
||||
QskHashValue QskTextColors::hash( QskHashValue seed ) const
|
||||
{
|
||||
const QRgb rgb[] = { textColor.rgba(), styleColor.rgba(), linkColor.rgba() };
|
||||
return qHashBits( rgb, sizeof( rgb ), seed );
|
||||
|
@ -25,7 +25,7 @@ class QSK_EXPORT QskTextColors
|
||||
static QVariant interpolate( const QskTextColors&,
|
||||
const QskTextColors&, qreal ratio );
|
||||
|
||||
uint hash( uint seed = 0 ) const;
|
||||
QskHashValue hash( QskHashValue seed = 0 ) const;
|
||||
|
||||
QColor textColor;
|
||||
QColor styleColor;
|
||||
|
@ -50,9 +50,9 @@ QskTextOptions::TextFormat QskTextOptions::effectiveFormat( const QString& text
|
||||
return m_format;
|
||||
}
|
||||
|
||||
uint qHash( const QskTextOptions& options, uint seed ) noexcept
|
||||
QskHashValue qHash( const QskTextOptions& options, QskHashValue seed ) noexcept
|
||||
{
|
||||
uint hash;
|
||||
QskHashValue hash;
|
||||
|
||||
hash = qHash( options.maximumLineCount(), seed );
|
||||
hash = qHash( options.fontSizeMode(), hash );
|
||||
|
@ -164,7 +164,7 @@ inline constexpr bool QskTextOptions::operator!=(
|
||||
return !( *this == other );
|
||||
}
|
||||
|
||||
QSK_EXPORT uint qHash( const QskTextOptions&, uint seed = 0 ) noexcept;
|
||||
QSK_EXPORT QskHashValue qHash( const QskTextOptions&, QskHashValue seed = 0 ) noexcept;
|
||||
|
||||
#ifndef QT_NO_DEBUG_STREAM
|
||||
class QDebug;
|
||||
|
@ -1007,7 +1007,7 @@ quint64 QskGraphic::modificationId() const
|
||||
return m_data->modificationId;
|
||||
}
|
||||
|
||||
uint QskGraphic::hash( uint seed ) const
|
||||
QskHashValue QskGraphic::hash( QskHashValue seed ) const
|
||||
{
|
||||
auto hash = qHash( m_data->renderHints, seed );
|
||||
|
||||
|
@ -127,7 +127,7 @@ class QSK_EXPORT QskGraphic : public QPaintDevice
|
||||
static QskGraphic fromPixmapAsImage( const QPixmap& );
|
||||
|
||||
quint64 modificationId() const;
|
||||
uint hash( uint seed ) const;
|
||||
QskHashValue hash( QskHashValue seed ) const;
|
||||
|
||||
protected:
|
||||
virtual QSize sizeMetrics() const;
|
||||
|
@ -32,9 +32,9 @@ void QskArcNode::paint( QPainter* painter, const QSizeF& size )
|
||||
renderer.renderArc( rect, m_metrics, m_gradient, painter );
|
||||
}
|
||||
|
||||
uint QskArcNode::hash() const
|
||||
QskHashValue QskArcNode::hash() const
|
||||
{
|
||||
uint h = m_metrics.hash();
|
||||
auto h = m_metrics.hash();
|
||||
|
||||
for( const auto& stop : qAsConst( m_gradient.stops() ) )
|
||||
h = stop.hash( h );
|
||||
|
@ -20,7 +20,7 @@ class QSK_EXPORT QskArcNode : public QskPaintedNode
|
||||
const QskGradient&, QQuickWindow* );
|
||||
|
||||
void paint( QPainter* painter, const QSizeF& size ) override;
|
||||
uint hash() const override;
|
||||
QskHashValue hash() const override;
|
||||
|
||||
private:
|
||||
QskArcMetrics m_metrics;
|
||||
|
@ -9,10 +9,10 @@
|
||||
#include "QskBoxShapeMetrics.h"
|
||||
#include "QskFunctions.h"
|
||||
|
||||
static inline uint qskMetricsHash(
|
||||
static inline QskHashValue qskMetricsHash(
|
||||
const QskBoxShapeMetrics& shape, const QskBoxBorderMetrics& border )
|
||||
{
|
||||
uint hash = 13000;
|
||||
QskHashValue hash = 13000;
|
||||
|
||||
hash = shape.hash( hash );
|
||||
return border.hash( hash );
|
||||
@ -32,7 +32,7 @@ QskBoxClipNode::~QskBoxClipNode()
|
||||
void QskBoxClipNode::setBox( const QRectF& rect,
|
||||
const QskBoxShapeMetrics& shape, const QskBoxBorderMetrics& border )
|
||||
{
|
||||
const uint hash = qskMetricsHash( shape, border );
|
||||
const auto hash = qskMetricsHash( shape, border );
|
||||
if ( hash == m_hash && rect == m_rect )
|
||||
return;
|
||||
|
||||
|
@ -22,7 +22,7 @@ class QSK_EXPORT QskBoxClipNode : public QSGClipNode
|
||||
const QskBoxShapeMetrics&, const QskBoxBorderMetrics& );
|
||||
|
||||
private:
|
||||
uint m_hash;
|
||||
QskHashValue m_hash;
|
||||
QRectF m_rect;
|
||||
|
||||
QSGGeometry m_geometry;
|
||||
|
@ -20,19 +20,19 @@ QSK_QT_PRIVATE_END
|
||||
|
||||
Q_GLOBAL_STATIC( QSGVertexColorMaterial, qskMaterialVertex )
|
||||
|
||||
static inline uint qskMetricsHash(
|
||||
static inline QskHashValue qskMetricsHash(
|
||||
const QskBoxShapeMetrics& shape, const QskBoxBorderMetrics& borderMetrics )
|
||||
{
|
||||
uint hash = 13000;
|
||||
QskHashValue hash = 13000;
|
||||
|
||||
hash = shape.hash( hash );
|
||||
return borderMetrics.hash( hash );
|
||||
}
|
||||
|
||||
static inline uint qskColorsHash(
|
||||
static inline QskHashValue qskColorsHash(
|
||||
const QskBoxBorderColors& borderColors, const QskGradient& fillGradient )
|
||||
{
|
||||
uint hash = 13000;
|
||||
QskHashValue hash = 13000;
|
||||
hash = borderColors.hash( hash );
|
||||
return fillGradient.hash( hash );
|
||||
}
|
||||
@ -45,8 +45,8 @@ class QskBoxNodePrivate final : public QSGGeometryNodePrivate
|
||||
{
|
||||
}
|
||||
|
||||
uint metricsHash = 0;
|
||||
uint colorsHash = 0;
|
||||
QskHashValue metricsHash = 0;
|
||||
QskHashValue colorsHash = 0;
|
||||
QRectF rect;
|
||||
|
||||
QSGGeometry geometry;
|
||||
@ -89,8 +89,8 @@ void QskBoxNode::setBoxData( const QRectF& rect,
|
||||
#endif
|
||||
|
||||
#if 1
|
||||
const uint metricsHash = qskMetricsHash( shape, borderMetrics );
|
||||
const uint colorsHash = qskColorsHash( borderColors, fillGradient );
|
||||
const auto metricsHash = qskMetricsHash( shape, borderMetrics );
|
||||
const auto colorsHash = qskColorsHash( borderColors, fillGradient );
|
||||
|
||||
if ( ( metricsHash == d->metricsHash ) &&
|
||||
( colorsHash == d->colorsHash ) && ( rect == d->rect ) )
|
||||
|
@ -8,11 +8,11 @@
|
||||
#include "QskColorFilter.h"
|
||||
#include "QskPainterCommand.h"
|
||||
|
||||
static inline uint qskHash(
|
||||
static inline QskHashValue qskHash(
|
||||
const QskGraphic& graphic, const QskColorFilter& colorFilter,
|
||||
QskTextureRenderer::RenderMode renderMode )
|
||||
{
|
||||
uint hash = 12000;
|
||||
QskHashValue hash = 12000;
|
||||
|
||||
const auto& substitutions = colorFilter.substitutions();
|
||||
if ( substitutions.size() > 0 )
|
||||
|
@ -28,7 +28,7 @@ class QSK_EXPORT QskGraphicNode : public QskTextureNode
|
||||
void setTexture( QQuickWindow*,
|
||||
const QRectF&, uint id, Qt::Orientations ) = delete;
|
||||
|
||||
uint m_hash;
|
||||
QskHashValue m_hash;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
@ -22,7 +22,7 @@ class QSK_EXPORT QskPaintedNode : public QskTextureNode
|
||||
virtual void paint( QPainter*, const QSizeF& ) = 0;
|
||||
|
||||
// a hash value of '0' always results in repainting
|
||||
virtual uint hash() const = 0;
|
||||
virtual QskHashValue hash() const = 0;
|
||||
|
||||
private:
|
||||
class PaintHelper;
|
||||
@ -30,7 +30,7 @@ class QSK_EXPORT QskPaintedNode : public QskTextureNode
|
||||
void setTexture( QQuickWindow*,
|
||||
const QRectF&, uint id, Qt::Orientations ) = delete;
|
||||
|
||||
uint m_hash;
|
||||
QskHashValue m_hash;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
@ -11,12 +11,12 @@
|
||||
#include <qfont.h>
|
||||
#include <qstring.h>
|
||||
|
||||
static inline uint qskHash(
|
||||
static inline QskHashValue qskHash(
|
||||
const QString& text, const QSizeF& size, const QFont& font,
|
||||
const QskTextOptions& options, const QskTextColors& colors,
|
||||
Qt::Alignment alignment, Qsk::TextStyle textStyle )
|
||||
{
|
||||
uint hash = 11000;
|
||||
QskHashValue hash = 11000;
|
||||
|
||||
hash = qHash( text, hash );
|
||||
hash = qHash( font, hash );
|
||||
@ -49,7 +49,7 @@ void QskTextNode::setTextData(
|
||||
if ( matrix != this->matrix() ) // avoid setting DirtyMatrix accidently
|
||||
setMatrix( matrix );
|
||||
|
||||
const uint hash = qskHash( text, rect.size(), font,
|
||||
const auto hash = qskHash( text, rect.size(), font,
|
||||
options, colors, alignment, textStyle );
|
||||
|
||||
if ( hash != m_hash )
|
||||
|
@ -29,7 +29,7 @@ class QSK_EXPORT QskTextNode : public QSGTransformNode
|
||||
Qt::Alignment, Qsk::TextStyle );
|
||||
|
||||
private:
|
||||
uint m_hash;
|
||||
QskHashValue m_hash;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
@ -34,7 +34,7 @@ class QskTickmarksNodePrivate final : public QSGGeometryNodePrivate
|
||||
QRectF rect;
|
||||
int lineWidth = 0;
|
||||
|
||||
uint hash = 0;
|
||||
QskHashValue hash = 0;
|
||||
};
|
||||
|
||||
QskTickmarksNode::QskTickmarksNode()
|
||||
@ -65,7 +65,7 @@ void QskTickmarksNode::update(
|
||||
markDirty( QSGNode::DirtyGeometry );
|
||||
}
|
||||
|
||||
const uint hash = tickmarks.hash( 17435 );
|
||||
const auto hash = tickmarks.hash( 17435 );
|
||||
|
||||
if( ( hash != d->hash ) || ( rect != d->rect ) )
|
||||
{
|
||||
|
Loading…
x
Reference in New Issue
Block a user