diff options
Diffstat (limited to 'src/imports')
-rw-r--r-- | src/imports/shapes/plugin.cpp | 1 | ||||
-rw-r--r-- | src/imports/shapes/qquickshapegenericrenderer.cpp | 4 | ||||
-rw-r--r-- | src/imports/shapes/qquickshapenvprrenderer.cpp | 8 | ||||
-rw-r--r-- | src/imports/shapes/shaders/blit.frag | 9 | ||||
-rw-r--r-- | src/imports/shapes/shaders/blit.vert | 12 | ||||
-rw-r--r-- | src/imports/shapes/shaders/blit_core.frag | 13 | ||||
-rw-r--r-- | src/imports/shapes/shaders/blit_core.vert | 14 | ||||
-rw-r--r-- | src/imports/shapes/shaders/lineargradient.frag | 9 | ||||
-rw-r--r-- | src/imports/shapes/shaders/lineargradient.vert | 15 | ||||
-rw-r--r-- | src/imports/shapes/shaders/lineargradient_core.frag | 12 | ||||
-rw-r--r-- | src/imports/shapes/shaders/lineargradient_core.vert | 17 | ||||
-rw-r--r-- | src/imports/shapes/shapes.pro | 2 | ||||
-rw-r--r-- | src/imports/shapes/shapes.qrc | 12 |
13 files changed, 122 insertions, 6 deletions
diff --git a/src/imports/shapes/plugin.cpp b/src/imports/shapes/plugin.cpp index ae0d02da93..1729fc88b4 100644 --- a/src/imports/shapes/plugin.cpp +++ b/src/imports/shapes/plugin.cpp @@ -47,6 +47,7 @@ static void initResources() #ifdef QT_STATIC Q_INIT_RESOURCE(qmake_QtQuick_Shapes); #endif + Q_INIT_RESOURCE(shapes); } QT_BEGIN_NAMESPACE diff --git a/src/imports/shapes/qquickshapegenericrenderer.cpp b/src/imports/shapes/qquickshapegenericrenderer.cpp index ca5f2a0e91..41bab83582 100644 --- a/src/imports/shapes/qquickshapegenericrenderer.cpp +++ b/src/imports/shapes/qquickshapegenericrenderer.cpp @@ -703,9 +703,9 @@ QSGMaterialType QQuickShapeLinearGradientShader::type; QQuickShapeLinearGradientShader::QQuickShapeLinearGradientShader() { setShaderSourceFile(QOpenGLShader::Vertex, - QStringLiteral(":/qt-project.org/items/shaders/lineargradient.vert")); + QStringLiteral(":/qt-project.org/shapes/shaders/lineargradient.vert")); setShaderSourceFile(QOpenGLShader::Fragment, - QStringLiteral(":/qt-project.org/items/shaders/lineargradient.frag")); + QStringLiteral(":/qt-project.org/shapes/shaders/lineargradient.frag")); } void QQuickShapeLinearGradientShader::initialize() diff --git a/src/imports/shapes/qquickshapenvprrenderer.cpp b/src/imports/shapes/qquickshapenvprrenderer.cpp index f3f8d807ec..57306a4d53 100644 --- a/src/imports/shapes/qquickshapenvprrenderer.cpp +++ b/src/imports/shapes/qquickshapenvprrenderer.cpp @@ -835,11 +835,11 @@ bool QQuickNvprBlitter::create() m_program = new QOpenGLShaderProgram; if (QOpenGLContext::currentContext()->format().profile() == QSurfaceFormat::CoreProfile) { - m_program->addCacheableShaderFromSourceFile(QOpenGLShader::Vertex, QStringLiteral(":/qt-project.org/items/shaders/shadereffect_core.vert")); - m_program->addCacheableShaderFromSourceFile(QOpenGLShader::Fragment, QStringLiteral(":/qt-project.org/items/shaders/shadereffect_core.frag")); + m_program->addCacheableShaderFromSourceFile(QOpenGLShader::Vertex, QStringLiteral(":/qt-project.org/shapes/shaders/blit_core.vert")); + m_program->addCacheableShaderFromSourceFile(QOpenGLShader::Fragment, QStringLiteral(":/qt-project.org/shapes/shaders/blit_core.frag")); } else { - m_program->addCacheableShaderFromSourceFile(QOpenGLShader::Vertex, QStringLiteral(":/qt-project.org/items/shaders/shadereffect.vert")); - m_program->addCacheableShaderFromSourceFile(QOpenGLShader::Fragment, QStringLiteral(":/qt-project.org/items/shaders/shadereffect.frag")); + m_program->addCacheableShaderFromSourceFile(QOpenGLShader::Vertex, QStringLiteral(":/qt-project.org/shapes/shaders/blit.vert")); + m_program->addCacheableShaderFromSourceFile(QOpenGLShader::Fragment, QStringLiteral(":/qt-project.org/shapes/shaders/blit.frag")); } m_program->bindAttributeLocation("qt_Vertex", 0); m_program->bindAttributeLocation("qt_MultiTexCoord0", 1); diff --git a/src/imports/shapes/shaders/blit.frag b/src/imports/shapes/shaders/blit.frag new file mode 100644 index 0000000000..505f0db179 --- /dev/null +++ b/src/imports/shapes/shaders/blit.frag @@ -0,0 +1,9 @@ +varying highp vec2 qt_TexCoord0; + +uniform sampler2D source; +uniform lowp float qt_Opacity; + +void main() +{ + gl_FragColor = texture2D(source, qt_TexCoord0) * qt_Opacity; +} diff --git a/src/imports/shapes/shaders/blit.vert b/src/imports/shapes/shaders/blit.vert new file mode 100644 index 0000000000..f8306bd945 --- /dev/null +++ b/src/imports/shapes/shaders/blit.vert @@ -0,0 +1,12 @@ +uniform highp mat4 qt_Matrix; + +attribute highp vec4 qt_Vertex; +attribute highp vec2 qt_MultiTexCoord0; + +varying highp vec2 qt_TexCoord0; + +void main() +{ + qt_TexCoord0 = qt_MultiTexCoord0; + gl_Position = qt_Matrix * qt_Vertex; +} diff --git a/src/imports/shapes/shaders/blit_core.frag b/src/imports/shapes/shaders/blit_core.frag new file mode 100644 index 0000000000..7073808fba --- /dev/null +++ b/src/imports/shapes/shaders/blit_core.frag @@ -0,0 +1,13 @@ +#version 150 core + +in vec2 qt_TexCoord0; + +out vec4 fragColor; + +uniform sampler2D source; +uniform float qt_Opacity; + +void main() +{ + fragColor = texture(source, qt_TexCoord0) * qt_Opacity; +} diff --git a/src/imports/shapes/shaders/blit_core.vert b/src/imports/shapes/shaders/blit_core.vert new file mode 100644 index 0000000000..5246441da3 --- /dev/null +++ b/src/imports/shapes/shaders/blit_core.vert @@ -0,0 +1,14 @@ +#version 150 core + +in vec4 qt_Vertex; +in vec2 qt_MultiTexCoord0; + +out vec2 qt_TexCoord0; + +uniform mat4 qt_Matrix; + +void main() +{ + qt_TexCoord0 = qt_MultiTexCoord0; + gl_Position = qt_Matrix * qt_Vertex; +} diff --git a/src/imports/shapes/shaders/lineargradient.frag b/src/imports/shapes/shaders/lineargradient.frag new file mode 100644 index 0000000000..7f4a739109 --- /dev/null +++ b/src/imports/shapes/shaders/lineargradient.frag @@ -0,0 +1,9 @@ +uniform sampler2D gradTabTexture; +uniform highp float opacity; + +varying highp float gradTabIndex; + +void main() +{ + gl_FragColor = texture2D(gradTabTexture, vec2(gradTabIndex, 0.5)) * opacity; +} diff --git a/src/imports/shapes/shaders/lineargradient.vert b/src/imports/shapes/shaders/lineargradient.vert new file mode 100644 index 0000000000..eb21b8886b --- /dev/null +++ b/src/imports/shapes/shaders/lineargradient.vert @@ -0,0 +1,15 @@ +attribute vec4 vertexCoord; +attribute vec4 vertexColor; + +uniform mat4 matrix; +uniform vec2 gradStart; +uniform vec2 gradEnd; + +varying float gradTabIndex; + +void main() +{ + vec2 gradVec = gradEnd - gradStart; + gradTabIndex = dot(gradVec, vertexCoord.xy - gradStart) / (gradVec.x * gradVec.x + gradVec.y * gradVec.y); + gl_Position = matrix * vertexCoord; +} diff --git a/src/imports/shapes/shaders/lineargradient_core.frag b/src/imports/shapes/shaders/lineargradient_core.frag new file mode 100644 index 0000000000..5908acfa67 --- /dev/null +++ b/src/imports/shapes/shaders/lineargradient_core.frag @@ -0,0 +1,12 @@ +#version 150 core + +uniform sampler2D gradTabTexture; +uniform float opacity; + +in float gradTabIndex; +out vec4 fragColor; + +void main() +{ + fragColor = texture(gradTabTexture, vec2(gradTabIndex, 0.5)) * opacity; +} diff --git a/src/imports/shapes/shaders/lineargradient_core.vert b/src/imports/shapes/shaders/lineargradient_core.vert new file mode 100644 index 0000000000..60b56f38e3 --- /dev/null +++ b/src/imports/shapes/shaders/lineargradient_core.vert @@ -0,0 +1,17 @@ +#version 150 core + +in vec4 vertexCoord; +in vec4 vertexColor; + +uniform mat4 matrix; +uniform vec2 gradStart; +uniform vec2 gradEnd; + +out float gradTabIndex; + +void main() +{ + vec2 gradVec = gradEnd - gradStart; + gradTabIndex = dot(gradVec, vertexCoord.xy - gradStart) / (gradVec.x * gradVec.x + gradVec.y * gradVec.y); + gl_Position = matrix * vertexCoord; +} diff --git a/src/imports/shapes/shapes.pro b/src/imports/shapes/shapes.pro index 80e6a22142..4406474c3f 100644 --- a/src/imports/shapes/shapes.pro +++ b/src/imports/shapes/shapes.pro @@ -28,4 +28,6 @@ qtConfig(opengl) { qquickshapenvprrenderer.cpp } +RESOURCES += shapes.qrc + load(qml_plugin) diff --git a/src/imports/shapes/shapes.qrc b/src/imports/shapes/shapes.qrc new file mode 100644 index 0000000000..65ee2007f9 --- /dev/null +++ b/src/imports/shapes/shapes.qrc @@ -0,0 +1,12 @@ +<RCC> + <qresource prefix="/qt-project.org/shapes"> + <file>shaders/blit.vert</file> + <file>shaders/blit.frag</file> + <file>shaders/blit_core.frag</file> + <file>shaders/blit_core.vert</file> + <file>shaders/lineargradient.vert</file> + <file>shaders/lineargradient.frag</file> + <file>shaders/lineargradient_core.vert</file> + <file>shaders/lineargradient_core.frag</file> + </qresource> +</RCC> |