summaryrefslogtreecommitdiffstats
path: root/src/gui/painting/qcolorspace.cpp
Commit message (Collapse)AuthorAgeFilesLines
* Avoid crashing when constructing color-space from invalid enumAllan Sandfeld Jensen2019-12-161-0/+4
| | | | | | | | This is not to be taken as supported and is still undefined behavior, but I prefer we do not crash. Change-Id: Icf4f3398bfd57fcbdc611a5a821a1f2de0838330 Reviewed-by: Eirik Aavitsland <eirik.aavitsland@qt.io>
* Fix crash on debug output of null QColorSpaceAllan Sandfeld Jensen2019-12-091-4/+6
| | | | | Change-Id: I7d1d20d7dc2c5ac10dbe8d0a0b4111e8198bfabf Reviewed-by: Eirik Aavitsland <eirik.aavitsland@qt.io>
* Simplify QColorSpacePrivate initializationTor Arne Vestbø2019-09-121-7/+1
| | | | | | | | | | | QColorVector and QColorMatrix are default-constructed following the Qt philosophy of types always being well-defined. The corner-case where we need uninitialized versions of these types for performance reasons is handled explicitly. Change-Id: I629334d1ffc63563ec9fd1298c623946e0799d1d Reviewed-by: Paul Olav Tvete <paul.tvete@qt.io> Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Remove BT.2020 support from QColorSpaceAllan Sandfeld Jensen2019-09-081-30/+1
| | | | | | | | | | | | BT.2020 is an HDR color space and its luminance range doesn't match that of the rest of the currently available color spaces. Without support for white-point luminance in 5.14, there would be a behavior change when luminance support is later introduced, so it is better to remove it now, and reintroduce it when the necessary handling of different luminance levels is available. Change-Id: Ie29e4dd757faae3ac91d4252e1206acce42801dc Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
* Simplify QColorSpace named presetsTor Arne Vestbø2019-09-031-72/+54
| | | | | | | | | | | | | | We don't need a getter for the 'preset' of a color-space, as color spaces can be compared to the presets directly. This allows us to remove the Undefined and Unknown values from the presets. Internally we still distinguish known presets from unknown or undefined presets via the magic 0-value. The validity of a QColorSpace is not based on this preset, but on its actual values. Fixes: QTBUG-77963 Change-Id: I1e0a2a4be83021b8c82b3c778019f680fd46455b Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
* Fixup move semantics of QColorSpaceAllan Sandfeld Jensen2019-09-021-31/+43
| | | | | | | | | | | | Stop using QExplicitlySharedDataPointer, makes it possible to inline the move constructor and assign operator. Also protect other methods from nullptr d_ptr, and change the default constructed value to also have a null d_ptr, to match the result after a move. Change-Id: I40928feef90cc956ef84d0516a77b0ee0f8986c7 Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
* Add an easier way to change colorspacesAllan Sandfeld Jensen2019-08-021-9/+97
| | | | | | | | | | Adds setters for transfer-functions and primaries. This allows us to remove use of private QColorSpace API from the PNG handler. Change-Id: Ieeff81c813c253649500acd1e53f35247b872325 Reviewed-by: Eirik Aavitsland <eirik.aavitsland@qt.io>
* Improve our color space terminologyAllan Sandfeld Jensen2019-08-021-56/+60
| | | | | | | | | | | | | | | Replace our use of 'gamut' with 'primaries'. One is the axes of the color space, the other the volume of representable values. For the currently supported color spaces those are mostly equivalent, but when we later add support for scRgb, this would be misleading as it has the same primaries as sRGB but a much wider gamut, and we would like to use the same primaries/"gamut" id for it. Also few people would know what "the sRGB gamut" is, but "the sRGB primaries" is easily googable. Change-Id: I3348ccaae27a071ec77a4356331b9bbbf92e0d19 Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
* Fix QColorTransform memory leakAllan Sandfeld Jensen2019-08-011-0/+1
| | | | | | | Introduced recently when the smart-pointer was made manual. Change-Id: I29a041631e94a8e131dd29dae32975d68b386e00 Reviewed-by: Marc Mutz <marc.mutz@kdab.com>
* Parse color space name from ICC profileAllan Sandfeld Jensen2019-07-311-7/+14
| | | | | | | Adds parsing of ICCv2 and ICCv4 description tags. Change-Id: I8647e1529d4127950624f16c475d8dba610149b6 Reviewed-by: Eirik Aavitsland <eirik.aavitsland@qt.io>
* Fix comparisons of image with different color spacesAllan Sandfeld Jensen2019-07-231-1/+1
| | | | | | | | Take color space into account when comparing images, and fix gamma comparison that was trying to be too accurate. Change-Id: I3674653abb21b66aaacb557addc4afb4ee75cfdd Reviewed-by: Eirik Aavitsland <eirik.aavitsland@qt.io>
* Remove public d_func from QColorSpaceAllan Sandfeld Jensen2019-07-231-14/+0
| | | | | | | Replaced with getter in private. Change-Id: I968eb45052a80b45750213cf6a0c08b5973dfc4d Reviewed-by: Eirik Aavitsland <eirik.aavitsland@qt.io>
* ABI fixups for QColorSpaceAllan Sandfeld Jensen2019-07-121-2/+8
| | | | | | | Declare it shared to Qt and make the move method noexcept. Change-Id: I25d5d255d300fda109ffa1a08e1849b15e9ff29c Reviewed-by: Marc Mutz <marc.mutz@kdab.com>
* QColorTransform: make fit for releaseMarc Mutz2019-07-121-4/+5
| | | | | | | | | | | | | | | | | | | | | | | - Unexport the value class, export only out-of-line public member functions to give us more leeway in changing code later (otherwise, we'd be bound by BC with MSVC debug builds, which call even inline methods from the DLL. - Don't use QSharedPointer as the d_ptr. It's twice the size of a pointer. Use a naked pointer-to-const. Derive Private from QSharedData. This requires some changes in QColorSpace, and, as usual, an out-of-line copy ctor. - Add member-swap(), Q_DECLARE_SHARED(). - Drop noexcept from the dtor. It implicitly is, adding it explicitly looks weird. - Pass QRgb and QRgba64 by value, not by cref. They're trivially-copyable, so passed in registers if passed by value. Passing by cref forces them onto the stack. Change-Id: I669643d219ede6b7d07f15afbf8728e16150b3b2 Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
* Fix qdoc warnings for Qt 5.14Friedemann Kleint2019-05-211-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | src/corelib/tools/qstring.cpp:9505:clang found diagnostics parsing \fn int QLatin1String::indexOf(QLatin1String l1, int from Qt::CaseSensitivity cs) const error: expected ')' error: out-of-line definition of 'indexOf' does not match any declaration in 'QLatin1String' src/corelib/tools/qstringview.cpp:723:clang found diagnostics parsing \fn qsizetype QStringView::indexOf(QLatin1String l1, qsizetype from Qt::CaseSensitivity cs) const error: expected ')' error: out-of-line definition of 'indexOf' does not match any declaration in 'QStringView' src/corelib/tools/qstringview.cpp:822:Unknown command '\t' src/corelib/tools/qstringview.cpp:825:Unknown command '\t' src/corelib/tools/qstringview.cpp:826:Unknown command '\t' src/corelib/tools/qstringview.cpp:831:Unknown command '\t' src/corelib/global/qnamespace.qdoc:2448:Undocumented enum item 'MarkdownText' in Qt::TextFormat src/corelib/tools/qstringmatcher.cpp:183:No such parameter 'pattern' in QStringMatcher::QStringMatcher() src/network/ssl/qsslerror.cpp:58:Undocumented enum item 'CertificateStatusUnknown' in QSslError::SslError src/gui/kernel/qevent.cpp:5321:Undocumented parameter 'screenOrientation' in QScreenOrientationChangeEvent::QScreenOrientationChangeEvent() src/gui/kernel/qevent.cpp:5321:Undocumented parameter 'screen' in QScreenOrientationChangeEvent::QScreenOrientationChangeEvent() src/gui/kernel/qevent.cpp:5321:No such parameter 'orientation' in QScreenOrientationChangeEvent::QScreenOrientationChangeEvent() src/gui/text/qtextformat.cpp:532:Undocumented enum item 'BlockCodeLanguage' in QTextFormat::Property src/gui/text/qtextformat.cpp:532:Undocumented enum item 'BlockQuoteLevel' in QTextFormat::Property src/gui/text/qtextformat.cpp:532:Undocumented enum item 'BlockMarker' in QTextFormat::Property src/gui/text/qtextdocument.cpp:3294:Undocumented parameter 'features' in QTextDocument::toMarkdown() src/gui/painting/qcolorspace.cpp:659:Undocumented parameter 'colorSpace1' in QColorSpace::operator!=() src/gui/painting/qcolorspace.cpp:659:Undocumented parameter 'colorSpace2' in QColorSpace::operator!=() src/gui/painting/qcolorspace.cpp:659:No such parameter 'colorspace1' in QColorSpace::operator!=() src/gui/painting/qcolorspace.cpp:659:No such parameter 'colorspace2' in QColorSpace::operator!=() examples/widgets/doc/src/icons.qdoc:269:Command '\snippet (//! [43])' failed at end of file 'widgets/icons/iconpreviewarea.cpp' src/widgets/styles/qstyle.cpp:2026:Undocumented enum item 'SP_DialogRetryButton' in QStyle::StandardPixmap src/widgets/styles/qstyle.cpp:2026:Undocumented enum item 'SP_DialogYesToAllButton' in QStyle::StandardPixmap src/widgets/styles/qstyle.cpp:2026:Undocumented enum item 'SP_DialogIgnoreButton' in QStyle::StandardPixmap src/widgets/styles/qstyle.cpp:2026:Undocumented enum item 'SP_DialogNoToAllButton' in QStyle::StandardPixmap src/widgets/styles/qstyle.cpp:2026:Undocumented enum item 'SP_DialogAbortButton' in QStyle::StandardPixmap src/widgets/styles/qstyle.cpp:2026:Undocumented enum item 'SP_RestoreDefaultsButton' in QStyle::StandardPixmap src/widgets/styles/qstyle.cpp:2026:Undocumented enum item 'SP_DialogSaveAllButton' in QStyle::StandardPixmap src/testlib/qtestcase.qdoc:439:Undocumented parameter 'TestClass' in QTest::QTEST_HIGHDPI_SCALING_MAIN src/testlib/qtestcase.qdoc:452:Undocumented parameter 'TestClass' in QTest::QTEST_NO_HIGHDPI_SCALING_MAIN Change-Id: Ib0e9bf81c5caaa6b1fc644ac92085af47c600e0e Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io> Reviewed-by: Anton Kudryavtsev <antkudr@mail.ru> Reviewed-by: Paul Wicking <paul.wicking@qt.io>
* Fix race in colorspace LUT generationAllan Sandfeld Jensen2019-05-161-0/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The old code did not prevent concurrent writes to the LUTs by separate threads, each finding lutsGenerated to be false. Let's consider whether the change is safe now: the storeRelease(1) comes before the QMutex::unlock(), but since it is release semantics no writes may be ordered past it. We have two releases, and their order doesn't matter, since nothing else happens in-between. Could we use a normal relaxed store? No, because the unlock() of the mutex only synchronizes with the lock() of the same mutex, which doesn't happen if the loadAcquire() succeeds. For loadAcquire() to happen-before a write to the luts, we need a storeRelease() on the atomic. So, everything is correct, and minimal. But maybe, to save the next reader from having to do the same mental exercise again, add a manual locker.unlock() in front of the storeRelease()? Again no: that opens a gap where the luts are already generated on T0, and the mutex unlocked, but the atomic not set. If another thread T1 gets to execute the function, it will enter the critical section, then writing new values to the LUT. Meanwhile, the T0 sets generate to true and a T2 enters the function, sees the final write from T0 and starts using the luts -> data race with the writes concurrently done by T1. Change-Id: Id278812a74b6e326e3ddf0dbcbb94b34766aa52e Reviewed-by: Marc Mutz <marc.mutz@kdab.com>
* Custom color-space based on chromaticitiesAllan Sandfeld Jensen2019-05-021-23/+132
| | | | | Change-Id: I7fa6efa8993aa2b79ea60b6a21bf57c4f67a120f Reviewed-by: Eirik Aavitsland <eirik.aavitsland@qt.io>
* Long live QColorSpace and friendsAllan Sandfeld Jensen2019-02-081-0/+633
Adds QColorSpace and QColorTransform classes, and parsing of a common subset of ICC profiles found in images, and also parses the ICC profiles in PNG and JPEGs. For backwards compatibility no automatic color handling is done by this patch. [ChangeLog][QtGui] A QColorSpace class has been added, and color spaces are now parsed from PNG and JPEG images. No automatic color space conversion is done however, and applications must request it. Change-Id: Ic09935f84640a716467fa3a9ed1e73c02daf3675 Reviewed-by: Eirik Aavitsland <eirik.aavitsland@qt.io>