Split frag and vert code of FadingNode into separate files
Summary: This matches what Qt does internally, it's easier to read and gives us syntax highlighting on the shader files, but more importantly in future we will get Qt's automatic loading of core profile shaders. Test Plan: Opened QML with IconItem, made the icon switch. Still looks the same Reviewers: #plasma, mart Reviewed By: mart Subscribers: mart, broulik, plasma-devel, #frameworks Tags: #plasma, #frameworks Differential Revision: https://phabricator.kde.org/D4848
This commit is contained in:
parent
3a9fc22724
commit
3b05f569ac
@ -24,6 +24,8 @@ set(corebindings_SRCS
|
||||
windowthumbnail.cpp
|
||||
)
|
||||
|
||||
qt5_add_resources(corebindings_SRCS shaders.qrc)
|
||||
|
||||
add_library(corebindingsplugin SHARED ${corebindings_SRCS})
|
||||
target_link_libraries(corebindingsplugin
|
||||
Qt5::Quick
|
||||
|
10
src/declarativeimports/core/fadingmaterial.frag
Normal file
10
src/declarativeimports/core/fadingmaterial.frag
Normal file
@ -0,0 +1,10 @@
|
||||
varying highp vec2 v_coord;
|
||||
uniform sampler2D u_src;
|
||||
uniform sampler2D u_target;
|
||||
uniform highp float u_transitionProgress;
|
||||
uniform lowp float qt_Opacity;
|
||||
void main() {
|
||||
lowp vec4 tex1 = texture2D(u_target, v_coord);
|
||||
lowp vec4 tex2 = texture2D(u_src, v_coord);
|
||||
gl_FragColor = mix(tex2, tex1, u_transitionProgress) * qt_Opacity;
|
||||
}
|
8
src/declarativeimports/core/fadingmaterial.vert
Normal file
8
src/declarativeimports/core/fadingmaterial.vert
Normal file
@ -0,0 +1,8 @@
|
||||
uniform highp mat4 qt_Matrix;
|
||||
attribute highp vec4 qt_Vertex;
|
||||
attribute highp vec2 qt_MultiTexCoord0;
|
||||
varying highp vec2 v_coord;
|
||||
void main() {
|
||||
v_coord = qt_MultiTexCoord0;
|
||||
gl_Position = qt_Matrix * qt_Vertex;
|
||||
}
|
@ -34,9 +34,7 @@ class FadingMaterialShader : public QSGSimpleMaterialShader<FadingMaterialState>
|
||||
{
|
||||
QSG_DECLARE_SIMPLE_SHADER(FadingMaterialShader, FadingMaterialState)
|
||||
public:
|
||||
const char* fragmentShader() const Q_DECL_OVERRIDE;
|
||||
const char* vertexShader() const Q_DECL_OVERRIDE;
|
||||
|
||||
FadingMaterialShader();
|
||||
using QSGSimpleMaterialShader<FadingMaterialState>::updateState;
|
||||
virtual void updateState(const FadingMaterialState* newState, const FadingMaterialState* oldState) override;
|
||||
QList<QByteArray> attributes() const Q_DECL_OVERRIDE;
|
||||
@ -47,38 +45,18 @@ private:
|
||||
int m_progressId = 0;
|
||||
};
|
||||
|
||||
|
||||
FadingMaterialShader::FadingMaterialShader()
|
||||
{
|
||||
setShaderSourceFile(QOpenGLShader::Fragment, QStringLiteral(":/plasma-framework/shaders/fadingmaterial.frag"));
|
||||
setShaderSourceFile(QOpenGLShader::Vertex, QStringLiteral(":/plasma-framework/shaders/fadingmaterial.vert"));
|
||||
}
|
||||
|
||||
QList<QByteArray> FadingMaterialShader::attributes() const
|
||||
{
|
||||
return QList<QByteArray>() << "qt_Vertex" << "qt_MultiTexCoord0";
|
||||
}
|
||||
|
||||
const char* FadingMaterialShader::vertexShader() const
|
||||
{
|
||||
return "uniform highp mat4 qt_Matrix;"
|
||||
"attribute highp vec4 qt_Vertex;"
|
||||
"attribute highp vec2 qt_MultiTexCoord0;"
|
||||
"varying highp vec2 v_coord;"
|
||||
"void main() {"
|
||||
" v_coord = qt_MultiTexCoord0;"
|
||||
" gl_Position = qt_Matrix * qt_Vertex;"
|
||||
" }";
|
||||
}
|
||||
|
||||
const char* FadingMaterialShader::fragmentShader() const
|
||||
{
|
||||
return "varying highp vec2 v_coord;"
|
||||
"uniform sampler2D u_src;"
|
||||
"uniform sampler2D u_target;"
|
||||
"uniform highp float u_transitionProgress;"
|
||||
"uniform lowp float qt_Opacity;"
|
||||
"void main() {"
|
||||
"lowp vec4 tex1 = texture2D(u_target, v_coord);"
|
||||
"lowp vec4 tex2 = texture2D(u_src, v_coord);"
|
||||
"gl_FragColor = mix(tex2, tex1, u_transitionProgress) * qt_Opacity;"
|
||||
"}";
|
||||
}
|
||||
|
||||
|
||||
void FadingMaterialShader::updateState(const FadingMaterialState* newState, const FadingMaterialState* oldState)
|
||||
{
|
||||
if (!oldState || oldState->source != newState->source) {
|
||||
|
6
src/declarativeimports/core/shaders.qrc
Normal file
6
src/declarativeimports/core/shaders.qrc
Normal file
@ -0,0 +1,6 @@
|
||||
<!DOCTYPE RCC><RCC version="1.0">
|
||||
<qresource prefix="/plasma-framework/shaders">
|
||||
<file>fadingmaterial.vert</file>
|
||||
<file>fadingmaterial.frag</file>
|
||||
</qresource>
|
||||
</RCC>
|
Loading…
x
Reference in New Issue
Block a user