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