qgraphicsshadereffect.cpp

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

Generated by Squish Coco Non-Commercial 4.3.0-BETA-master-30-08-2018-4cb69e9