summaryrefslogtreecommitdiffstats
path: root/src/gui/painting
Commit message (Collapse)AuthorAgeFilesLines
* QtGui: compile-optimize inline swap functionsMarc Mutz2022-03-197-7/+7
| | | | | | | | | | | | | | | | | | | Instead of using the overly-generic qSwap() monster, use - qt_ptr_swap() for swapping raw pointers - member-swap for swapping smart pointers - std::swap() for swapping scalars In QtCore, this has proven to give a nice reduction in compile time for Qt users, cf. b1b0c2970e480ef460a61f37fa430dc443390358. Task-number: QTBUG-97601 Change-Id: I987ff95e8751a22a4f283655d8225dd16de21178 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io> (cherry picked from commit c839efb07a6aa3b487dac5f86f905f35ef2c3a08) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
* Painting: fix overriding and combining different clip typesEirik Aavitsland2022-03-163-26/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | In a recent improvement (6de36918c03e91933fbfb5bf7b53abbe03edf460) the last set clip region or path was stored in separate variables, in order to be set again if the aliasing mode changed. That solution was too simplistic, as it would break down as soon as more than one clip area was set, with the latter either replacing or intersecting the first. It was also unnecessary to introduce new storing of clip areas and transforms, as those are already recorded in the clipInfo stack in the painter state. This patch hence reverts much of that implementation. However the basic idea of setting the clip area again after AA change is good, so that part is kept, implementated instead by calling a pre-existing function to replay the clipInfo stack. One of the baseline test cases is extended to excercise the combination of clip areas. As a driveby, support for setClipRectF is added to the painting baseline test scripts, and the build of the manual lance tool is fixed. Fixes: QTBUG-101474 Change-Id: Ide8b70d8cbf138deb06cbb84f69e62f7405886e6 Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io> (cherry picked from commit f46db29d8c5185e952f4665d6d141586373d3a0f) Reviewed-by: Eirik Aavitsland <eirik.aavitsland@qt.io>
* Painting: Fix value check in isUnclipped()Robert Löhning2022-03-161-1/+1
| | | | | | | | | | left() == INT_MIN or top() == INT_MIN will still underflow in QRect's ctor, so the check must be more strict Change-Id: I12ab148934c8c90865ca9247bd8badeedd4a9f45 Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io> (cherry picked from commit d865129d9ea9f15d27bd1cc05058c95c17e23ebf) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
* Fix deprecated uses of QScopedPointerMårten Nordheim2022-03-105-12/+19
| | | | | | | | | | By changing it to unique_ptr. Change-Id: I91abb69445b537d4c95983ae735341882352b29d Reviewed-by: Marc Mutz <marc.mutz@qt.io> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> (cherry picked from commit 034d8898f8166423db085da529787e56204c8e15) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
* Fix painting clipping glitches with fractional scalingEirik Aavitsland2022-03-033-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 Change-Id: Iaae6464b9b17f8bf3adc69007f6ef8d623bf2c80 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io> (cherry picked from commit 423b6509382c3bcc36eca78ced0254bfb463d017) Reviewed-by: Eirik Aavitsland <eirik.aavitsland@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 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io> Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> (cherry picked from commit 44eff8f39f56cfe25dbd5a8b9d289b42137d06e2) Reviewed-by: Qt Cherry-pick Bot <cherrypick_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 Change-Id: I30f7f41311182f056f2f6d5a9b49385fb09d194e Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> (cherry picked from commit a24ef92468b5d482733b8258265474ca98646a1f) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
* 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). Fixes: QTBUG-100217 Change-Id: Idbc6700b85cb30198d69fedbf8f3be3e1ab65e40 Reviewed-by: Lars Knoll <lars.knoll@qt.io> (cherry picked from commit d6c4a3edf9adb02b6f96d43768db9f90a6623de7) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
* 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' Change-Id: Ib6c19f02f7c7593c9e22da5e648ea1f2f2ae757b Reviewed-by: Marc Mutz <marc.mutz@qt.io> (cherry picked from commit 8d714c0c692d03c312f530c27c336c33a94d6ce0) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
* 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. Change-Id: I0e7f354a0341e94e9a9401a7d3b4529a8ff20a3d Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> (cherry picked from commit 65b62d2d5c229f0847a3073a72167674e7d23a26) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
* QPageSize: remove 119 relocationsMarc Mutz2022-02-101-1/+1
| | | | | | | | | | Also saves ~1.4KiB in combined TEXT and DATA size on optimized Linux GCC 11 C++20 AMD64 builds. Change-Id: I53922ccd191e412a13e3e23f2e26fdb3bf43af33 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> (cherry picked from commit bfd21b888b329b2e434e45c15abe0f27b61968a1) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
* 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 Change-Id: I1e0ebbc2d6e1ffd98b9f3f537e83893579606a4b Reviewed-by: Eirik Aavitsland <eirik.aavitsland@qt.io> (cherry picked from commit 52a83658c3e930e4b751ea2546baf9b13b1fce5b) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
* Fix infinite loop in dash strokerEskil Abrahamsen Blomfeldt2022-02-091-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 Change-Id: Ia6a42f21b6b4c6adf5cdd703b6483750513a88ba Reviewed-by: Lars Knoll <lars.knoll@qt.io> (cherry picked from commit 26a0638222933fc549f250333c28d0184205b704) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
* 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. Fixes: QTBUG-100327 Change-Id: I149ad39147176e00ce753979d55dc8633704dc1a Reviewed-by: Eirik Aavitsland <eirik.aavitsland@qt.io> (cherry picked from commit 2536d73adc9ee83443165892d391b36c1992c081) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
* Fix clipped glyphs in text rendering of QGraphicsTextItemViktor Arvidsson2022-02-032-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 Change-Id: Ibdb0e4116872af0f88bf03d9b3ac95331058b882 Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io> (cherry picked from commit 724e4646e2bf354fe1bf4daba1925b33bd695288) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
* QColorTransform: optimize member-swap()Marc Mutz2022-01-201-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 Change-Id: Ie054848922a50dbf746781491cb28e598c0e12bc Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> (cherry picked from commit 5d4f8a947ceb63371c22bd8c42fb0e0c2b5fed73) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
* 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 Change-Id: Ie6f67da7ef39a16c98a7451d37b6d96531656392 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> (cherry picked from commit f7ac5968fc92d9c656b4c2f742ee8245a9692bb4) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
* 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. 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> (cherry picked from commit b99c08dd4ed6c9660e1b2c4d93cb1271e8039e03) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
* 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> Change-Id: I06a4f2cd928846eab6330af014981fd0a3170ba0 Reviewed-by: Marc Mutz <marc.mutz@qt.io> (cherry picked from commit 3215416e3c07e662f5ea99c82d4f8b08340be005) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
* 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 Change-Id: I8b1b0f319683ecfb2c93cc51a047616fe29770f7 Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io> (cherry picked from commit 61a136bf26e82c32652147af7c1a6863c8b6d259) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
* 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> Change-Id: I11e2873fbb1f432953a1a8e07054f9478dd90fbd Reviewed-by: Eirik Aavitsland <eirik.aavitsland@qt.io> (cherry picked from commit 8678ab9354e01b40e414c1413596dfb475752a9a) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
* 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. Change-Id: Ibc190c2ef825e634956758f612a018f642f4202b Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Eirik Aavitsland <eirik.aavitsland@qt.io> (cherry picked from commit ae6dc7d6df12b3a5631d20b968823e23f6d7f1f2) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
* 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>
* Remove special casing of HSL QColor comparisonAllan Sandfeld Jensen2021-07-231-12/+3
| | | | | | | | | | | | | All other equality comparisons except floating-point are value comparisons, not interpretation comparisons. [ChangeLog][QColor] Equality on HSL colors is now raw value based like other color-formats, instead of being partially interpretation based. Pick-to: 6.2 Change-Id: I391464da172af6a2d69178b94203d36f7ce2c07d Reviewed-by: Eirik Aavitsland <eirik.aavitsland@qt.io>
* QColorSpace: Guard against division by zeroRobert Löhning2021-07-221-5/+9
| | | | | | | | Fixes oss-fuzz issue 35547. Pick-to: 5.15 6.2 Change-Id: Ida0b92ab17548f359d8634114bbdeb4c9d3a8dc8 Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
* QPainter: replace manual memory management [5/5]: d_ptrsMarc Mutz2021-07-162-20/+10
| | | | | | | | Replace a manually-managed pointer + size with QVarLengthArray, allowing use of pre-allocated space. Change-Id: Ife3abea0b3b0f2577bb76c348513d52d46f79641 Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* QPainter: replace manual memory management [4/5]: emulationEngineMarc Mutz2021-07-162-21/+8
| | | | | | | | | | | Use unique_ptr to indicate ownership. The QPainter dtor is now empty, = default it. As a drive-by, fix a non-sensical if (p) p = nullptr; Change-Id: I5c811eb7de6abf8a9f279cf3630d5f86db6b3864 Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* QPainterPrivate: use NSDMI, outline ctorMarc Mutz2021-07-152-16/+17
| | | | | | | As a drive-by, make the ctor explicit. Change-Id: I4c0c597e4b6e96e800017c90acced33bbccd1d10 Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* QGradient: optimize empty stopsMarc Mutz2021-07-141-3/+4
| | | | | | | | Don't allocate memory, use QList::fromReadOnlyData() over a static constexpr array instead. Change-Id: I596a3d61d5dd9603eea7f72a88d627af63ca54cd Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* QPainter: replace manual memory management [3/5]: engineMarc Mutz2021-07-142-8/+14
| | | | | | | | | Use unique_ptr to indicate ownership, even though it's conditional (on QPaintEngine::autoDestruct()). That just requires a custom deleter. Change-Id: Icf8e356c333f9617b2e5172b14f13197e63c9502 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>