summaryrefslogtreecommitdiffstats
path: root/src/gui/painting/qcolortransform.cpp
Commit message (Collapse)AuthorAgeFilesLines
* Simplify QColorSpacePrivate initializationTor Arne Vestbø2019-09-121-1/+11
| | | | | | | | | | | 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>
* QColorTransform: make fit for releaseMarc Mutz2019-07-121-10/+17
| | | | | | | | | | | | | | | | | | | | | | | - 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>
* Port from QAtomic::load() to loadRelaxed()Giuseppe D'Angelo2019-06-201-2/+2
| | | | | | | | | | | | | | | Semi-automated, just needed ~20 manual fixes: $ find \( -iname \*.cpp -or -iname \*.h \) -exec perl -pe 's/(\.|->)load\(\)/$1loadRelaxed\(\)/g' -i \{\} + $ find \( -iname \*.cpp -or -iname \*.h \) -exec perl -pe 's/(\.|->)store\(/$1storeRelaxed\(/g' -i \{\} + It can be easily improved (e.g. for store check that there are no commas after the opening parens). The most common offender is QLibrary::load, and some code using std::atomic directly. Change-Id: I07c38a3c8ed32c924ef4999e85c7e45cf48f0f6c Reviewed-by: Marc Mutz <marc.mutz@kdab.com>
* Fix race in colorspace LUT generationAllan Sandfeld Jensen2019-05-161-7/+14
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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>
* Add Extended RGB model to QColorAllan Sandfeld Jensen2019-04-121-11/+28
| | | | | | | Can be used to represent wide-gamut and HDR colors. Change-Id: I1cca442069ce2f2c070f723fe930fe1f2f5580ad Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* Long live QColorSpace and friendsAllan Sandfeld Jensen2019-02-081-0/+679
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>