From 1f6bfc220774e9407fe88916843b76ed103cff72 Mon Sep 17 00:00:00 2001 From: Cristian Maureira-Fredes Date: Mon, 3 Sep 2018 14:02:13 +0200 Subject: Doc: Move literal code block to a separate file MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit We need to override this snippet for the documentation we generate for Qt for Python, and it is easier to have it on a separate file. Task-number: PYSIDE-801 Task-number: PYSIDE-691 Change-Id: Ideb5b6af25024279f167137d3b65660bb9c96a7e Reviewed-by: Topi Reiniƶ --- src/opengl/qgraphicsshadereffect.cpp | 46 +++--------------------------------- 1 file changed, 3 insertions(+), 43 deletions(-) (limited to 'src/opengl/qgraphicsshadereffect.cpp') diff --git a/src/opengl/qgraphicsshadereffect.cpp b/src/opengl/qgraphicsshadereffect.cpp index cf3d307d71..97b83a6b3d 100644 --- a/src/opengl/qgraphicsshadereffect.cpp +++ b/src/opengl/qgraphicsshadereffect.cpp @@ -70,48 +70,12 @@ QT_BEGIN_NAMESPACE grayscale and then applies a colorize operation using the \c effectColor value: - \code - static char const colorizeShaderCode[] = - "uniform lowp vec4 effectColor;\n" - "lowp vec4 customShader(lowp sampler2D imageTexture, highp vec2 textureCoords) {\n" - " vec4 src = texture2D(imageTexture, textureCoords);\n" - " float gray = dot(src.rgb, vec3(0.212671, 0.715160, 0.072169));\n" - " vec4 colorize = 1.0-((1.0-gray)*(1.0-effectColor));\n" - " return vec4(colorize.rgb, src.a);\n" - "}"; - \endcode + \snippet code/src_opengl_qgraphicsshadereffect.cpp 0 To use this shader code, it is necessary to define a subclass of QGraphicsShaderEffect as follows: - \code - class ColorizeEffect : public QGraphicsShaderEffect - { - Q_OBJECT - public: - ColorizeEffect(QObject *parent = 0) - : QGraphicsShaderEffect(parent), color(Qt::black) - { - setPixelShaderFragment(colorizeShaderCode); - } - - QColor effectColor() const { return color; } - void setEffectColor(const QColor& c) - { - color = c; - setUniformsDirty(); - } - - protected: - void setUniforms(QGLShaderProgram *program) - { - program->setUniformValue("effectColor", color); - } - - private: - QColor color; - }; - \endcode + \snippet code/src_opengl_qgraphicsshadereffect.cpp 1 The setUniforms() function is called when the effect is about to be used for drawing to give the subclass the opportunity to @@ -216,11 +180,7 @@ QByteArray QGraphicsShaderEffect::pixelShaderFragment() const shader program. The following is the default pixel shader fragment, which draws a pixmap with no effect applied: - \code - lowp vec4 customShader(lowp sampler2D imageTexture, highp vec2 textureCoords) { - return texture2D(imageTexture, textureCoords); - } - \endcode + \snippet code/src_opengl_qgraphicsshadereffect.cpp 2 \sa pixelShaderFragment(), setUniforms() */ -- cgit v1.2.3