diff options
author | Tarja Sundqvist <tarja.sundqvist@qt.io> | 2022-11-11 09:29:17 +0200 |
---|---|---|
committer | Tarja Sundqvist <tarja.sundqvist@qt.io> | 2022-11-11 09:29:17 +0200 |
commit | 4ee4fc18b4067b90efa46ca9baba74f53b54d9ec (patch) | |
tree | cc68622c9b85992d99a8373ab55471ee821a4ebf /src/gui/painting/qpainter.cpp | |
parent | ab28ff2207e8f33754c79793089dbf943d67736d (diff) | |
parent | ebb49c66aaf22ed55d62ff7bc3690fce00b7d8ba (diff) |
Merge remote-tracking branch 'origin/tqtc/lts-5.15.8' into tqtc/lts-5.15-opensourcev5.15.8-lts-lgpl
Change-Id: I569a2246c9e8d70430e8c5405b9f3df2218078ee
Diffstat (limited to 'src/gui/painting/qpainter.cpp')
-rw-r--r-- | src/gui/painting/qpainter.cpp | 66 |
1 files changed, 31 insertions, 35 deletions
diff --git a/src/gui/painting/qpainter.cpp b/src/gui/painting/qpainter.cpp index aaeb0e86a2..826a7ab27f 100644 --- a/src/gui/painting/qpainter.cpp +++ b/src/gui/painting/qpainter.cpp @@ -175,6 +175,23 @@ static bool qt_painter_thread_test(int devType, int engineType, const char *what } #endif +static bool needsEmulation(const QBrush &brush) +{ + bool res = false; + + const QGradient *bg = brush.gradient(); + if (bg) { + res = (bg->coordinateMode() > QGradient::LogicalMode); + } else if (brush.style() == Qt::TexturePattern) { + if (qHasPixmapTexture(brush)) + res = !qFuzzyCompare(brush.texture().devicePixelRatio(), qreal(1.0)); + else + res = !qFuzzyCompare(brush.textureImage().devicePixelRatio(), qreal(1.0)); + } + + return res; +} + void QPainterPrivate::checkEmulation() { Q_ASSERT(extended); @@ -182,21 +199,12 @@ void QPainterPrivate::checkEmulation() if (state->bgMode == Qt::OpaqueMode) doEmulation = true; - const QGradient *bg = state->brush.gradient(); - if (bg && bg->coordinateMode() > QGradient::LogicalMode) + if (needsEmulation(state->brush)) doEmulation = true; - const QGradient *pg = qpen_brush(state->pen).gradient(); - if (pg && pg->coordinateMode() > QGradient::LogicalMode) + if (needsEmulation(qpen_brush(state->pen))) doEmulation = true; - if (state->brush.style() == Qt::TexturePattern) { - if (qHasPixmapTexture(state->brush)) - doEmulation |= !qFuzzyCompare(state->brush.texture().devicePixelRatioF(), 1.0); - else - doEmulation |= !qFuzzyCompare(state->brush.textureImage().devicePixelRatioF(), 1.0); - } - if (doEmulation && extended->flags() & QPaintEngineEx::DoNotEmulate) return; @@ -3319,12 +3327,9 @@ void QPainter::strokePath(const QPainterPath &path, const QPen &pen) if (path.isEmpty()) return; - if (d->extended) { - const QGradient *g = qpen_brush(pen).gradient(); - if (!g || g->coordinateMode() == QGradient::LogicalMode) { - d->extended->stroke(qtVectorPathForPath(path), pen); - return; - } + if (d->extended && !needsEmulation(pen.brush())) { + d->extended->stroke(qtVectorPathForPath(path), pen); + return; } QBrush oldBrush = d->state->brush; @@ -3362,12 +3367,9 @@ void QPainter::fillPath(const QPainterPath &path, const QBrush &brush) if (path.isEmpty()) return; - if (d->extended) { - const QGradient *g = brush.gradient(); - if (!g || g->coordinateMode() == QGradient::LogicalMode) { - d->extended->fill(qtVectorPathForPath(path), brush); - return; - } + if (d->extended && !needsEmulation(brush)) { + d->extended->fill(qtVectorPathForPath(path), brush); + return; } QBrush oldBrush = d->state->brush; @@ -6956,12 +6958,9 @@ void QPainter::fillRect(const QRectF &r, const QBrush &brush) if (!d->engine) return; - if (d->extended) { - const QGradient *g = brush.gradient(); - if (!g || g->coordinateMode() == QGradient::LogicalMode) { - d->extended->fillRect(r, brush); - return; - } + if (d->extended && !needsEmulation(brush)) { + d->extended->fillRect(r, brush); + return; } QPen oldPen = pen(); @@ -6994,12 +6993,9 @@ void QPainter::fillRect(const QRect &r, const QBrush &brush) if (!d->engine) return; - if (d->extended) { - const QGradient *g = brush.gradient(); - if (!g || g->coordinateMode() == QGradient::LogicalMode) { - d->extended->fillRect(r, brush); - return; - } + if (d->extended && !needsEmulation(brush)) { + d->extended->fillRect(r, brush); + return; } QPen oldPen = pen(); |