| Absolute File Name: | /home/qt/qt5_coco/qt5/qtbase/src/gui/painting/qemulationpaintengine.cpp |
| Source code | Switch to Preprocessed file |
| Line | Source | Count | ||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 1 | /**************************************************************************** | - | ||||||||||||||||||
| 2 | ** | - | ||||||||||||||||||
| 3 | ** Copyright (C) 2015 The Qt Company Ltd. | - | ||||||||||||||||||
| 4 | ** Contact: http://www.qt.io/licensing/ | - | ||||||||||||||||||
| 5 | ** | - | ||||||||||||||||||
| 6 | ** This file is part of the QtGui module of the Qt Toolkit. | - | ||||||||||||||||||
| 7 | ** | - | ||||||||||||||||||
| 8 | ** $QT_BEGIN_LICENSE:LGPL21$ | - | ||||||||||||||||||
| 9 | ** Commercial License Usage | - | ||||||||||||||||||
| 10 | ** Licensees holding valid commercial Qt licenses may use this file in | - | ||||||||||||||||||
| 11 | ** accordance with the commercial license agreement provided with the | - | ||||||||||||||||||
| 12 | ** Software or, alternatively, in accordance with the terms contained in | - | ||||||||||||||||||
| 13 | ** a written agreement between you and The Qt Company. For licensing terms | - | ||||||||||||||||||
| 14 | ** and conditions see http://www.qt.io/terms-conditions. For further | - | ||||||||||||||||||
| 15 | ** information use the contact form at http://www.qt.io/contact-us. | - | ||||||||||||||||||
| 16 | ** | - | ||||||||||||||||||
| 17 | ** GNU Lesser General Public License Usage | - | ||||||||||||||||||
| 18 | ** Alternatively, this file may be used under the terms of the GNU Lesser | - | ||||||||||||||||||
| 19 | ** General Public License version 2.1 or version 3 as published by the Free | - | ||||||||||||||||||
| 20 | ** Software Foundation and appearing in the file LICENSE.LGPLv21 and | - | ||||||||||||||||||
| 21 | ** LICENSE.LGPLv3 included in the packaging of this file. Please review the | - | ||||||||||||||||||
| 22 | ** following information to ensure the GNU Lesser General Public License | - | ||||||||||||||||||
| 23 | ** requirements will be met: https://www.gnu.org/licenses/lgpl.html and | - | ||||||||||||||||||
| 24 | ** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. | - | ||||||||||||||||||
| 25 | ** | - | ||||||||||||||||||
| 26 | ** As a special exception, The Qt Company gives you certain additional | - | ||||||||||||||||||
| 27 | ** rights. These rights are described in The Qt Company LGPL Exception | - | ||||||||||||||||||
| 28 | ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. | - | ||||||||||||||||||
| 29 | ** | - | ||||||||||||||||||
| 30 | ** $QT_END_LICENSE$ | - | ||||||||||||||||||
| 31 | ** | - | ||||||||||||||||||
| 32 | ****************************************************************************/ | - | ||||||||||||||||||
| 33 | - | |||||||||||||||||||
| 34 | #include <private/qemulationpaintengine_p.h> | - | ||||||||||||||||||
| 35 | #include <private/qpainter_p.h> | - | ||||||||||||||||||
| 36 | #include <private/qtextengine_p.h> | - | ||||||||||||||||||
| 37 | #include <qdebug.h> | - | ||||||||||||||||||
| 38 | - | |||||||||||||||||||
| 39 | QT_BEGIN_NAMESPACE | - | ||||||||||||||||||
| 40 | - | |||||||||||||||||||
| 41 | QEmulationPaintEngine::QEmulationPaintEngine(QPaintEngineEx *engine) | - | ||||||||||||||||||
| 42 | : real_engine(engine) | - | ||||||||||||||||||
| 43 | { | - | ||||||||||||||||||
| 44 | QPaintEngine::state = real_engine->state(); | - | ||||||||||||||||||
| 45 | } never executed: end of block | 0 | ||||||||||||||||||
| 46 | - | |||||||||||||||||||
| 47 | - | |||||||||||||||||||
| 48 | QPaintEngine::Type QEmulationPaintEngine::type() const | - | ||||||||||||||||||
| 49 | { | - | ||||||||||||||||||
| 50 | return real_engine->type(); never executed: return real_engine->type(); | 0 | ||||||||||||||||||
| 51 | } | - | ||||||||||||||||||
| 52 | - | |||||||||||||||||||
| 53 | bool QEmulationPaintEngine::begin(QPaintDevice *) | - | ||||||||||||||||||
| 54 | { | - | ||||||||||||||||||
| 55 | return true; never executed: return true; | 0 | ||||||||||||||||||
| 56 | } | - | ||||||||||||||||||
| 57 | - | |||||||||||||||||||
| 58 | bool QEmulationPaintEngine::end() | - | ||||||||||||||||||
| 59 | { | - | ||||||||||||||||||
| 60 | return true; never executed: return true; | 0 | ||||||||||||||||||
| 61 | } | - | ||||||||||||||||||
| 62 | - | |||||||||||||||||||
| 63 | - | |||||||||||||||||||
| 64 | QPainterState *QEmulationPaintEngine::createState(QPainterState *orig) const | - | ||||||||||||||||||
| 65 | { | - | ||||||||||||||||||
| 66 | return real_engine->createState(orig); never executed: return real_engine->createState(orig); | 0 | ||||||||||||||||||
| 67 | } | - | ||||||||||||||||||
| 68 | - | |||||||||||||||||||
| 69 | void QEmulationPaintEngine::fill(const QVectorPath &path, const QBrush &brush) | - | ||||||||||||||||||
| 70 | { | - | ||||||||||||||||||
| 71 | QPainterState *s = state(); | - | ||||||||||||||||||
| 72 | - | |||||||||||||||||||
| 73 | if (s->bgMode == Qt::OpaqueMode) {
| 0 | ||||||||||||||||||
| 74 | Qt::BrushStyle style = brush.style(); | - | ||||||||||||||||||
| 75 | if ((style >= Qt::Dense1Pattern && style <= Qt::DiagCrossPattern) || (style == Qt::TexturePattern ))
| 0 | ||||||||||||||||||
| 76 | real_engine->fill(path, s->bgBrush); never executed: real_engine->fill(path, s->bgBrush); | 0 | ||||||||||||||||||
| 77 | } never executed: end of block | 0 | ||||||||||||||||||
| 78 | - | |||||||||||||||||||
| 79 | Qt::BrushStyle style = qbrush_style(brush); | - | ||||||||||||||||||
| 80 | if (style >= Qt::LinearGradientPattern && style <= Qt::ConicalGradientPattern) {
| 0 | ||||||||||||||||||
| 81 | const QGradient *g = brush.gradient(); | - | ||||||||||||||||||
| 82 | - | |||||||||||||||||||
| 83 | if (g->coordinateMode() > QGradient::LogicalMode) {
| 0 | ||||||||||||||||||
| 84 | if (g->coordinateMode() == QGradient::StretchToDeviceMode) {
| 0 | ||||||||||||||||||
| 85 | QBrush copy = brush; | - | ||||||||||||||||||
| 86 | QTransform mat = copy.transform(); | - | ||||||||||||||||||
| 87 | mat.scale(real_engine->painter()->device()->width(), real_engine->painter()->device()->height()); | - | ||||||||||||||||||
| 88 | copy.setTransform(mat); | - | ||||||||||||||||||
| 89 | real_engine->fill(path, copy); | - | ||||||||||||||||||
| 90 | return; never executed: return; | 0 | ||||||||||||||||||
| 91 | } else if (g->coordinateMode() == QGradient::ObjectBoundingMode) {
| 0 | ||||||||||||||||||
| 92 | QBrush copy = brush; | - | ||||||||||||||||||
| 93 | QTransform mat = copy.transform(); | - | ||||||||||||||||||
| 94 | QRectF r = path.controlPointRect(); | - | ||||||||||||||||||
| 95 | mat.translate(r.x(), r.y()); | - | ||||||||||||||||||
| 96 | mat.scale(r.width(), r.height()); | - | ||||||||||||||||||
| 97 | copy.setTransform(mat); | - | ||||||||||||||||||
| 98 | real_engine->fill(path, copy); | - | ||||||||||||||||||
| 99 | return; never executed: return; | 0 | ||||||||||||||||||
| 100 | } | - | ||||||||||||||||||
| 101 | } never executed: end of block | 0 | ||||||||||||||||||
| 102 | } never executed: end of block | 0 | ||||||||||||||||||
| 103 | - | |||||||||||||||||||
| 104 | real_engine->fill(path, brush); | - | ||||||||||||||||||
| 105 | } never executed: end of block | 0 | ||||||||||||||||||
| 106 | - | |||||||||||||||||||
| 107 | void QEmulationPaintEngine::stroke(const QVectorPath &path, const QPen &pen) | - | ||||||||||||||||||
| 108 | { | - | ||||||||||||||||||
| 109 | QPainterState *s = state(); | - | ||||||||||||||||||
| 110 | - | |||||||||||||||||||
| 111 | if (s->bgMode == Qt::OpaqueMode && pen.style() > Qt::SolidLine) {
| 0 | ||||||||||||||||||
| 112 | QPen bgPen = pen; | - | ||||||||||||||||||
| 113 | bgPen.setBrush(s->bgBrush); | - | ||||||||||||||||||
| 114 | bgPen.setStyle(Qt::SolidLine); | - | ||||||||||||||||||
| 115 | real_engine->stroke(path, bgPen); | - | ||||||||||||||||||
| 116 | } never executed: end of block | 0 | ||||||||||||||||||
| 117 | - | |||||||||||||||||||
| 118 | QBrush brush = pen.brush(); | - | ||||||||||||||||||
| 119 | QPen copy = pen; | - | ||||||||||||||||||
| 120 | Qt::BrushStyle style = qbrush_style(brush); | - | ||||||||||||||||||
| 121 | if (style >= Qt::LinearGradientPattern && style <= Qt::ConicalGradientPattern) {
| 0 | ||||||||||||||||||
| 122 | const QGradient *g = brush.gradient(); | - | ||||||||||||||||||
| 123 | - | |||||||||||||||||||
| 124 | if (g->coordinateMode() > QGradient::LogicalMode) {
| 0 | ||||||||||||||||||
| 125 | if (g->coordinateMode() == QGradient::StretchToDeviceMode) {
| 0 | ||||||||||||||||||
| 126 | QTransform mat = brush.transform(); | - | ||||||||||||||||||
| 127 | mat.scale(real_engine->painter()->device()->width(), real_engine->painter()->device()->height()); | - | ||||||||||||||||||
| 128 | brush.setTransform(mat); | - | ||||||||||||||||||
| 129 | copy.setBrush(brush); | - | ||||||||||||||||||
| 130 | real_engine->stroke(path, copy); | - | ||||||||||||||||||
| 131 | return; never executed: return; | 0 | ||||||||||||||||||
| 132 | } else if (g->coordinateMode() == QGradient::ObjectBoundingMode) {
| 0 | ||||||||||||||||||
| 133 | QTransform mat = brush.transform(); | - | ||||||||||||||||||
| 134 | QRectF r = path.controlPointRect(); | - | ||||||||||||||||||
| 135 | mat.translate(r.x(), r.y()); | - | ||||||||||||||||||
| 136 | mat.scale(r.width(), r.height()); | - | ||||||||||||||||||
| 137 | brush.setTransform(mat); | - | ||||||||||||||||||
| 138 | copy.setBrush(brush); | - | ||||||||||||||||||
| 139 | real_engine->stroke(path, copy); | - | ||||||||||||||||||
| 140 | return; never executed: return; | 0 | ||||||||||||||||||
| 141 | } | - | ||||||||||||||||||
| 142 | } never executed: end of block | 0 | ||||||||||||||||||
| 143 | } never executed: end of block | 0 | ||||||||||||||||||
| 144 | - | |||||||||||||||||||
| 145 | real_engine->stroke(path, pen); | - | ||||||||||||||||||
| 146 | } never executed: end of block | 0 | ||||||||||||||||||
| 147 | - | |||||||||||||||||||
| 148 | void QEmulationPaintEngine::clip(const QVectorPath &path, Qt::ClipOperation op) | - | ||||||||||||||||||
| 149 | { | - | ||||||||||||||||||
| 150 | real_engine->clip(path, op); | - | ||||||||||||||||||
| 151 | } never executed: end of block | 0 | ||||||||||||||||||
| 152 | - | |||||||||||||||||||
| 153 | void QEmulationPaintEngine::drawPixmap(const QRectF &r, const QPixmap &pm, const QRectF &sr) | - | ||||||||||||||||||
| 154 | { | - | ||||||||||||||||||
| 155 | if (state()->bgMode == Qt::OpaqueMode && pm.isQBitmap())
| 0 | ||||||||||||||||||
| 156 | fillBGRect(r); never executed: fillBGRect(r); | 0 | ||||||||||||||||||
| 157 | real_engine->drawPixmap(r, pm, sr); | - | ||||||||||||||||||
| 158 | } never executed: end of block | 0 | ||||||||||||||||||
| 159 | - | |||||||||||||||||||
| 160 | void QEmulationPaintEngine::drawTextItem(const QPointF &p, const QTextItem &textItem) | - | ||||||||||||||||||
| 161 | { | - | ||||||||||||||||||
| 162 | if (state()->bgMode == Qt::OpaqueMode) {
| 0 | ||||||||||||||||||
| 163 | const QTextItemInt &ti = static_cast<const QTextItemInt &>(textItem); | - | ||||||||||||||||||
| 164 | QRectF rect(p.x(), p.y() - ti.ascent.toReal(), ti.width.toReal(), (ti.ascent + ti.descent).toReal()); | - | ||||||||||||||||||
| 165 | fillBGRect(rect); | - | ||||||||||||||||||
| 166 | } never executed: end of block | 0 | ||||||||||||||||||
| 167 | - | |||||||||||||||||||
| 168 | QPainterState *s = state(); | - | ||||||||||||||||||
| 169 | Qt::BrushStyle style = qbrush_style(s->pen.brush()); | - | ||||||||||||||||||
| 170 | if (style >= Qt::LinearGradientPattern && style <= Qt::ConicalGradientPattern)
| 0 | ||||||||||||||||||
| 171 | { | - | ||||||||||||||||||
| 172 | QPen savedPen = s->pen; | - | ||||||||||||||||||
| 173 | QGradient g = *s->pen.brush().gradient(); | - | ||||||||||||||||||
| 174 | - | |||||||||||||||||||
| 175 | if (g.coordinateMode() > QGradient::LogicalMode) {
| 0 | ||||||||||||||||||
| 176 | QTransform mat = s->pen.brush().transform(); | - | ||||||||||||||||||
| 177 | if (g.coordinateMode() == QGradient::StretchToDeviceMode) {
| 0 | ||||||||||||||||||
| 178 | mat.scale(real_engine->painter()->device()->width(), real_engine->painter()->device()->height()); | - | ||||||||||||||||||
| 179 | } else if (g.coordinateMode() == QGradient::ObjectBoundingMode) { never executed: end of block
| 0 | ||||||||||||||||||
| 180 | const QTextItemInt &ti = static_cast<const QTextItemInt &>(textItem); | - | ||||||||||||||||||
| 181 | QRectF r(p.x(), p.y() - ti.ascent.toReal(), ti.width.toReal(), (ti.ascent + ti.descent + 1).toReal()); | - | ||||||||||||||||||
| 182 | mat.translate(r.x(), r.y()); | - | ||||||||||||||||||
| 183 | mat.scale(r.width(), r.height()); | - | ||||||||||||||||||
| 184 | } never executed: end of block | 0 | ||||||||||||||||||
| 185 | g.setCoordinateMode(QGradient::LogicalMode); | - | ||||||||||||||||||
| 186 | QBrush brush(g); | - | ||||||||||||||||||
| 187 | brush.setTransform(mat); | - | ||||||||||||||||||
| 188 | s->pen.setBrush(brush); | - | ||||||||||||||||||
| 189 | penChanged(); | - | ||||||||||||||||||
| 190 | real_engine->drawTextItem(p, textItem); | - | ||||||||||||||||||
| 191 | s->pen = savedPen; | - | ||||||||||||||||||
| 192 | penChanged(); | - | ||||||||||||||||||
| 193 | return; never executed: return; | 0 | ||||||||||||||||||
| 194 | } | - | ||||||||||||||||||
| 195 | } never executed: end of block | 0 | ||||||||||||||||||
| 196 | - | |||||||||||||||||||
| 197 | real_engine->drawTextItem(p, textItem); | - | ||||||||||||||||||
| 198 | } never executed: end of block | 0 | ||||||||||||||||||
| 199 | - | |||||||||||||||||||
| 200 | void QEmulationPaintEngine::drawStaticTextItem(QStaticTextItem *item) | - | ||||||||||||||||||
| 201 | { | - | ||||||||||||||||||
| 202 | real_engine->drawStaticTextItem(item); | - | ||||||||||||||||||
| 203 | } never executed: end of block | 0 | ||||||||||||||||||
| 204 | - | |||||||||||||||||||
| 205 | void QEmulationPaintEngine::drawTiledPixmap(const QRectF &r, const QPixmap &pixmap, const QPointF &s) | - | ||||||||||||||||||
| 206 | { | - | ||||||||||||||||||
| 207 | if (state()->bgMode == Qt::OpaqueMode && pixmap.isQBitmap())
| 0 | ||||||||||||||||||
| 208 | fillBGRect(r); never executed: fillBGRect(r); | 0 | ||||||||||||||||||
| 209 | real_engine->drawTiledPixmap(r, pixmap, s); | - | ||||||||||||||||||
| 210 | } never executed: end of block | 0 | ||||||||||||||||||
| 211 | - | |||||||||||||||||||
| 212 | void QEmulationPaintEngine::drawImage(const QRectF &r, const QImage &pm, const QRectF &sr, Qt::ImageConversionFlags flags) | - | ||||||||||||||||||
| 213 | { | - | ||||||||||||||||||
| 214 | real_engine->drawImage(r, pm, sr, flags); | - | ||||||||||||||||||
| 215 | } never executed: end of block | 0 | ||||||||||||||||||
| 216 | - | |||||||||||||||||||
| 217 | void QEmulationPaintEngine::clipEnabledChanged() | - | ||||||||||||||||||
| 218 | { | - | ||||||||||||||||||
| 219 | real_engine->clipEnabledChanged(); | - | ||||||||||||||||||
| 220 | } never executed: end of block | 0 | ||||||||||||||||||
| 221 | - | |||||||||||||||||||
| 222 | void QEmulationPaintEngine::penChanged() | - | ||||||||||||||||||
| 223 | { | - | ||||||||||||||||||
| 224 | real_engine->penChanged(); | - | ||||||||||||||||||
| 225 | } never executed: end of block | 0 | ||||||||||||||||||
| 226 | - | |||||||||||||||||||
| 227 | void QEmulationPaintEngine::brushChanged() | - | ||||||||||||||||||
| 228 | { | - | ||||||||||||||||||
| 229 | real_engine->brushChanged(); | - | ||||||||||||||||||
| 230 | } never executed: end of block | 0 | ||||||||||||||||||
| 231 | - | |||||||||||||||||||
| 232 | void QEmulationPaintEngine::brushOriginChanged() | - | ||||||||||||||||||
| 233 | { | - | ||||||||||||||||||
| 234 | real_engine->brushOriginChanged(); | - | ||||||||||||||||||
| 235 | } never executed: end of block | 0 | ||||||||||||||||||
| 236 | - | |||||||||||||||||||
| 237 | void QEmulationPaintEngine::opacityChanged() | - | ||||||||||||||||||
| 238 | { | - | ||||||||||||||||||
| 239 | real_engine->opacityChanged(); | - | ||||||||||||||||||
| 240 | } never executed: end of block | 0 | ||||||||||||||||||
| 241 | - | |||||||||||||||||||
| 242 | void QEmulationPaintEngine::compositionModeChanged() | - | ||||||||||||||||||
| 243 | { | - | ||||||||||||||||||
| 244 | real_engine->compositionModeChanged(); | - | ||||||||||||||||||
| 245 | } never executed: end of block | 0 | ||||||||||||||||||
| 246 | - | |||||||||||||||||||
| 247 | void QEmulationPaintEngine::renderHintsChanged() | - | ||||||||||||||||||
| 248 | { | - | ||||||||||||||||||
| 249 | real_engine->renderHintsChanged(); | - | ||||||||||||||||||
| 250 | } never executed: end of block | 0 | ||||||||||||||||||
| 251 | - | |||||||||||||||||||
| 252 | void QEmulationPaintEngine::transformChanged() | - | ||||||||||||||||||
| 253 | { | - | ||||||||||||||||||
| 254 | real_engine->transformChanged(); | - | ||||||||||||||||||
| 255 | } never executed: end of block | 0 | ||||||||||||||||||
| 256 | - | |||||||||||||||||||
| 257 | void QEmulationPaintEngine::setState(QPainterState *s) | - | ||||||||||||||||||
| 258 | { | - | ||||||||||||||||||
| 259 | QPaintEngine::state = s; | - | ||||||||||||||||||
| 260 | real_engine->setState(s); | - | ||||||||||||||||||
| 261 | } never executed: end of block | 0 | ||||||||||||||||||
| 262 | - | |||||||||||||||||||
| 263 | void QEmulationPaintEngine::beginNativePainting() | - | ||||||||||||||||||
| 264 | { | - | ||||||||||||||||||
| 265 | real_engine->beginNativePainting(); | - | ||||||||||||||||||
| 266 | } never executed: end of block | 0 | ||||||||||||||||||
| 267 | - | |||||||||||||||||||
| 268 | void QEmulationPaintEngine::endNativePainting() | - | ||||||||||||||||||
| 269 | { | - | ||||||||||||||||||
| 270 | real_engine->endNativePainting(); | - | ||||||||||||||||||
| 271 | } never executed: end of block | 0 | ||||||||||||||||||
| 272 | - | |||||||||||||||||||
| 273 | void QEmulationPaintEngine::fillBGRect(const QRectF &r) | - | ||||||||||||||||||
| 274 | { | - | ||||||||||||||||||
| 275 | qreal pts[] = { r.x(), r.y(), r.x() + r.width(), r.y(), | - | ||||||||||||||||||
| 276 | r.x() + r.width(), r.y() + r.height(), r.x(), r.y() + r.height() }; | - | ||||||||||||||||||
| 277 | QVectorPath vp(pts, 4, 0, QVectorPath::RectangleHint); | - | ||||||||||||||||||
| 278 | real_engine->fill(vp, state()->bgBrush); | - | ||||||||||||||||||
| 279 | } never executed: end of block | 0 | ||||||||||||||||||
| 280 | - | |||||||||||||||||||
| 281 | QT_END_NAMESPACE | - | ||||||||||||||||||
| Source code | Switch to Preprocessed file |