diff --git a/playground/parrots/BlurringNode.cpp b/playground/parrots/BlurringNode.cpp index 66fdbf5a..620ab8a1 100644 --- a/playground/parrots/BlurringNode.cpp +++ b/playground/parrots/BlurringNode.cpp @@ -63,7 +63,11 @@ namespace to the quickeffects module. */ setShaderFileName( VertexStage, ":/shaders/blur.vert.qsb" ); +#if 0 setShaderFileName( FragmentStage, ":/shaders/blur.frag.qsb" ); +#else + setShaderFileName( FragmentStage, ":/shaders/rgbswap.frag.qsb" ); +#endif } bool updateUniformData( RenderState& state, diff --git a/playground/parrots/main.cpp b/playground/parrots/main.cpp index 644dbcb8..4bd75f3a 100644 --- a/playground/parrots/main.cpp +++ b/playground/parrots/main.cpp @@ -13,6 +13,7 @@ #include #include #include +#include #include #include @@ -22,6 +23,17 @@ #include "Overlay.h" +class Image : public QskGraphicLabel +{ + public: + Image( QQuickItem* parent = nullptr ) + : QskGraphicLabel( parent ) + { + const QImage image( ":/images/parrots.jpg" ); + setGraphic( QskGraphic::fromImage( image ) ); + } +}; + class ForegroundItem : public QskLinearBox { public: @@ -31,10 +43,7 @@ class ForegroundItem : public QskLinearBox setMargins( 20 ); #if 1 - auto label = new QskGraphicLabel( this ); - - const QImage image( ":/images/parrots.jpg" ); - label->setGraphic( QskGraphic::fromImage( image ) ); + auto label = new Image( this ); label->setSizePolicy( QskSizePolicy::Fixed, QskSizePolicy::Fixed ); label->setLayoutAlignmentHint( Qt::AlignCenter ); label->setObjectName( "miniParrots" ); @@ -86,16 +95,15 @@ class BackgroundItem : public QskControl BackgroundItem( QQuickItem* parent = nullptr ) : QskControl( parent ) { - m_label = new QskGraphicLabel( this ); - m_label->setFillMode( QskGraphicLabel::Stretch ); + setObjectName( "background" ); - const QImage image( ":/images/parrots.jpg" ); - m_label->setGraphic( QskGraphic::fromImage( image ) ); +#if 1 + m_label = new Image( this ); + m_label->setFillMode( QskGraphicLabel::Stretch ); + m_label->setObjectName( "parrots" ); +#endif startTimer( 20 ); - - setObjectName( "background" ); - m_label->setObjectName( "parrots" ); } protected: @@ -127,11 +135,12 @@ class BackgroundItem : public QskControl labelRect.adjust( margin, margin, -margin, -margin ); labelRect.translate( margin * x, margin * y ); - m_label->setGeometry( labelRect ); + if ( m_label ) + m_label->setGeometry( labelRect ); } private: - QskGraphicLabel* m_label; + QskGraphicLabel* m_label = nullptr; }; class MainView : public QskControl @@ -146,8 +155,8 @@ class MainView : public QskControl #if 0 { auto box = new QskBox( m_background ); - box->setGeometry( 0, 0, 600, 400 ); - box->setFillGradient( Qt::darkRed ); + box->setGeometry( 20, 20, 600, 400 ); + box->setFillGradient( QskRgb::SaddleBrown ); box->setObjectName( "redBox" ); } #endif @@ -158,7 +167,7 @@ class MainView : public QskControl { auto box = new QskBox( m_background ); box->setGeometry( 50, 50, 400, 200 ); - box->setFillGradient( Qt::darkBlue ); + box->setFillGradient( QskRgb::PaleGreen ); box->setObjectName( "blueBox" ); } #endif diff --git a/playground/parrots/shaders.qrc b/playground/parrots/shaders.qrc index b1f60720..98ade156 100644 --- a/playground/parrots/shaders.qrc +++ b/playground/parrots/shaders.qrc @@ -6,5 +6,7 @@ shaders/blur.vert.qsb shaders/blur.frag.qsb + + shaders/rgbswap.frag.qsb diff --git a/playground/parrots/shaders/rgbswap-vulkan.frag b/playground/parrots/shaders/rgbswap-vulkan.frag new file mode 100644 index 00000000..f53a2139 --- /dev/null +++ b/playground/parrots/shaders/rgbswap-vulkan.frag @@ -0,0 +1,18 @@ +#version 440 + +layout( location = 0 ) in vec2 coord; +layout( location = 0 ) out vec4 fragColor; + +layout( binding = 1 ) uniform sampler2D source; + +layout( std140, binding = 0 ) uniform buf +{ + mat4 matrix; + float opacity; +} ubuf; + +void main() +{ + vec4 c = texture( source, coord ); + fragColor = c.yzxw * ubuf.opacity;; +} diff --git a/playground/parrots/shaders/rgbswap.frag.qsb b/playground/parrots/shaders/rgbswap.frag.qsb new file mode 100644 index 00000000..85e03f20 Binary files /dev/null and b/playground/parrots/shaders/rgbswap.frag.qsb differ diff --git a/playground/parrots/shaders/vulkan2qsb.sh b/playground/parrots/shaders/vulkan2qsb.sh index 4b53dc70..ef1f0727 100755 --- a/playground/parrots/shaders/vulkan2qsb.sh +++ b/playground/parrots/shaders/vulkan2qsb.sh @@ -7,3 +7,4 @@ function qsbcompile { qsbcompile blur-vulkan.vert qsbcompile blur-vulkan.frag +qsbcompile rgbswap-vulkan.frag