qgraphicsshadereffect.cpp

Switch to Source codePreprocessed file
LineSource CodeCoverage
1 -
2 -
3 -
4static const char qglslDefaultImageFragmentShader[] = " lowp vec4 customShader(lowp sampler2D imageTexture, highp vec2 textureCoords) { return texture2D(imageTexture, textureCoords); }\n"; -
5 -
6 -
7 -
8 -
9 -
10 -
11class QGLCustomShaderEffectStage : public QGLCustomShaderStage -
12{ -
13public: -
14 QGLCustomShaderEffectStage -
15 (QGraphicsShaderEffect *e, const QByteArray& source) -
16 : QGLCustomShaderStage(), -
17 effect(e) -
18 { -
19 setSource(source); -
20 }
never executed: }
0
21 -
22 void setUniforms(QGLShaderProgram *program); -
23 -
24 QGraphicsShaderEffect *effect; -
25}; -
26 -
27void QGLCustomShaderEffectStage::setUniforms(QGLShaderProgram *program) -
28{ -
29 effect->setUniforms(program); -
30}
never executed: }
0
31 -
32 -
33 -
34class QGraphicsShaderEffectPrivate : public QGraphicsEffectPrivate -
35{ -
36 inline QGraphicsShaderEffect* q_func() { return static_cast<QGraphicsShaderEffect *>(q_ptr); } inline const QGraphicsShaderEffect* q_func() const { return static_cast<const QGraphicsShaderEffect *>(q_ptr); } friend class QGraphicsShaderEffect; -
37public: -
38 QGraphicsShaderEffectPrivate() -
39 : pixelShaderFragment(qglslDefaultImageFragmentShader) -
40 -
41 , customShaderStage(0) -
42 -
43 { -
44 }
never executed: }
0
45 -
46 QByteArray pixelShaderFragment; -
47 -
48 QGLCustomShaderEffectStage *customShaderStage; -
49 -
50}; -
51 -
52 -
53 -
54 -
55QGraphicsShaderEffect::QGraphicsShaderEffect(QObject *parent) -
56 : QGraphicsEffect(*new QGraphicsShaderEffectPrivate(), parent) -
57{ -
58}
never executed: }
0
59 -
60 -
61 -
62 -
63QGraphicsShaderEffect::~QGraphicsShaderEffect() -
64{ -
65 -
66 QGraphicsShaderEffectPrivate * const d = d_func(); -
67 delete d->customShaderStage; -
68 -
69}
never executed: }
0
70QByteArray QGraphicsShaderEffect::pixelShaderFragment() const -
71{ -
72 const QGraphicsShaderEffectPrivate * const d = d_func(); -
73 return d->pixelShaderFragment;
never executed: return d->pixelShaderFragment;
0
74} -
75void QGraphicsShaderEffect::setPixelShaderFragment(const QByteArray& code) -
76{ -
77 QGraphicsShaderEffectPrivate * const d = d_func(); -
78 if (d->pixelShaderFragment != code) {
never evaluated: d->pixelShaderFragment != code
0
79 d->pixelShaderFragment = code; -
80 -
81 delete d->customShaderStage; -
82 d->customShaderStage = 0; -
83 -
84 }
never executed: }
0
85}
never executed: }
0
86 -
87 -
88 -
89 -
90void QGraphicsShaderEffect::draw(QPainter *painter) -
91{ -
92 QGraphicsShaderEffectPrivate * const d = d_func(); -
93 -
94 -
95 -
96 -
97 -
98 if (!d->customShaderStage) {
never evaluated: !d->customShaderStage
0
99 d->customShaderStage = new QGLCustomShaderEffectStage -
100 (this, d->pixelShaderFragment); -
101 }
never executed: }
0
102 bool usingShader = d->customShaderStage->setOnPainter(painter); -
103 -
104 QPoint offset; -
105 if (sourceIsPixmap()) {
never evaluated: sourceIsPixmap()
0
106 -
107 const QPixmap pixmap = sourcePixmap(Qt::LogicalCoordinates, &offset); -
108 painter->drawPixmap(offset, pixmap); -
109 } else {
never executed: }
0
110 -
111 const QPixmap pixmap = sourcePixmap(Qt::DeviceCoordinates, &offset); -
112 QTransform restoreTransform = painter->worldTransform(); -
113 painter->setWorldTransform(QTransform()); -
114 painter->drawPixmap(offset, pixmap); -
115 painter->setWorldTransform(restoreTransform); -
116 }
never executed: }
0
117 -
118 -
119 if (usingShader)
never evaluated: usingShader
0
120 d->customShaderStage->removeFromPainter(painter);
never executed: d->customShaderStage->removeFromPainter(painter);
0
121 -
122 -
123 -
124}
never executed: }
0
125void QGraphicsShaderEffect::setUniformsDirty() -
126{ -
127 -
128 QGraphicsShaderEffectPrivate * const d = d_func(); -
129 if (d->customShaderStage)
never evaluated: d->customShaderStage
0
130 d->customShaderStage->setUniformsDirty();
never executed: d->customShaderStage->setUniformsDirty();
0
131 -
132}
never executed: }
0
133void QGraphicsShaderEffect::setUniforms(QGLShaderProgram *program) -
134{ -
135 (void)program;; -
136}
never executed: }
0
137 -
138 -
139 -
Switch to Source codePreprocessed file

Generated by Squish Coco Non-Commercial