handling of primitives optimized
This commit is contained in:
parent
38f48a7cb0
commit
8426e71156
|
@ -36,6 +36,32 @@ namespace
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static quint8 qskPrimitiveCount[ 3 ] =
|
||||||
|
{ QskAspect::FontRole + 1, QskAspect::Border + 1, QskAspect::LinkColor + 1 };
|
||||||
|
|
||||||
|
quint8 QskAspect::primitiveCount( Type type )
|
||||||
|
{
|
||||||
|
return qskPrimitiveCount[ type ];
|
||||||
|
}
|
||||||
|
|
||||||
|
void QskAspect::reservePrimitives( Type type, quint8 count )
|
||||||
|
{
|
||||||
|
constexpr quint8 maxCount = 1 << 5; // we have 5 bits for the primitives
|
||||||
|
|
||||||
|
Q_ASSERT( count <= maxCount );
|
||||||
|
|
||||||
|
if ( count > maxCount )
|
||||||
|
{
|
||||||
|
qWarning() << "QskAspect: having more than"
|
||||||
|
<< maxCount << "primitives is not supported.";
|
||||||
|
|
||||||
|
count = maxCount;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( count > qskPrimitiveCount[ type ] )
|
||||||
|
qskPrimitiveCount[ type ] = count;
|
||||||
|
}
|
||||||
|
|
||||||
Q_GLOBAL_STATIC( AspectRegistry, qskAspectRegistry )
|
Q_GLOBAL_STATIC( AspectRegistry, qskAspectRegistry )
|
||||||
|
|
||||||
QskAspect::State QskAspect::registerState(
|
QskAspect::State QskAspect::registerState(
|
||||||
|
@ -201,27 +227,27 @@ static inline QDebug qskDebugEnum(
|
||||||
return debug;
|
return debug;
|
||||||
}
|
}
|
||||||
|
|
||||||
QDebug operator<<( QDebug debug, const QskAspect::Type& type )
|
QDebug operator<<( QDebug debug, QskAspect::Type type )
|
||||||
{
|
{
|
||||||
return qskDebugEnum( debug, "Type", type );
|
return qskDebugEnum( debug, "Type", type );
|
||||||
}
|
}
|
||||||
|
|
||||||
QDebug operator<<( QDebug debug, const QskAspect::FlagPrimitive& primitive )
|
QDebug operator<<( QDebug debug, QskAspect::FlagPrimitive primitive )
|
||||||
{
|
{
|
||||||
return qskDebugEnum( debug, "FlagPrimitive", primitive );
|
return qskDebugEnum( debug, "FlagPrimitive", primitive );
|
||||||
}
|
}
|
||||||
|
|
||||||
QDebug operator<<( QDebug debug, const QskAspect::ColorPrimitive& primitive )
|
QDebug operator<<( QDebug debug, QskAspect::ColorPrimitive primitive )
|
||||||
{
|
{
|
||||||
return qskDebugEnum( debug, "ColorPrimitive", primitive );
|
return qskDebugEnum( debug, "ColorPrimitive", primitive );
|
||||||
}
|
}
|
||||||
|
|
||||||
QDebug operator<<( QDebug debug, const QskAspect::MetricPrimitive& primitive )
|
QDebug operator<<( QDebug debug, QskAspect::MetricPrimitive primitive )
|
||||||
{
|
{
|
||||||
return qskDebugEnum( debug, "MetricPrimitive", primitive );
|
return qskDebugEnum( debug, "MetricPrimitive", primitive );
|
||||||
}
|
}
|
||||||
|
|
||||||
QDebug operator<<( QDebug debug, const QskAspect::Subcontrol& subControl )
|
QDebug operator<<( QDebug debug, QskAspect::Subcontrol subControl )
|
||||||
{
|
{
|
||||||
QDebugStateSaver saver( debug );
|
QDebugStateSaver saver( debug );
|
||||||
|
|
||||||
|
@ -233,19 +259,19 @@ QDebug operator<<( QDebug debug, const QskAspect::Subcontrol& subControl )
|
||||||
return debug;
|
return debug;
|
||||||
}
|
}
|
||||||
|
|
||||||
QDebug operator<<( QDebug debug, const QskAspect::Placement& placement )
|
QDebug operator<<( QDebug debug, QskAspect::Placement placement )
|
||||||
{
|
{
|
||||||
qskDebugEnum( debug, "Placement", placement );
|
qskDebugEnum( debug, "Placement", placement );
|
||||||
return debug;
|
return debug;
|
||||||
}
|
}
|
||||||
|
|
||||||
QDebug operator<<( QDebug debug, const QskAspect::State& state )
|
QDebug operator<<( QDebug debug, QskAspect::State state )
|
||||||
{
|
{
|
||||||
qskDebugState( debug, nullptr, state );
|
qskDebugState( debug, nullptr, state );
|
||||||
return debug;
|
return debug;
|
||||||
}
|
}
|
||||||
|
|
||||||
QDebug operator<<( QDebug debug, const QskAspect::Aspect& aspect )
|
QDebug operator<<( QDebug debug, QskAspect::Aspect aspect )
|
||||||
{
|
{
|
||||||
qskDebugAspect( debug, nullptr, aspect );
|
qskDebugAspect( debug, nullptr, aspect );
|
||||||
return debug;
|
return debug;
|
||||||
|
@ -264,8 +290,6 @@ void qskDebugState( QDebug debug, const QMetaObject* metaObject, QskAspect::Stat
|
||||||
|
|
||||||
void qskDebugAspect( QDebug debug, const QMetaObject* metaObject, QskAspect::Aspect aspect )
|
void qskDebugAspect( QDebug debug, const QMetaObject* metaObject, QskAspect::Aspect aspect )
|
||||||
{
|
{
|
||||||
using namespace QskAspect;
|
|
||||||
|
|
||||||
QDebugStateSaver saver( debug );
|
QDebugStateSaver saver( debug );
|
||||||
|
|
||||||
debug.resetFormat();
|
debug.resetFormat();
|
||||||
|
@ -286,13 +310,13 @@ void qskDebugAspect( QDebug debug, const QMetaObject* metaObject, QskAspect::Asp
|
||||||
|
|
||||||
switch ( aspect.type() )
|
switch ( aspect.type() )
|
||||||
{
|
{
|
||||||
case Color:
|
case QskAspect::Color:
|
||||||
{
|
{
|
||||||
if ( aspect.colorPrimitive() != 0 )
|
if ( aspect.colorPrimitive() != 0 )
|
||||||
debug << ", " << qskEnumString( "ColorPrimitive", aspect.colorPrimitive() );
|
debug << ", " << qskEnumString( "ColorPrimitive", aspect.colorPrimitive() );
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case Metric:
|
case QskAspect::Metric:
|
||||||
{
|
{
|
||||||
if ( aspect.metricPrimitive() != 0 )
|
if ( aspect.metricPrimitive() != 0 )
|
||||||
debug << ", " << qskEnumString( "MetricPrimitive", aspect.metricPrimitive() );
|
debug << ", " << qskEnumString( "MetricPrimitive", aspect.metricPrimitive() );
|
||||||
|
|
|
@ -51,7 +51,7 @@ QSK_NAMESPACE( QskAspect )
|
||||||
};
|
};
|
||||||
QSK_ENUM( Type )
|
QSK_ENUM( Type )
|
||||||
|
|
||||||
enum { LastType = Color }; // max. value for all types
|
constexpr uint typeCount = 3;
|
||||||
|
|
||||||
enum FlagPrimitive : quint8
|
enum FlagPrimitive : quint8
|
||||||
{
|
{
|
||||||
|
@ -209,9 +209,9 @@ namespace QskAspect
|
||||||
uint type : 3;
|
uint type : 3;
|
||||||
uint isAnimator : 1;
|
uint isAnimator : 1;
|
||||||
|
|
||||||
uint primitive : 7;
|
uint primitive : 5;
|
||||||
uint placement : 3;
|
uint placement : 3;
|
||||||
uint reserved1 : 6;
|
uint reserved1 : 8;
|
||||||
|
|
||||||
uint states : 16;
|
uint states : 16;
|
||||||
uint reserved2 : 16;
|
uint reserved2 : 16;
|
||||||
|
@ -537,6 +537,10 @@ namespace QskAspect
|
||||||
QSK_EXPORT QByteArray subControlName( Subcontrol );
|
QSK_EXPORT QByteArray subControlName( Subcontrol );
|
||||||
QSK_EXPORT QVector< QByteArray > subControlNames( const QMetaObject* = nullptr );
|
QSK_EXPORT QVector< QByteArray > subControlNames( const QMetaObject* = nullptr );
|
||||||
QSK_EXPORT QVector< Subcontrol > subControls( const QMetaObject* );
|
QSK_EXPORT QVector< Subcontrol > subControls( const QMetaObject* );
|
||||||
|
|
||||||
|
QSK_EXPORT quint8 primitiveCount( Type );
|
||||||
|
QSK_EXPORT void reservePrimitives( Type, quint8 count );
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace std
|
namespace std
|
||||||
|
@ -556,16 +560,16 @@ Q_DECLARE_TYPEINFO( QskAspect::Aspect, Q_MOVABLE_TYPE );
|
||||||
|
|
||||||
class QDebug;
|
class QDebug;
|
||||||
|
|
||||||
QSK_EXPORT QDebug operator<<( QDebug, const QskAspect::Aspect& );
|
QSK_EXPORT QDebug operator<<( QDebug, QskAspect::Aspect );
|
||||||
QSK_EXPORT QDebug operator<<( QDebug, const QskAspect::Type& );
|
QSK_EXPORT QDebug operator<<( QDebug, QskAspect::Type );
|
||||||
QSK_EXPORT QDebug operator<<( QDebug, const QskAspect::Subcontrol& );
|
QSK_EXPORT QDebug operator<<( QDebug, QskAspect::Subcontrol );
|
||||||
|
|
||||||
QSK_EXPORT QDebug operator<<( QDebug, const QskAspect::FlagPrimitive& );
|
QSK_EXPORT QDebug operator<<( QDebug, QskAspect::FlagPrimitive );
|
||||||
QSK_EXPORT QDebug operator<<( QDebug, const QskAspect::ColorPrimitive& );
|
QSK_EXPORT QDebug operator<<( QDebug, QskAspect::ColorPrimitive );
|
||||||
QSK_EXPORT QDebug operator<<( QDebug, const QskAspect::MetricPrimitive& );
|
QSK_EXPORT QDebug operator<<( QDebug, QskAspect::MetricPrimitive );
|
||||||
|
|
||||||
QSK_EXPORT QDebug operator<<( QDebug, const QskAspect::Placement& );
|
QSK_EXPORT QDebug operator<<( QDebug, QskAspect::Placement );
|
||||||
QSK_EXPORT QDebug operator<<( QDebug, const QskAspect::State& );
|
QSK_EXPORT QDebug operator<<( QDebug, QskAspect::State );
|
||||||
|
|
||||||
QSK_EXPORT void qskDebugState( QDebug, const QMetaObject*, QskAspect::State );
|
QSK_EXPORT void qskDebugState( QDebug, const QMetaObject*, QskAspect::State );
|
||||||
QSK_EXPORT void qskDebugAspect( QDebug, const QMetaObject*, QskAspect::Aspect );
|
QSK_EXPORT void qskDebugAspect( QDebug, const QMetaObject*, QskAspect::Aspect );
|
||||||
|
|
|
@ -977,7 +977,7 @@ void QskSkinnable::setSkinState( QskAspect::State newState, bool animated )
|
||||||
|
|
||||||
const auto& skinTable = skin->hintTable();
|
const auto& skinTable = skin->hintTable();
|
||||||
|
|
||||||
for ( int i = 0; i <= QskAspect::LastType; i++ )
|
for ( uint i = 0; i < QskAspect::typeCount; i++ )
|
||||||
{
|
{
|
||||||
const auto type = static_cast< QskAspect::Type >( i );
|
const auto type = static_cast< QskAspect::Type >( i );
|
||||||
|
|
||||||
|
@ -989,8 +989,10 @@ void QskSkinnable::setSkinState( QskAspect::State newState, bool animated )
|
||||||
Starting an animator for all primitives,
|
Starting an animator for all primitives,
|
||||||
that differ between the states
|
that differ between the states
|
||||||
*/
|
*/
|
||||||
for ( uint primitive = 0;
|
|
||||||
primitive <= QskAspect::LastPrimitive; primitive++ )
|
const auto primitiveCount = QskAspect::primitiveCount( type );
|
||||||
|
|
||||||
|
for ( uint primitive = 0; primitive < primitiveCount; primitive++ )
|
||||||
{
|
{
|
||||||
aspect.setPrimitive( type, primitive );
|
aspect.setPrimitive( type, primitive );
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue