[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    koffice
From:       Cyrille Berger <cyb () lepi ! org>
Date:       2010-01-18 21:38:08
Message-ID: 1263850688.198369.7102.nullmailer () svn ! kde ! org
[Download RAW message or body]

SVN commit 1076792 by berger:

Cache colorspaces


 M  +1 -1      krita/image/kis_paint_device.cc  
 M  +16 -4     libs/pigment/KoColorSpaceFactory.cpp  
 M  +3 -3      libs/pigment/KoColorSpaceFactory.h  
 M  +4 -5      libs/pigment/KoColorSpaceRegistry.cpp  
 M  +4 -4      libs/pigment/KoColorSpaceRegistry.h  
 M  +1 -1      libs/pigment/KoIncompleteColorSpace.h  


--- trunk/koffice/krita/image/kis_paint_device.cc #1076791:1076792
@@ -451,7 +451,7 @@
     }
 
     KisDataManagerSP oldData = m_datamanager;
-    const KoColorSpace *oldColorSpace = m_d->colorSpace;
+    KoColorSpace *oldColorSpace = m_d->colorSpace;
 
     KisPaintDeviceConvertTypeCommand* cmd = new \
KisPaintDeviceConvertTypeCommand(this,  oldData,
--- trunk/koffice/libs/pigment/KoColorSpaceFactory.cpp #1076791:1076792
@@ -18,8 +18,12 @@
  */
 
 #include "KoColorSpaceFactory.h"
+#include "KoColorProfile.h"
+#include "KoColorSpace.h"
 
 struct KoColorSpaceFactory::Private {
+    QList<KoColorSpace*> colorspaces;
+    QMap<QString, QList<KoColorSpace*> > availableColorspaces;
 };
 
 KoColorSpaceFactory::KoColorSpaceFactory() : d(new Private)
@@ -31,12 +35,20 @@
     delete d;
 }
 
-KoColorSpace* KoColorSpaceFactory::grabColorSpace(const KoColorProfile * profile) \
const +KoColorSpace* KoColorSpaceFactory::grabColorSpace(const KoColorProfile * \
profile)  {
-    return createColorSpace(profile);
+    QList<KoColorSpace*>& csList = d->availableColorspaces[profile->name()];
+    if (!csList.isEmpty()) {
+        KoColorSpace* cs = csList.back();
+        csList.pop_back();
+        return cs;
+    }
+    KoColorSpace* cs = createColorSpace(profile);
+    d->colorspaces.push_back(cs);
+    return cs;
 }
 
-void KoColorSpaceFactory::releaseColorSpace(const KoColorSpace *) const
+void KoColorSpaceFactory::releaseColorSpace(KoColorSpace * colorspace)
 {
+    d->availableColorspaces[colorspace->profile()->name()].push_back(colorspace);
 }
-
--- trunk/koffice/libs/pigment/KoColorSpaceFactory.h #1076791:1076792
@@ -109,9 +109,9 @@
      */
     virtual QString defaultProfile() const = 0;
 
-    KoColorSpace* grabColorSpace(const KoColorProfile* profile) const;
-    
-    void releaseColorSpace(const KoColorSpace *) const;
+    KoColorSpace* grabColorSpace(const KoColorProfile* profile);
+
+    void releaseColorSpace(KoColorSpace *);
 protected:
     /**
      * creates a color space using the given profile.
--- trunk/koffice/libs/pigment/KoColorSpaceRegistry.cpp #1076791:1076792
@@ -252,12 +252,12 @@
 
 KoColorSpace* KoColorSpaceRegistry::grabColorSpace(const KoColorSpace* colorSpace)
 {
-    return colorSpace->clone();
+    return d->colorsSpaceFactoryRegistry.value(colorSpace->id())->grabColorSpace(colorSpace->profile());
  }
 
-void KoColorSpaceRegistry::releaseColorSpace(const KoColorSpace* colorSpace)
+void KoColorSpaceRegistry::releaseColorSpace(KoColorSpace* colorSpace)
 {
-    delete colorSpace;
+    d->colorsSpaceFactoryRegistry.value(colorSpace->id())->releaseColorSpace(colorSpace);
  }
 
 const KoColorSpaceFactory* KoColorSpaceRegistry::colorSpaceFactory(const QString \
&colorSpaceId) const @@ -542,8 +542,7 @@
 
     foreach(KoColorSpaceFactory* factory, factories) {
         if (visibility == AllColorSpaces || factory->userVisible()) {
-            if(pSelection == OnlyDefaultProfile)
-            {
+            if (pSelection == OnlyDefaultProfile) {
                 colorSpaces.append(colorSpace(factory->id(), 0));
             } else {
                 QList<const KoColorProfile*> profiles = \
                KoColorSpaceRegistry::instance()->profilesFor(factory->id());
--- trunk/koffice/libs/pigment/KoColorSpaceRegistry.h #1076791:1076792
@@ -142,9 +142,9 @@
      */
     QList<const KoColorProfile *>  profilesFor(const QString &colorSpaceId);
     const KoColorSpaceFactory* colorSpaceFactory(const QString &colorSpaceId) const;
-    
-    KoColorSpace* grabColorSpace(const KoColorSpace* );
-    void releaseColorSpace(const KoColorSpace*);
+
+    KoColorSpace* grabColorSpace(const KoColorSpace*);
+    void releaseColorSpace(KoColorSpace*);
 private:
     /**
      * Return a colorspace that works with the parameter profile.
@@ -307,7 +307,7 @@
     /**
      * @return a list with an instance of all color space with their default profile
      */
-    QList<const KoColorSpace*> allColorSpaces(ColorSpaceListVisibility visibility, \
ColorSpaceListProfilesSelection pSelection ); +    QList<const KoColorSpace*> \
allColorSpaces(ColorSpaceListVisibility visibility, ColorSpaceListProfilesSelection \
pSelection);  
 private:
 
--- trunk/koffice/libs/pigment/KoIncompleteColorSpace.h #1076791:1076792
@@ -107,7 +107,7 @@
 
 private:
     mutable quint16 * m_qcolordata; // A small buffer for conversion from and to \
                qcolor.
-    const KoColorSpace* m_fallBackColorSpace;
+    KoColorSpace* m_fallBackColorSpace;
     quint32 m_cmType;
     mutable QByteArray m_convertionCache;
 };


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic