summaryrefslogtreecommitdiffstats
path: root/src/gui/painting
Commit message (Collapse)AuthorAgeFilesLines
* Centralize the implementation of move assignment operatorsGiuseppe D'Angelo2020-10-038-23/+10
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | At the moment we have two main strategies for dealing with move assignment in Qt: 1) move-and-swap, used by "containers" (in the broad sense): containers, but also smart pointers and similar classes that can hold user-defined types; 2) pure swap, used by containers that hold only memory (e.g. QString, QByteArray, ...) as well as most implicitly shared datatypes. Given the fact that a move assignment operator's code is just boilerplate (whether it's move-and-swap or pure swap), provide two _strictly internal_ macros to help write them, and apply the macros across corelib and gui, porting away from the hand-rolled implementations. The rule of thumb when porting to the new macros is: * Try to stick to the existing code behavior, unless broken * if changing, then follow this checklist: * if the class does not have a move constructor => pure swap (but consider ADDING a move constructor, if possible!) * if the class does have a move constructor, try to follow the criteria above, namely: * if the class holds only memory, pure swap; * if the class may hold anything else but memory (file handles, etc.), then move and swap. Noteworthy details: * some operators planned to be removed in Qt 6 were not ported; * as drive-by, some move constructors were simplified to be using qExchange(); others were outright broken and got fixed; * some contained some more interesting code and were not touched. Change-Id: Idaab3489247dcbabb6df3fa1e5286b69e1d372e9 Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
* Do not assert on invalid ICC curv tableAllan Sandfeld Jensen2020-10-012-17/+35
| | | | | | | | Reject invalid table data, do not assert it. Pick-to: 5.15 Change-Id: I1fdda4c735bb97bb93ac8f8654ac4cc5fada5389 Reviewed-by: Eirik Aavitsland <eirik.aavitsland@qt.io>
* Revert "Reimplement non-antialiased cosmetic pen"Allan Sandfeld Jensen2020-10-011-98/+193
| | | | | | | | | This reverts commit 81008ef4b91eac3f8ddcdad0aaf48b51135c4010. Reason for revert: Doesn't handle line-caps correctly. Change-Id: I0c77dbef6671fec326ec27f492ea3214054829ab Reviewed-by: Gatis Paeglis <gatis.paeglis@qt.io>
* Get rid of some #ifdef qt6Allan Sandfeld Jensen2020-09-302-15/+1
| | | | | | | | | None of this code is even compiled in qt6. Change-Id: I5891cc9459320083ad3908fcbf646f3ba75b8a4d Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io> Reviewed-by: Sona Kurazyan <sona.kurazyan@qt.io> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Reimplement non-antialiased cosmetic penAllan Sandfeld Jensen2020-09-291-193/+98
| | | | | | | | | Simplify rounding to get rid of hacks to make lines meet up again. This also results in better looking drawing results in general. Task-number: QTBUG-25896 Change-Id: I48f08f0e7bd7ff869d6767f7bac2a18c2d280615 Reviewed-by: Gatis Paeglis <gatis.paeglis@qt.io>
* Fix qdoc warnings: remove docs for inherited/implicit membersVolker Hilsheimer2020-09-281-23/+0
| | | | | Change-Id: I8654dbc3c0d1b86690f805cc1282e581dbcc5c55 Reviewed-by: Paul Wicking <paul.wicking@qt.io>
* Avoid heap-buffer-overflowRobert Loehning2020-09-251-0/+2
| | | | | | | | | [ChangeLog][QOutlineMapper] Avoid heap-buffer-overflow Fixes: oss-fuzz-24615 Pick-to: 5.12 5.15 Change-Id: Ia67e1fb830850d04f068d8b5c009687f3deff156 Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
* Replace Q_REQUIRED_RESULT with [[nodiscard]]Allan Sandfeld Jensen2020-09-255-31/+31
| | | | | | | It was already used many places directly making the code inconsistent. Change-Id: I3b14bc6c333640fb3ba33c71eba97e78c973e44b Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* Fix some qdoc warnings: printer API cleanupVolker Hilsheimer2020-09-221-107/+0
| | | | | | | | | | | | Puge references from removed QPrinter methods. QPdfWriter's setter API documentation only added the word "PDF" to the QPagedPaintDevice documentation. This was not useful - when the latter talks about "page", it's obvious what is meant in the context of PDF, so remove the duplication. Change-Id: I7b16cbc82de8d35b5224288c9e36deff4e01fb44 Reviewed-by: Paul Wicking <paul.wicking@qt.io>
* Define inverted QRects consistentlyAllan Sandfeld Jensen2020-09-211-35/+3
| | | | | | | | | | | | | | | | Changes the definition of invalid QRects to be more consistent. This simplifies the logic, and makes it possible for us to fix normalized() so dimensions don't change. The actual API is not changed except for inverted rects. Only one use-case for the old normalized() function existed, and has been reimplemented as QRect::span(). Fixes: QTBUG-22934 Change-Id: I29dad2952dc6c8e84a6d931898dc7e43d66780f3 Reviewed-by: hjk <hjk@qt.io> Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* Fix deprecation documentation about margin and orientation in QPrinterÖmer Fadıl USTA2020-09-172-4/+4
| | | | | | | | There were a small typos about those methods and fixed with correct ones. Fixes: QTBUG-86635 Change-Id: Ib853e502fdcdafdf3ddf7ef6d25d368ebc2a631f Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* QIcc: fix alignment concerns in ICC profile parsingAndrei Golubev2020-09-152-86/+103
| | | | | | | | | | | Updated QIcc::fromIccProfile() and friends to not rely on QByteArray pointer alignment. Used qFromUnaligned() instead Task-number: QTBUG-84267 Pick-to: 5.15 Change-Id: I69ef7e011707bec27cd84693e7f0e92d79a577d1 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
* Fix uninitialized variableLars Knoll2020-09-121-0/+3
| | | | | | | Amends defc8414fde0ea9f52fe554e00fe2f04947b7578 Change-Id: I0a62f08cb9428e94b30f659d810c767c2bc1b4b2 Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* Fix documentations string in QPagedPaintDeviceNicolas Fella2020-09-121-1/+1
| | | | | | | | pageLayout().pageOrientation() does not exist, but pageLayout().orientation() does. Pick-to: 5.15 Change-Id: I17a667b18aba284b91972422e604568e2fdbda05 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* Replace qreal with float in QColorAllan Sandfeld Jensen2020-09-112-224/+224
| | | | | | | | There is no reason to use double precision for colors. We at most have 16 significant bits anyway. Change-Id: I8b402cd978675b8ba7248176976d934363212ff1 Reviewed-by: Christian Ehrlicher <ch.ehrlicher@gmx.de>
* Minimal ABI necessary for future optimized QPixmapAllan Sandfeld Jensen2020-09-112-1/+44
| | | | | | | | Add virtual hooks that can make it possible in Qt6 to implement paint device specific pixmaps. Change-Id: Ib1d1d7b5e32d9430203f718534344b25c0ead744 Reviewed-by: Eirik Aavitsland <eirik.aavitsland@qt.io>
* Cleanup QGradientLars Knoll2020-09-113-51/+25
| | | | | | | Tackle some cleanups scheduled for Qt 6. Change-Id: I46e6e49e3d74f49ce953a36c5611d635232d43b1 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* Cleanup PageSize enum for Qt6Allan Sandfeld Jensen2020-09-103-157/+8
| | | | | | | Fixes B5/B6 order and removes abandoned documentation for a removed duplicate. Change-Id: I7647ee31a4ef4aa754058c8a6f68b4d4304e0043 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* Clean-up of old VC6 work-aroundAllan Sandfeld Jensen2020-09-101-54/+43
| | | | | Change-Id: Ic518f48b62055a4fa229751a80362f9426e0ac42 Reviewed-by: Eirik Aavitsland <eirik.aavitsland@qt.io>
* Port from devicePixelRatioF() to devicePixelRatio()Morten Johan Sørvig2020-09-104-8/+8
| | | | | | | This ports all of QtBase. Change-Id: If6712da44d7749b97b74f4614a04fac360f69d9e Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
* Clean up PageSizeId enumVolker Hilsheimer2020-09-102-7/+5
| | | | | | | | | | | Reorder, and remove ### Qt 6 comment It would be nice to have a way to statically assert that the order of StandardPageSizes (and their id) matches the order of the enum, but it's not possible (or at least very cumbersome) to do so. Change-Id: Id0d0a58958f1e17151725cbe8f8068db64f84939 Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
* Use C++17 [[maybe_unused]]Allan Sandfeld Jensen2020-09-062-168/+168
| | | | | | | In some places needs to be ordered before const/constexpr though. Change-Id: I57a521ac0ad22b5a018761c4d52befbef69d64c0 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Merge QPainterPathPrivate and QPainterPathDataVolker Hilsheimer2020-09-043-93/+70
| | | | | | | As per ### Qt 6 comment, and the code that never allocated QPainterPathPrivate. Change-Id: I553e3559fdb2a675f37cdd9855462a2f22ef84c6 Reviewed-by: Eirik Aavitsland <eirik.aavitsland@qt.io>
* Remove deprecated QPrinter and QPagedPaintDevice APIsVolker Hilsheimer2020-09-045-416/+4
| | | | | | | | | | | Adjusting the QPrinter test case - some use cases no longer exist, or are already tested in QPageSize and QPageLayout tests. Adjust examples and manual tests. Change-Id: I01cbc65f3d8031aea2dac86dd942126ba708b111 Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
* Mark obsolete QPrinter functions as deprecated from 5.15 onVolker Hilsheimer2020-09-032-1/+17
| | | | | | | | | | | Some of the methods are overrides of virtuals in QPagedPaintDevice, so document and mark those as obsolete as well. Adjust code that calls those APIs to use the recommended replacement. Change-Id: I3cd1980609ea20808d17379a5f97ca595e869875 Pick-to: 5.15 Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
* Remove last traces of the PostScript paint engineVolker Hilsheimer2020-09-022-2/+0
| | | | | | | Remove enum value, documentation, and another ### Qt 6 comment. Change-Id: I046d9581625d39c8fc8cf75287e8767501aae0cc Reviewed-by: Eirik Aavitsland <eirik.aavitsland@qt.io>
* Qpagedpaintdevice: Use marginsF instead of internal struct marginsPeng Wenhao2020-09-014-23/+9
| | | | | | | resolve remaining Qt6 TODOs Change-Id: Iad659a09ddfe136bdc545bc0635b4c695540c58b Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* Doc: Fix documentation warnings for Qt GUITopi Reinio2020-08-283-5/+13
| | | | | | | | | | | | * Drop deprecation warnings for now-dropped items * Use the 'qt6' define and a new \nothing doc macro to conditionally document items on Qt 6 * Add a custom module header for docs that pulls in also Vulkan headers * Add \internal command for internal classes/functions * Move QtGUI-related code snippets from widgets to gui docs Change-Id: Ieb386b96631a49568d09059906d307c45c01d93a Reviewed-by: Paul Wicking <paul.wicking@qt.io>
* Make QPaintDevice::devicePixelRatio() return qrealMorten Johan Sørvig2020-08-262-4/+4
| | | | | | | | | | | | | | | For historical reasons Qt 5 has: int QPaintDevice::devicePixelRatio() qreal QPaintDevice::devicePixelRatioF() Change the int to qreal so that Qt 6 will have qreal QPaintDevice::devicePixelRatio() qreal QPaintDevice::devicePixelRatioF() [to-be-removed] Change-Id: Ie904e02ec490cbcd2acb5dcecb193e9af4cb90f0 Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
* Introduce QWindow::paintEvent with QPA plumbingTor Arne Vestbø2020-08-261-7/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The explicit paint event on QtGui and QPA level allows us to untangle the expose event, which today has at least 3 different meanings. It also allows us to follow the platform more closely in its semantics of when painting can happen. On some platforms a paint can come in before a window is exposed, e.g. to prepare the first frame. On others a paint can come in after a window has been de-exposed, to save a snapshot of the window for use in an application switcher or similar. The expose keeps its semantics of being a barrier signaling that the application can now render at will, for example in a threaded render loop. There are two compatibility code paths in this patch: 1. For platform plugins that do not yet report the PaintEvents capability, QtGui will synthesize paint events on the platform's behalf, based on the existing expose events coming from the platform. 2. For applications that do not yet implement paintEvent, QtGui will send expose events instead, ensuring the same behavior as before. For now none of the platform plugins deliver paint events natively, so the first compatibility code path is always active. Task-numnber: QTBUG-82676 Change-Id: I0fbe0d4cf451d6a1f07f5eab8d376a6c8a53ce8c Reviewed-by: Paul Olav Tvete <paul.tvete@qt.io>
* Fix a number of qdoc warningsFriedemann Kleint2020-08-201-26/+2
| | | | | | | | | | | - Remove obsolete functions and enumeration values - Remove QObject * parameter from QMetaProperty accessors - Fix renamed enumerations in QSsl - Fix list items to be \li - Fix function signatures and variable names Change-Id: I37c7e6bf2c8ff92bc7b82620bae0a27796f866ab Reviewed-by: Paul Wicking <paul.wicking@qt.io>
* Remove QVariant(int type, void *data, ...) constructorLars Knoll2020-08-157-8/+8
| | | | | | | | It was marked internal anyway. Use the constructor taking a QMetaType instead. Change-Id: I15b9cd0911aac063a0f0fe0352fa2c84b7f7c691 Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* Replace Qt CONSTEXPR defines with constexprAllan Sandfeld Jensen2020-08-1412-318/+318
| | | | | | | | Both normal and relaxed constexpr are required by our new minimum of C++17. Change-Id: Ic028b88a2e7a6cb7d5925f3133b9d54859a81744 Reviewed-by: Sona Kurazyan <sona.kurazyan@qt.io>
* Allow smooth curve stroking for very wide linesEirik Aavitsland2020-08-121-1/+5
| | | | | | | | | | | | | | The earlier limit set on the curve threshold turned out to be too strict, leading to visibly bad rendering in reasonable use cases. Ref. 5322998a0ba80b1e095340245ddb00aaf5947be9 As a drive-by, add a missing fixed-to-real conversion. (This is a no-op in a default build, where qfixed==qreal.) Fixes: QTBUG-85193 Pick-to: 5.15 5.12 Change-Id: I7cc3543d7aa4e90643b275686372400879decef2 Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>
* Avoid UB in 64bit compositionsAllan Sandfeld Jensen2020-08-081-17/+17
| | | | | | | | Multiplying 65535 by 65535 would exceed the precision of an int, so use 65535U instead. Change-Id: I066e552fb7db03ce867bcbfbd0b555ac98ca4bbf Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* QBezier: Don't try calculating a unit vector when length is nullRobert Loehning2020-08-071-0/+4
| | | | | | | | | It's undefined and causes a division by zero. Fixes: oss-fuzz-24273 Pick-to: 5.12 5.15 Change-Id: I3d34d5c43cccff9255abaf87af265ddea3fe6d95 Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
* QPolygon: streamline constructors and special member functionsGiuseppe D'Angelo2020-08-071-24/+10
| | | | | | | | | | | Employ RO0; inherit the constructors from the base class; and do some code tidies as a drive by. The inherited constructors bring in goodies like initializer_list support. Change-Id: Ia00a3f9b0ccbf182bf837bc65ba2305110c8dc60 Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* Update qgrayraster.cAllan Sandfeld Jensen2020-08-061-79/+77
| | | | | | | | In particular switching the SUBPIXELS macro with FRACT makes the logic valid for all 24dot8 fixed point values. Change-Id: I4e58df94f8cf3c557f670c5d3088942e9b8efa6d Reviewed-by: Eirik Aavitsland <eirik.aavitsland@qt.io>
* MSVC: remove the extern templateThiago Macieira2020-08-051-31/+33
| | | | | | | | | | | | The problem was that QtCore exported those classes deriving from containers, which caused applications to try and import those same functions from QtCore, depending on whether they saw the #include or not. Now we don't need the hack anymore. Change-Id: I0a103569c81b4711a649fffd14ec9282454a1fdc Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* Clear old triangulated vertex data when a path is completely clippedJoni Poikelin2020-08-051-1/+1
| | | | | | | | | | | Old data was held in buffers which caused OpenGL paint engine to re-render previous shape again with current settings if the current path was completely clipped. Pick-to: 5.15 Fixes: QTBUG-35513 Change-Id: I0cd448e0b18d199af11e82d79b1ab72d0f89c79e Reviewed-by: Eirik Aavitsland <eirik.aavitsland@qt.io>
* Fix compiler issues when qreal is floatMichal Klocek2020-08-053-4/+4
| | | | | Change-Id: Ide3b5a3b0f2d93708409edac8aa999eb25c3ab54 Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
* Fix "rectange" typos in qtbaseOliver Wolff2020-08-052-2/+2
| | | | | | Pick-to: 5.15 Change-Id: If064fae5eaaeb2e53e3dd05cb9dc1cdf49ad1f04 Reviewed-by: Rainer Keller <Rainer.Keller@qt.io>
* Doc: Document QGradient::Preset enum valuesTopi Reinio2020-08-031-1/+170
| | | | | | | | Pick-to: 5.15 Fixes: QTBUG-85749 Change-Id: Ie77145e851ff64d4c88fce7211135d66e9b94a84 Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io> Reviewed-by: Paul Wicking <paul.wicking@qt.io>
* Another round of 0->nullptr cleanupAllan Sandfeld Jensen2020-07-315-17/+19
| | | | | Change-Id: Ic8db7dc252f8fea46eb5a4f334726d6c7f4645a6 Reviewed-by: Sona Kurazyan <sona.kurazyan@qt.io>
* Replace Q_ALWAYS_INLINE with static inlineAllan Sandfeld Jensen2020-07-285-48/+46
| | | | | | | | | Static inline on functions serves the same purpose of keeping non- inlined instances from different binaries from being mixed, and has the benefit of being available across compilers. Change-Id: I12467f6d887471d8fd70ff4623c473c2a5a45664 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Multiply instead of shiftingRobert Loehning2020-07-231-1/+1
| | | | | | | | | The shift operator is undefined for negative values. Fixes: oss-fuzz-23735 Pick-to: 5.15 5.12 Change-Id: Ib4bad0bf2135f9ddc95f6d7de64d935a02b4791e Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
* Fix SSE4 instruction leak in GCC10 debug buildsAllan Sandfeld Jensen2020-07-211-2/+2
| | | | | | | | toArgb32 was leaking an SSE4 instruction when not inlined. Pick-to: 5.15 Change-Id: I5df87bc7343f4ec40881a0aedd6f066323143817 Reviewed-by: Eirik Aavitsland <eirik.aavitsland@qt.io>
* QtGui/Windows: Move the QRegion conversion functions into QtGuiFriedemann Kleint2020-07-162-0/+71
| | | | | | Task-number: QTBUG-81876 Change-Id: I2297291a4157e7015f499b0a6127301d9cb58526 Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
* Avoid warnings regarding bit-field signednessDimitrios Apostolou2020-07-161-2/+2
| | | | | | | | | | | Up to (including) C++11, integral bitfields of unspecified signedness have implementation dependent signedness. Detected by LGTM.com static analyzer. Pick-to: 5.15 Change-Id: Ibaa0fdc6e443495a3cd40330c4573c9cc6ccdf5b Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* Check returns of hex2int in get_hex_rgbRobert Loehning2020-07-131-0/+2
| | | | | | | | | | Avoids undefined behavior when trying to shift negative values. Fixes: oss-fuzz-21860 Fixes: oss-fuzz-23968 Pick-to: 5.15 5.12 Change-Id: I879c97624e3f8ba9cf01e0a3a682379cd8c4a199 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>