Commit e50c5a76 authored by Cyrille Berger's avatar Cyrille Berger

store when the colorspace is owned by the registry

svn path=/trunk/koffice/; revision=1008054
parent 5d8a3f6b
...@@ -16,12 +16,13 @@ ...@@ -16,12 +16,13 @@
* the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301, USA. * Boston, MA 02110-1301, USA.
*/ */
#include "KoColorSpace.h"
#include <QThreadStorage> #include <QThreadStorage>
#include <QByteArray> #include <QByteArray>
#include <QBitArray> #include <QBitArray>
#include "KoColorSpace.h"
#include "KoChannelInfo.h" #include "KoChannelInfo.h"
#include "DebugPigment.h" #include "DebugPigment.h"
#include "KoCompositeOp.h" #include "KoCompositeOp.h"
...@@ -36,23 +37,7 @@ ...@@ -36,23 +37,7 @@
#include "KoFallBackColorTransformation.h" #include "KoFallBackColorTransformation.h"
#include "KoUniqueNumberForIdServer.h" #include "KoUniqueNumberForIdServer.h"
struct KoColorSpace::Private { #include "KoColorSpace_p.h"
QString id;
quint32 idNumber;
QString name;
QHash<QString, KoCompositeOp *> compositeOps;
QList<KoChannelInfo *> channels;
KoMixColorsOp* mixColorsOp;
KoConvolutionOp* convolutionOp;
QThreadStorage< QVector<quint8>* > conversionCache;
mutable KoColorConversionTransformation* transfoToRGBA16;
mutable KoColorConversionTransformation* transfoFromRGBA16;
mutable KoColorConversionTransformation* transfoToLABA16;
mutable KoColorConversionTransformation* transfoFromLABA16;
};
KoColorSpace::KoColorSpace() KoColorSpace::KoColorSpace()
: d (new Private()) : d (new Private())
...@@ -75,6 +60,7 @@ KoColorSpace::KoColorSpace(const QString &id, const QString &name, KoMixColorsOp ...@@ -75,6 +60,7 @@ KoColorSpace::KoColorSpace(const QString &id, const QString &name, KoMixColorsOp
KoColorSpace::~KoColorSpace() KoColorSpace::~KoColorSpace()
{ {
Q_ASSERT(!d->ownedByRegistry);
qDeleteAll(d->compositeOps); qDeleteAll(d->compositeOps);
foreach(KoChannelInfo * channel, d->channels) foreach(KoChannelInfo * channel, d->channels)
{ {
......
...@@ -124,7 +124,7 @@ public: ...@@ -124,7 +124,7 @@ public:
* *
*/ */
class PIGMENTCMS_EXPORT KoColorSpace { class PIGMENTCMS_EXPORT KoColorSpace {
friend class KoColorSpaceRegistry;
protected: protected:
/// Only for use by classes that serve as baseclass for real color spaces /// Only for use by classes that serve as baseclass for real color spaces
KoColorSpace(); KoColorSpace();
......
...@@ -48,6 +48,7 @@ ...@@ -48,6 +48,7 @@
#include "colorspaces/KoLabColorSpace.h" #include "colorspaces/KoLabColorSpace.h"
#include "colorspaces/KoRgbU16ColorSpace.h" #include "colorspaces/KoRgbU16ColorSpace.h"
#include "colorspaces/KoRgbU8ColorSpace.h" #include "colorspaces/KoRgbU8ColorSpace.h"
#include "KoColorSpace_p.h"
struct KoColorSpaceRegistry::Private { struct KoColorSpaceRegistry::Private {
QHash<QString, KoColorProfile * > profileMap; QHash<QString, KoColorProfile * > profileMap;
...@@ -167,6 +168,7 @@ KoColorSpaceRegistry::~KoColorSpaceRegistry() ...@@ -167,6 +168,7 @@ KoColorSpaceRegistry::~KoColorSpaceRegistry()
} }
d->profileMap.clear(); d->profileMap.clear();
foreach( const KoColorSpace * cs, d->csMap) { foreach( const KoColorSpace * cs, d->csMap) {
cs->d->ownedByRegistry = false;
delete cs; delete cs;
} }
d->csMap.clear(); d->csMap.clear();
...@@ -311,6 +313,7 @@ const KoColorSpace * KoColorSpaceRegistry::colorSpace(const QString &csID, const ...@@ -311,6 +313,7 @@ const KoColorSpace * KoColorSpaceRegistry::colorSpace(const QString &csID, const
} }
d->csMap[name] = cs; d->csMap[name] = cs;
cs->d->ownedByRegistry = true;
dbgPigmentCSRegistry << "colorspace count: " << d->csMap.count() << ", adding name: " << name; dbgPigmentCSRegistry << "colorspace count: " << d->csMap.count() << ", adding name: " << name;
} }
...@@ -352,6 +355,7 @@ const KoColorSpace * KoColorSpaceRegistry::colorSpace(const QString &csID, const ...@@ -352,6 +355,7 @@ const KoColorSpace * KoColorSpaceRegistry::colorSpace(const QString &csID, const
QString name = csID + "<comb>" + profile->name(); QString name = csID + "<comb>" + profile->name();
d->csMap[name] = cs; d->csMap[name] = cs;
cs->d->ownedByRegistry = true;
dbgPigmentCSRegistry << "colorspace count: " << d->csMap.count() << ", adding name: " << name; dbgPigmentCSRegistry << "colorspace count: " << d->csMap.count() << ", adding name: " << name;
} }
......
/*
* Copyright (c) 2005 Boudewijn Rempt <boud@valdyas.org>
*
* 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 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 _KOCOLORSPACE_P_H_
#define _KOCOLORSPACE_P_H_
#include "KoColorSpace.h"
struct KoColorSpace::Private {
Private() : ownedByRegistry(false)
{}
QString id;
quint32 idNumber;
QString name;
QHash<QString, KoCompositeOp *> compositeOps;
QList<KoChannelInfo *> channels;
KoMixColorsOp* mixColorsOp;
KoConvolutionOp* convolutionOp;
QThreadStorage< QVector<quint8>* > conversionCache;
mutable KoColorConversionTransformation* transfoToRGBA16;
mutable KoColorConversionTransformation* transfoFromRGBA16;
mutable KoColorConversionTransformation* transfoToLABA16;
mutable KoColorConversionTransformation* transfoFromLABA16;
bool ownedByRegistry;
};
#endif
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment