summaryrefslogtreecommitdiffstats
path: root/src/gui/painting
Commit message (Collapse)AuthorAgeFilesLines
* Fix deprecated uses of QScopedPointerMårten Nordheim2022-03-085-12/+19
| | | | | | | | | By changing it to unique_ptr. Pick-to: 6.2 6.3 Change-Id: I91abb69445b537d4c95983ae735341882352b29d Reviewed-by: Marc Mutz <marc.mutz@qt.io> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* QColor: port string-parsing from out parameters to optional<>Marc Mutz2022-03-082-35/+31
| | | | | | | | | Makes for easier reading of code, and allows qt_get_hex_rgb(), which is called from different TUs, to be marked as PURE. Change-Id: Ie7d4e5a164ca1daf521e18ff47f17885bc1443c1 Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
* QColor: remove setColorFromString()Marc Mutz2022-03-082-31/+9
| | | | | | | | | | | | | | | | This private method doubled as the implementation of both fromString() and isValidColorName(). By reformulating isValidColorName() as fromString().isValid(), we can then turn setColorFromString() into fromString(), by returning the data, instead of setting it on *this through use of exported functions. Since we need to touch the if's anyway, to remove braces, use C++17 if-with-initializer to turn the second if into an else-of, saving one return {}. Change-Id: If3f8182a40c0c6d6ad514431b5870e69d0e95769 Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io> Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* Long live QColor::fromString()!Marc Mutz2022-03-082-10/+78
| | | | | | | | | | | | | | | | | | | | | | | | | It is customary for Qt types that can be constructed from string-ish to provide a fromString() named constructor. QColor didn't, relying instead on a set of overloaded implicit and explicit constructors. Add the named constructor, with the intent to deprecate the string-ish QColor constructors after a grace period. To prevent new users from using known-to-become-deprecated API, mark the old functions as \obsolete. Also rename isValidColor() to isValidColorName(). The only reason why these are lumped together in single commit is so that their docs can refer to each other instead of having to temporarily refer to obsolete API. [ChangeLog][QtGui][QColor] Added fromString() and isValidColorName(), both taking QAnyStringView. Task-number: QTBUG-101389 Change-Id: I2857c728257ad2f14c7c968b45547bdf07c44b63 Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
* Miscellanea fixes for QT_TYPESAFE_FLAGS in our headersGiuseppe D'Angelo2022-03-072-4/+4
| | | | | | | | | | | | | | | | | | | | | In preparation for adding it to headersclean. Some remarks: * QStandardItemModel builds just fine (QFlags has comparison operators against literal zero); the warning we however get is about 0 converted to a null pointer constant. There's nothing we can do about that one (even <compare> gives such a warning). * Several code was depending on flags->int conversions. Add toInt(), but also cast again to the expected type to avoid warnings in case toInt() returns unsigned int. * Ported to explicit casts to bool rather than test(Any)Flag to minimize confusion for people unfamiliar with the test*Flag methods. Change-Id: I5be280ac33a0b38e2680096f0e79129fd55ba241 Reviewed-by: Marc Mutz <marc.mutz@qt.io>
* Fix Q_FLAG declaration over enumerationsGiuseppe D'Angelo2022-03-021-1/+1
| | | | | | | | | | One should use Q_ENUM, not Q_FLAG, to mark an enumeration. Q_FLAG should go on the respective flag type. Change-Id: I16cd5c0d405c3db1951569b72805fdae18898c45 Pick-to: 5.15 6.2 6.3 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io> Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Fix painting clipping glitches with fractional scalingEirik Aavitsland2022-03-023-6/+21
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | In QPainter, clipping can only be done on whole pixels. The various ways of specifying a clipping rectangle to the QPainter API have been inconsistent in how fractional rectangles (either specified directly, or as a result of fractional scaling) are mapped (rounded) to integer coordinates. Also, the mappings have not made sure to keep the edge-to-edge property of clip rects under scaling. This is particularly important when scaling QRegions with multiple rects, as QRegion is designed on the assumption that an area can be described as a set of edge-to-edge rects. The fix rounds a clip rect identically with a fill rect. (Indeed, a followup plan would be to merge QRasterPaintEngine's toNormalizedFillRect() with the rectangle rounding function in this commit). Notably, a QRectF clip is now interpreted the same as a QPainterPath clip describing the same area. This modifies d9cc1499954829faf9486fb72056e29f1bad58e3 Task-number: QTBUG-100329 Fixes: QTBUG-95957 Task-number: QTBUG-100343 Pick-to: 6.3 Change-Id: Iaae6464b9b17f8bf3adc69007f6ef8d623bf2c80 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* Make sure all qtbase private headers include at least one otherThiago Macieira2022-02-247-5/+11
| | | | | | | | | | See script in qtbase/util/includeprivate for the rules. Since these files are being touched anyway, I also ran the updatecopyright.pl script too. Change-Id: Ib056b47dde3341ef9a52ffff13ef677e471674b6 Reviewed-by: Marc Mutz <marc.mutz@qt.io>
* QColor: avoid Unicode table lookups in fromString()Marc Mutz2022-02-181-4/+15
| | | | | | | | | | | | | | All color names supported by QColor are US-ASCII. Enforce this with a static_assert, then use this fact to perform the case-folding of the input in US-ASCII instead of Unicode. Avoids lookups in the Unicode tables. Add QtMiscUtils::toAsciiLower() to foster sharing. Change-Id: Ie0e123405d772943313dc4be1808667b152770b1 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* QColor: port parsing to QAnyStringViewMarc Mutz2022-02-182-26/+24
| | | | | | | | | | | | The private setColorFromString() function was never called from inline code in Qt 6 (didn't check Qt 5, which doesn't matter for BC purposes). This is in preparation of adding a QColor::fromString(QAnyStringView). Change-Id: I265d7c388370e2e7bb417db1573658346aad4690 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
* QColor: eradicate QT_STRINGVIEW_LEVELMarc Mutz2022-02-162-12/+0
| | | | | | | | | It's not used and not useful. Task-number: QTBUG-100861 Pick-to: 6.3 6.2 Change-Id: I30f7f41311182f056f2f6d5a9b49385fb09d194e Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Fix integer overflow for broken QPainterPathsEskil Abrahamsen Blomfeldt2022-02-141-1/+1
| | | | | | | | | | | | | With some bogus input, we can end up with NaN in the bounding rects of the control points. This in turn causes problems later when it is converted to ints and used in code. To avoid it, we exit early if the rect is invalid (negative or NaN size). Pick-to: 5.15 6.2 6.3 Fixes: QTBUG-100217 Change-Id: Idbc6700b85cb30198d69fedbf8f3be3e1ab65e40 Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* Fix compiling with C++20 on macOSAllan Sandfeld Jensen2022-02-101-6/+6
| | | | | | | | | | | This code triggers warnings about mixing enums of different types, which breaks compiling with warnings-are-errors. 'bitwise operation between different enumeration types is deprecated' Pick-to: 6.3 6.2 Change-Id: Ib6c19f02f7c7593c9e22da5e648ea1f2f2ae757b Reviewed-by: Marc Mutz <marc.mutz@qt.io>
* QPageSize: pack StandardPageSize structMarc Mutz2022-02-101-5/+6
| | | | | | | | | | | | | | | | | | | | On most platforms, the old struct had a padding hole before the FP members, as well as after the character array. By packing the integer members into bit fields, we compress five ints incl. the padding hole (24 bytes) into 64 bits w/o padding (8 bytes). The size of the struct shrinks from 80 to 64 bytes, saving almost 2KiB in TEXT size. Four bytes of tail padding remain, and are available to grow the character array in the future. More compactification could be had by changing the FP members (either by turning them into floats and/or by making them a union over {mm, in}, because one can be calculated from the other), but these are for another patch, because they change return values. Pick-to: 6.3 6.2 Change-Id: I0e7f354a0341e94e9a9401a7d3b4529a8ff20a3d Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Don't replace IntersectClip with ReplaceClip on a QPictureChunLin Wang2022-02-101-2/+3
| | | | | | | | | | QPainter should not try to be smart and optimize IntersectClip with ReplaceClip when working on a QPicture paint device. Doing so will change the end result as the actually state when replayed might be different from the one it was recorded in. QPainter will no longer try to replace IntersectClip with ReplaceClip if the paint engine is a QPicture.Consistent with QPainter::setClipRect and QPainter::setClipRegion. Fixes: QTBUG-100420 Pick-to: 6.2 6.3 Change-Id: I1e0ebbc2d6e1ffd98b9f3f537e83893579606a4b Reviewed-by: Eirik Aavitsland <eirik.aavitsland@qt.io>
* QPageSize: remove 119 relocationsMarc Mutz2022-02-091-1/+1
| | | | | | | | | Also saves ~1.4KiB in combined TEXT and DATA size on optimized Linux GCC 11 C++20 AMD64 builds. Pick-to: 6.3 6.2 Change-Id: I53922ccd191e412a13e3e23f2e26fdb3bf43af33 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Fix accuracy with screen compositionAllan Sandfeld Jensen2022-02-091-4/+4
| | | | | | | | | | | | It was using a faster divide by 256 instead of an accurate divide by 255. This meant black screen wasn't a null operation as it should be. This also fixes alpha mixing for a few other compositions. Pick-to: 6.3 6.2 5.15 Fixes: QTBUG-100327 Change-Id: I149ad39147176e00ce753979d55dc8633704dc1a Reviewed-by: Eirik Aavitsland <eirik.aavitsland@qt.io>
* Fix infinite loop in dash strokerEskil Abrahamsen Blomfeldt2022-02-041-1/+2
| | | | | | | | | | | | | | | | | | | | | | | When the positions were large enough, we would get precision errors with the floating point numbers. We calculate the relative position: dpos = pos + dashes[istart] - doffset - estart and then later pos = dpos + estart If estart is a huge number (range of 10^18) and dashes[istart] is a low number (10^1), then estart + dashes[istart] == estart and the loop will never progress, dpos will be 0. Since the loop should never iterate more than dashCount times (since we cut away all full dash sequences before entering it), we add a failsafe that exits the loop if it detects the error. Fixes: QTBUG-99690 Pick-to: 5.15 6.2 6.3 Change-Id: Ia6a42f21b6b4c6adf5cdd703b6483750513a88ba Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* Fix clipped glyphs in text rendering of QGraphicsTextItemViktor Arvidsson2022-02-022-7/+7
| | | | | | | | | | | | | [ChangeLog][QtGui] Clipping of visible glyphs when doing partial updates of a graphics view was off by 1. Also fixed an issue that caused rounding errors when transforming the clip rect into the glyphs draw space which was caused by transforming a QRect instead of a QRectF. Fixes: QTBUG-93432 Pick-to: 5.15 6.2 6.3 Change-Id: Ibdb0e4116872af0f88bf03d9b3ac95331058b882 Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>
* QColorTransform: optimize member-swap()Marc Mutz2022-01-191-1/+1
| | | | | | | | | | | | | | | | | | | We know decltype(d), so we don't need to jump though the ADL-enabling that qSwap() does. Just call QExplicitlySharedDataPointer's member-swap directly. Found through Clang -ftrace-time over PCH'ed libQt6Gui.so build: **** Templates that took longest to instantiate: [...] 4050 ms: qSwap<QExplicitlySharedDataPointer<QColorTransformPrivate> > (87 times, avg 46 ms) which is gone afterwards. Task-number: QTBUG-97601 Pick-to: 6.3 6.2 Change-Id: Ie054848922a50dbf746781491cb28e598c0e12bc Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* QPolygon: de-inline setPoint()Marc Mutz2022-01-192-8/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | In Qt 5 times, the core of QList::realloc() was out-of-line by design, because it was independent of T. Now that QList is QVector, its equivalent detachAndGrow() function on QArrayDataPointer is inline and instantiated for each type anew. We therefore need to be careful to not use detach()ing QList operations in non-generic code inline code (in public, but also private, headers), because (common) PCH builds force this code to be compiled over and over again. Generic code is only instantiated when used in a TU, so that's ok. But for non-generic code, the only option is to de-inline. If there is an effect on compile-times, it's hidden in the run-by-run noise of building QtGui, but at least this entry is gone afterwards from clang -ftime-trace: **** Templates that took longest to instantiate: [...] 4676 ms: QList<QPoint>::operator[] (261 times, avg 17 ms) Added 'inline' to the definition of the setPoint(int, QPoint) overload, since MinGW used to complain about it missing. Task-number: QTBUG-97601 Pick-to: 6.3 Change-Id: Ie6f67da7ef39a16c98a7451d37b6d96531656392 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Remove unused .qrc filesJoerg Bornemann2022-01-171-7/+0
| | | | | | | | Task-number: QTBUG-94446 Change-Id: I136d8b4ab070a832866aa50b5701fc6bd863df8a Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Alexey Edelev <alexey.edelev@qt.io> Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
* Doc: Use \inmodule for all classes and headersTopi Reinio2022-01-171-0/+1
| | | | | | | | | | | | | | | QDoc made some assumptions about the module a class/header belongs to, based on the source file path. This feature is rather error-prone and unnecessarily complex and will be removed from QDoc. Define modules explicitly to avoid documentation warnings when this removal happens. Pick-to: 6.2 6.3 Change-Id: I7947d197db5ac36c12e816caa19bb2f74eda8849 Reviewed-by: Edward Welbourne <edward.welbourne@qt.io> Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io> Reviewed-by: Venugopal Shivashankar <Venugopal.Shivashankar@qt.io>
* QPathEdge: Fix array initializationIvan Tkachenko2022-01-141-5/+1
| | | | | | | | | | | | We had a copy-paste error there: not all array members were initialized. Pointed out by PVS-Studio static analysis tool: https://habr.com/ru/company/pvs-studio/blog/542760 Co-Authored-By: Marc Mutz <marc.mutz@qt.io> Pick-to: 6.3 6.2 5.15 Change-Id: I06a4f2cd928846eab6330af014981fd0a3170ba0 Reviewed-by: Marc Mutz <marc.mutz@qt.io>
* Draw extended RGB solid colorsAllan Sandfeld Jensen2022-01-125-25/+42
| | | | | | | Pass extended RGB colors through the paint engine. Change-Id: I2e212cd4c76aaa65439746352c0da2b9db4a506d Reviewed-by: Eirik Aavitsland <eirik.aavitsland@qt.io>
* Replace QString with QStringView and use qsizetype in QPdfEnginePrivateØystein Heskestad2022-01-112-4/+4
| | | | | | | | Task-number: QTBUG-98763 Change-Id: Iab09d5a4d23215fd44e4b2cf4212688cd8f27a63 Reviewed-by: Marc Mutz <marc.mutz@qt.io> Reviewed-by: Ievgenii Meshcheriakov <ievgenii.meshcheriakov@qt.io> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Remove unused internal flag from raster painting engineEirik Aavitsland2021-12-282-27/+0
| | | | | | | | | Just a leftover from code that has been replaced long ago. Task-number: QTBUG-95237 Pick-to: 6.3 6.2 5.15 Change-Id: I8b1b0f319683ecfb2c93cc51a047616fe29770f7 Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
* Use qint64 to replace int while qt_transform_image_rasterizeZhang Hao2021-12-211-23/+30
| | | | | | | | | | | | | When rotating a very large image(for example,the image size is 42000*24000),using QTransform will cause the the variable of the qt_transform_image_rasterize function exceeds the range of int. Fix this by Use qint64 to replace int. Fixes: QTBUG-99163 Done-with: Eirik Aavitsland <eirik.aavitsland@qt.io> Pick-to: 6.3 6.2 5.15 Change-Id: I11e2873fbb1f432953a1a8e07054f9478dd90fbd Reviewed-by: Eirik Aavitsland <eirik.aavitsland@qt.io>
* Fix qt_scrollRectInImage when scrolling outside of the imageTor Arne Vestbø2021-12-141-12/+14
| | | | | | | | | | | | | | | | | | | | | We were clipping the source rect to the image, both pre and post scrolling, but did not apply the same logic to the target position. By computing the target position based on the already clipped source rect we ensure that the target position is also correct. This was causing valgrind warnings on Linux, and crashes on Windows, when trying to test the lower level QBackingStore::scroll() function. The reason we were not seeing this in practice was that QWidget does its own sanitation and clipping of the arguments before passing them on. As a drive-by, fix the access of image to use constBits instead of a manual cast, and rename variables to better reflect their use. Pick-to: 6.3 6.2 5.15 Change-Id: Ibc190c2ef825e634956758f612a018f642f4202b Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Eirik Aavitsland <eirik.aavitsland@qt.io>
* QPageLayout: do not calculate an invalid marginGiuseppe D'Angelo2021-12-061-4/+4
| | | | | | | | | | | | | | | | | | A default constructed QPageLayout has an invalid QPageSize. When asking for its size, an invalid QSize is returned (-1, -1). This size is then used to calculate the maximum margins the page layout can have, resulting in negative margins. I'm not sure if that makes sense for QPageLayout (in principle, a negative margin is acceptable, meaning to "grow" the size), but then this margin is passed as an upper bound to a series of qBound calls in QPageLayoutPrivate::clampMargins. To fix this, change the calculations of the maximum margins by using a lower bound of 0. Change-Id: I429104acfb2296d9eb1ee54c113e9d7e22d9b6ab Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* Clean up line clipping code in rasterizerEirik Aavitsland2021-11-191-36/+59
| | | | | | | | | | | | | | Replace old code with the line clipper from qcosmeticstroker. Also avoids tripping some issue with the current clang 13 that would cause paint errors on macOS. Fixes: QTBUG-98403 Fixes: QTBUG-98388 Pick-to: 6.2 6.2.2 Change-Id: I257eeec6f71153ec51b4176df3be8c443938484c Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io> Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
* Clarify validity of image returned from QPlatformBackingStore::toImage()Tor Arne Vestbø2021-11-181-0/+5
| | | | | | | | | | | | The backingstore may reconfigure the internal data, so clients should not assume that the image is valid beyond any new operations on the backingstore. Pick-to: 6.2 Change-Id: I137ad4f2adb45ec8bb78a989fbb5bac1e72965ce Reviewed-by: Eirik Aavitsland <eirik.aavitsland@qt.io> Reviewed-by: Paul Wicking <paul.wicking@qt.io> Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io>
* Update clipping area when antialiasing changesChen Bin2021-10-273-0/+41
| | | | | | | | | | | | | | | | | | | Antialiasing is disabled when the painter's antialiasing attribute is set behind the clipping function(example `setClipPath` or `setClipRegion`). The cause of this problem is that the antialiasing state of the clipping region is not updated after the antialiasing attribute is set. A variable is required to record the painter's transformation state set before the clipping function, because the transformation will be applied to the clipping region, resulting in the abnormal clipping region. The value of `s->matrix` is not accurate for the clipping fun- ction. Pick-to: 6.2 Fixes: QTBUG-97269 Change-Id: I409a9db32efc3b991ebb97ec9aed19bbddb273d8 Reviewed-by: Eirik Aavitsland <eirik.aavitsland@qt.io>
* Handle DPR in QPainter's drawing methods taking a brush parameterEirik Aavitsland2021-10-181-35/+31
| | | | | | | | | | | | | | The emulation paint engine is required not only for non-LogicalMode gradient brushes, but also for texture (pixmap/image) brushes with DPR != 1. fillRect(), strokePath() etc. would check for the former case, but not the latter. Fix by factoring out a common checking function. Pick-to: 6.2 5.15 Fixes: QTBUG-89101 Change-Id: I3cddf8a86a321de97b12c85a187069e77d2acea6 Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
* gui: Fix typos in documentationJonas Kvinge2021-10-126-7/+7
| | | | | | Pick-to: 5.15 6.2 Change-Id: I533f5a55cd0cd60a76990b552d7dab51a301ac1c Reviewed-by: Giuseppe D'Angelo <giuseppe.dangelo@kdab.com>
* gui: Fix typos in source code commentsJonas Kvinge2021-10-1210-13/+13
| | | | | | Pick-to: 5.15 6.2 Change-Id: Ie53e5542a8f93856470982939ecd8ec90b323d69 Reviewed-by: Eirik Aavitsland <eirik.aavitsland@qt.io>
* Support transformations in pattern/texture brushes in pdfEirik Aavitsland2021-10-051-0/+2
| | | | | | | | | | | | The brush transform was ignored for pattern/texture brushes. Since fill patterns always have a transform in pdf anyway, we can just multiply in the brush transform. Fixes: QTBUG-96978 Pick-to: 6.2 Change-Id: I80357f61fb879dfb1226d4ef9469ae5c9a9c1147 Reviewed-by: Lars Knoll <lars.knoll@qt.io> Reviewed-by: Albert Astals Cid <albert.astals.cid@kdab.com>
* Fix QPainterPath with QFont::SmallCapsAlbert Astals Cid2021-10-041-1/+1
| | | | | | | | | | | | | | Previous code was getting the QFontEngine from the font+script instead of from the QTextEngine. The font+script is not enough information to know if a given character is smallcaps or not, while the QTextEngine actually has access to the information needed and returns a properly a scaled fontengine if character is small caps Pick-to: 6.2 Fixes: QTBUG-13965 Change-Id: I9f95bd2f3c3bdff76c3acb94fa2edc99cdeb0a13 Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
* Remove checks for features available in C++17Ievgenii Meshcheriakov2021-10-021-4/+0
| | | | | | | | | | This patch removes most of the checks that are made using C++20 __cpp_* macros for features available in C++17 and earlier. Library feature check macros (__cpp_lib_*) are unaffected. Change-Id: I557b2bd0d4ff09b13837555e9880eb28e0355f64 Reviewed-by: Edward Welbourne <edward.welbourne@qt.io> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Fix scrolling of QRasterBackingStore when operating on QRasterGLSurfaceTor Arne Vestbø2021-10-012-13/+2
| | | | | | | | | | | | We were to strict in what surface type we allowed scrolling for. The RasterGLSurface type is an odd one, used by widgets to compose GL and raster content, which means we still have a raster backingstore we can scroll. It's just the flush that's different. Pick-to: 6.2 Change-Id: Ia229c21c00ad38df9e87f4fc78e341e030ef228d Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io> Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
* Avoid generating large pdf files when using dashed cosmetic pensEirik Aavitsland2021-09-291-8/+8
| | | | | | | | | | | | | | | | | | | There was a bug in the pdf writer for cosmetic pens when they were drawn using native pdf strokes (QTBUG-68537). The workaround that was done for that bug was to disable native atroking for such pens, so they would always be emulated. The drawback of that was that painting with dashed cosmetic pens would then produce unexpectedly large pdf files, since it would contain individual strokes for every dash. This change fixes the original bug and removes the workaround, re-enabling native stroking for cosmetic lines. Pick-to: 6.2 5.15 Fixes: QTBUG-86094 Change-Id: I58d06ad2db81206025ca2de394f072e822c03d47 Reviewed-by: Lars Knoll <lars.knoll@qt.io> Reviewed-by: Albert Astals Cid <albert.astals.cid@kdab.com> Reviewed-by: André de la Rocha <andre.rocha@qt.io>
* PDF generation: disentangle native pen from transformsEirik Aavitsland2021-09-292-7/+15
| | | | | | | | | | | | | | | | | | | In the PDF engine, transforms are implented with a global pdf transform if and only if the current pen is "simple", that is, renderable by a native pdf pen. For non-simple pens, the painted objects are transformed by QTransform instead. Hence, the internal simplePen flag was used to indicate both a pen state and a transform state. This commit splits these two states into separate flags. No behavior is changed, but it prepares for an improved implementation of cosmetic pen rendering. Pick-to: 6.2 5.15 Task-number: QTBUG-86094 Change-Id: If02e1dfc021778e3db7c9ff9a1ed35b3d6cbf3f8 Reviewed-by: Lars Knoll <lars.knoll@qt.io> Reviewed-by: André de la Rocha <andre.rocha@qt.io>
* Remove redundant semi-colonsAllan Sandfeld Jensen2021-09-221-1/+1
| | | | | | | | Causes warnings with clang-cl Change-Id: I57395819debe07aecd045c5a8c747632e6c04fc1 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Use qmath.h's conversions between degrees and radiansEdward Welbourne2021-09-101-3/+2
| | | | | | | | The make the semantics overt and avoid the joys of yet another approximation to pi/180 hard-coded in our source-code. Change-Id: I9dcbaada2e7de119e385fc7056bc601ecd59311a Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
* QPaintEngineEx: solve compile errorZhang Hao2021-09-071-1/+1
| | | | | | | | | Use the same variable name in function Amends 6869d2463a2e0d71bd04dbc82f5d6ef4933dc510 Pick-to: 6.1 6.2 Change-Id: If710a53993e84d048f9052f4fcf92eb57635f585 Reviewed-by: Giuseppe D'Angelo <giuseppe.dangelo@kdab.com>
* Port to QImage and QPixmap deviceIndependentSize()Morten Sørvig2021-09-012-4/+4
| | | | | | | | | Replace the “size() / devicePixelRatio()” pattern with a call to deviceIndependentSize(). Change-Id: I9d9359e80b9e6643e7395028cd43e3261d449ae7 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
* Painting: handle large and negative dash offset valuesEirik Aavitsland2021-08-242-3/+6
| | | | | | | | | The mapping of the dash offset into the dash pattern was susceptible to int overflow. Pick-to: 6.2 6.1 5.15 Change-Id: I254ed40b323ef516d10abc8e6008b14cfc23d2a0 Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
* QDashStroker: cap the number of repetitions of the patternEirik Aavitsland2021-08-244-24/+39
| | | | | | | | | | | | | Since the dashing is computed even outside the clipping and device area, painting very long dashed lines could consume unexpected amounts of time and resources. Fix by placing a limit on the dashing, and fall back to solid line drawing if hit. Fixes: QTBUG-95594 Pick-to: 6.2 6.1 5.15 Change-Id: Ida05ecd8fe6df402c9e669206fd5cec4a9f5386a Reviewed-by: Robert Löhning <robert.loehning@qt.io> Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
* Refix for avoiding huge number of tiny dashesEirik Aavitsland2021-08-101-4/+4
| | | | | | | | | | | Previous fix hit too widely so some valid horizontal and vertical lines were affected; the root problem being that such lines have an empty control point rect (width or height is 0). Fix by caculating in the pen width. Pick-to: 6.2 6.1 5.15 Change-Id: I7a436e873f6d485028f6759d0e2c6456f07eebdc Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
* Improve fix for avoiding huge number of tiny dashesEirik Aavitsland2021-07-271-1/+1
| | | | | | | | | Some pathological cases were not caught by the previous fix. Fixes: QTBUG-95239 Pick-to: 6.2 6.1 5.15 Change-Id: I0337ee3923ff93ccb36c4d7b810a9c0667354cc5 Reviewed-by: Robert Löhning <robert.loehning@qt.io>