Commit 82df3900 authored by Casper Boemann's avatar Casper Boemann

This is a big one. The colorspaces now have

profiles as attributes rather the being two 
seperate entities.

The colorspace registry has been replaced by a 
colorspace_factory_registry. Each colormode (eg 
rgb_u08) has a factory that make colorspaces. So 
now we can have many colorspaces, but only when 
they have different profiles.

The new registry handles it so that colorspace 
instances are still shared.

Some colorspaces do not have profiles. Wet is one 
of those.

I can't guarantee that there will be no fallout or 
regression.

Nothing new featurewise in this commit, although it 
does open the possibilities for future colorspace 
independence, which we all know IS a big thing.


svn path=/trunk/koffice/; revision=463852
parent 016ce447
......@@ -12,7 +12,7 @@ OPENEXR_SOURCES=kis_f16half_base_colorspace.cc
endif
libkiscolor_strategy_la_SOURCES = kis_abstract_colorspace.cc \
kis_colorspace_registry.cc \
kis_colorspace_factory_registry.cc \
kis_alpha_colorspace.cc \
kis_color_conversions.cc \
kis_xyz_colorspace.cc \
......
......@@ -31,11 +31,11 @@
#include "kis_id.h"
#include "kis_integer_maths.h"
#include "kis_color_conversions.h"
#include "kis_colorspace_registry.h"
#include "kis_colorspace_factory_registry.h"
#include "kis_channelinfo.h"
#include "kis_xyz_colorspace.h"
KisAbstractColorSpace::KisAbstractColorSpace(const KisID& id, DWORD cmType, icColorSpaceSignature colorSpaceSignature)
KisAbstractColorSpace::KisAbstractColorSpace(const KisID& id, DWORD cmType, icColorSpaceSignature colorSpaceSignature, KisProfile *p)
: m_id(id),
m_cmType(cmType),
m_colorSpaceSignature(colorSpaceSignature)
......@@ -44,22 +44,19 @@ KisAbstractColorSpace::KisAbstractColorSpace(const KisID& id, DWORD cmType, icCo
m_alphaSize = -1;
m_qcolordata = 0;
m_lastUsedDstProfile = 0;
m_lastUsedSrcProfile = 0;
m_lastUsedTransform = 0;
m_defaultProfile = 0;
m_profile = p;
}
void KisAbstractColorSpace::init()
{
// Only create the defaul transforms if
if (m_defaultProfile == 0) return;
// Default pixel buffer for QColor conversion
m_qcolordata = new Q_UINT8[3];
Q_CHECK_PTR(m_qcolordata);
cmsHPROFILE hProfile = m_defaultProfile->profile();
if(m_profile==0) return;
cmsHPROFILE hProfile = m_profile->profile();
if (m_cmType != TYPE_BGR_8) {
// For conversions from default rgb
......@@ -96,13 +93,13 @@ KisAbstractColorSpace::~KisAbstractColorSpace()
bool KisAbstractColorSpace::convertTo(KisPixel& src, KisPixel& dst, Q_INT32 renderingIntent)
{
return convertPixelsTo(src.channels(), src.profile(),
dst.channels(), dst.colorSpace(), dst.profile(),
return convertPixelsTo(src.channels(),
dst.channels(), dst.colorSpace(),
renderingIntent);
}
bool KisAbstractColorSpace::convertPixelsTo(const Q_UINT8 * src, KisProfile * srcProfile,
Q_UINT8 * dst, KisColorSpace * dstColorSpace, KisProfile * dstProfile,
bool KisAbstractColorSpace::convertPixelsTo(const Q_UINT8 * src,
Q_UINT8 * dst, KisColorSpace * dstColorSpace,
Q_UINT32 numPixels,
Q_INT32 renderingIntent)
{
......@@ -112,46 +109,38 @@ bool KisAbstractColorSpace::convertPixelsTo(const Q_UINT8 * src, KisProfile * s
Q_INT32 srcPixelSize = pixelSize();
Q_INT32 dstPixelSize = dstColorSpace -> pixelSize();
if (!srcProfile) {
srcProfile = getDefaultProfile();
}
if (!dstProfile) {
dstProfile = dstColorSpace->getDefaultProfile();
}
// kdDebug() << "src space: " << id().name() << ", src profile " << srcProfile->productName()
// << ", dst space: " << dstColorSpace->id().name() << ", dst profile " << dstProfile->productName()
// << ", number of pixels: " << numPixels << "\n";
if (m_lastUsedTransform != 0) {
if (dstProfile == m_lastUsedDstProfile && srcProfile == m_lastUsedSrcProfile)
if (dstColorSpace->getProfile() == m_lastUsedDstProfile)
tf = m_lastUsedTransform;
}
if (!tf && srcProfile && dstProfile) {
if (!tf && m_profile && dstColorSpace->getProfile()) {
if (!m_transforms.contains(KisProfilePair(srcProfile, dstProfile))) {
if (!m_transforms.contains(KisProfilePair(m_profile, dstColorSpace->getProfile()))) {
tf = createTransform(dstColorSpace,
srcProfile,
dstProfile,
m_profile,
dstColorSpace->getProfile(),
renderingIntent);
if (tf) {
// kdDebug() << "Going to add transform to cache "
// << " srcprofile: " << srcProfile->productName()
// << " dstProfile " << dstProfile->productName() << "\n";
// << " m_profile: " << m_profile->productName()
// << " dstProfile " << dstColorSpace->getProfile()->productName() << "\n";
m_transforms[KisProfilePair(srcProfile, dstProfile)] = tf;
m_transforms[KisProfilePair(m_profile, dstColorSpace->getProfile())] = tf;
}
}
else {
tf = m_transforms[KisProfilePair(srcProfile, dstProfile)];
tf = m_transforms[KisProfilePair(m_profile, dstColorSpace->getProfile())];
}
if ( tf ) {
m_lastUsedTransform = tf;
m_lastUsedSrcProfile = srcProfile;
m_lastUsedDstProfile = dstProfile;
m_lastUsedDstProfile = dstColorSpace->getProfile();
}
}
......@@ -208,7 +197,7 @@ void KisAbstractColorSpace::applyAdjustment(const Q_UINT8 */*src*/, Q_UINT8 */*d
Q_INT8 KisAbstractColorSpace::difference(const Q_UINT8* src1, const Q_UINT8* src2)
{
if ( m_defaultToXYZ != 0 && m_defaultFromXYZ != 0 ) {
Q_INT32 psize = xyz::MAX_CHANNEL_XYZA * sizeof(Q_UINT16);
Q_UINT32 psize = xyz::MAX_CHANNEL_XYZA * sizeof(Q_UINT16);
if ( m_conversionCache.size() < 2 * psize ) {
......@@ -218,7 +207,7 @@ Q_INT8 KisAbstractColorSpace::difference(const Q_UINT8* src1, const Q_UINT8* src
cmsDoTransform( m_defaultToXYZ, const_cast<Q_UINT8*>( src1 ), m_conversionCache.data(), 1);
cmsDoTransform( m_defaultToXYZ, const_cast<Q_UINT8*>( src2 ), m_conversionCache.data() + psize, 1);
return KisColorSpaceRegistry::getXYZ16()->difference( m_conversionCache.data(), m_conversionCache.data() + psize );
return KisColorSpaceFactoryRegistry::getXYZ16()->difference( m_conversionCache.data(), m_conversionCache.data() + psize );
}
else {
......@@ -368,9 +357,7 @@ void KisAbstractColorSpace::bitBlt(Q_UINT8 *dst,
Q_UINT8 opacity,
Q_INT32 rows,
Q_INT32 cols,
const KisCompositeOp& op,
KisProfile * srcProfile,
KisProfile * dstProfile)
const KisCompositeOp& op)
{
if (rows <= 0 || cols <= 0)
return;
......@@ -378,8 +365,8 @@ void KisAbstractColorSpace::bitBlt(Q_UINT8 *dst,
if (m_id!= srcSpace -> id()) {
Q_UINT32 len = pixelSize() * rows * cols;
if ( !srcProfile ) srcProfile = srcSpace->getDefaultProfile();
if ( !dstProfile ) dstProfile = getDefaultProfile();
KisProfile * srcProfile = srcSpace -> getProfile();
KisProfile * dstProfile = getProfile();
// If our conversion cache is too small, extend it.
if (!m_conversionCache.resize( len, QGArray::SpeedOptim )) {
......@@ -390,15 +377,15 @@ void KisAbstractColorSpace::bitBlt(Q_UINT8 *dst,
if (srcProfile && dstProfile) {
for (Q_INT32 row = 0; row < rows; row++) {
srcSpace -> convertPixelsTo(src + row * srcRowStride, srcProfile,
m_conversionCache.data() + row * cols * pixelSize(), this, dstProfile,
srcSpace -> convertPixelsTo(src + row * srcRowStride,
m_conversionCache.data() + row * cols * pixelSize(), this,
cols);
}
}
else {
for (Q_INT32 row = 0; row < rows; row++) {
srcSpace -> convertPixelsTo(src + row * srcRowStride, 0,
m_conversionCache.data() + row * cols * pixelSize(), this, 0,
srcSpace -> convertPixelsTo(src + row * srcRowStride,
m_conversionCache.data() + row * cols * pixelSize(), this,
cols);
}
}
......@@ -433,34 +420,24 @@ void KisAbstractColorSpace::bitBlt(Q_UINT8 *dst,
}
}
QValueVector<KisProfile *> KisAbstractColorSpace::profiles()
{
return KisColorSpaceRegistry::instance()->profilesFor( this );
}
Q_INT32 KisAbstractColorSpace::profileCount()
{
return KisColorSpaceRegistry::instance()->profilesFor( this ).size();
}
QImage KisAbstractColorSpace::convertToQImage(const Q_UINT8 *data, Q_INT32 width, Q_INT32 height,
KisProfile * srcProfile, KisProfile * dstProfile,
KisProfile * dstProfile,
Q_INT32 renderingIntent, float /*exposure*/)
{
QImage img = QImage(width, height, 32, 0, QImage::LittleEndian);
img.setAlphaBuffer( true );
KisColorSpace * dstCS = KisColorSpaceRegistry::instance() -> get("RGBA");
if (! srcProfile && ! dstProfile) {
srcProfile = getDefaultProfile();
dstProfile = dstCS->getDefaultProfile();
}
KisColorSpace * dstCS = KisColorSpaceFactoryRegistry::instance() -> getColorSpace(KisID("RGBA",""),"");
printf("profile = %d dstProfile = %d\n",getProfile(),dstProfile);
if(getProfile())
printf("profile = %s\n",getProfile()->productName().ascii());
if(dstProfile)
printf("dstProfile = %s\n",dstProfile->productName().ascii());
if(dstCS->getProfile())
printf("dstCS->Profile = %s\n",dstCS->getProfile()->productName().ascii());
convertPixelsTo(const_cast<Q_UINT8 *>(data), srcProfile,
img.bits(), dstCS, dstProfile,
width * height, renderingIntent);
convertPixelsTo(const_cast<Q_UINT8 *>(data), img.bits(), dstCS, width * height, renderingIntent);
return img;
}
......
......@@ -71,12 +71,13 @@ public:
* @param id The Krita identification of this color model.
* @param cmType The littlecms colorstrategy type we wrap.
* @param colorSpaceSignature The icc signature for the colorspace we are.
* @param p The KisProfile for the colorspace we are, can be 0.
*/
KisAbstractColorSpace(const KisID & id, DWORD cmType, icColorSpaceSignature colorSpaceSignature);
KisAbstractColorSpace(const KisID & id, DWORD cmType, icColorSpaceSignature colorSpaceSignature, KisProfile *p);
/**
* After creating the default profile, call init to setup the default
* colortransforms from and to rgb and xyz -- if your colorspace needs
* Call init to setup the default
* colortransforms from and to sRGB and xyz -- if your colorspace needs
* the fallback to the default transforms for the qcolor conversion
* and the default pixel ops.
*/
......@@ -175,16 +176,9 @@ public:
//========== Display profiles =============================================//
/**
* Get a list of profiles that apply to this color space
* Return the profile of this color space. This may be 0
*/
QValueVector<KisProfile *> profiles();
/**
* Return the number of profiles available for this color space
*/
Q_INT32 profileCount();
virtual KisProfile * getProfile() { return m_profile; };
//================= Conversion functions ==================================//
......@@ -195,29 +189,24 @@ public:
* and fills a byte array with the corresponding color in the
* the colorspace managed by this strategy.
*
* The profile parameter is the profile of the paint device; the other profile
* is the display profile -- since we are moving from QColor
* that have most likely been picked from the display itself.
*
* XXX: We actually do not use the display yet, nor the paint device profile
* XXX: We actually do not use the display profile yet
*/
virtual void fromQColor(const QColor& c, Q_UINT8 *dst, KisProfile * profile = 0) = 0;
virtual void fromQColor(const QColor& c, Q_UINT8 opacity, Q_UINT8 *dst, KisProfile * profile = 0) = 0;
virtual void fromQColor(const QColor& c, Q_UINT8 *dst) = 0;
virtual void fromQColor(const QColor& c, Q_UINT8 opacity, Q_UINT8 *dst) = 0;
/**
* The toQColor methods take a byte array that is at least pixelSize() long
* and converts the contents to a QColor, using the given profile as a source
* profile and the display profile as a destination profile.
* and converts the contents to a QColor, using the display profile as a destination profile.
*
* XXX: We actually do not use the display yet, nor the paint device profile
* XXX: We actually do not use the display profile yet
*
*/
virtual void toQColor(const Q_UINT8 *src, QColor *c, KisProfile * profile= 0 ) = 0;
virtual void toQColor(const Q_UINT8 *src, QColor *c, Q_UINT8 *opacity, KisProfile * profile = 0) = 0;
virtual void toQColor(const Q_UINT8 *src, QColor *c) = 0;
virtual void toQColor(const Q_UINT8 *src, QColor *c, Q_UINT8 *opacity) = 0;
virtual KisPixelRO toKisPixelRO(const Q_UINT8 *src, KisProfile * profile) = 0;
virtual KisPixel toKisPixel(Q_UINT8 *src, KisProfile * profile) = 0;
virtual KisPixelRO toKisPixelRO(const Q_UINT8 *src) = 0;
virtual KisPixel toKisPixel(Q_UINT8 *src) = 0;
/**
* This function is used to convert a KisPixelRepresentation from this color strategy to the specified
......@@ -235,13 +224,12 @@ public:
* @param data A pointer to a contiguous memory region containing width * height pixels
* @param width in pixels
* @param height in pixels
* @param srcProfile source profile
* @param dstProfile destination profile
* @param renderingIntent the rendering intent
* @param exposure The exposure setting for rendering a preview of a high dynamic range image.
*/
virtual QImage convertToQImage(const Q_UINT8 *data, Q_INT32 width, Q_INT32 height,
KisProfile * srcProfile, KisProfile * dstProfile,
KisProfile * dstProfile,
Q_INT32 renderingIntent = INTENT_PERCEPTUAL,
float exposure = 0.0f);
......@@ -253,8 +241,8 @@ public:
*
* Returns false if the conversion failed, true if it succeeded
*/
virtual bool convertPixelsTo(const Q_UINT8 * src, KisProfile * srcProfile,
Q_UINT8 * dst, KisColorSpace * dstColorSpace, KisProfile * dstProfile,
virtual bool convertPixelsTo(const Q_UINT8 * src,
Q_UINT8 * dst, KisColorSpace * dstColorSpace,
Q_UINT32 numPixels,
Q_INT32 renderingIntent = INTENT_PERCEPTUAL);
......@@ -368,17 +356,8 @@ public:
Q_UINT8 opacity,
Q_INT32 rows,
Q_INT32 cols,
const KisCompositeOp& op,
KisProfile * srcProfile = 0,
KisProfile * dstProfile = 0);
const KisCompositeOp& op);
/**
* Return the default profile for this colorspace. This may be 0.
*/
virtual KisProfile * getDefaultProfile() { return m_defaultProfile; };
void setDefaultProfile(KisProfile * profile) { m_defaultProfile = profile; };
//========================== END of Public API ========================================//
......@@ -410,7 +389,6 @@ protected:
protected:
QStringList m_profileFilenames;
KisProfile * m_defaultProfile;
Q_UINT8 * m_qcolordata; // A small buffer for conversion from and to qcolor.
Q_INT32 m_alphaPos; // The position in _bytes_ of the alpha channel
Q_INT32 m_alphaSize; // The width in _bytes_ of the alpha channel
......@@ -420,7 +398,7 @@ protected:
cmsHTRANSFORM m_defaultToXYZ;
cmsHTRANSFORM m_defaultFromXYZ;
KisProfile * m_lastUsedSrcProfile;
KisProfile * m_profile;
KisProfile * m_lastUsedDstProfile;
cmsHTRANSFORM m_lastUsedTransform;
......
......@@ -28,7 +28,6 @@
#include LCMS_HEADER
#include "kis_colorspace_registry.h"
#include "kis_image.h"
#include "kis_alpha_colorspace.h"
#include "kis_u8_base_colorspace.h"
......@@ -41,24 +40,23 @@ namespace {
const Q_UINT8 PIXEL_MASK = 0;
}
KisAlphaColorSpace::KisAlphaColorSpace() :
KisU8BaseColorSpace(KisID("ALPHA", i18n("Alpha mask")), TYPE_GRAY_8, icSigGrayData)
KisAlphaColorSpace::KisAlphaColorSpace(KisProfile *p) :
KisU8BaseColorSpace(KisID("ALPHA", i18n("Alpha mask")), TYPE_GRAY_8, icSigGrayData, p)
{
m_channels.push_back(new KisChannelInfo(i18n("Alpha"), 0, ALPHA));
m_alphaPos = 0;
m_defaultProfile = 0;
}
KisAlphaColorSpace::~KisAlphaColorSpace()
{
}
void KisAlphaColorSpace::fromQColor(const QColor& /*c*/, Q_UINT8 *dst, KisProfile * /*profile*/)
void KisAlphaColorSpace::fromQColor(const QColor& /*c*/, Q_UINT8 *dst)
{
dst[PIXEL_MASK] = OPACITY_OPAQUE;
}
void KisAlphaColorSpace::fromQColor(const QColor& /*c*/, Q_UINT8 opacity, Q_UINT8 *dst, KisProfile * /*profile*/)
void KisAlphaColorSpace::fromQColor(const QColor& /*c*/, Q_UINT8 opacity, Q_UINT8 *dst)
{
dst[PIXEL_MASK] = opacity;
}
......@@ -68,12 +66,12 @@ void KisAlphaColorSpace::getAlpha(const Q_UINT8 *pixel, Q_UINT8 *alpha)
*alpha = *pixel;
}
void KisAlphaColorSpace::toQColor(const Q_UINT8 */*src*/, QColor *c, KisProfile * /*profile*/)
void KisAlphaColorSpace::toQColor(const Q_UINT8 */*src*/, QColor *c)
{
c -> setRgb(255, 255, 255);
}
void KisAlphaColorSpace::toQColor(const Q_UINT8 *src, QColor *c, Q_UINT8 *opacity, KisProfile * /*profile*/)
void KisAlphaColorSpace::toQColor(const Q_UINT8 *src, QColor *c, Q_UINT8 *opacity)
{
c -> setRgb(255, 255, 255);
*opacity = src[PIXEL_MASK];
......@@ -145,12 +143,12 @@ QImage KisAlphaColorSpace::convertToQImage(const Q_UINT8 *data, Q_INT32 width, Q
}
#endif
bool KisAlphaColorSpace::convertPixelsTo(const Q_UINT8 *src, KisProfile * /*srcProfile*/,
Q_UINT8 *dst, KisAbstractColorSpace * dstColorSpace, KisProfile * dstProfile,
bool KisAlphaColorSpace::convertPixelsTo(const Q_UINT8 *src,
Q_UINT8 *dst, KisAbstractColorSpace * dstColorSpace,
Q_UINT32 numPixels,
Q_INT32 /*renderingIntent*/)
{
// No lcms trickery here, we are a QColor + opacity channel
// No lcms trickery here, we are only a opacity channel
Q_INT32 size = dstColorSpace -> pixelSize();
Q_UINT32 j = 0;
......@@ -158,7 +156,7 @@ bool KisAlphaColorSpace::convertPixelsTo(const Q_UINT8 *src, KisProfile * /*src
while ( i < numPixels ) {
dstColorSpace -> fromQColor(Qt::red, OPACITY_OPAQUE - *(src + i), (dst + j), dstProfile);
dstColorSpace -> fromQColor(Qt::red, OPACITY_OPAQUE - *(src + i), (dst + j));
i += 1;
j += size;
......
......@@ -33,20 +33,20 @@
*/
class KisAlphaColorSpace : public KisU8BaseColorSpace {
public:
KisAlphaColorSpace();
KisAlphaColorSpace(KisProfile *p);
virtual ~KisAlphaColorSpace();
public:
virtual void fromQColor(const QColor& c, Q_UINT8 *dst, KisProfile * profile = 0);
virtual void fromQColor(const QColor& c, Q_UINT8 opacity, Q_UINT8 *dst, KisProfile * profile = 0);
virtual void fromQColor(const QColor& c, Q_UINT8 *dst);
virtual void fromQColor(const QColor& c, Q_UINT8 opacity, Q_UINT8 *dst);
virtual void getAlpha(const Q_UINT8 *pixel, Q_UINT8 *alpha);
virtual void toQColor(const Q_UINT8 *src, QColor *c, KisProfile * profile = 0);
virtual void toQColor(const Q_UINT8 *src, QColor *c, Q_UINT8 *opacity, KisProfile * profile = 0);
virtual void toQColor(const Q_UINT8 *src, QColor *c);
virtual void toQColor(const Q_UINT8 *src, QColor *c, Q_UINT8 *opacity);
virtual KisPixelRO toKisPixelRO(const Q_UINT8 *src, KisProfile * profile = 0) { return KisPixelRO (src, src, this, profile); }
virtual KisPixel toKisPixel(Q_UINT8 *src, KisProfile * profile = 0) { return KisPixel (src, src, this, profile); }
virtual KisPixelRO toKisPixelRO(const Q_UINT8 *src) { return KisPixelRO (src, src, this); }
virtual KisPixel toKisPixel(Q_UINT8 *src) { return KisPixel (src, src, this); }
virtual Q_INT8 difference(const Q_UINT8 *src1, const Q_UINT8 *src2);
virtual void mixColors(const Q_UINT8 **colors, const Q_UINT8 *weights, Q_UINT32 nColors, Q_UINT8 *dst) const;
......@@ -76,8 +76,8 @@ protected:
*
* Returns false if the conversion failed, true if it succeeded
*/
virtual bool convertPixelsTo(const Q_UINT8 *src, KisProfile * srcProfile,
Q_UINT8 *dst, KisAbstractColorSpace * dstColorSpace, KisProfile * dstProfile,
virtual bool convertPixelsTo(const Q_UINT8 *src,
Q_UINT8 *dst, KisAbstractColorSpace * dstColorSpace,
Q_UINT32 numPixels,
Q_INT32 renderingIntent = INTENT_PERCEPTUAL);
......
......@@ -26,74 +26,39 @@
#include "kis_factory.h"
#include "kis_types.h"
#include "kis_colorspace.h"
#include "kis_profile.h"
#include "kis_colorspace_factory_registry.h"
#include "kis_xyz_colorspace.h"
#include "kis_alpha_colorspace.h"
#include "kis_colorspace_registry.h"
#include "kis_pixel_op.h"
KisColorSpaceRegistry *KisColorSpaceRegistry::m_singleton = 0;
KisColorSpace * KisColorSpaceRegistry::m_rgb = 0;
KisColorSpace * KisColorSpaceRegistry::m_alpha = 0;
KisColorSpace * KisColorSpaceRegistry::m_xyz = 0;
KisColorSpaceFactoryRegistry *KisColorSpaceFactoryRegistry::m_singleton = 0;
KisColorSpaceRegistry::KisColorSpaceRegistry()
KisColorSpaceFactoryRegistry::KisColorSpaceFactoryRegistry()
{
Q_ASSERT(KisColorSpaceRegistry::m_singleton == 0);
KisColorSpaceRegistry::m_singleton = this;
Q_ASSERT(KisColorSpaceFactoryRegistry::m_singleton == 0);
KisColorSpaceFactoryRegistry::m_singleton = this;
}
KisColorSpaceRegistry::~KisColorSpaceRegistry()
KisColorSpaceFactoryRegistry::~KisColorSpaceFactoryRegistry()
{
}
KisColorSpaceRegistry* KisColorSpaceRegistry::instance()
KisColorSpaceFactoryRegistry* KisColorSpaceFactoryRegistry::instance()
{
if(KisColorSpaceRegistry::m_singleton == 0)
if(KisColorSpaceFactoryRegistry::m_singleton == 0)
{
KisColorSpaceRegistry::m_singleton = new KisColorSpaceRegistry();
Q_CHECK_PTR(KisColorSpaceRegistry::m_singleton);
if ( !m_xyz ) {
m_xyz = new KisXyzColorSpace();
m_singleton->add(m_xyz);
}
if ( !m_alpha ) {
m_alpha = new KisAlphaColorSpace();
}
KisColorSpaceFactoryRegistry::m_singleton = new KisColorSpaceFactoryRegistry();
Q_CHECK_PTR(KisColorSpaceFactoryRegistry::m_singleton);
m_singleton->resetProfiles();
}
return KisColorSpaceRegistry::m_singleton;
}
KisColorSpace * KisColorSpaceRegistry::getRGB8()
{
if ( m_rgb == 0 ) {
m_rgb = m_singleton->get( "RGBA" );
}
return m_rgb;
}
KisColorSpace * KisColorSpaceRegistry::getAlpha8()
{
if ( m_alpha == 0 ) {
m_alpha = new KisAlphaColorSpace();
}
return m_alpha;
}
KisColorSpace * KisColorSpaceRegistry::getXYZ16()
{
if ( m_xyz == 0 ) {
m_xyz = new KisXyzColorSpace();
m_singleton->add( m_xyz );
KisColorSpaceFactoryRegistry::m_singleton->m_xyzCs = new KisXyzColorSpace(0);
// m_singleton->m_csMap[cs->id().id()] = cs; //XXX should this be user visible
KisColorSpaceFactoryRegistry::m_singleton->m_alphaCs = new KisAlphaColorSpace(0);
}
return m_xyz;
return KisColorSpaceFactoryRegistry::m_singleton;
}
KisProfile * KisColorSpaceRegistry::getProfileByName(const QString & name)
KisProfile * KisColorSpaceFactoryRegistry::getProfileByName(const QString & name)
{
if (m_profileMap.find(name) == m_profileMap.end()) {
return 0;
......@@ -102,22 +67,26 @@ KisProfile * KisColorSpaceRegistry::getProfileByName(const QString & name)
return m_profileMap[name];
}
QValueVector<KisProfile *> KisColorSpaceRegistry::profilesFor(KisColorSpace * cs)
QValueVector<KisProfile *> KisColorSpaceFactoryRegistry::profilesFor(KisID id)
{
return profilesFor(get(id));