summaryrefslogtreecommitdiffstats
path: root/src/gui/image
Commit message (Collapse)AuthorAgeFilesLines
* Centralize the implementation of move assignment operatorsGiuseppe D'Angelo2020-10-034-12/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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>
* Get rid of some #ifdef qt6Allan Sandfeld Jensen2020-09-302-13/+0
| | | | | | | | | 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>
* Add logging categories to image handlersAllan Sandfeld Jensen2020-09-305-17/+40
| | | | | Change-Id: Ia0c47826d08b3f641c17d8a585f62d008a8b095b Reviewed-by: Eirik Aavitsland <eirik.aavitsland@qt.io>
* Do not parse low-level PNG colorspaces if they are not usedAllan Sandfeld Jensen2020-09-291-5/+5
| | | | | | | Minor cleanup. Change-Id: I92c271f737d82c5f853b79c418db5a6cedfaa399 Reviewed-by: Eirik Aavitsland <eirik.aavitsland@qt.io>
* Preserve formats in QImage::scaled()Allan Sandfeld Jensen2020-09-261-12/+48
| | | | | | | | | Do not always use the smoothScaled routine, the normal routines are also optimized, and do not convert to alpha formats when not necessary. Task-number: QTBUG-49719 Change-Id: I6ee9b620cc259472c419e7363357f41ce29b594a Reviewed-by: Eirik Aavitsland <eirik.aavitsland@qt.io>
* Replace Q_REQUIRED_RESULT with [[nodiscard]]Allan Sandfeld Jensen2020-09-251-9/+9
| | | | | | | It was already used many places directly making the code inconsistent. Change-Id: I3b14bc6c333640fb3ba33c71eba97e78c973e44b Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* Give QPixmap a move constructorVolker Hilsheimer2020-09-232-0/+11
| | | | | | | | | | | | It already has a move-assignment operator, and implements swapping. This requires a specialization of the QExplicitlySharedDataPointer destructor to be forward declared, and an implementation that is identical to the default version. Otherwise we would need QPlatformPixmap to be fully defined in the public QPixmap header. Change-Id: I2651bbc29a7083a93e3b3ad671d3aeea659b7d5a Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
* Inline trivial function used only by deprecated functionsEdward Welbourne2020-09-211-17/+4
| | | | | | | | | | | QIcon had two methods calling a trivial local static; both were deprecated. Inlined the local static rather than #if-ing it on the same deprecation #if-ery. Shift the #if-ery on the deprecated methods to embrace also their docs. Change-Id: I5f6755ef99dd6b4abddc343c9bedf4815e50d567 Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
* xpm handler: fix read error caused by off-by-one in overflow checkEirik Aavitsland2020-09-181-2/+2
| | | | | | | | | | | | | The recently introduced overflow check for 8 bit images was too aggressive, causing the last pixel on each line to be rejected. As a driveby, add the same (fixed) overflow check also for 32bit images. Pick-to: 5.15 5.12 Fixes: QTBUG-86691 Change-Id: I62e4d5884e314f1171cb5a3e2c48657ce7259676 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* Fix deprecation warning in QIcon::actualSize()Edward Welbourne2020-09-181-2/+10
| | | | | | | | The non-deprecated one called the deprecated one :-( Inline the deprecated one and simplify, given the null pointer passed down. Change-Id: I5b99053357fc3be109e61ccf1161835bf527b686 Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
* Deprecate implicit QPixmap conversion to QBitmapVolker Hilsheimer2020-09-172-43/+71
| | | | | | | | | | | | | | | | It is lossy, so should be requested explicitly, using a dedicated fromPixmap factory function. Deprecate the constructor and assignment operator, and make the constructor explicit. [ChangeLog][QtGui][QBitmap] Implicitly constructing and assigning to a QBitmap from a QPixmap has been deprecated, and the respective constructor has been made explicit. Use the fromPixmap factory function instead. Change-Id: I68ce85b26c901415137b664a1db687021d48bae0 Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* Get rid of Qt4 virtual hooksAllan Sandfeld Jensen2020-09-152-73/+5
| | | | | | | | They have existed throughout Qt5, and no longer used by any QIconEngine I am aware of. Change-Id: Iab0a978be808a60fb82379467e294e2457056bae Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
* Make QStringList an alias to QList<QString>Lars Knoll2020-09-122-2/+0
| | | | | | | | | | | | | | | | | | Fix our API, so that QStringList and QList<QString> are the same thing. This required a bit of refactoring in QList and moving the indexOf(), lastIndexOf() and contains() method into QListSpecialMethods. In addition, we need to ensure that the QStringList(const QString&) constructor is still available for compatibility with Qt 5. Once those two are done, all methods in QStringList can be moved into QListSpecialMethods<QString>. Change-Id: Ib8afbf5b6d9df4d0d47051252233506f62335fa3 Reviewed-by: Andrei Golubev <andrei.golubev@qt.io> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Remove dead code and obsolete commentVolker Hilsheimer2020-09-121-8/+0
| | | | | | | | | | | | | | The special members do nothing that the compiler-generated default doesn't do, so remove them. Remove the comment introduced in d06b4ca9a1a9baf3faa83a8b0 about QBitmap inherting QPixmap being a problem. It which wasn't followed up on for Qt 6, and making QBitmap a QPaintDevice rather than a QPixmap subclass (as implied in the commit message) would result in significant code duplication. Change-Id: I8d5032062f95ab19b38eb97d17191a9b13af870f Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* Port from devicePixelRatioF() to devicePixelRatio()Morten Johan Sørvig2020-09-102-2/+2
| | | | | | | This ports all of QtBase. Change-Id: If6712da44d7749b97b74f4614a04fac360f69d9e Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
* Create consistent sets of QImage methodsAllan Sandfeld Jensen2020-09-092-8/+49
| | | | | | | Adds consistently named inplace and imperative methods. Change-Id: I8739c1c4585d2ba4aa181bb9a681255d76c120d7 Reviewed-by: Eirik Aavitsland <eirik.aavitsland@qt.io>
* Change translation context of strings to new classVolker Hilsheimer2020-09-051-13/+6
| | | | | | | | | | | The strings were in QFileDialog context even though they were in QFileIconProvider, probably for historical reasons. Now that the strings have been moved into QtGui, using a QtWidgets class as the context makes no sense. Change-Id: Ia4f3bd18abaab2a5fbbb94e945782f4d2d94e7d1 Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* Fix compiler warnings from using deprecated qChecksum overloadVolker Hilsheimer2020-09-052-4/+4
| | | | | Change-Id: Ib7a6d0e752dc662a42abe38f2010da3f2b4626f1 Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* Deprecate and remove all uses of AA_UseHighDpiPixmapsTor Arne Vestbø2020-08-313-31/+10
| | | | | | | High-DPI pixmaps are always enabled, and cannot be disabled. Change-Id: I01a006b404e5431582b64ef812974c1c022b39ae Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* Deprecate QIcon API which take a QWindow pointerMorten Johan Sørvig2020-08-292-0/+15
| | | | | | | | | | | - pixmap(QWindow * ...) Use pixmap(size, dpr) instead - actualSize(QWindow *, ...) Use actualSize(size) instead Task-number: QTBUG-85885 Change-Id: Ia2d73eec9f040cd659f39c854463e3cd3ba72b93 Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
* QPixmapIconEngine: port to new virtual functionsMorten Johan Sørvig2020-08-292-24/+16
| | | | | | | | | Add availableSizes() override function and move the implementation out of virtual_hook(). Task-number: QTBUG-85885 Change-Id: Ida3575b25e9bca6167b5be97d6a8f0f624559602 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* QIconLoader: port to use new virtual functionsMorten Johan Sørvig2020-08-292-45/+40
| | | | | | | | | Add override functions and move the implementation out of virtual_hook(). Task-number: QTBUG-85885 Change-Id: I35ed81a3483dd85d49474b78572d5302b0e5b608 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* Add rgb64 inplace generic conversionAllan Sandfeld Jensen2020-08-283-10/+108
| | | | | | | Can avoid having direct conversions between all high precision formats. Change-Id: I36dd223d028cfda1b6f4116b38ca79cdb7bc5243 Reviewed-by: Eirik Aavitsland <eirik.aavitsland@qt.io>
* Doc: Compile image snippetsPaul Wicking2020-08-281-1/+1
| | | | | | | | | | | Fix minor issues (e.g. whitespace, missing semi-colon) in passing. Update documentation to use same snippet to avoid duplication of snippets across snippet files. Remove offending snippet. Done-with: Nico Vertriest <nico.vertriest@qt.io> Task-number: QTBUG-81486 Change-Id: Ia45549d50e8f4e22ce72667a19c38132306d38b3 Reviewed-by: Topi Reiniö <topi.reinio@qt.io>
* Doc: Fix documentation warnings for Qt GUITopi Reinio2020-08-285-10/+7
| | | | | | | | | | | | * 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>
* QIconEngine: move away from virtual_hook usageMorten Johan Sørvig2020-08-273-15/+13
| | | | | | | | | | | | | | | | | | | | | Upgrade existing functions to be virtual functions: - virtual QString iconName() - virtual bool isNull() - virtual QPixmap scaledPixmap(...) - virtual QList<QSize> availableSizes(...) Make all of them non-const and remove the const_casts in the implementation. Keep the default implementation which calls virtual_hook(), for compatibility. Note: availableSizes was already virtual, but now loses the “const”. Port two overrides in the platform themes. Keep virutal_hook() around for future expansion. Task-number: QTBUG-85885 Change-Id: I76d0c9f75bfd6ca870c669047d4ef18b82c692e5 Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
* QIcon: Add pixmap() overload which take devicePixelRatioMorten Johan Sørvig2020-08-272-20/+43
| | | | | | | | | | | | | Add new QIcon::pixmap() overload: QPixmap pixmap(const QSize &size, qreal devicePixelRatio, ...) This function replaces the existing pixmap() function which take a QWindow pointer, and should be more convenient in use. Task-number: QTBUG-85885 Change-Id: Ie4ca96a266d9278864678dc61bdfc2836cabdb93 Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
* Implement QAbstractFileIconProvider to use theme and mime databasesVolker Hilsheimer2020-08-262-11/+42
| | | | | | | | | | | | | | This doesn't give useful defaults on all platforms; icon themes are not provided on platforms other than Linux, and the mime database doesn't always return user-friendly names based on file names. However, both icon themes and the mime database can be customized by application developers by shipping a data file side-by-side with the application, without the need for reimplementing the provider class. Change-Id: Ie4b18ac1b861e2da64f01d1f209986b27fbe6bd5 Task-number: QTBUG-66177 Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
* Document the QAbstractFileIconProvider::IconType enumVolker Hilsheimer2020-08-251-7/+8
| | | | | | | | | Follow language from the icon naming specification on freedesktop.org at https://specifications.freedesktop.org/icon-naming-spec/icon-naming-spec-latest.html Change-Id: I740842a39a9cd56152a799698a648ad6a6e274e5 Reviewed-by: Paul Wicking <paul.wicking@qt.io>
* Move QFileSystemModel into QtGuiVolker Hilsheimer2020-08-254-2/+359
| | | | | | | | | | | | | | This requires a QAbstractFileIconProvider in QtGui, as the standard QFileIconProvider depends on QStyle, and cannot be moved out of QtWidgets. QAbstractFileIconProvider returns strings for file types, but returns no icons yet. Support for a default icon set might be added in a follow-up commit. Change-Id: Ib9d095cd612fdcf04db62f2e40709fcffe3dc2b7 Fixes: QTBUG-66177 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Fix a number of qdoc warningsFriedemann Kleint2020-08-202-20/+0
| | | | | | | | | | | - 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>
* Make QCursor constructor explicit to prevent comparison of QPixmapVolker Hilsheimer2020-08-172-0/+4
| | | | | | | | | | | | | | | | | | | | | | | | QPixmap doesn't implement operator==, but QCursor had a non-explicit constructor from a QPixmap, which the compiler would use if two pixmaps get compared. Making that QCursor constructor explicit prevents that implicit conversion, at the cost of potential (but trivially resolved) source incompatibility. Also, make QCursor's comparison operators into hidden friends to avoid any other implicit conversions, and allow only QCursor object to be compared. In addition, delete operator== and operator!= in QPixmap so that the compiler generates a useful error message, rather than a screen full of global operator== candidates. Delete these operators in QIcon as well for consistency. Change-Id: I9b3f770da5718360ecc41c35cf327ef4f60d169b Fixes: QTBUG-85993 Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* Remove QVariant(int type, void *data, ...) constructorLars Knoll2020-08-154-4/+4
| | | | | | | | 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-143-4/+4
| | | | | | | | 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>
* Avoid potential ub in corrupt bmp fileEirik Aavitsland2020-08-061-0/+2
| | | | | | | | | | biHeight may be int_min, in which case qAbs<int>() will not work. Fixes: oss-fuzz-22997 Pick-to: 5.15 5.12 Change-Id: Ic07d5aa0b4e4f2b6395e1a12d742e31b5282fdfc Reviewed-by: Robert Loehning <robert.loehning@qt.io> Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* Another round of 0->nullptr cleanupAllan Sandfeld Jensen2020-07-312-3/+3
| | | | | Change-Id: Ic8db7dc252f8fea46eb5a4f334726d6c7f4645a6 Reviewed-by: Sona Kurazyan <sona.kurazyan@qt.io>
* QtGui: Add Windows conversion functions for to QImageFriedemann Kleint2020-07-242-13/+116
| | | | | | | | | Add conversions from/to HBITMAP, HICON to QImage. Split the pixmap conversion functions apart to use them. Task-number: QTBUG-81876 Change-Id: Ic0c41a402a1f6e9bec572fc4d691357bd48e6423 Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
* Fix buffer overflow in XBM parserAllan Sandfeld Jensen2020-07-241-1/+3
| | | | | | | | | | | | | Avoid parsing over the buffer limit, or interpreting non-hex as hex. This still leaves parsing of lines longer than 300 chars unreliable Change-Id: I1c57a7e530c4380f6f9040b2ec729ccd7dc7a5fb Pick-to: 5.15 5.12 Reviewed-by: Robert Loehning <robert.loehning@qt.io> Reviewed-by: Eirik Aavitsland <eirik.aavitsland@qt.io>
* Fix buffer overflowRobert Loehning2020-07-101-1/+1
| | | | | | | Fixes: oss-fuzz-23988 Pick-to: 5.15 5.12 Change-Id: I4efdbfc3c0a96917c0c8224642896088ade99f35 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* Use QList instead of QVector in gui implementationJarek Kobus2020-07-078-42/+40
| | | | | | | Task-number: QTBUG-84469 Change-Id: I366e845249203d80d640355a7780ac2f91a762f1 Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io> Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
* Add ; to Q_UNUSEDLars Schmertmann2020-07-072-10/+10
| | | | | | | | This is required to remove the ; from the macro with Qt 6. Task-number: QTBUG-82978 Change-Id: I3f0b6717956ca8fa486bed9817b89dfa19f5e0e1 Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
* Use QList instead of QVector in guiJarek Kobus2020-06-295-17/+17
| | | | | | | | Applied to headers only. Source file to be changed separately. Task-number: QTBUG-84469 Change-Id: Ic08a899321eaffc46b8461aaee3dbaa4d2c727a9 Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io>
* QImageIO: use the new allocation checker in the format handlersEirik Aavitsland2020-06-265-77/+34
| | | | | | Change-Id: I604d99ce476d4758a1e20b78257082911f1f1546 Task-number: QTBUG-85037 Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* Introduce a settable allocation limit on image loadingEirik Aavitsland2020-06-264-1/+80
| | | | | | | | | | [ChangeLog][QtGui][QImageReader] Introduced a settable allocation limit on image loading to limit resource usage from corrupt image files. Change-Id: Ibed7b0cac32798125a060e6db80b17ebc5e70759 Task-number: QTBUG-85037 Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* Move implementation of QVector/List back to qlist.hLars Knoll2020-06-201-1/+1
| | | | | | | | | | | | | And name the main class QList. That's also the one we document. This gives less porting pain for our users, and a lot less churn in our API, as we use QList in Qt 5 in 95% of our API. In addition, it gives more consistent naming with QStringList and QByteArrayList and disambiguates QList vs QVector(2|3|4)D. Fixes: QTBUG-84468 Change-Id: I3cba9d1d3179969d8bf9320b31be2230d021d1a9 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* Port Q_STATIC_ASSERT(_X) to static_assertGiuseppe D'Angelo2020-06-192-2/+2
| | | | | | | | | | | | | | | | | There is no reason for keep using our macro now that we have C++17. The macro itself is left in for the moment being, as well as its detection logic, because it's needed for C code (not everything supports C11 yet). A few more cleanups will arrive in the next few patches. Note that this is a mere search/replace; some places were using double braces to work around the presence of commas in a macro, no attempt has been done to fix those. tst_qglobal had just some minor changes to keep testing the macro. Change-Id: I1c1c397d9f3e63db3338842bf350c9069ea57639 Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* Add more LTTNG tracing pointsJosé Dapena Paz2020-06-112-0/+23
| | | | | | | | | | | | * QImage and QPixmap copy and transform operations. * OpenGL paint engine texture cache texture upload * OpenGL paint engine draw texture Task-number: QTBUG-83347 Pick-to: 5.15 Change-Id: I03150d6ff80cbbcd787133d75854715cb81b5571 Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io> Reviewed-by: Eirik Aavitsland <eirik.aavitsland@qt.io>
* Make it possible to avoid loading comments from JPEG and PNG filesElvis Lee2020-06-111-0/+4
| | | | | | | | | | | | Skip reading JPEG and PNG comments information from the header to save the memory. This can now be configured through the feature system. Change-Id: I3744312f69aa3201d5188776cbd99fe690b75d32 Task-number: QTBUG-83123 Pick-to: 5.15 Reviewed-by: Eirik Aavitsland <eirik.aavitsland@qt.io>
* Port QtGui from QStringRef to QStringViewLars Knoll2020-06-113-7/+7
| | | | | | Task-number: QTBUG-84319 Change-Id: I1761096fbcc9421a013cf73f831a2a2ba0c18006 Reviewed-by: Alex Blasche <alexander.blasche@qt.io>
* Remove winrtOliver Wolff2020-06-061-1/+1
| | | | | | | | | Macros and the await helper function from qfunctions_winrt(_p).h are needed in other Qt modules which use UWP APIs on desktop windows. Task-number: QTBUG-84434 Change-Id: Ice09c11436ad151c17bdccd2c7defadd08c13925 Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>