diff options
author | Samuel Rødal <sroedal@trolltech.com> | 2009-06-30 07:45:14 (GMT) |
---|---|---|
committer | Samuel Rødal <sroedal@trolltech.com> | 2009-06-30 12:20:11 (GMT) |
commit | 351e890aa13faac69a0ceaa8cb02660b2275cf82 (patch) | |
tree | caf61d0d83735128390759638b20011d3b150cf7 /src/opengl/gl2paintengineex/qglengineshadermanager_p.h | |
parent | 9dd82fcebc50ca802e9e24a50283152e1dc35508 (diff) | |
download | Qt-351e890aa13faac69a0ceaa8cb02660b2275cf82.zip Qt-351e890aa13faac69a0ceaa8cb02660b2275cf82.tar.gz Qt-351e890aa13faac69a0ceaa8cb02660b2275cf82.tar.bz2 |
Added custom shader hook to the GL 2 paint engine.
This will make it easier to implement pixmap filters, YUV->RGB
conversions, etc in other parts of Qt.
Diffstat (limited to 'src/opengl/gl2paintengineex/qglengineshadermanager_p.h')
-rw-r--r-- | src/opengl/gl2paintengineex/qglengineshadermanager_p.h | 41 |
1 files changed, 32 insertions, 9 deletions
diff --git a/src/opengl/gl2paintengineex/qglengineshadermanager_p.h b/src/opengl/gl2paintengineex/qglengineshadermanager_p.h index 34f0768..891776f 100644 --- a/src/opengl/gl2paintengineex/qglengineshadermanager_p.h +++ b/src/opengl/gl2paintengineex/qglengineshadermanager_p.h @@ -199,18 +199,19 @@ O = Global Opacity - CUSTOM SHADER CODE (idea, depricated) + CUSTOM SHADER CODE ================== The use of custom shader code is supported by the engine for drawImage and drawPixmap calls. This is implemented via hooks in the fragment pipeline. - The custom shader is passed to the engine as a partial fragment shader - (QGLCustomizedShader). The shader will implement a pre-defined method name - which Qt's fragment pipeline will call. There are two different hooks which - can be implemented as custom shader code: + The custom shader is passed to the shader manager as a partial fragment shader + by calling setCustomShader(). Qt's fragment pipeline will call the following + method name in the custom shader: mediump vec4 customShader(sampler2d src, vec2 srcCoords) - mediump vec4 customShaderWithDest(sampler2d dest, sampler2d src, vec2 srcCoords) + + Transformations, clipping, opacity, and composition modes set using QPainter + will be respected when using the custom shader hook. */ @@ -227,6 +228,22 @@ QT_BEGIN_NAMESPACE QT_MODULE(OpenGL) +class Q_OPENGL_EXPORT QGLCustomShader +{ +public: + QGLCustomShader(QGLShader *shader = 0); + virtual ~QGLCustomShader(); + + virtual void updateUniforms(QGLShaderProgram *program); + + void setShader(QGLShader *shader); + QGLShader *shader() const; + +private: + Q_DISABLE_COPY(QGLCustomShader) + + QGLShader *m_shader; +}; struct QGLEngineShaderProg { @@ -259,7 +276,7 @@ struct QGLEngineCachedShaderProg static const GLuint QT_VERTEX_COORDS_ATTR = 0; static const GLuint QT_TEXTURE_COORDS_ATTR = 1; -class QGLEngineShaderManager : public QObject +class Q_OPENGL_EXPORT QGLEngineShaderManager : public QObject { Q_OBJECT public: @@ -271,7 +288,8 @@ public: ImageSrc = Qt::TexturePattern+1, NonPremultipliedImageSrc = Qt::TexturePattern+2, PatternSrc = Qt::TexturePattern+3, - TextureSrcWithPattern = Qt::TexturePattern+4 + TextureSrcWithPattern = Qt::TexturePattern+4, + CustomSrc = Qt::TexturePattern + 5 }; // There are optimisations we can do, depending on the brush transform: @@ -285,6 +303,8 @@ public: void setMaskType(MaskType); void setCompositionMode(QPainter::CompositionMode); + void setCustomShader(QGLCustomShader *shader); + uint getUniformIdentifier(const char *uniformName); uint getUniformLocation(uint id); @@ -322,6 +342,7 @@ public: MainFragmentShader, ImageSrcFragmentShader, + CustomSrcFragmentShader, ImageSrcWithPatternFragmentShader, NonPremultipliedImageSrcFragmentShader, SolidBrushSrcFragmentShader, @@ -366,7 +387,6 @@ public: Q_ENUMS(ShaderName) #endif - private: QGLContext* ctx; bool shaderProgNeedsChanging; @@ -383,6 +403,9 @@ private: QGLShaderProgram* simpleShaderProg; QGLEngineShaderProg* currentShaderProg; + QGLEngineShaderProg customShaderProg; + QGLCustomShader* customShader; + // TODO: Possibly convert to a LUT QList<QGLEngineShaderProg> cachedPrograms; |