| Absolute File Name: | /home/opencoverage/opencoverage/guest-scripts/qtdeclarative/src/qtdeclarative/src/quick/items/context2d/qquickcontext2dcommandbuffer.cpp |
| Switch to Source code | Preprocessed file |
| Line | Source | Count | ||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 1 | - | |||||||||||||||||||||||||||||||
| 2 | - | |||||||||||||||||||||||||||||||
| 3 | - | |||||||||||||||||||||||||||||||
| 4 | - | |||||||||||||||||||||||||||||||
| 5 | - | |||||||||||||||||||||||||||||||
| 6 | - | |||||||||||||||||||||||||||||||
| 7 | - | |||||||||||||||||||||||||||||||
| 8 | void qt_image_boxblur(QImage& image, int radius, bool quality); | - | ||||||||||||||||||||||||||||||
| 9 | - | |||||||||||||||||||||||||||||||
| 10 | namespace { | - | ||||||||||||||||||||||||||||||
| 11 | class ShadowImageMaker | - | ||||||||||||||||||||||||||||||
| 12 | { | - | ||||||||||||||||||||||||||||||
| 13 | public: | - | ||||||||||||||||||||||||||||||
| 14 | virtual ~ShadowImageMaker() {} | - | ||||||||||||||||||||||||||||||
| 15 | - | |||||||||||||||||||||||||||||||
| 16 | void paintShapeAndShadow(QPainter *p, qreal offsetX, qreal offsetY, qreal blur, const QColor &color) | - | ||||||||||||||||||||||||||||||
| 17 | { | - | ||||||||||||||||||||||||||||||
| 18 | QRectF bounds = boundingRect().translated(offsetX, offsetY).adjusted(-2*blur, -2*blur, 2*blur, 2*blur); | - | ||||||||||||||||||||||||||||||
| 19 | QRect boundsAligned = bounds.toAlignedRect(); | - | ||||||||||||||||||||||||||||||
| 20 | - | |||||||||||||||||||||||||||||||
| 21 | QImage shadowImage(boundsAligned.size(), QImage::Format_ARGB32_Premultiplied); | - | ||||||||||||||||||||||||||||||
| 22 | shadowImage.fill(0); | - | ||||||||||||||||||||||||||||||
| 23 | - | |||||||||||||||||||||||||||||||
| 24 | QPainter shadowPainter(&shadowImage); | - | ||||||||||||||||||||||||||||||
| 25 | shadowPainter.setRenderHints(p->renderHints()); | - | ||||||||||||||||||||||||||||||
| 26 | shadowPainter.translate(offsetX - boundsAligned.left(), offsetY - boundsAligned.top()); | - | ||||||||||||||||||||||||||||||
| 27 | paint(&shadowPainter); | - | ||||||||||||||||||||||||||||||
| 28 | shadowPainter.end(); | - | ||||||||||||||||||||||||||||||
| 29 | - | |||||||||||||||||||||||||||||||
| 30 | if (blur > 0
| 0 | ||||||||||||||||||||||||||||||
| 31 | qt_image_boxblur(shadowImage, qMax(1, qRound(blur / 2)), true); never executed: qt_image_boxblur(shadowImage, qMax(1, qRound(blur / 2)), true); | 0 | ||||||||||||||||||||||||||||||
| 32 | - | |||||||||||||||||||||||||||||||
| 33 | - | |||||||||||||||||||||||||||||||
| 34 | shadowPainter.begin(&shadowImage); | - | ||||||||||||||||||||||||||||||
| 35 | shadowPainter.setCompositionMode(QPainter::CompositionMode_SourceIn); | - | ||||||||||||||||||||||||||||||
| 36 | shadowPainter.fillRect(shadowImage.rect(), color); | - | ||||||||||||||||||||||||||||||
| 37 | shadowPainter.end(); | - | ||||||||||||||||||||||||||||||
| 38 | - | |||||||||||||||||||||||||||||||
| 39 | p->drawImage(boundsAligned.topLeft(), shadowImage); | - | ||||||||||||||||||||||||||||||
| 40 | paint(p); | - | ||||||||||||||||||||||||||||||
| 41 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 42 | - | |||||||||||||||||||||||||||||||
| 43 | virtual void paint(QPainter *p) const = 0; | - | ||||||||||||||||||||||||||||||
| 44 | virtual QRectF boundingRect() const = 0; | - | ||||||||||||||||||||||||||||||
| 45 | }; | - | ||||||||||||||||||||||||||||||
| 46 | - | |||||||||||||||||||||||||||||||
| 47 | class FillRectShadow : public ShadowImageMaker | - | ||||||||||||||||||||||||||||||
| 48 | { | - | ||||||||||||||||||||||||||||||
| 49 | public: | - | ||||||||||||||||||||||||||||||
| 50 | FillRectShadow(const QRectF &rect, const QBrush &brush) | - | ||||||||||||||||||||||||||||||
| 51 | : m_rect(rect.normalized()) | - | ||||||||||||||||||||||||||||||
| 52 | , m_brush(brush) | - | ||||||||||||||||||||||||||||||
| 53 | { | - | ||||||||||||||||||||||||||||||
| 54 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 55 | - | |||||||||||||||||||||||||||||||
| 56 | void paint(QPainter *p) const override { p->fillRect(m_rect, m_brush); } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 57 | QRectF boundingRect() const override { return never executed: m_rect;return m_rect;never executed: }return m_rect; | 0 | ||||||||||||||||||||||||||||||
| 58 | - | |||||||||||||||||||||||||||||||
| 59 | private: | - | ||||||||||||||||||||||||||||||
| 60 | QRectF m_rect; | - | ||||||||||||||||||||||||||||||
| 61 | QBrush m_brush; | - | ||||||||||||||||||||||||||||||
| 62 | }; | - | ||||||||||||||||||||||||||||||
| 63 | - | |||||||||||||||||||||||||||||||
| 64 | class FillPathShadow : public ShadowImageMaker | - | ||||||||||||||||||||||||||||||
| 65 | { | - | ||||||||||||||||||||||||||||||
| 66 | public: | - | ||||||||||||||||||||||||||||||
| 67 | FillPathShadow(const QPainterPath &path, const QBrush &brush) | - | ||||||||||||||||||||||||||||||
| 68 | : m_path(path) | - | ||||||||||||||||||||||||||||||
| 69 | , m_brush(brush) | - | ||||||||||||||||||||||||||||||
| 70 | { | - | ||||||||||||||||||||||||||||||
| 71 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 72 | - | |||||||||||||||||||||||||||||||
| 73 | void paint(QPainter *p) const override { p->fillPath(m_path, m_brush); } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 74 | QRectF boundingRect() const override { return never executed: m_path.boundingRect();return m_path.boundingRect();never executed: }return m_path.boundingRect(); | 0 | ||||||||||||||||||||||||||||||
| 75 | - | |||||||||||||||||||||||||||||||
| 76 | private: | - | ||||||||||||||||||||||||||||||
| 77 | QPainterPath m_path; | - | ||||||||||||||||||||||||||||||
| 78 | QBrush m_brush; | - | ||||||||||||||||||||||||||||||
| 79 | }; | - | ||||||||||||||||||||||||||||||
| 80 | - | |||||||||||||||||||||||||||||||
| 81 | class StrokePathShadow : public ShadowImageMaker | - | ||||||||||||||||||||||||||||||
| 82 | { | - | ||||||||||||||||||||||||||||||
| 83 | public: | - | ||||||||||||||||||||||||||||||
| 84 | StrokePathShadow(const QPainterPath &path, const QPen &pen) | - | ||||||||||||||||||||||||||||||
| 85 | : m_path(path) | - | ||||||||||||||||||||||||||||||
| 86 | , m_pen(pen) | - | ||||||||||||||||||||||||||||||
| 87 | { | - | ||||||||||||||||||||||||||||||
| 88 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 89 | - | |||||||||||||||||||||||||||||||
| 90 | void paint(QPainter *p) const override { p->strokePath(m_path, m_pen); } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 91 | - | |||||||||||||||||||||||||||||||
| 92 | QRectF boundingRect() const override | - | ||||||||||||||||||||||||||||||
| 93 | { | - | ||||||||||||||||||||||||||||||
| 94 | qreal d = qMax(qreal(1), m_pen.widthF()); | - | ||||||||||||||||||||||||||||||
| 95 | return never executed: m_path.boundingRect().adjusted(-d, -d, d, d);return m_path.boundingRect().adjusted(-d, -d, d, d);never executed: return m_path.boundingRect().adjusted(-d, -d, d, d); | 0 | ||||||||||||||||||||||||||||||
| 96 | } | - | ||||||||||||||||||||||||||||||
| 97 | - | |||||||||||||||||||||||||||||||
| 98 | private: | - | ||||||||||||||||||||||||||||||
| 99 | QPainterPath m_path; | - | ||||||||||||||||||||||||||||||
| 100 | QPen m_pen; | - | ||||||||||||||||||||||||||||||
| 101 | }; | - | ||||||||||||||||||||||||||||||
| 102 | - | |||||||||||||||||||||||||||||||
| 103 | class DrawImageShadow : public ShadowImageMaker | - | ||||||||||||||||||||||||||||||
| 104 | { | - | ||||||||||||||||||||||||||||||
| 105 | public: | - | ||||||||||||||||||||||||||||||
| 106 | DrawImageShadow(const QImage &image, const QPointF &offset) | - | ||||||||||||||||||||||||||||||
| 107 | : m_image(image) | - | ||||||||||||||||||||||||||||||
| 108 | , m_offset(offset) | - | ||||||||||||||||||||||||||||||
| 109 | { | - | ||||||||||||||||||||||||||||||
| 110 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 111 | - | |||||||||||||||||||||||||||||||
| 112 | void paint(QPainter *p) const override { p->drawImage(m_offset, m_image); } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 113 | - | |||||||||||||||||||||||||||||||
| 114 | QRectF boundingRect() const override { return never executed: QRectF(m_image.rect()).translated(m_offset);return QRectF(m_image.rect()).translated(m_offset);never executed: }return QRectF(m_image.rect()).translated(m_offset); | 0 | ||||||||||||||||||||||||||||||
| 115 | - | |||||||||||||||||||||||||||||||
| 116 | private: | - | ||||||||||||||||||||||||||||||
| 117 | QImage m_image; | - | ||||||||||||||||||||||||||||||
| 118 | QPointF m_offset; | - | ||||||||||||||||||||||||||||||
| 119 | }; | - | ||||||||||||||||||||||||||||||
| 120 | } | - | ||||||||||||||||||||||||||||||
| 121 | - | |||||||||||||||||||||||||||||||
| 122 | static void fillRectShadow(QPainter* p, QRectF shadowRect, qreal offsetX, qreal offsetY, qreal blur, const QColor& color) | - | ||||||||||||||||||||||||||||||
| 123 | { | - | ||||||||||||||||||||||||||||||
| 124 | FillRectShadow shadowMaker(shadowRect, p->brush()); | - | ||||||||||||||||||||||||||||||
| 125 | shadowMaker.paintShapeAndShadow(p, offsetX, offsetY, blur, color); | - | ||||||||||||||||||||||||||||||
| 126 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 127 | - | |||||||||||||||||||||||||||||||
| 128 | static void fillShadowPath(QPainter* p, const QPainterPath& path, qreal offsetX, qreal offsetY, qreal blur, const QColor& color) | - | ||||||||||||||||||||||||||||||
| 129 | { | - | ||||||||||||||||||||||||||||||
| 130 | FillPathShadow shadowMaker(path, p->brush()); | - | ||||||||||||||||||||||||||||||
| 131 | shadowMaker.paintShapeAndShadow(p, offsetX, offsetY, blur, color); | - | ||||||||||||||||||||||||||||||
| 132 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 133 | - | |||||||||||||||||||||||||||||||
| 134 | static void strokeShadowPath(QPainter* p, const QPainterPath& path, qreal offsetX, qreal offsetY, qreal blur, const QColor& color) | - | ||||||||||||||||||||||||||||||
| 135 | { | - | ||||||||||||||||||||||||||||||
| 136 | StrokePathShadow shadowMaker(path, p->pen()); | - | ||||||||||||||||||||||||||||||
| 137 | shadowMaker.paintShapeAndShadow(p, offsetX, offsetY, blur, color); | - | ||||||||||||||||||||||||||||||
| 138 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 139 | - | |||||||||||||||||||||||||||||||
| 140 | QPen QQuickContext2DCommandBuffer::makePen(const QQuickContext2D::State& state) | - | ||||||||||||||||||||||||||||||
| 141 | { | - | ||||||||||||||||||||||||||||||
| 142 | QPen pen; | - | ||||||||||||||||||||||||||||||
| 143 | pen.setWidthF(state.lineWidth); | - | ||||||||||||||||||||||||||||||
| 144 | pen.setCapStyle(state.lineCap); | - | ||||||||||||||||||||||||||||||
| 145 | pen.setJoinStyle(state.lineJoin); | - | ||||||||||||||||||||||||||||||
| 146 | pen.setMiterLimit(state.miterLimit); | - | ||||||||||||||||||||||||||||||
| 147 | pen.setBrush(state.strokeStyle); | - | ||||||||||||||||||||||||||||||
| 148 | return never executed: pen;return pen;never executed: return pen; | 0 | ||||||||||||||||||||||||||||||
| 149 | } | - | ||||||||||||||||||||||||||||||
| 150 | - | |||||||||||||||||||||||||||||||
| 151 | void QQuickContext2DCommandBuffer::setPainterState(QPainter* p, const QQuickContext2D::State& state, const QPen& pen) | - | ||||||||||||||||||||||||||||||
| 152 | { | - | ||||||||||||||||||||||||||||||
| 153 | p->setTransform(state.matrix * p->transform()); | - | ||||||||||||||||||||||||||||||
| 154 | - | |||||||||||||||||||||||||||||||
| 155 | if (pen != p->pen()
| 0 | ||||||||||||||||||||||||||||||
| 156 | p->setPen(pen); never executed: p->setPen(pen); | 0 | ||||||||||||||||||||||||||||||
| 157 | - | |||||||||||||||||||||||||||||||
| 158 | if (state.fillStyle != p->brush()
| 0 | ||||||||||||||||||||||||||||||
| 159 | p->setBrush(state.fillStyle); never executed: p->setBrush(state.fillStyle); | 0 | ||||||||||||||||||||||||||||||
| 160 | - | |||||||||||||||||||||||||||||||
| 161 | if (state.font != p->font()
| 0 | ||||||||||||||||||||||||||||||
| 162 | p->setFont(state.font); never executed: p->setFont(state.font); | 0 | ||||||||||||||||||||||||||||||
| 163 | - | |||||||||||||||||||||||||||||||
| 164 | if (state.globalAlpha != p->opacity()
| 0 | ||||||||||||||||||||||||||||||
| 165 | p->setOpacity(state.globalAlpha); | - | ||||||||||||||||||||||||||||||
| 166 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 167 | - | |||||||||||||||||||||||||||||||
| 168 | if (state.globalCompositeOperation != p->compositionMode()
| 0 | ||||||||||||||||||||||||||||||
| 169 | p->setCompositionMode(state.globalCompositeOperation); never executed: p->setCompositionMode(state.globalCompositeOperation); | 0 | ||||||||||||||||||||||||||||||
| 170 | - | |||||||||||||||||||||||||||||||
| 171 | p->setClipping(state.clip); | - | ||||||||||||||||||||||||||||||
| 172 | if (state.clip
| 0 | ||||||||||||||||||||||||||||||
| 173 | p->setClipPath(state.clipPath); never executed: p->setClipPath(state.clipPath); | 0 | ||||||||||||||||||||||||||||||
| 174 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 175 | - | |||||||||||||||||||||||||||||||
| 176 | static void qt_drawImage(QPainter *p, QQuickContext2D::State& state, QImage image, const QRectF& sr, const QRectF& dr, bool shadow = false) | - | ||||||||||||||||||||||||||||||
| 177 | { | - | ||||||||||||||||||||||||||||||
| 178 | ((p) ? static_cast<void>(0) : qt_assert("p", __FILE__, 225)); | - | ||||||||||||||||||||||||||||||
| 179 | - | |||||||||||||||||||||||||||||||
| 180 | if (image.isNull()
| 0 | ||||||||||||||||||||||||||||||
| 181 | return; never executed: return; | 0 | ||||||||||||||||||||||||||||||
| 182 | - | |||||||||||||||||||||||||||||||
| 183 | qreal sx = sr.x(); | - | ||||||||||||||||||||||||||||||
| 184 | qreal sy = sr.y(); | - | ||||||||||||||||||||||||||||||
| 185 | qreal sw = sr.width(); | - | ||||||||||||||||||||||||||||||
| 186 | qreal sh = sr.height(); | - | ||||||||||||||||||||||||||||||
| 187 | qreal dx = dr.x(); | - | ||||||||||||||||||||||||||||||
| 188 | qreal dy = dr.y(); | - | ||||||||||||||||||||||||||||||
| 189 | qreal dw = dr.width(); | - | ||||||||||||||||||||||||||||||
| 190 | qreal dh = dr.height(); | - | ||||||||||||||||||||||||||||||
| 191 | - | |||||||||||||||||||||||||||||||
| 192 | if (sw == -1
| 0 | ||||||||||||||||||||||||||||||
| 193 | sw = image.width(); | - | ||||||||||||||||||||||||||||||
| 194 | sh = image.height(); | - | ||||||||||||||||||||||||||||||
| 195 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 196 | if (sx != 0
| 0 | ||||||||||||||||||||||||||||||
| 197 | image = image.copy(sx, sy, sw, sh); never executed: image = image.copy(sx, sy, sw, sh); | 0 | ||||||||||||||||||||||||||||||
| 198 | - | |||||||||||||||||||||||||||||||
| 199 | if (sw != dw
| 0 | ||||||||||||||||||||||||||||||
| 200 | image = image.scaled(dw, dh); never executed: image = image.scaled(dw, dh); | 0 | ||||||||||||||||||||||||||||||
| 201 | - | |||||||||||||||||||||||||||||||
| 202 | - | |||||||||||||||||||||||||||||||
| 203 | p->beginNativePainting(); | - | ||||||||||||||||||||||||||||||
| 204 | - | |||||||||||||||||||||||||||||||
| 205 | if (shadow
| 0 | ||||||||||||||||||||||||||||||
| 206 | DrawImageShadow shadowMaker(image, QPointF(dx, dy)); | - | ||||||||||||||||||||||||||||||
| 207 | shadowMaker.paintShapeAndShadow(p, state.shadowOffsetX, state.shadowOffsetY, state.shadowBlur, state.shadowColor); | - | ||||||||||||||||||||||||||||||
| 208 | } never executed: else {end of block | 0 | ||||||||||||||||||||||||||||||
| 209 | p->drawImage(dx, dy, image); | - | ||||||||||||||||||||||||||||||
| 210 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 211 | - | |||||||||||||||||||||||||||||||
| 212 | p->endNativePainting(); | - | ||||||||||||||||||||||||||||||
| 213 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 214 | - | |||||||||||||||||||||||||||||||
| 215 | void QQuickContext2DCommandBuffer::replay(QPainter* p, QQuickContext2D::State& state, const QVector2D &scaleFactor) | - | ||||||||||||||||||||||||||||||
| 216 | { | - | ||||||||||||||||||||||||||||||
| 217 | if (!p
| 0 | ||||||||||||||||||||||||||||||
| 218 | return; never executed: return; | 0 | ||||||||||||||||||||||||||||||
| 219 | - | |||||||||||||||||||||||||||||||
| 220 | reset(); | - | ||||||||||||||||||||||||||||||
| 221 | - | |||||||||||||||||||||||||||||||
| 222 | p->scale(scaleFactor.x(), scaleFactor.y()); | - | ||||||||||||||||||||||||||||||
| 223 | QTransform originMatrix = p->worldTransform(); | - | ||||||||||||||||||||||||||||||
| 224 | - | |||||||||||||||||||||||||||||||
| 225 | QPen pen = makePen(state); | - | ||||||||||||||||||||||||||||||
| 226 | setPainterState(p, state, pen); | - | ||||||||||||||||||||||||||||||
| 227 | - | |||||||||||||||||||||||||||||||
| 228 | while (hasNext()
| 0 | ||||||||||||||||||||||||||||||
| 229 | QQuickContext2D::PaintCommand cmd = takeNextCommand(); | - | ||||||||||||||||||||||||||||||
| 230 | switch (cmd) { | - | ||||||||||||||||||||||||||||||
| 231 | case never executed: QQuickContext2D::UpdateMatrix:case QQuickContext2D::UpdateMatrix:never executed: case QQuickContext2D::UpdateMatrix: | 0 | ||||||||||||||||||||||||||||||
| 232 | { | - | ||||||||||||||||||||||||||||||
| 233 | state.matrix = takeMatrix(); | - | ||||||||||||||||||||||||||||||
| 234 | p->setWorldTransform(state.matrix * originMatrix); | - | ||||||||||||||||||||||||||||||
| 235 | break; never executed: break; | 0 | ||||||||||||||||||||||||||||||
| 236 | } | - | ||||||||||||||||||||||||||||||
| 237 | case never executed: QQuickContext2D::ClearRect:case QQuickContext2D::ClearRect:never executed: case QQuickContext2D::ClearRect: | 0 | ||||||||||||||||||||||||||||||
| 238 | { | - | ||||||||||||||||||||||||||||||
| 239 | QPainter::CompositionMode cm = p->compositionMode(); | - | ||||||||||||||||||||||||||||||
| 240 | p->setCompositionMode(QPainter::CompositionMode_Clear); | - | ||||||||||||||||||||||||||||||
| 241 | p->fillRect(takeRect(), Qt::white); | - | ||||||||||||||||||||||||||||||
| 242 | p->setCompositionMode(cm); | - | ||||||||||||||||||||||||||||||
| 243 | break; never executed: break; | 0 | ||||||||||||||||||||||||||||||
| 244 | } | - | ||||||||||||||||||||||||||||||
| 245 | case never executed: QQuickContext2D::FillRect:case QQuickContext2D::FillRect:never executed: case QQuickContext2D::FillRect: | 0 | ||||||||||||||||||||||||||||||
| 246 | { | - | ||||||||||||||||||||||||||||||
| 247 | QRectF r = takeRect(); | - | ||||||||||||||||||||||||||||||
| 248 | if ((state.shadowColor.isValid()
| 0 | ||||||||||||||||||||||||||||||
| 249 | fillRectShadow(p, r, state.shadowOffsetX, state.shadowOffsetY, state.shadowBlur, state.shadowColor); never executed: fillRectShadow(p, r, state.shadowOffsetX, state.shadowOffsetY, state.shadowBlur, state.shadowColor); | 0 | ||||||||||||||||||||||||||||||
| 250 | else | - | ||||||||||||||||||||||||||||||
| 251 | p->fillRect(r, p->brush()); never executed: p->fillRect(r, p->brush()); | 0 | ||||||||||||||||||||||||||||||
| 252 | break; never executed: break; | 0 | ||||||||||||||||||||||||||||||
| 253 | } | - | ||||||||||||||||||||||||||||||
| 254 | case never executed: QQuickContext2D::ShadowColor:case QQuickContext2D::ShadowColor:never executed: case QQuickContext2D::ShadowColor: | 0 | ||||||||||||||||||||||||||||||
| 255 | { | - | ||||||||||||||||||||||||||||||
| 256 | state.shadowColor = takeColor(); | - | ||||||||||||||||||||||||||||||
| 257 | break; never executed: break; | 0 | ||||||||||||||||||||||||||||||
| 258 | } | - | ||||||||||||||||||||||||||||||
| 259 | case never executed: QQuickContext2D::ShadowBlur:case QQuickContext2D::ShadowBlur:never executed: case QQuickContext2D::ShadowBlur: | 0 | ||||||||||||||||||||||||||||||
| 260 | { | - | ||||||||||||||||||||||||||||||
| 261 | state.shadowBlur = takeShadowBlur(); | - | ||||||||||||||||||||||||||||||
| 262 | break; never executed: break; | 0 | ||||||||||||||||||||||||||||||
| 263 | } | - | ||||||||||||||||||||||||||||||
| 264 | case never executed: QQuickContext2D::ShadowOffsetX:case QQuickContext2D::ShadowOffsetX:never executed: case QQuickContext2D::ShadowOffsetX: | 0 | ||||||||||||||||||||||||||||||
| 265 | { | - | ||||||||||||||||||||||||||||||
| 266 | state.shadowOffsetX = takeShadowOffsetX(); | - | ||||||||||||||||||||||||||||||
| 267 | break; never executed: break; | 0 | ||||||||||||||||||||||||||||||
| 268 | } | - | ||||||||||||||||||||||||||||||
| 269 | case never executed: QQuickContext2D::ShadowOffsetY:case QQuickContext2D::ShadowOffsetY:never executed: case QQuickContext2D::ShadowOffsetY: | 0 | ||||||||||||||||||||||||||||||
| 270 | { | - | ||||||||||||||||||||||||||||||
| 271 | state.shadowOffsetY = takeShadowOffsetY(); | - | ||||||||||||||||||||||||||||||
| 272 | break; never executed: break; | 0 | ||||||||||||||||||||||||||||||
| 273 | } | - | ||||||||||||||||||||||||||||||
| 274 | case never executed: QQuickContext2D::FillStyle:case QQuickContext2D::FillStyle:never executed: case QQuickContext2D::FillStyle: | 0 | ||||||||||||||||||||||||||||||
| 275 | { | - | ||||||||||||||||||||||||||||||
| 276 | state.fillStyle = takeFillStyle(); | - | ||||||||||||||||||||||||||||||
| 277 | state.fillPatternRepeatX = takeBool(); | - | ||||||||||||||||||||||||||||||
| 278 | state.fillPatternRepeatY = takeBool(); | - | ||||||||||||||||||||||||||||||
| 279 | p->setBrush(state.fillStyle); | - | ||||||||||||||||||||||||||||||
| 280 | break; never executed: break; | 0 | ||||||||||||||||||||||||||||||
| 281 | } | - | ||||||||||||||||||||||||||||||
| 282 | case never executed: QQuickContext2D::StrokeStyle:case QQuickContext2D::StrokeStyle:never executed: case QQuickContext2D::StrokeStyle: | 0 | ||||||||||||||||||||||||||||||
| 283 | { | - | ||||||||||||||||||||||||||||||
| 284 | state.strokeStyle = takeStrokeStyle(); | - | ||||||||||||||||||||||||||||||
| 285 | state.strokePatternRepeatX = takeBool(); | - | ||||||||||||||||||||||||||||||
| 286 | state.strokePatternRepeatY = takeBool(); | - | ||||||||||||||||||||||||||||||
| 287 | QPen nPen = p->pen(); | - | ||||||||||||||||||||||||||||||
| 288 | nPen.setBrush(state.strokeStyle); | - | ||||||||||||||||||||||||||||||
| 289 | p->setPen(nPen); | - | ||||||||||||||||||||||||||||||
| 290 | break; never executed: break; | 0 | ||||||||||||||||||||||||||||||
| 291 | } | - | ||||||||||||||||||||||||||||||
| 292 | case never executed: QQuickContext2D::LineWidth:case QQuickContext2D::LineWidth:never executed: case QQuickContext2D::LineWidth: | 0 | ||||||||||||||||||||||||||||||
| 293 | { | - | ||||||||||||||||||||||||||||||
| 294 | state.lineWidth = takeLineWidth(); | - | ||||||||||||||||||||||||||||||
| 295 | QPen nPen = p->pen(); | - | ||||||||||||||||||||||||||||||
| 296 | - | |||||||||||||||||||||||||||||||
| 297 | nPen.setWidthF(state.lineWidth); | - | ||||||||||||||||||||||||||||||
| 298 | p->setPen(nPen); | - | ||||||||||||||||||||||||||||||
| 299 | break; never executed: break; | 0 | ||||||||||||||||||||||||||||||
| 300 | } | - | ||||||||||||||||||||||||||||||
| 301 | case never executed: QQuickContext2D::LineCap:case QQuickContext2D::LineCap:never executed: case QQuickContext2D::LineCap: | 0 | ||||||||||||||||||||||||||||||
| 302 | { | - | ||||||||||||||||||||||||||||||
| 303 | state.lineCap = takeLineCap(); | - | ||||||||||||||||||||||||||||||
| 304 | QPen nPen = p->pen(); | - | ||||||||||||||||||||||||||||||
| 305 | nPen.setCapStyle(state.lineCap); | - | ||||||||||||||||||||||||||||||
| 306 | p->setPen(nPen); | - | ||||||||||||||||||||||||||||||
| 307 | break; never executed: break; | 0 | ||||||||||||||||||||||||||||||
| 308 | } | - | ||||||||||||||||||||||||||||||
| 309 | case never executed: QQuickContext2D::LineJoin:case QQuickContext2D::LineJoin:never executed: case QQuickContext2D::LineJoin: | 0 | ||||||||||||||||||||||||||||||
| 310 | { | - | ||||||||||||||||||||||||||||||
| 311 | state.lineJoin = takeLineJoin(); | - | ||||||||||||||||||||||||||||||
| 312 | QPen nPen = p->pen(); | - | ||||||||||||||||||||||||||||||
| 313 | nPen.setJoinStyle(state.lineJoin); | - | ||||||||||||||||||||||||||||||
| 314 | p->setPen(nPen); | - | ||||||||||||||||||||||||||||||
| 315 | break; never executed: break; | 0 | ||||||||||||||||||||||||||||||
| 316 | } | - | ||||||||||||||||||||||||||||||
| 317 | case never executed: QQuickContext2D::MiterLimit:case QQuickContext2D::MiterLimit:never executed: case QQuickContext2D::MiterLimit: | 0 | ||||||||||||||||||||||||||||||
| 318 | { | - | ||||||||||||||||||||||||||||||
| 319 | state.miterLimit = takeMiterLimit(); | - | ||||||||||||||||||||||||||||||
| 320 | QPen nPen = p->pen(); | - | ||||||||||||||||||||||||||||||
| 321 | nPen.setMiterLimit(state.miterLimit); | - | ||||||||||||||||||||||||||||||
| 322 | p->setPen(nPen); | - | ||||||||||||||||||||||||||||||
| 323 | break; never executed: break; | 0 | ||||||||||||||||||||||||||||||
| 324 | } | - | ||||||||||||||||||||||||||||||
| 325 | case never executed: QQuickContext2D::TextAlign:case QQuickContext2D::TextAlign:never executed: case QQuickContext2D::TextAlign: | 0 | ||||||||||||||||||||||||||||||
| 326 | case never executed: QQuickContext2D::TextBaseline:case QQuickContext2D::TextBaseline:never executed: case QQuickContext2D::TextBaseline: | 0 | ||||||||||||||||||||||||||||||
| 327 | break; never executed: break; | 0 | ||||||||||||||||||||||||||||||
| 328 | case never executed: QQuickContext2D::Fill:case QQuickContext2D::Fill:never executed: case QQuickContext2D::Fill: | 0 | ||||||||||||||||||||||||||||||
| 329 | { | - | ||||||||||||||||||||||||||||||
| 330 | QPainterPath path = takePath(); | - | ||||||||||||||||||||||||||||||
| 331 | path.closeSubpath(); | - | ||||||||||||||||||||||||||||||
| 332 | if ((state.shadowColor.isValid()
| 0 | ||||||||||||||||||||||||||||||
| 333 | fillShadowPath(p,path, state.shadowOffsetX, state.shadowOffsetY, state.shadowBlur, state.shadowColor); never executed: fillShadowPath(p,path, state.shadowOffsetX, state.shadowOffsetY, state.shadowBlur, state.shadowColor); | 0 | ||||||||||||||||||||||||||||||
| 334 | else | - | ||||||||||||||||||||||||||||||
| 335 | p->fillPath(path, p->brush()); never executed: p->fillPath(path, p->brush()); | 0 | ||||||||||||||||||||||||||||||
| 336 | break; never executed: break; | 0 | ||||||||||||||||||||||||||||||
| 337 | } | - | ||||||||||||||||||||||||||||||
| 338 | case never executed: QQuickContext2D::Stroke:case QQuickContext2D::Stroke:never executed: case QQuickContext2D::Stroke: | 0 | ||||||||||||||||||||||||||||||
| 339 | { | - | ||||||||||||||||||||||||||||||
| 340 | if ((state.shadowColor.isValid()
| 0 | ||||||||||||||||||||||||||||||
| 341 | strokeShadowPath(p,takePath(), state.shadowOffsetX, state.shadowOffsetY, state.shadowBlur, state.shadowColor); never executed: strokeShadowPath(p,takePath(), state.shadowOffsetX, state.shadowOffsetY, state.shadowBlur, state.shadowColor); | 0 | ||||||||||||||||||||||||||||||
| 342 | else | - | ||||||||||||||||||||||||||||||
| 343 | p->strokePath(takePath(), p->pen()); never executed: p->strokePath(takePath(), p->pen()); | 0 | ||||||||||||||||||||||||||||||
| 344 | break; never executed: break; | 0 | ||||||||||||||||||||||||||||||
| 345 | } | - | ||||||||||||||||||||||||||||||
| 346 | case never executed: QQuickContext2D::Clip:case QQuickContext2D::Clip:never executed: case QQuickContext2D::Clip: | 0 | ||||||||||||||||||||||||||||||
| 347 | { | - | ||||||||||||||||||||||||||||||
| 348 | state.clip = takeBool(); | - | ||||||||||||||||||||||||||||||
| 349 | state.clipPath = takePath(); | - | ||||||||||||||||||||||||||||||
| 350 | p->setClipping(state.clip); | - | ||||||||||||||||||||||||||||||
| 351 | if (state.clip
| 0 | ||||||||||||||||||||||||||||||
| 352 | p->setClipPath(state.clipPath); never executed: p->setClipPath(state.clipPath); | 0 | ||||||||||||||||||||||||||||||
| 353 | break; never executed: break; | 0 | ||||||||||||||||||||||||||||||
| 354 | } | - | ||||||||||||||||||||||||||||||
| 355 | case never executed: QQuickContext2D::GlobalAlpha:case QQuickContext2D::GlobalAlpha:never executed: case QQuickContext2D::GlobalAlpha: | 0 | ||||||||||||||||||||||||||||||
| 356 | { | - | ||||||||||||||||||||||||||||||
| 357 | state.globalAlpha = takeGlobalAlpha(); | - | ||||||||||||||||||||||||||||||
| 358 | p->setOpacity(state.globalAlpha); | - | ||||||||||||||||||||||||||||||
| 359 | break; never executed: break; | 0 | ||||||||||||||||||||||||||||||
| 360 | } | - | ||||||||||||||||||||||||||||||
| 361 | case never executed: QQuickContext2D::GlobalCompositeOperation:case QQuickContext2D::GlobalCompositeOperation:never executed: case QQuickContext2D::GlobalCompositeOperation: | 0 | ||||||||||||||||||||||||||||||
| 362 | { | - | ||||||||||||||||||||||||||||||
| 363 | state.globalCompositeOperation = takeGlobalCompositeOperation(); | - | ||||||||||||||||||||||||||||||
| 364 | p->setCompositionMode(state.globalCompositeOperation); | - | ||||||||||||||||||||||||||||||
| 365 | break; never executed: break; | 0 | ||||||||||||||||||||||||||||||
| 366 | } | - | ||||||||||||||||||||||||||||||
| 367 | case never executed: QQuickContext2D::DrawImage:case QQuickContext2D::DrawImage:never executed: case QQuickContext2D::DrawImage: | 0 | ||||||||||||||||||||||||||||||
| 368 | { | - | ||||||||||||||||||||||||||||||
| 369 | QRectF sr = takeRect(); | - | ||||||||||||||||||||||||||||||
| 370 | QRectF dr = takeRect(); | - | ||||||||||||||||||||||||||||||
| 371 | qt_drawImage(p, state, takeImage(), sr, dr, (state.shadowColor.isValid() && state.shadowColor.alpha() && (state.shadowBlur || state.shadowOffsetX || state.shadowOffsetY))); | - | ||||||||||||||||||||||||||||||
| 372 | break; never executed: break; | 0 | ||||||||||||||||||||||||||||||
| 373 | } | - | ||||||||||||||||||||||||||||||
| 374 | case never executed: QQuickContext2D::DrawPixmap:case QQuickContext2D::DrawPixmap:never executed: case QQuickContext2D::DrawPixmap: | 0 | ||||||||||||||||||||||||||||||
| 375 | { | - | ||||||||||||||||||||||||||||||
| 376 | QRectF sr = takeRect(); | - | ||||||||||||||||||||||||||||||
| 377 | QRectF dr = takeRect(); | - | ||||||||||||||||||||||||||||||
| 378 | - | |||||||||||||||||||||||||||||||
| 379 | QQmlRefPointer<QQuickCanvasPixmap> pix = takePixmap(); | - | ||||||||||||||||||||||||||||||
| 380 | ((!pix.isNull()) ? static_cast<void>(0) : qt_assert("!pix.isNull()", __FILE__, 427)); | - | ||||||||||||||||||||||||||||||
| 381 | - | |||||||||||||||||||||||||||||||
| 382 | const bool hasShadow = (state.shadowColor.isValid()
| 0 | ||||||||||||||||||||||||||||||
| 383 | - | |||||||||||||||||||||||||||||||
| 384 | qt_drawImage(p, state, pix->image(), sr, dr, hasShadow); | - | ||||||||||||||||||||||||||||||
| 385 | break; never executed: break; | 0 | ||||||||||||||||||||||||||||||
| 386 | } | - | ||||||||||||||||||||||||||||||
| 387 | case never executed: QQuickContext2D::GetImageData:case QQuickContext2D::GetImageData:never executed: case QQuickContext2D::GetImageData: | 0 | ||||||||||||||||||||||||||||||
| 388 | { | - | ||||||||||||||||||||||||||||||
| 389 | - | |||||||||||||||||||||||||||||||
| 390 | break; never executed: break; | 0 | ||||||||||||||||||||||||||||||
| 391 | } | - | ||||||||||||||||||||||||||||||
| 392 | default never executed: :default:never executed: default: | 0 | ||||||||||||||||||||||||||||||
| 393 | break; never executed: break; | 0 | ||||||||||||||||||||||||||||||
| 394 | } | - | ||||||||||||||||||||||||||||||
| 395 | } | - | ||||||||||||||||||||||||||||||
| 396 | - | |||||||||||||||||||||||||||||||
| 397 | p->end(); | - | ||||||||||||||||||||||||||||||
| 398 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 399 | - | |||||||||||||||||||||||||||||||
| 400 | QQuickContext2DCommandBuffer::QQuickContext2DCommandBuffer() | - | ||||||||||||||||||||||||||||||
| 401 | : cmdIdx(0) | - | ||||||||||||||||||||||||||||||
| 402 | , intIdx(0) | - | ||||||||||||||||||||||||||||||
| 403 | , boolIdx(0) | - | ||||||||||||||||||||||||||||||
| 404 | , realIdx(0) | - | ||||||||||||||||||||||||||||||
| 405 | , rectIdx(0) | - | ||||||||||||||||||||||||||||||
| 406 | , colorIdx(0) | - | ||||||||||||||||||||||||||||||
| 407 | , matrixIdx(0) | - | ||||||||||||||||||||||||||||||
| 408 | , brushIdx(0) | - | ||||||||||||||||||||||||||||||
| 409 | , pathIdx(0) | - | ||||||||||||||||||||||||||||||
| 410 | , imageIdx(0) | - | ||||||||||||||||||||||||||||||
| 411 | , pixmapIdx(0) | - | ||||||||||||||||||||||||||||||
| 412 | { | - | ||||||||||||||||||||||||||||||
| 413 | static bool registered = false; | - | ||||||||||||||||||||||||||||||
| 414 | if (!registered
| 0 | ||||||||||||||||||||||||||||||
| 415 | qRegisterMetaType<QQuickContext2DCommandBuffer*>("QQuickContext2DCommandBuffer*"); | - | ||||||||||||||||||||||||||||||
| 416 | registered = true; | - | ||||||||||||||||||||||||||||||
| 417 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 418 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 419 | - | |||||||||||||||||||||||||||||||
| 420 | - | |||||||||||||||||||||||||||||||
| 421 | QQuickContext2DCommandBuffer::~QQuickContext2DCommandBuffer() | - | ||||||||||||||||||||||||||||||
| 422 | { | - | ||||||||||||||||||||||||||||||
| 423 | } | - | ||||||||||||||||||||||||||||||
| 424 | - | |||||||||||||||||||||||||||||||
| 425 | void QQuickContext2DCommandBuffer::clear() | - | ||||||||||||||||||||||||||||||
| 426 | { | - | ||||||||||||||||||||||||||||||
| 427 | commands.clear(); | - | ||||||||||||||||||||||||||||||
| 428 | ints.clear(); | - | ||||||||||||||||||||||||||||||
| 429 | bools.clear(); | - | ||||||||||||||||||||||||||||||
| 430 | reals.clear(); | - | ||||||||||||||||||||||||||||||
| 431 | rects.clear(); | - | ||||||||||||||||||||||||||||||
| 432 | colors.clear(); | - | ||||||||||||||||||||||||||||||
| 433 | matrixes.clear(); | - | ||||||||||||||||||||||||||||||
| 434 | brushes.clear(); | - | ||||||||||||||||||||||||||||||
| 435 | pathes.clear(); | - | ||||||||||||||||||||||||||||||
| 436 | images.clear(); | - | ||||||||||||||||||||||||||||||
| 437 | pixmaps.clear(); | - | ||||||||||||||||||||||||||||||
| 438 | reset(); | - | ||||||||||||||||||||||||||||||
| 439 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 440 | - | |||||||||||||||||||||||||||||||
| 441 | void QQuickContext2DCommandBuffer::reset() | - | ||||||||||||||||||||||||||||||
| 442 | { | - | ||||||||||||||||||||||||||||||
| 443 | cmdIdx = 0; | - | ||||||||||||||||||||||||||||||
| 444 | intIdx = 0; | - | ||||||||||||||||||||||||||||||
| 445 | boolIdx = 0; | - | ||||||||||||||||||||||||||||||
| 446 | realIdx = 0; | - | ||||||||||||||||||||||||||||||
| 447 | rectIdx = 0; | - | ||||||||||||||||||||||||||||||
| 448 | colorIdx = 0; | - | ||||||||||||||||||||||||||||||
| 449 | matrixIdx = 0; | - | ||||||||||||||||||||||||||||||
| 450 | brushIdx = 0; | - | ||||||||||||||||||||||||||||||
| 451 | pathIdx = 0; | - | ||||||||||||||||||||||||||||||
| 452 | imageIdx = 0; | - | ||||||||||||||||||||||||||||||
| 453 | pixmapIdx = 0; | - | ||||||||||||||||||||||||||||||
| 454 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 455 | - | |||||||||||||||||||||||||||||||
| 456 | - | |||||||||||||||||||||||||||||||
| Switch to Source code | Preprocessed file |