| Absolute File Name: | /home/qt/qt5_coco/qt5/qtbase/src/opengl/qgraphicsshadereffect.cpp | 
| Switch to Source code | Preprocessed file | 
| Line | Source | Count | ||||||
|---|---|---|---|---|---|---|---|---|
| 1 | - | |||||||
| 2 | - | |||||||
| 3 | - | |||||||
| 4 | - | |||||||
| 5 | - | |||||||
| 6 | - | |||||||
| 7 | static const char qglslDefaultImageFragmentShader[] = " lowp vec4 customShader(lowp sampler2D imageTexture, highp vec2 textureCoords) { return texture2D(imageTexture, textureCoords); }\n"; | - | ||||||
| 8 | - | |||||||
| 9 | - | |||||||
| 10 | - | |||||||
| 11 | - | |||||||
| 12 | - | |||||||
| 13 | - | |||||||
| 14 | class QGLCustomShaderEffectStage : public QGLCustomShaderStage | - | ||||||
| 15 | { | - | ||||||
| 16 | public: | - | ||||||
| 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 | - | |||||||
| 30 | void QGLCustomShaderEffectStage::setUniforms(QGLShaderProgram *program) | - | ||||||
| 31 | { | - | ||||||
| 32 | effect->setUniforms(program); | - | ||||||
| 33 | } never executed:  end of block | 0 | ||||||
| 34 | - | |||||||
| 35 | - | |||||||
| 36 | - | |||||||
| 37 | class 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; | - | ||||||
| 40 | public: | - | ||||||
| 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 | - | |||||||
| 58 | QGraphicsShaderEffect::QGraphicsShaderEffect(QObject *parent) | - | ||||||
| 59 | : QGraphicsEffect(*new QGraphicsShaderEffectPrivate(), parent) | - | ||||||
| 60 | { | - | ||||||
| 61 | } never executed:  end of block | 0 | ||||||
| 62 | - | |||||||
| 63 | - | |||||||
| 64 | - | |||||||
| 65 | - | |||||||
| 66 | QGraphicsShaderEffect::~QGraphicsShaderEffect() | - | ||||||
| 67 | { | - | ||||||
| 68 | - | |||||||
| 69 | QGraphicsShaderEffectPrivate * const d = d_func(); | - | ||||||
| 70 | delete d->customShaderStage; | - | ||||||
| 71 | - | |||||||
| 72 | } never executed:  end of block | 0 | ||||||
| 73 | QByteArray QGraphicsShaderEffect::pixelShaderFragment() const | - | ||||||
| 74 | { | - | ||||||
| 75 | const QGraphicsShaderEffectPrivate * const d = d_func(); | - | ||||||
| 76 |     return never executed:   d->pixelShaderFragment;return d->pixelShaderFragment;never executed:  return d->pixelShaderFragment; | 0 | ||||||
| 77 | } | - | ||||||
| 78 | void QGraphicsShaderEffect::setPixelShaderFragment(const QByteArray& code) | - | ||||||
| 79 | { | - | ||||||
| 80 | QGraphicsShaderEffectPrivate * const d = d_func(); | - | ||||||
| 81 |     if (d->pixelShaderFragment != code
  | 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 | - | |||||||
| 93 | void QGraphicsShaderEffect::draw(QPainter *painter) | - | ||||||
| 94 | { | - | ||||||
| 95 | QGraphicsShaderEffectPrivate * const d = d_func(); | - | ||||||
| 96 | - | |||||||
| 97 | - | |||||||
| 98 | - | |||||||
| 99 | - | |||||||
| 100 | - | |||||||
| 101 |     if (!d->customShaderStage
  | 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()
  | 0 | ||||||
| 109 | - | |||||||
| 110 | const QPixmap pixmap = sourcePixmap(Qt::LogicalCoordinates, &offset); | - | ||||||
| 111 | painter->drawPixmap(offset, pixmap); | - | ||||||
| 112 |     } never executed:   else {end of block | 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
  | 0 | ||||||
| 123 |         d->customShaderStage->removeFromPainter(painter); never executed:  d->customShaderStage->removeFromPainter(painter); | 0 | ||||||
| 124 | - | |||||||
| 125 | - | |||||||
| 126 | - | |||||||
| 127 | } never executed:  end of block | 0 | ||||||
| 128 | void QGraphicsShaderEffect::setUniformsDirty() | - | ||||||
| 129 | { | - | ||||||
| 130 | - | |||||||
| 131 | QGraphicsShaderEffectPrivate * const d = d_func(); | - | ||||||
| 132 |     if (d->customShaderStage
  | 0 | ||||||
| 133 |         d->customShaderStage->setUniformsDirty(); never executed:  d->customShaderStage->setUniformsDirty(); | 0 | ||||||
| 134 | - | |||||||
| 135 | } never executed:  end of block | 0 | ||||||
| 136 | void QGraphicsShaderEffect::setUniforms(QGLShaderProgram *program) | - | ||||||
| 137 | { | - | ||||||
| 138 | (void)program;; | - | ||||||
| 139 | } never executed:  end of block | 0 | ||||||
| 140 | - | |||||||
| 141 | - | |||||||
| Switch to Source code | Preprocessed file |