diff --git a/libs/image/tests/kis_iterators_ng_test.cpp b/libs/image/tests/kis_iterators_ng_test.cpp index 930219f0a1..b6500fb3ae 100644 --- a/libs/image/tests/kis_iterators_ng_test.cpp +++ b/libs/image/tests/kis_iterators_ng_test.cpp @@ -1,497 +1,497 @@ /* * Copyright (c) 2007 Boudewijn Rempt * Copyright (c) 2010 Cyrille Berger * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #include "kis_iterators_ng_test.h" #include #include #include #include #include #include #include "kis_random_accessor_ng.h" #include "kis_random_sub_accessor.h" #include "kis_paint_device.h" #include #include "kis_global.h" #include "testutil.h" -void KisIteratorTest::allCsApplicator(void (KisIteratorTest::* funcPtr)(const KoColorSpace*cs)) +void KisIteratorNGTest::allCsApplicator(void (KisIteratorNGTest::* funcPtr)(const KoColorSpace*cs)) { - QList colorsapces = KoColorSpaceRegistry::instance()->allColorSpaces(KoColorSpaceRegistry::AllColorSpaces, KoColorSpaceRegistry::OnlyDefaultProfile); + QList colorspaces = KoColorSpaceRegistry::instance()->allColorSpaces(KoColorSpaceRegistry::AllColorSpaces, KoColorSpaceRegistry::OnlyDefaultProfile); - Q_FOREACH (const KoColorSpace* cs, colorsapces) { + Q_FOREACH (const KoColorSpace* cs, colorspaces) { dbgKrita << "Testing with" << cs->id(); if (cs->id() != "GRAYU16") // No point in testing extend for GRAYU16 (this->*funcPtr)(cs); } } inline quint8* allocatePixels(const KoColorSpace *colorSpace, int numPixels) { quint8 * bytes = new quint8[colorSpace->pixelSize() * 64 * 64 * 10]; KoColor color(Qt::red, colorSpace); const int pixelSize = colorSpace->pixelSize(); for(int i = 0; i < numPixels; i++) { memcpy(bytes + i * pixelSize, color.data(), pixelSize); } return bytes; } -void KisIteratorTest::writeBytes(const KoColorSpace * colorSpace) +void KisIteratorNGTest::writeBytes(const KoColorSpace * colorSpace) { KisPaintDevice dev(colorSpace); QCOMPARE(dev.extent(), QRect(0, 0, 0, 0)); // Check allocation on tile boundaries // Allocate memory for a 2 * 5 tiles grid QScopedArrayPointer bytes(allocatePixels(colorSpace, 64 * 64 * 10)); // Covers 5 x 2 tiles dev.writeBytes(bytes.data(), 0, 0, 5 * 64, 2 * 64); // Covers QCOMPARE(dev.extent(), QRect(0, 0, 64 * 5, 64 * 2)); QCOMPARE(dev.exactBounds(), QRect(0, 0, 64 * 5, 64 * 2)); dev.clear(); QCOMPARE(dev.extent(), QRect(qint32_MAX, qint32_MAX, 0, 0)); dev.clear(); // Covers three by three tiles dev.writeBytes(bytes.data(), 10, 10, 130, 130); QCOMPARE(dev.extent(), QRect(0, 0, 64 * 3, 64 * 3)); QCOMPARE(dev.exactBounds(), QRect(10, 10, 130, 130)); dev.clear(); // Covers 11 x 2 tiles dev.writeBytes(bytes.data(), -10, -10, 10 * 64, 64); QCOMPARE(dev.extent(), QRect(-64, -64, 64 * 11, 64 * 2)); QCOMPARE(dev.exactBounds(), QRect(-10, -10, 640, 64)); } -void KisIteratorTest::fill(const KoColorSpace * colorSpace) +void KisIteratorNGTest::fill(const KoColorSpace * colorSpace) { KisPaintDevice dev(colorSpace); QCOMPARE(dev.extent(), QRect(0, 0, 0, 0)); QScopedArrayPointer bytes(allocatePixels(colorSpace, 1)); dev.fill(0, 0, 5, 5, bytes.data()); QCOMPARE(dev.extent(), QRect(0, 0, 64, 64)); QCOMPARE(dev.exactBounds(), QRect(0, 0, 5, 5)); dev.clear(); dev.fill(5, 5, 5, 5, bytes.data()); QCOMPARE(dev.extent(), QRect(0, 0, 64, 64)); QCOMPARE(dev.exactBounds(), QRect(5, 5, 5, 5)); dev.clear(); dev.fill(5, 5, 500, 500, bytes.data()); QCOMPARE(dev.extent(), QRect(0, 0, 8 * 64, 8 * 64)); QCOMPARE(dev.exactBounds(), QRect(5, 5, 500, 500)); dev.clear(); dev.fill(33, -10, 348, 1028, bytes.data()); QCOMPARE(dev.extent(), QRect(0, -64, 6 * 64, 17 * 64)); QCOMPARE(dev.exactBounds(), QRect(33, -10, 348, 1028)); } -void KisIteratorTest::sequentialIter(const KoColorSpace * colorSpace) +void KisIteratorNGTest::sequentialIter(const KoColorSpace * colorSpace) { KisPaintDeviceSP dev = new KisPaintDevice(colorSpace); QCOMPARE(dev->extent(), QRect(0, 0, 0, 0)); // Const does not extend the extent { KisSequentialConstIterator it(dev, QRect(0, 0, 128, 128)); while (it.nextPixel()); QCOMPARE(dev->extent(), QRect(0, 0, 0, 0)); QCOMPARE(dev->exactBounds(), QRect(QPoint(0, 0), QPoint(-1, -1))); } // Non-const does { KisSequentialIterator it(dev, QRect(0, 0, 128, 128)); int i = -1; while (it.nextPixel()) { i++; KoColor c(QColor(i % 255, i / 255, 0), colorSpace); memcpy(it.rawData(), c.data(), colorSpace->pixelSize()); QCOMPARE(it.x(), i % 128); QCOMPARE(it.y(), i / 128); } QCOMPARE(dev->extent(), QRect(0, 0, 128, 128)); QCOMPARE(dev->exactBounds(), QRect(0, 0, 128, 128)); } { // check const iterator KisSequentialConstIterator it(dev, QRect(0, 0, 128, 128)); int i = -1; while (it.nextPixel()) { i++; KoColor c(QColor(i % 255, i / 255, 0), colorSpace); QVERIFY(memcmp(it.rawDataConst(), c.data(), colorSpace->pixelSize()) == 0); } QCOMPARE(dev->extent(), QRect(0, 0, 128, 128)); QCOMPARE(dev->exactBounds(), QRect(0, 0, 128, 128)); } { // check const iterator with **empty** area! It should neither crash nor enter the loop KisSequentialConstIterator it(dev, QRect()); QVERIFY(!it.rawDataConst()); QVERIFY(!it.oldRawData()); while (it.nextPixel()) { QVERIFY(0 && "we should never enter the loop"); } } { // check const iterator with strides KisSequentialConstIterator it(dev, QRect(0, 0, 128, 128)); int i = -1; int numConseqPixels = it.nConseqPixels(); while (it.nextPixels(numConseqPixels)) { numConseqPixels = it.nConseqPixels(); for (int j = 0; j < numConseqPixels; j++) { i++; KoColor c(QColor(i % 255, i / 255, 0), colorSpace); QVERIFY(memcmp(it.rawDataConst() + j * colorSpace->pixelSize(), c.data(), colorSpace->pixelSize()) == 0); } } QCOMPARE(dev->extent(), QRect(0, 0, 128, 128)); QCOMPARE(dev->exactBounds(), QRect(0, 0, 128, 128)); } { // check const iterator with strides and **empty** area KisSequentialConstIterator it(dev, QRect()); QVERIFY(!it.rawDataConst()); QVERIFY(!it.oldRawData()); int numConseqPixels = it.nConseqPixels(); while (it.nextPixels(numConseqPixels)) { QVERIFY(0 && "we should never enter the loop"); } } dev->clear(); { KisSequentialIterator it(dev, QRect(10, 10, 128, 128)); int i = -1; while (it.nextPixel()) { i++; KoColor c(QColor(i % 255, i / 255, 0), colorSpace); memcpy(it.rawData(), c.data(), colorSpace->pixelSize()); } QCOMPARE(dev->extent(), QRect(0, 0, 3 * 64, 3 * 64)); QCOMPARE(dev->exactBounds(), QRect(10, 10, 128, 128)); } dev->clear(); dev->setX(10); dev->setY(-15); { KisSequentialIterator it(dev, QRect(10, 10, 128, 128)); int i = -1; while (it.nextPixel()) { i++; KoColor c(QColor(i % 255, i / 255, 0), colorSpace); memcpy(it.rawData(), c.data(), colorSpace->pixelSize()); } QCOMPARE(dev->extent(), QRect(10, -15, 128, 192)); QCOMPARE(dev->exactBounds(), QRect(10, 10, 128, 128)); } { KisSequentialIterator it(dev, QRect(10, 10, 128, 128)); QCOMPARE(it.rawData(), it.oldRawData()); } } -void KisIteratorTest::hLineIter(const KoColorSpace * colorSpace) +void KisIteratorNGTest::hLineIter(const KoColorSpace * colorSpace) { KisPaintDevice dev(colorSpace); QScopedArrayPointer bytes(allocatePixels(colorSpace, 1)); QCOMPARE(dev.extent(), QRect(0, 0, 0, 0)); KisHLineConstIteratorSP cit = dev.createHLineConstIteratorNG(0, 0, 128); while (!cit->nextPixel()); QCOMPARE(dev.extent(), QRect(0, 0, 0, 0)); QCOMPARE(dev.exactBounds(), QRect(QPoint(0, 0), QPoint(-1, -1))); dev.clear(); KisHLineIteratorSP it = dev.createHLineIteratorNG(0, 0, 128); do { memcpy(it->rawData(), bytes.data(), colorSpace->pixelSize()); } while (it->nextPixel()); QCOMPARE(dev.extent(), QRect(0, 0, 128, 64)); QCOMPARE(dev.exactBounds(), QRect(0, 0, 128, 1)); dev.clear(); it = dev.createHLineIteratorNG(0, 1, 128); do { memcpy(it->rawData(), bytes.data(), colorSpace->pixelSize()); } while (it->nextPixel()); QCOMPARE(dev.extent(), QRect(0, 0, 128, 64)); QCOMPARE(dev.exactBounds(), QRect(0, 1, 128, 1)); dev.clear(); it = dev.createHLineIteratorNG(10, 10, 128); do { memcpy(it->rawData(), bytes.data(), colorSpace->pixelSize()); } while (it->nextPixel()); QCOMPARE(dev.extent(), QRect(0, 0, 192, 64)); QCOMPARE(dev.exactBounds(), QRect(10, 10, 128, 1)); dev.clear(); dev.setX(10); dev.setY(-15); it = dev.createHLineIteratorNG(10, 10, 128); do { memcpy(it->rawData(), bytes.data(), colorSpace->pixelSize()); } while (it->nextPixel()); QCOMPARE(dev.extent(), QRect(10, -15, 128, 64)); QCOMPARE(dev.exactBounds(), QRect(10, 10, 128, 1)); it = dev.createHLineIteratorNG(10, 10, 128); it->nextRow(); QCOMPARE(it->rawData(), it->oldRawData()); } -void KisIteratorTest::justCreation(const KoColorSpace * colorSpace) +void KisIteratorNGTest::justCreation(const KoColorSpace * colorSpace) { KisPaintDevice dev(colorSpace); dev.createVLineConstIteratorNG(0, 0, 128); dev.createVLineIteratorNG(0, 0, 128); dev.createHLineConstIteratorNG(0, 0, 128); dev.createHLineIteratorNG(0, 0, 128); } -void KisIteratorTest::vLineIter(const KoColorSpace * colorSpace) +void KisIteratorNGTest::vLineIter(const KoColorSpace * colorSpace) { KisPaintDevice dev(colorSpace); QScopedArrayPointer bytes(allocatePixels(colorSpace, 1)); QCOMPARE(dev.extent(), QRect(0, 0, 0, 0)); KisVLineConstIteratorSP cit = dev.createVLineConstIteratorNG(0, 0, 128); while (cit->nextPixel()); QCOMPARE(dev.extent(), QRect(0, 0, 0, 0)); QCOMPARE(dev.exactBounds(), QRect(QPoint(0, 0), QPoint(-1, -1))); cit.clear(); KisVLineIteratorSP it = dev.createVLineIteratorNG(0, 0, 128); do { memcpy(it->rawData(), bytes.data(), colorSpace->pixelSize()); } while(it->nextPixel()); QCOMPARE((QRect) dev.extent(), QRect(0, 0, 64, 128)); QCOMPARE((QRect) dev.exactBounds(), QRect(0, 0, 1, 128)); it.clear(); dev.clear(); it = dev.createVLineIteratorNG(10, 10, 128); do { memcpy(it->rawData(), bytes.data(), colorSpace->pixelSize()); } while(it->nextPixel()); QCOMPARE(dev.extent(), QRect(0, 0, 64, 192)); QCOMPARE(dev.exactBounds(), QRect(10, 10, 1, 128)); dev.clear(); dev.setX(10); dev.setY(-15); it = dev.createVLineIteratorNG(10, 10, 128); do { memcpy(it->rawData(), bytes.data(), colorSpace->pixelSize()); } while(it->nextPixel()); QCOMPARE(dev.extent(), QRect(10, -15, 64, 192)); QCOMPARE(dev.exactBounds(), QRect(10, 10, 1, 128)); it = dev.createVLineIteratorNG(10, 10, 128); it->nextColumn(); QCOMPARE(it->rawData(), it->oldRawData()); } -void KisIteratorTest::randomAccessor(const KoColorSpace * colorSpace) +void KisIteratorNGTest::randomAccessor(const KoColorSpace * colorSpace) { KisPaintDevice dev(colorSpace); QScopedArrayPointer bytes(allocatePixels(colorSpace, 1)); QCOMPARE(dev.extent(), QRect(0, 0, 0, 0)); KisRandomConstAccessorSP acc = dev.createRandomConstAccessorNG(0, 0); for (int y = 0; y < 128; ++y) { for (int x = 0; x < 128; ++x) { acc->moveTo(x, y); } } QCOMPARE(dev.extent(), QRect(0, 0, 0, 0)); KisRandomAccessorSP ac = dev.createRandomAccessorNG(0, 0); for (int y = 0; y < 128; ++y) { for (int x = 0; x < 128; ++x) { ac->moveTo(x, y); memcpy(ac->rawData(), bytes.data(), colorSpace->pixelSize()); } } QCOMPARE(dev.extent(), QRect(0, 0, 128, 128)); QCOMPARE(dev.exactBounds(), QRect(0, 0, 128, 128)); dev.clear(); dev.setX(10); dev.setY(-15); ac = dev.createRandomAccessorNG(0, 0); for (int y = 0; y < 128; ++y) { for (int x = 0; x < 128; ++x) { ac->moveTo(x, y); memcpy(ac->rawData(), bytes.data(), colorSpace->pixelSize()); } } QCOMPARE(dev.extent(), QRect(-54, -15, 192, 192)); QCOMPARE(dev.exactBounds(), QRect(0, 0, 128, 128)); } -void KisIteratorTest::writeBytes() +void KisIteratorNGTest::writeBytes() { - allCsApplicator(&KisIteratorTest::writeBytes); + allCsApplicator(&KisIteratorNGTest::writeBytes); } -void KisIteratorTest::fill() +void KisIteratorNGTest::fill() { - allCsApplicator(&KisIteratorTest::fill); + allCsApplicator(&KisIteratorNGTest::fill); } -void KisIteratorTest::sequentialIter() +void KisIteratorNGTest::sequentialIter() { - allCsApplicator(&KisIteratorTest::sequentialIter); + allCsApplicator(&KisIteratorNGTest::sequentialIter); } #include -void KisIteratorTest::sequentialIteratorWithProgress() +void KisIteratorNGTest::sequentialIteratorWithProgress() { KisPaintDeviceSP dev = new KisPaintDevice(KoColorSpaceRegistry::instance()->rgb8()); const QRect rc(10,10,200,200); TestUtil::TestProgressBar proxy; KisSequentialConstIteratorProgress it (dev, rc, &proxy); while (it.nextPixel()) { QCOMPARE(proxy.min(), rc.top()); QCOMPARE(proxy.max(), rc.top() + rc.height()); QCOMPARE(proxy.value(), it.y()); } QCOMPARE(proxy.max(), rc.top() + rc.height()); QCOMPARE(proxy.value(), proxy.max()); } -void KisIteratorTest::sequentialIteratorWithProgressIncomplete() +void KisIteratorNGTest::sequentialIteratorWithProgressIncomplete() { KisPaintDeviceSP dev = new KisPaintDevice(KoColorSpaceRegistry::instance()->rgb8()); const QRect rc(10,10,100,100); TestUtil::TestProgressBar proxy; { KisSequentialConstIteratorProgress it (dev, rc, &proxy); QCOMPARE(proxy.max(), rc.top() + rc.height()); QCOMPARE(proxy.value(), rc.top()); } // on desruction, iterator automatically completes progress reporting QCOMPARE(proxy.max(), rc.top() + rc.height()); QCOMPARE(proxy.value(), proxy.max()); } -void KisIteratorTest::hLineIter() +void KisIteratorNGTest::hLineIter() { - allCsApplicator(&KisIteratorTest::hLineIter); + allCsApplicator(&KisIteratorNGTest::hLineIter); } -void KisIteratorTest::justCreation() +void KisIteratorNGTest::justCreation() { - allCsApplicator(&KisIteratorTest::justCreation); + allCsApplicator(&KisIteratorNGTest::justCreation); } -void KisIteratorTest::vLineIter() +void KisIteratorNGTest::vLineIter() { - allCsApplicator(&KisIteratorTest::vLineIter); + allCsApplicator(&KisIteratorNGTest::vLineIter); } -void KisIteratorTest::randomAccessor() +void KisIteratorNGTest::randomAccessor() { - allCsApplicator(&KisIteratorTest::randomAccessor); + allCsApplicator(&KisIteratorNGTest::randomAccessor); } -QTEST_MAIN(KisIteratorTest) +KISTEST_MAIN(KisIteratorNGTest) diff --git a/libs/image/tests/kis_iterators_ng_test.h b/libs/image/tests/kis_iterators_ng_test.h index cc0cd7e42f..a3862bd83d 100644 --- a/libs/image/tests/kis_iterators_ng_test.h +++ b/libs/image/tests/kis_iterators_ng_test.h @@ -1,55 +1,55 @@ /* * Copyright (c) 2007 Boudewijn Rempt * Copyright (c) 2010 Cyrille Berger * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #ifndef KIS_ITERATOR_NG_TEST_H #define KIS_ITERATOR_NG_TEST_H #include class KoColorSpace; -class KisIteratorTest : public QObject +class KisIteratorNGTest : public QObject { Q_OBJECT private: - void allCsApplicator(void (KisIteratorTest::* funcPtr)(const KoColorSpace*cs)); + void allCsApplicator(void (KisIteratorNGTest::* funcPtr)(const KoColorSpace*cs)); void justCreation(const KoColorSpace * cs); void vLineIter(const KoColorSpace * cs); void writeBytes(const KoColorSpace * cs); void fill(const KoColorSpace * cs); void sequentialIter(const KoColorSpace * colorSpace); void hLineIter(const KoColorSpace * cs); void randomAccessor(const KoColorSpace * cs); private Q_SLOTS: void justCreation(); void vLineIter(); void writeBytes(); void fill(); void sequentialIter(); void sequentialIteratorWithProgress(); void sequentialIteratorWithProgressIncomplete(); void hLineIter(); void randomAccessor(); }; #endif diff --git a/libs/pigment/KoColorSpaceRegistry.h b/libs/pigment/KoColorSpaceRegistry.h index 8db1fe2054..3bee4e3a26 100644 --- a/libs/pigment/KoColorSpaceRegistry.h +++ b/libs/pigment/KoColorSpaceRegistry.h @@ -1,360 +1,361 @@ /* * Copyright (c) 2003 Patrick Julien * Copyright (c) 2004,2010 Cyrille Berger * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this library; see the file COPYING.LIB. If not, write to * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, * Boston, MA 02110-1301, USA. */ #ifndef KOCOLORSPACEREGISTRY_H #define KOCOLORSPACEREGISTRY_H #include #include #include #include "kritapigment_export.h" #include #include #include class KoColorProfile; class KoColorConversionSystem; class KoColorConversionCache; class KoColorConversionTransformation; /** * The registry for colorspaces and profiles. * This class contains: * - a registry of colorspace instantiated with specific profiles. * - a registry of singleton colorspace factories. * - a registry of icc profiles * * Locking policy details: * * Basically, we have two levels of locks in the registry: * 1) (outer level) is Private::registrylock, which controls the structures * of the color space registry itself * 2) (inner level) is KoColorProfileStorage::Private::lock controls * the structures related to profiles. * * The locks can be taken individually, but if you are going to take both * of them, you should always follow the order 1) registry; 2) profiles. * Otherwise you'll get a deadlock. * * To avoid recursive deadlocks, all the dependent classes * (KoColorConversionSystem and KoColorSpaceFactory) now do not use the direct * links to the registry. Instead, they use special private interfaces that * skip recursive locking and ensure we take a lock twice. */ class KRITAPIGMENT_EXPORT KoColorSpaceRegistry { public: KoColorSpaceRegistry(); enum ColorSpaceListVisibility { OnlyUserVisible = 1, ///< Only user visible color space AllColorSpaces = 4 ///< All color space even those not visible to the user }; enum ColorSpaceListProfilesSelection { OnlyDefaultProfile = 1, ///< Only add the default profile AllProfiles = 4 ///< Add all profiles }; /** * Return an instance of the KoColorSpaceRegistry * Creates an instance if that has never happened before and returns the singleton instance. */ static KoColorSpaceRegistry * instance(); virtual ~KoColorSpaceRegistry(); public: /** * add a color space to the registry * @param item the color space factory to add */ void add(KoColorSpaceFactory* item); /** * Remove a color space factory from the registry. Note that it is the * responsibility of the caller to ensure that the colorspaces are not * used anymore. */ void remove(KoColorSpaceFactory* item); /** * Add a profile to the profile map but do not add it to the * color conversion system yet. * @param profile the new profile to be registered. */ void addProfileToMap(KoColorProfile *p); /** * register the profile with the color space registry * @param profile the new profile to be registered so it can be combined with * colorspaces. */ void addProfile(KoColorProfile* profile); void addProfile(const KoColorProfile* profile); // TODO why ? void removeProfile(KoColorProfile* profile); /** * Create an alias to a profile with a different name. Then @ref profileByName * will return the profile @p to when passed @p name as a parameter. */ void addProfileAlias(const QString& name, const QString& to); /** * @return the profile alias, or name if not aliased */ QString profileAlias(const QString& name) const; /** * create a profile of the specified type. */ const KoColorProfile *createColorProfile(const QString & colorModelId, const QString & colorDepthId, const QByteArray& rawData); /** * Return a profile by its given name, or 0 if none registered. * @return a profile by its given name, or 0 if none registered. * @param name the product name as set on the profile. * @see addProfile() * @see KoColorProfile::productName() */ const KoColorProfile * profileByName(const QString & name) const ; /** * Returns a profile by its unique id stored/calculated in the header. * The first call to this function might take long, because the map is * created on the first use only (atm used by SVG only) * @param id unique ProfileID of the profile (MD5 sum of its header) * @return the profile or 0 if not found */ const KoColorProfile *profileByUniqueId(const QByteArray &id) const; bool profileIsCompatible(const KoColorProfile* profile, const QString &colorSpaceId); /** * Return the list of profiles for a colorspace with the argument id. * Profiles will not work with any color space, you can query which profiles * that are registered with this registry can be used in combination with the * argument factory. * @param colorSpaceId the colorspace-id with which all the returned profiles will work. * @return a list of profiles for the factory */ QList profilesFor(const QString& csID) const; QString defaultProfileForColorSpace(const QString &colorSpaceId) const; /** * This function is called by the color space to create a color conversion * between two color space. This function search in the graph of transformations * the best possible path between the two color space. */ KoColorConversionTransformation* createColorConverter(const KoColorSpace * srcColorSpace, const KoColorSpace * dstColorSpace, KoColorConversionTransformation::Intent renderingIntent, KoColorConversionTransformation::ConversionFlags conversionFlags) const; /** * This function creates two transformations, one from the color space and one to the * color space. The destination color space is picked from a list of color space, such * as the conversion between the two color space is of the best quality. * * The typical use case of this function is for KoColorTransformationFactory which * doesn't support all color spaces, so unsupported color space have to find an * acceptable conversion in order to use that KoColorTransformationFactory. * * @param colorSpace the source color space * @param possibilities a list of color space among which we need to find the best * conversion * @param fromCS the conversion from the source color space will be affected to this * variable * @param toCS the revert conversion to the source color space will be affected to this * variable */ void createColorConverters(const KoColorSpace* colorSpace, const QList< QPair >& possibilities, KoColorConversionTransformation*& fromCS, KoColorConversionTransformation*& toCS) const; /** * Return a colorspace that works with the parameter profile. * @param colorSpaceId the ID string of the colorspace that you want to have returned * @param profile the profile be combined with the colorspace * @return the wanted colorspace, or 0 when the cs and profile can not be combined. */ const KoColorSpace * colorSpace(const QString & colorModelId, const QString & colorDepthId, const KoColorProfile *profile); /** * Return a colorspace that works with the parameter profile. * @param profileName the name of the KoColorProfile to be combined with the colorspace * @return the wanted colorspace, or 0 when the cs and profile can not be combined. */ const KoColorSpace * colorSpace(const QString & colorModelId, const QString & colorDepthId, const QString &profileName); const KoColorSpace * colorSpace(const QString & colorModelId, const QString & colorDepthId); /** * Return the id of the colorspace that have the defined colorModelId with colorDepthId. * @param colorModelId id of the color model * @param colorDepthId id of the color depth * @return the id of the wanted colorspace, or "" if no colorspace correspond to those ids */ QString colorSpaceId(const QString & colorModelId, const QString & colorDepthId) const; /** * It's a convenient function that behave like the above. * Return the id of the colorspace that have the defined colorModelId with colorDepthId. * @param colorModelId id of the color model * @param colorDepthId id of the color depth * @return the id of the wanted colorspace, or "" if no colorspace correspond to those ids */ QString colorSpaceId(const KoID& colorModelId, const KoID& colorDepthId) const; /** * @return a the identifiant of the color model for the given color space id. * * This function is a compatibility function used to get the color space from * all kra files. */ KoID colorSpaceColorModelId(const QString & _colorSpaceId) const; /** * @return a the identifiant of the color depth for the given color space id. * * This function is a compatibility function used to get the color space from * all kra files. */ KoID colorSpaceColorDepthId(const QString & _colorSpaceId) const; /** * Convenience methods to get the often used alpha colorspaces */ const KoColorSpace *alpha8(); const KoColorSpace *alpha16(); #include #ifdef HAVE_OPENEXR const KoColorSpace *alpha16f(); #endif const KoColorSpace *alpha32f(); /** * Convenience method to get an RGBA 8bit colorspace. If a profile is not specified, * an sRGB profile will be used. * @param profileName the name of an RGB color profile * @return the wanted colorspace, or 0 if the color space and profile can not be combined. */ const KoColorSpace * rgb8(const QString &profileName = QString()); /** * Convenience method to get an RGBA 8bit colorspace with the given profile. * @param profile an RGB profile * @return the wanted colorspace, or 0 if the color space and profile can not be combined. */ const KoColorSpace * rgb8(const KoColorProfile * profile); /** * Convenience method to get an RGBA 16bit colorspace. If a profile is not specified, * an sRGB profile will be used. * @param profileName the name of an RGB color profile * @return the wanted colorspace, or 0 if the color space and profile can not be combined. */ const KoColorSpace * rgb16(const QString &profileName = QString()); /** * Convenience method to get an RGBA 16bit colorspace with the given profile. * @param profile an RGB profile * @return the wanted colorspace, or 0 if the color space and profile can not be combined. */ const KoColorSpace * rgb16(const KoColorProfile * profile); /** * Convenience method to get an Lab 16bit colorspace. If a profile is not specified, * an Lab profile with a D50 whitepoint will be used. * @param profileName the name of an Lab color profile * @return the wanted colorspace, or 0 if the color space and profile can not be combined. */ const KoColorSpace * lab16(const QString &profileName = QString()); /** * Convenience method to get an Lab 16bit colorspace with the given profile. * @param profile an Lab profile * @return the wanted colorspace, or 0 if the color space and profile can not be combined. */ const KoColorSpace * lab16(const KoColorProfile * profile); /** * @return the list of available color models */ QList colorModelsList(ColorSpaceListVisibility option) const; /** * @return the list of available color models for the given colorModelId */ QList colorDepthList(const KoID& colorModelId, ColorSpaceListVisibility option) const; /** * @return the list of available color models for the given colorModelId */ QList colorDepthList(const QString & colorModelId, ColorSpaceListVisibility option) const; /** * @return the cache of color conversion transformation to be use by KoColorSpace */ KoColorConversionCache* colorConversionCache() const; /** * @return a permanent colorspace owned by the registry, of the same type and profile * as the one given in argument */ const KoColorSpace* permanentColorspace(const KoColorSpace* _colorSpace); /** * This function return a list of all the keys in KoID format by using the name() method * on the objects stored in the registry. */ QList listKeys() const; private: friend class KisCsConversionTest; friend class KisIteratorTest; + friend class KisIteratorNGTest; friend class KisPainterTest; friend class KisCrashFilterTest; friend class KoColorSpacesBenchmark; friend class TestKoColorSpaceSanity; friend class TestColorConversionSystem; friend class FriendOfColorSpaceRegistry; /** * @return a list with an instance of all color space with their default profile. */ QList allColorSpaces(ColorSpaceListVisibility visibility, ColorSpaceListProfilesSelection pSelection); /** * @return the color conversion system use by the registry and the color * spaces to create color conversion transformation. * * WARNING: conversion system is guared by the registry locks, don't * use it anywhere other than unttests! */ const KoColorConversionSystem* colorConversionSystem() const; private: KoColorSpaceRegistry(const KoColorSpaceRegistry&); KoColorSpaceRegistry operator=(const KoColorSpaceRegistry&); void init(); private: struct Private; Private * const d; }; #endif // KOCOLORSPACEREGISTRY_H