diff --git a/src/nodes/QskGradientMaterial.cpp b/src/nodes/QskGradientMaterial.cpp index acfccaaf..5421af50 100644 --- a/src/nodes/QskGradientMaterial.cpp +++ b/src/nodes/QskGradientMaterial.cpp @@ -37,10 +37,10 @@ QSK_QT_PRIVATE_END namespace { - class GradientTexture : public QSGPlainTexture + class ColorRamp : public QSGPlainTexture { public: - GradientTexture( const QskGradientStops& stops, QGradient::Spread spread ) + ColorRamp( const QskGradientStops& stops, QGradient::Spread spread ) { /* Qt creates tables of 1024 colors, while Chrome, Firefox, and Android @@ -75,10 +75,10 @@ namespace } }; - class TextureHashKey + class ColorRampHashKey { public: - inline bool operator==( const TextureHashKey& other ) const + inline bool operator==( const ColorRampHashKey& other ) const { return rhi == other.rhi && spread == other.spread && stops == other.stops; } @@ -88,7 +88,7 @@ namespace const QGradient::Spread spread; }; - inline size_t qHash( const TextureHashKey& key, size_t seed = 0 ) + inline size_t qHash( const ColorRampHashKey& key, size_t seed = 0 ) { size_t valus = seed + key.spread; @@ -98,15 +98,15 @@ namespace return valus; } - class TextureCache + class ColorRampCache { public: - static TextureCache* instance() + static ColorRampCache* instance() { - static TextureCache* s_instance = nullptr; + static ColorRampCache* s_instance = nullptr; if ( s_instance == nullptr ) { - s_instance = new TextureCache(); + s_instance = new ColorRampCache(); /* For RHI we have QRhi::addCleanupCallback, but with @@ -119,20 +119,20 @@ namespace return s_instance; } - ~TextureCache() + ~ColorRampCache() { qDeleteAll( m_hashTable ); } - GradientTexture* texture( const void* rhi, + ColorRamp* colorRamp( const void* rhi, const QskGradientStops& stops, QGradient::Spread spread ) { - const TextureHashKey key { rhi, stops, spread }; + const ColorRampHashKey key { rhi, stops, spread }; auto texture = m_hashTable[key]; if ( texture == nullptr ) { - texture = new GradientTexture( stops, spread ); + texture = new ColorRamp( stops, spread ); m_hashTable[ key ] = texture; if ( rhi != nullptr ) @@ -141,7 +141,7 @@ namespace if ( !m_rhiTable.contains( myrhi ) ) { - myrhi->addCleanupCallback( TextureCache::cleanupRhi ); + myrhi->addCleanupCallback( ColorRampCache::cleanupRhi ); m_rhiTable += myrhi; } } @@ -177,7 +177,7 @@ namespace cache->m_rhiTable.removeAll( rhi ); } - QHash< TextureHashKey, GradientTexture* > m_hashTable; + QHash< ColorRampHashKey, ColorRamp* > m_hashTable; QVector< const QRhi* > m_rhiTable; }; } @@ -253,9 +253,9 @@ namespace updateUniformValues( material ); - auto texture = TextureCache::instance()->texture( + auto colorRamp = ColorRampCache::instance()->colorRamp( nullptr, material->stops(), material->spread() ); - texture->bind(); + colorRamp->bind(); } char const* const* attributeNames() const override final @@ -292,16 +292,16 @@ namespace auto material = static_cast< const GradientMaterial* >( newMaterial ); - auto texture = TextureCache::instance()->texture( + auto colorRamp = ColorRampCache::instance()->colorRamp( state.rhi(), material->stops(), material->spread() ); #if QT_VERSION < QT_VERSION_CHECK( 6, 0, 0 ) - texture->updateRhiTexture( state.rhi(), state.resourceUpdateBatch() ); + colorRamp->updateRhiTexture( state.rhi(), state.resourceUpdateBatch() ); #else - texture->commitTextureOperations( state.rhi(), state.resourceUpdateBatch() ); + colorRamp->commitTextureOperations( state.rhi(), state.resourceUpdateBatch() ); #endif - textures[0] = texture; + textures[0] = colorRamp; } }; #endif diff --git a/src/nodes/shaders/boxshadow.frag.qsb b/src/nodes/shaders/boxshadow.frag.qsb index e5d35e43..ff5c1229 100644 Binary files a/src/nodes/shaders/boxshadow.frag.qsb and b/src/nodes/shaders/boxshadow.frag.qsb differ diff --git a/src/nodes/shaders/boxshadow.vert.qsb b/src/nodes/shaders/boxshadow.vert.qsb index 40cab02d..c0499440 100644 Binary files a/src/nodes/shaders/boxshadow.vert.qsb and b/src/nodes/shaders/boxshadow.vert.qsb differ diff --git a/src/nodes/shaders/gradientconic-vulkan.frag b/src/nodes/shaders/gradientconic-vulkan.frag index 681ac96c..526e224d 100644 --- a/src/nodes/shaders/gradientconic-vulkan.frag +++ b/src/nodes/shaders/gradientconic-vulkan.frag @@ -12,11 +12,11 @@ layout( std140, binding = 0 ) uniform buf float opacity; } ubuf; -layout( binding = 1 ) uniform sampler2D palette; +layout( binding = 1 ) uniform sampler2D colorRamp; vec4 colorAt( highp float value ) { - return texture( palette, vec2( value, 0.0 ) ); + return texture( colorRamp, vec2( value, 0.0 ) ); } void main() diff --git a/src/nodes/shaders/gradientconic.frag b/src/nodes/shaders/gradientconic.frag index 55de04e4..b131e165 100644 --- a/src/nodes/shaders/gradientconic.frag +++ b/src/nodes/shaders/gradientconic.frag @@ -1,4 +1,4 @@ -uniform sampler2D palette; +uniform sampler2D colorRamp; uniform lowp float opacity; uniform highp float start; @@ -8,7 +8,7 @@ varying highp vec2 coord; lowp vec4 colorAt( highp float value ) { - return texture2D( palette, vec2( value, 0.0 ) ); + return texture2D( colorRamp, vec2( value, 0.0 ) ); } void main() diff --git a/src/nodes/shaders/gradientconic.frag.qsb b/src/nodes/shaders/gradientconic.frag.qsb index e6d57a32..b0e6d595 100644 Binary files a/src/nodes/shaders/gradientconic.frag.qsb and b/src/nodes/shaders/gradientconic.frag.qsb differ diff --git a/src/nodes/shaders/gradientconic.vert.qsb b/src/nodes/shaders/gradientconic.vert.qsb index 40e58729..b03b9384 100644 Binary files a/src/nodes/shaders/gradientconic.vert.qsb and b/src/nodes/shaders/gradientconic.vert.qsb differ diff --git a/src/nodes/shaders/gradientlinear-vulkan.frag b/src/nodes/shaders/gradientlinear-vulkan.frag index cf12ce53..e9347c7a 100644 --- a/src/nodes/shaders/gradientlinear-vulkan.frag +++ b/src/nodes/shaders/gradientlinear-vulkan.frag @@ -10,11 +10,11 @@ layout( std140, binding = 0 ) uniform buf float opacity; } ubuf; -layout( binding = 1 ) uniform sampler2D palette; +layout( binding = 1 ) uniform sampler2D colorRamp; vec4 colorAt( float value ) { - return texture( palette, vec2( value, 0.0 ) ); + return texture( colorRamp, vec2( value, 0.0 ) ); } void main() diff --git a/src/nodes/shaders/gradientlinear.frag b/src/nodes/shaders/gradientlinear.frag index dd0525b3..d1da259f 100644 --- a/src/nodes/shaders/gradientlinear.frag +++ b/src/nodes/shaders/gradientlinear.frag @@ -1,11 +1,11 @@ -uniform sampler2D palette; +uniform sampler2D colorRamp; uniform highp float opacity; varying highp float colorIndex; lowp vec4 colorAt( float value ) { - return texture2D( palette, vec2( value, 0.0 ) ); + return texture2D( colorRamp, vec2( value, 0.0 ) ); } void main() diff --git a/src/nodes/shaders/gradientlinear.frag.qsb b/src/nodes/shaders/gradientlinear.frag.qsb index 94221b97..12083ea1 100644 Binary files a/src/nodes/shaders/gradientlinear.frag.qsb and b/src/nodes/shaders/gradientlinear.frag.qsb differ diff --git a/src/nodes/shaders/gradientlinear.vert.qsb b/src/nodes/shaders/gradientlinear.vert.qsb index b374d361..e009615c 100644 Binary files a/src/nodes/shaders/gradientlinear.vert.qsb and b/src/nodes/shaders/gradientlinear.vert.qsb differ diff --git a/src/nodes/shaders/gradientradial-vulkan.frag b/src/nodes/shaders/gradientradial-vulkan.frag index 248faa9e..a250e8c7 100644 --- a/src/nodes/shaders/gradientradial-vulkan.frag +++ b/src/nodes/shaders/gradientradial-vulkan.frag @@ -11,11 +11,11 @@ layout( std140, binding = 0 ) uniform buf float opacity; } ubuf; -layout( binding = 1 ) uniform sampler2D palette; +layout( binding = 1 ) uniform sampler2D colorRamp; vec4 colorAt( float value ) { - return texture( palette, vec2( value, 0.0 ) ); + return texture( colorRamp, vec2( value, 0.0 ) ); } void main() diff --git a/src/nodes/shaders/gradientradial.frag b/src/nodes/shaders/gradientradial.frag index 1297d3e6..3638a17d 100644 --- a/src/nodes/shaders/gradientradial.frag +++ b/src/nodes/shaders/gradientradial.frag @@ -1,4 +1,4 @@ -uniform sampler2D palette; +uniform sampler2D colorRamp; uniform lowp float opacity; uniform highp vec2 radius; @@ -7,7 +7,7 @@ varying highp vec2 coord; lowp vec4 colorAt( highp float value ) { - return texture2D( palette, vec2( value, 0.0 ) ); + return texture2D( colorRamp, vec2( value, 0.0 ) ); } void main() diff --git a/src/nodes/shaders/gradientradial.frag.qsb b/src/nodes/shaders/gradientradial.frag.qsb index 69e6faaa..f8ec9321 100644 Binary files a/src/nodes/shaders/gradientradial.frag.qsb and b/src/nodes/shaders/gradientradial.frag.qsb differ diff --git a/src/nodes/shaders/gradientradial.vert.qsb b/src/nodes/shaders/gradientradial.vert.qsb index 29129e61..c2e3fe60 100644 Binary files a/src/nodes/shaders/gradientradial.vert.qsb and b/src/nodes/shaders/gradientradial.vert.qsb differ