summaryrefslogtreecommitdiffstats
path: root/src/opengl/gl2paintengineex/qglengineshadermanager_p.h
diff options
context:
space:
mode:
authorTom Cooksey <thomas.cooksey@nokia.com>2009-07-23 15:03:24 (GMT)
committerTom Cooksey <thomas.cooksey@nokia.com>2009-07-23 15:03:24 (GMT)
commit140ce8705f47a65bac32e804421b63d0c7b97d7d (patch)
tree5dfafd1cfe2d489ac2edd771e46385a4a7a748a1 /src/opengl/gl2paintengineex/qglengineshadermanager_p.h
parenta2d64535d011a47cb2bdf91002f9210cf6b656b1 (diff)
downloadQt-140ce8705f47a65bac32e804421b63d0c7b97d7d.zip
Qt-140ce8705f47a65bac32e804421b63d0c7b97d7d.tar.gz
Qt-140ce8705f47a65bac32e804421b63d0c7b97d7d.tar.bz2
Initial stab at a custom shader stage API
Diffstat (limited to 'src/opengl/gl2paintengineex/qglengineshadermanager_p.h')
-rw-r--r--src/opengl/gl2paintengineex/qglengineshadermanager_p.h30
1 files changed, 25 insertions, 5 deletions
diff --git a/src/opengl/gl2paintengineex/qglengineshadermanager_p.h b/src/opengl/gl2paintengineex/qglengineshadermanager_p.h
index 99711bd40..15082c3 100644
--- a/src/opengl/gl2paintengineex/qglengineshadermanager_p.h
+++ b/src/opengl/gl2paintengineex/qglengineshadermanager_p.h
@@ -205,12 +205,16 @@
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:
+ (QGLCustomShaderStage). The shader will implement a pre-defined method name
+ which Qt's fragment pipeline will call:
- mediump vec4 customShader(sampler2d src, vec2 srcCoords)
- mediump vec4 customShaderWithDest(sampler2d dest, sampler2d src, vec2 srcCoords)
+ lowp vec4 customShader()
+
+ Depending on the custom type, the custom shader has a small API it can use
+ to read pixels. The basic custom type is for image/pixmap drawing and thus
+ can use the following to sample the src texture (non-premultiplied)
+
+ lowp vec4 QSampleSrcPixel(mediump vec2 coords)
*/
@@ -221,6 +225,7 @@
#include <QGLShaderProgram>
#include <QPainter>
#include <private/qgl_p.h>
+#include <private/qglcustomshaderstage_p.h>
QT_BEGIN_HEADER
@@ -240,6 +245,17 @@ struct QGLEngineShaderProg
QGLShaderProgram* program;
QVector<uint> uniformLocations;
+
+ bool operator==(const QGLEngineShaderProg& other) {
+ // We don't care about the program
+ return ( mainVertexShader == other.mainVertexShader &&
+ positionVertexShader == other.positionVertexShader &&
+ mainFragShader == other.mainFragShader &&
+ srcPixelFragShader == other.srcPixelFragShader &&
+ maskFragShader == other.maskFragShader &&
+ compositionFragShader == other.compositionFragShader
+ );
+ }
};
/*
@@ -305,6 +321,8 @@ public:
void setUseGlobalOpacity(bool);
void setMaskType(MaskType);
void setCompositionMode(QPainter::CompositionMode);
+ void setCustomStage(QGLCustomShaderStage* stage);
+ void removeCustomStage(QGLCustomShaderStage* stage);
uint getUniformLocation(Uniform id);
@@ -346,6 +364,7 @@ public:
ImageSrcFragmentShader,
ImageSrcWithPatternFragmentShader,
NonPremultipliedImageSrcFragmentShader,
+ CustomImageSrcFragmentShader,
SolidBrushSrcFragmentShader,
TextureBrushSrcFragmentShader,
TextureBrushSrcWithPatternFragmentShader,
@@ -401,6 +420,7 @@ private:
MaskType maskType;
bool useTextureCoords;
QPainter::CompositionMode compositionMode;
+ QGLCustomShaderStage* customSrcStage;
QGLShaderProgram* blitShaderProg;
QGLShaderProgram* simpleShaderProg;