summaryrefslogtreecommitdiffstats
path: root/src/gui/painting/qcolortransform.cpp
Commit message (Collapse)AuthorAgeFilesLines
* Merge two color conversion methodsAllan Sandfeld Jensen34 hours1-84/+32
| | | | | | | | | We can do both conversions with the logic from applyElementListTransform with a few simple changes. Change-Id: I560a2954b3a4c1acfee57813fa0caa418b1fc5d6 Reviewed-by: Giuseppe D'Angelo <giuseppe.dangelo@kdab.com> Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
* Make possible code-paths assertedAllan Sandfeld Jensen2024-04-171-21/+21
| | | | | | | Makes it more obvious to code-checker what is possible. Change-Id: I8b2bbc55a600e8b570644135867a3244c6d57be7 Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* Add CMYK support to QColorSpaceAllan Sandfeld Jensen2024-04-121-92/+195
| | | | | | | | [ChangeLog][QtGui][QColorSpace] Support for CMYK color spaces has been added. Change-Id: I2c684dbeee8b97fc90ca4e2a892349a7fa465d06 Reviewed-by: Giuseppe D'Angelo <giuseppe.dangelo@kdab.com>
* Make QColorTrcLut more flexibleAllan Sandfeld Jensen2024-04-051-36/+36
| | | | | | | | Make it possible to generate one way QColorTrcLut tables, and make it easier test out different table size, Change-Id: I953c68d772699de87fdddbf15ce196e6ba8b9898 Reviewed-by: Giuseppe D'Angelo <giuseppe.dangelo@kdab.com>
* Add color space model, making gray color spaces explicitAllan Sandfeld Jensen2024-04-051-145/+305
| | | | | | | | | This also adds image conversion of both format and color space, which will also be required later for conversions to CMYK formats and color spaces. Change-Id: I578c0a010ffcdb4df4cf9080c0621fac8bc342bf Reviewed-by: Giuseppe D'Angelo <giuseppe.dangelo@kdab.com>
* Add A2B tables, and PCSLab support to QIccAllan Sandfeld Jensen2024-03-071-79/+436
| | | | | | | | | | | | | This finishes off ICC color space support in Qt (short of the optional multi process elements), and includes necessary parts for potential CMYK support (PCSLab and A2B support) [ChangeLog][QColorSpace] ICC profiles that are not three-component matrix based are now supported. Task-number: QTBUG-108175 Change-Id: Ie29b17a366d9ba0ea8135e1752530d6bb19e7520 Reviewed-by: Giuseppe D'Angelo <giuseppe.dangelo@kdab.com>
* Call QColorTransformPrivate::applyReturnGray directlyAllan Sandfeld Jensen2024-02-291-19/+7
| | | | | Change-Id: I03434d11cf0ee734b4c0300db9b675fe393ccfab Reviewed-by: Giuseppe D'Angelo <giuseppe.dangelo@kdab.com>
* QtGui: fix build with GCC 13's support for FP16Thiago Macieira2023-01-111-3/+3
| | | | | | | | | | | Conversion must be explicit from float, but doesn't need to be from int. qimage.cpp:1915:33: error: converting to ‘qfloat16::NativeType’ {aka ‘_Float16’} from ‘float’ with greater conversion rank [-Werror] Pick-to: 6.5 Change-Id: Ide4dbd0777a44ed0870efffd17390a0e86f1fd7e Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io> Reviewed-by: Giuseppe D'Angelo <giuseppe.dangelo@kdab.com>
* Add new map methods for QColorTransformAllan Sandfeld Jensen2022-05-311-0/+42
| | | | | Change-Id: I520fc4f4bd958472c6d6359bf671835796c677fe Reviewed-by: Eirik Aavitsland <eirik.aavitsland@qt.io>
* Test prepared qcolortransformAllan Sandfeld Jensen2022-05-311-6/+18
| | | | | | | | | | Add test of explicitly prepared qcolortransform, this is a state a transform can get into if used for an image transform. Also cleans up the test code. Change-Id: I9445ed114bed0edc790e14024aaae6a42989220b Reviewed-by: Eirik Aavitsland <eirik.aavitsland@qt.io>
* Expand QColorTransformAllan Sandfeld Jensen2022-05-261-3/+71
| | | | | | | | | | Add comparison operators and an isIdentity() method to detect (1-1) transforms. [ChangeLog][QtGui] Added QColorTransform::isIdentity() method. Added QImage::colorTransformed() transitive method. Change-Id: I5fbcd14e75f2179e43e94e8c5f42cd0a5600790b Reviewed-by: Eirik Aavitsland <eirik.aavitsland@qt.io>
* Add test of QColorTransformAllan Sandfeld Jensen2022-05-261-1/+1
| | | | | | | | | Before it was only tested indirectly as part of the qcolorspace tests. This also fixes a rounding for maximum RGB64 values. Pick-to: 6.3 Change-Id: I6106e662c0f9d00c0b3a0c13213cb051ea39e14e Reviewed-by: Eirik Aavitsland <eirik.aavitsland@qt.io>
* Use SPDX license identifiersLucie Gérard2022-05-161-38/+2
| | | | | | | | | | | | | Replace the current license disclaimer in files by a SPDX-License-Identifier. Files that have to be modified by hand are modified. License files are organized under LICENSES directory. Task-number: QTBUG-67283 Change-Id: Id880c92784c40f3bbde861c0d93f58151c18b9f1 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Lars Knoll <lars.knoll@qt.io> Reviewed-by: Jörg Bornemann <joerg.bornemann@qt.io>
* Add floating point color space conversionsAllan Sandfeld Jensen2022-05-141-8/+285
| | | | | | | | | | This allows color space conversions that produces values outside the 0.0->1.0 range, which is one of the intended functions of the floating point image formats. Change-Id: I63b37b0f6934d4382edafb4709486c785a637c67 Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io> Reviewed-by: Eirik Aavitsland <eirik.aavitsland@qt.io>
* QColorTrcLut: hold in shared_ptrMarc Mutz2021-07-121-5/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | ... instead of raw pointers or QSharedPointer. Raw pointers are, of course, a no-no in modern code. In particular, when the result is then held in shared_ptr or QSharedPointer, make_shared or QSharedPointer::create() should be used to reduce number of memory allocations. Since this is private API, we're free to use std::shared_ptr, which does only half the atomic operations on copies, compared to QSharedPointer, so is more efficient. For either make_shared or QSharedPointer::create(), we need to work around the private ctor, which we do by inheriting a member-function local class from QColorTrcLut and make_shared'ing that. As a member-function-local class, it has access to the otherwise private parts of QColorTrcLut, including its default constructor. As a public subclass, shared_ptr has no problem performing the derived-to-base pointer adjustment in the return statement. This way, we can use make_shared even though our target's class' ctor is private. Change-Id: Icb11249b54cd5e544e692f6a0bf1f9dda1710454 Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io> Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
* Fix QColorTransform on RGBA64_PremultipliedAllan Sandfeld Jensen2021-06-101-6/+15
| | | | | | | | | The lack of an unsigned pack 32bit->16bit without SSE4, meant the premultiplied path would saturate color values over 32735. Pick-to: 6.2 Change-Id: Ia76e0369fd11a6767e8db78bf9a10eea30d91d2c Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Add SIMD optimizations for color-transform writesAllan Sandfeld Jensen2021-05-271-48/+190
| | | | | | | | | | Add NEON for RGB32 and RGBA64 writeback, and SSE2 for RGBA64 writeback. Change-Id: Id9ee803267a78f5bdff5beaa719e7a59c1dbb9fb Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* Add NEON optimizations to QColorTransformAllan Sandfeld Jensen2021-05-271-8/+125
| | | | | | | | | And avoid some needless shuffling. Change-Id: I5101eb0582c17f5e3cb6db8e20d315ef38bd1863 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Lars Knoll <lars.knoll@qt.io> Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
* Correct RGB to Grayscale conversionAllan Sandfeld Jensen2021-05-211-0/+63
| | | | | | | | | | | The existing conversions weren't handling gamma correctly and used an ad-hoc definition of gray instead of based on true luminance. [ChangeLog][QtGui] RGB conversions to grayscale formats are now gamma-corrected and produce color-space luminance values Change-Id: I88ab870c8f5e502ddb053e6a14a75102239a26f2 Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* Port QColorTransform to QESDPGiuseppe D'Angelo2020-10-161-11/+3
| | | | | | | | Remove the hand-rolled refcount management code, and cleanup the existing constructors. Change-Id: I1b91dbf888feff25d67310637d42dcdc3acaac13 Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
* 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>