summaryrefslogtreecommitdiffstats
path: root/src/gui/image
Commit message (Collapse)AuthorAgeFilesLines
* QColorSpace: port to QESDPGiuseppe D'Angelo2020-10-181-1/+1
| | | | | | | | | | Replace the hand-rolled refcount management with QESDP. Since the class has a default-constructed / moved-from state where the d-pointer can be nullptr, add a in-class detach() that ensures a private object. Change-Id: Id81431fa60132dbc0eed45bb60b38d4f7d73833f Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
* Fix Clang compiler warnings (-Wrange-loop-analysis)David Skoland2020-10-171-1/+1
| | | | | | | | | | | | | | | In a macOS environment, Clang throws a number of compiler warnings about loop variables when building qtbase. See task for more info about the environment. This changes a handful of loop variables, like QJsonValue references into QJsonValueRefs. Task-number: QTBUG-87216 Pick-to: 5.15 Change-Id: I26006efd7c75c2d56ebc7f7efb4c9bdcabe92e8b Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* doc: Add brief and group for native type conversionsTor Arne Vestbø2020-10-132-8/+22
| | | | | Change-Id: I74608619201bf77e487fb986bf213b349cc22f6a Reviewed-by: Paul Wicking <paul.wicking@qt.io>
* Add an example to the documentation of QImage::scanLine()Mitch Curtis2020-10-121-0/+4
| | | | | | | | | I couldn't find any examples in Qt's documentation of this when I was trying to use it in a project. Pick-to: 5.15 5.12 Change-Id: Ic7b7b71f219b2c1012829980866940b9a77bd11f Reviewed-by: Venugopal Shivashankar <Venugopal.Shivashankar@qt.io>
* Protect QImage work on shutdownAllan Sandfeld Jensen2020-10-121-4/+4
| | | | | | | | | | If the thread pool was not created, or already deleted, make sure the QImage routines can still run as they could before. Fixes: QTBUG-87320 Pick-to: 5.15 Change-Id: I4105a68b6ae0637faf82cdda5f5ae44298759396 Reviewed-by: Eirik Aavitsland <eirik.aavitsland@qt.io>
* Streamline the template specialization of QESDP's dtorGiuseppe D'Angelo2020-10-052-4/+3
| | | | | | | | | | | | | | | | | | | | | Declaring and implementing out of line a specialization for QESDP's destructor is needed if we have an implicitly shared type and we want to provide an inline move constructor for it. The code is however a bit heavy on the eyes, and the full implementation for the destructor must be provided (read: copy and pasted) -- the specialization destructor cannot just "reuse" the one from the primary template. This patch adds a few macros to streamline the above, so that we can start using the same pattern in more places. These macros are completely private for the moment being; we don't want to push this solution for our users. Port QPixmap to the new macros. Change-Id: Ia6a51ad988483e44c9d97c0eca2fb003b6bd21e3 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* 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>