Commit 2d6015e2 authored by Halla Rempt's avatar Halla Rempt

* Created KisID; a class used to uniquely and language-independently identify

Krita resources such as filters and colour models.
* Small optimization: if we create a black, transparent image, use the
default tiles and don't create tiles for the entire image size.
* Fix in kis_iterator_pixel: advance the selection iterator with just as much
as the pixel iterator.
* Added filter test to the performance tests -- these make Krita run out of
memory, though.

svn path=/trunk/koffice/; revision=400186
parent 8e0823c2
......@@ -76,12 +76,13 @@ lines, rectangles, ellipses and text tools.
* grayscale and RGB color models (and a buggy CMYK model)
* basic support for colour management.
* basic scripting support
* full colour management system
* pervasive use of selections
* auto-extending layers
Todo for version 1.0
* full colour management system
* working cmyk colour model
* pervasive use of selections
* code speedups
* bug-fixes
* Show/hide individual color channels
......@@ -89,7 +90,6 @@ Todo for version 1.0
* Loading and saving of selections
* Fix dockers to be dockers or floaters, according to user preferences. Make
tabs draggable.
* auto-extending layers
* lock layers
* brush-shaped outline cursor
* birds' eye box
......@@ -120,7 +120,7 @@ The man who for the first time made Krita into something that did almost work:
The architect of Krita's current design:
Patrick Julien <freak@codepimps.org>
Patrick Julien
The current crew:
......@@ -151,4 +151,5 @@ Caveat
In order to run this release, simply execute the 'krita' script in this directory. Be aware
that this messess with kdeinit, which is black magic, and running Krita may render your
existing KOffice installation unusable until you login onto KDE again.
existing KOffice installation unusable until you login onto KDE again. And... You have
followed the installation istructions, haven't you?
......@@ -35,7 +35,7 @@ libkritacore_la_SOURCES = kis_paint_device.cc kis_layer.cc kis_image.cc \
kis_doc.cc kis_view.cc kis_factory.cc kis_nameserver.cc kis_painter.cc \
kis_fill_painter.cc kis_gradient_painter.cc kis_convolution_painter.cc kis_cursor.cc \
kis_selection.cc kis_command.cc kis_background.cc kis_global.cc kis_config.cc \
kis_guide.cc kis_canvas_subject.cc kis_canvas_controller.cc kis_canvas_observer.cc \
kis_guide.cc kis_canvas_controller.cc kis_canvas_observer.cc \
kis_transaction.cc kis_vec.cc kis_rect.cc kis_iterators_pixel.cc kis_histogram.cc \
KRayonViewIface.cc KRayonViewIface.skel KIsDocIface.cc KIsDocIface.skel KIsImageIface.cc \
KIsImageIface.skel kis_selection_manager.cc kis_scale_visitor.cc \
......
......@@ -64,13 +64,13 @@ namespace {
KisStrategyColorSpaceSP getColorSpaceForColorType(ColorspaceType type) {
kdDebug() << "Colorspace type: " << type << "\n";
if (type == GRAYColorspace) {
KisColorSpaceRegistry::instance() -> get("CMYK");
KisColorSpaceRegistry::instance() -> get(KisID("CMYK", ""));
}
else if (type == CMYKColorspace) {
return KisColorSpaceRegistry::instance() -> get("GRAYA");
return KisColorSpaceRegistry::instance() -> get(KisID("GRAYA", ""));
}
else if (type == RGBColorspace || type == sRGBColorspace || type == TransparentColorspace) {
return KisColorSpaceRegistry::instance() -> get("RGBA");
return KisColorSpaceRegistry::instance() -> get(KisID("RGBA", ""));
}
return 0;
......@@ -246,7 +246,7 @@ KisImageBuilder_Result KisImageMagickConverter::decode(const KURL& uri, bool isB
emit notifyProgressError(this);
return KisImageBuilder_RESULT_UNSUPPORTED_COLORSPACE;
}
kdDebug() << "Image has colorspace: " << cs -> name() << "\n";
kdDebug() << "Image has colorspace: " << cs -> id().name() << "\n";
KisProfileSP profile = getProfileForProfileInfo(image, cs);
if (profile)
......
......@@ -33,13 +33,14 @@
#include "kis_colorspace_alpha.h"
#include "kis_channelinfo.h"
#include "kis_types.h"
#include "kis_id.h"
namespace {
const PIXELTYPE PIXEL_MASK = 0;
}
KisColorSpaceAlpha::KisColorSpaceAlpha() :
KisStrategyColorSpace("ALPHA", i18n("Alpha mask"), TYPE_GRAY_8, icSigGrayData)
KisStrategyColorSpace(KisID("ALPHA", i18n("Alpha mask")), TYPE_GRAY_8, icSigGrayData)
{
// kdDebug() << "Alpha mask created\n";
m_maskColor = Qt::red;
......@@ -128,10 +129,7 @@ bool KisColorSpaceAlpha::convertPixelsTo(QUANTUM * src, KisProfileSP /*srcProfil
Q_UINT32 length,
Q_INT32 /*renderingIntent*/)
{
// kdDebug() << "KisColorSpaceAlpha:: convertPixels for " << length << " pixels from " << name() << " to " << dstColorStrategy -> name() << "\n";
// No lcms trickery here, we are a QColor + opacity channel
Q_INT32 size = dstColorStrategy -> pixelSize();
Q_UINT32 j = 0;
......
......@@ -44,16 +44,11 @@ KisColorSpaceRegistry* KisColorSpaceRegistry::instance()
return KisColorSpaceRegistry::m_singleton;
}
QStringList KisColorSpaceRegistry::listColorSpaceNames() const
{
return listKeys();
}
KisProfileSP KisColorSpaceRegistry::getProfileByName(const QString & name) const
KisProfileSP KisColorSpaceRegistry::getProfileByName(const QString & name) const
{
KisProfileSP profile = 0;
QStringList keys = listKeys();
for ( QStringList::Iterator it = keys.begin(); it != keys.end(); ++it ) {
KisIDList keys = listKeys();
for ( KisIDList::Iterator it = keys.begin(); it != keys.end(); ++it ) {
profile = get(*it) -> getProfileByName(name);
if (profile != 0) return profile;
}
......
......@@ -38,7 +38,6 @@ class KisColorSpaceRegistry : public KisGenericRegistry<KisStrategyColorSpaceSP>
public:
virtual ~KisColorSpaceRegistry();
QStringList listColorSpaceNames() const;
static KisColorSpaceRegistry* instance();
KisProfileSP getProfileByName(const QString & name) const;
......
......@@ -29,9 +29,8 @@
#include "kis_profile.h"
#include "kis_config.h"
KisStrategyColorSpace::KisStrategyColorSpace(const QString& name, const QString& description, Q_UINT32 cmType, icColorSpaceSignature colorSpaceSignature)
: m_name(name),
m_description(description),
KisStrategyColorSpace::KisStrategyColorSpace(const KisID& id, Q_UINT32 cmType, icColorSpaceSignature colorSpaceSignature)
: m_id(id),
m_cmType(cmType),
m_colorSpaceSignature(colorSpaceSignature)
{
......@@ -52,8 +51,7 @@ bool KisStrategyColorSpace::convertTo(KisPixel& src, KisPixel& dst, Q_INT32 rend
{
return convertPixelsTo(src.channels(), src.profile(),
dst.channels(), dst.colorStrategy(), dst.profile(),
1);
renderingIntent);
}
bool KisStrategyColorSpace::convertPixelsTo(QUANTUM * src, KisProfileSP srcProfile,
......@@ -109,7 +107,7 @@ void KisStrategyColorSpace::bitBlt(Q_INT32 stride,
// kdDebug() << name() << "::bitBlt. source color space: " << srcSpace -> name() << "\n";
if (m_name != srcSpace -> name()) {
if (m_id!= srcSpace -> id()) {
// kdDebug() << "compositing heterogenous color spaces: src = " << srcSpace -> name() << ", dst = " << m_name << "\n";
int len = pixelSize() * rows * cols;
QUANTUM * convertedSrcPixels = new QUANTUM[len];
......
......@@ -30,6 +30,7 @@
#include "kis_types.h"
#include "kis_channelinfo.h"
#include "kis_profile.h"
#include "kis_id.h"
class QPainter;
class KisIteratorPixel;
......@@ -60,12 +61,11 @@ public:
/**
* Create a new colorspace strategy.
*
* @param name The internal Krita name for this color strategy that we can use for loading and saving
* @param description i18n'able The user-friendly description of this strategy
* @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.
*/
KisStrategyColorSpace(const QString& name, const QString& description, Q_UINT32 cmType, icColorSpaceSignature colorSpaceSignature);
KisStrategyColorSpace(const KisID & id, Q_UINT32 cmType, icColorSpaceSignature colorSpaceSignature);
virtual ~KisStrategyColorSpace();
......@@ -120,16 +120,7 @@ public:
*/
virtual bool alpha() const = 0;
/**
* The internal identification of this color model
*/
inline QString name() const { return m_name; };
/**
* The user-friendly name of this color model.
*/
inline QString description() const { return m_description; };
inline KisID id() const { return m_id; }
/**
* This function is used to convert a KisPixelRepresentation from this color strategy to the specified
......@@ -231,8 +222,7 @@ protected:
private:
QString m_name; // The internal name
QString m_description; // The user-friendly description
KisID m_id;
Q_UINT32 m_cmType; // The colorspace type as defined by littlecms
icColorSpaceSignature m_colorSpaceSignature; // The colorspace signature as defined in icm/icc files
......
/*
* Copyright (c) 2004 Boudewijn Rempt <boud@valdyas.org>
*
* 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#ifndef KIS_TRANSFORM_H_
#define KIS_TRANSFORM_H_
#include "kis_global.h"
#include LCMS_HEADER
class KisTransform {
public:
KisTransform() {};
virtual ~KisTransform() {};
private:
cmsHTRANSFORM m_transform;
};
#endif // KIS_TRANSFORM_H_
/*
* Copyright (c) 2003 Patrick Julien <freak@codepimps.org>
*
* 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#include "kis_canvas_subject.h"
KisCanvasSubject::KisCanvasSubject()
{
}
KisCanvasSubject::~KisCanvasSubject()
{
}
......@@ -22,6 +22,7 @@
#include <qstring.h>
#include <qcolor.h>
#include "kis_types.h"
#include "kis_id.h"
class KoDocument;
class KisBrush;
......@@ -42,8 +43,8 @@ class KisFilterRegistry;
*/
class KisCanvasSubject {
public:
KisCanvasSubject();
virtual ~KisCanvasSubject();
KisCanvasSubject() {};
virtual ~KisCanvasSubject() {};
public:
virtual void attach(KisCanvasObserver *observer) = 0;
......@@ -66,8 +67,8 @@ public:
virtual KisProgressDisplayInterface *progressDisplay() const = 0;
virtual KisSelectionManager * selectionManager() = 0;
virtual KisFilterRegistry * filterRegistry() const = 0;
virtual KisFilterSP filterGet(const QString& name) = 0;
virtual QStringList filterList() = 0;
virtual KisFilterSP filterGet(const KisID& id) = 0;
virtual KisIDList filterList() = 0;
private:
KisCanvasSubject(const KisCanvasSubject&);
KisCanvasSubject& operator=(const KisCanvasSubject&);
......
......@@ -95,7 +95,7 @@ void KisClipboard::clipboardDataChanged()
QImage qimg = cb -> image();
if (!qimg.isNull()) {
KisStrategyColorSpaceSP cs = KisColorSpaceRegistry::instance()->get("RGBA");
KisStrategyColorSpaceSP cs = KisColorSpaceRegistry::instance()->get(KisID("RGBA",""));
m_clip =
new KisPaintDevice(cs,
......
......@@ -71,6 +71,7 @@
#include "kis_profile.h"
#include "kis_resource.h"
#include "kis_resourceserver.h"
#include "kis_id.h"
#include "KIsDocIface.h"
static const char *CURRENT_DTD_VERSION = "1.3";
......@@ -524,7 +525,7 @@ QDomElement KisDoc::saveImage(QDomDocument& doc, KisImageSP img)
image.setAttribute("mime", "application/x-kra");
image.setAttribute("width", img -> width());
image.setAttribute("height", img -> height());
image.setAttribute("colorspacename", img -> colorStrategy() -> name());
image.setAttribute("colorspacename", img -> colorStrategy() -> id().id());
image.setAttribute("description", img -> description());
// XXX: Save profile as blob inside the image, instead of the product name.
if (img -> profile() && img -> profile()-> valid())
......@@ -613,22 +614,24 @@ KisImageSP KisDoc::loadImage(const QDomElement& element)
{
case IMAGE_TYPE_GREYA:
case IMAGE_TYPE_GREY:
colorspacename = "Grayscale/Alpha";
colorspacename = "GRAYA";
break;
case IMAGE_TYPE_RGB:
case IMAGE_TYPE_RGBA:
colorspacename = "RGBA";
break;
case IMAGE_TYPE_CMYK:
colorspacename = "CMYKA";
break;
case IMAGE_TYPE_CMYKA:
colorspacename = "CMYK/Alpha";
colorspacename = "CMYKA";
break;
default:
return 0;
}
}
KisStrategyColorSpaceSP cs = KisColorSpaceRegistry::instance() -> get(colorspacename);
KisStrategyColorSpaceSP cs = KisColorSpaceRegistry::instance() -> get(KisID(colorspacename, ""));
// kdDebug() << "Colorspace: " << cs << "\n";
if (cs == 0) return 0;
......@@ -971,10 +974,8 @@ bool KisDoc::slotNewImage()
QColor c = dlg.backgroundColor();
KisImageSP img;
KisLayerSP layer;
KisFillPainter painter;
// kdDebug() << dlg.colorStrategyName() << "\n";
KisStrategyColorSpaceSP cs = KisColorSpaceRegistry::instance()->get(dlg.colorStrategyName());
KisStrategyColorSpaceSP cs = KisColorSpaceRegistry::instance()->get(dlg.colorStrategyID());
if (!cs) return false;
......@@ -984,14 +985,18 @@ bool KisDoc::slotNewImage()
dlg.imgName());
img -> setResolution(dlg.imgResolution(), dlg.imgResolution()); // XXX needs to be added to dialog
img -> setDescription(dlg.imgDescription());
// kdDebug() << "selected profile: " << dlg.profile() << "\n";
img -> setProfile(dlg.profile());
layer = new KisLayer(img, img -> nextLayerName(), OPACITY_OPAQUE);
painter.begin(layer.data());
painter.fillRect(0, 0, dlg.imgWidth(), dlg.imgHeight(), c, opacity);
painter.end();
// Default color and opacity: don't allocate memory
if ( c.red() != 0 || c.green() != 0 || c.blue() != 0 || opacity != 0) {
KisFillPainter painter;
painter.begin(layer.data());
painter.fillRect(0, 0, dlg.imgWidth(), dlg.imgHeight(), c, opacity);
painter.end();
}
img -> add(layer, -1);
......
......@@ -33,9 +33,10 @@
#include "kis_previewwidget.h"
#include "kis_painter.h"
#include "kis_selection.h"
#include "kis_id.h"
KisFilter::KisFilter(const QString& name, KisView * view) :
m_name(name),
KisFilter::KisFilter(const KisID& id, KisView * view) :
m_id(id),
m_view(view),
m_dialog(0)
{
......@@ -65,7 +66,7 @@ KisFilterConfigurationWidget* KisFilter::createConfigurationWidget(QWidget* )
void KisFilter::slotActivated()
{
kdDebug() << "Filter activated: " << m_name << "\n";
kdDebug() << "Filter activated: " << m_id.name() << "\n";
KisImageSP img = m_view -> currentImg();
if (!img) return;
......@@ -73,7 +74,7 @@ void KisFilter::slotActivated()
if (!layer) return;
// Create the config dialog
m_dialog = new KisPreviewDialog( (QWidget*) m_view, name().ascii(), true, name());
m_dialog = new KisPreviewDialog( (QWidget*) m_view, id().name().ascii(), true, id().name());
m_widget = createConfigurationWidget( (QWidget*)m_dialog->container() );
if( m_widget != 0)
......@@ -110,7 +111,7 @@ void KisFilter::slotActivated()
}
enableProgress();
KisTransaction * cmd = new KisTransaction(name(), layer.data());
KisTransaction * cmd = new KisTransaction(id().name(), layer.data());
process((KisPaintDeviceSP)layer, (KisPaintDeviceSP)layer, config, rect);
img -> undoAdapter() -> addCommand(cmd);
disableProgress();
......
......@@ -23,12 +23,14 @@
#include <qwidget.h>
#include <ksharedptr.h>
#include <klocale.h>
#include "kis_types.h"
#include "kis_view.h"
#include "kis_image.h"
#include "kis_layer.h"
#include "kis_filter_registry.h"
#include "kis_id.h"
class KisFilterConfigurationWidget;
class KisPreviewDialog;
......@@ -41,9 +43,9 @@ template<class F>
KisFilterSP createFilter(KisView* view)
{
KisFilterSP kfi;
if( view->filterRegistry()->exist( F::name() ) )
if( view->filterRegistry()->exists( F::id() ) )
{
kfi = view->filterRegistry()->get( F::name() );
kfi = view->filterRegistry()->get( F::id() );
} else {
kfi = new F(view);
view->filterRegistry()->add(kfi);
......@@ -69,7 +71,7 @@ class KisFilter : public KisProgressSubject, public KShared {
Q_OBJECT
public:
KisFilter(const QString& name, KisView * view);
KisFilter(const KisID& id, KisView * view);
virtual ~KisFilter() {}
public:
......@@ -94,7 +96,7 @@ public:
virtual void disableProgress();
virtual void setAutoUpdate(bool set);
inline const QString name() const { return m_name; };
inline const KisID id() const { return m_id; };
virtual KisFilterConfigurationWidget* createConfigurationWidget(QWidget* parent);
......@@ -116,7 +118,7 @@ protected:
bool m_cancelRequested;
bool m_progressEnabled;
QString m_name;
KisID m_id;
KisView * m_view;
KisFilterConfigurationWidget* m_widget;
KisPreviewDialog* m_dialog;
......
......@@ -23,14 +23,13 @@
#include <qstring.h>
#include <qstringlist.h>
#include <kdebug.h>
// XXX: Map on KisID to have a combination of unique identifying
// string and an an i18n-ed display string
#include "kis_id.h"
template<typename _T>
class KisGenericRegistry {
typedef std::map<QString, _T> storageMap;
typedef std::map<KisID, _T> storageMap;
public:
virtual ~KisGenericRegistry() { };
protected:
......@@ -38,10 +37,11 @@ protected:
public:
void add(_T item)
{
m_storage.insert( typename storageMap::value_type( item->name(), item) );
//kdDebug() << "Added " << item -> name() << "\n";
m_storage.insert( typename storageMap::value_type( item->id(), item) );
kdDebug() << "Added " << item -> id().name() << "\n";
}
_T get(const QString& name) const
_T get(const KisID& name) const
{
_T p;
typename storageMap::const_iterator it = m_storage.find(name);
......@@ -54,14 +54,32 @@ public:
}
return p;
}
bool exist(const QString& name) const
/**
* Get a single entry based on the identifying part of KisID, not the
* the descriptive part.
*/
_T get(const QString& id) const
{
typename storageMap::const_iterator it = m_storage.find(name);
return get(KisID(id, ""));
}
bool exists(const KisID& id) const
{
typename storageMap::const_iterator it = m_storage.find(id);
return (it != m_storage.end());
}
QStringList listKeys() const
bool exists(const QString& id) const
{
return exists(KisID(id, ""));
}
KisIDList listKeys() const
{
QStringList list;
KisIDList list;
typename storageMap::const_iterator it = m_storage.begin();
typename storageMap::const_iterator endit = m_storage.end();
while( it != endit )
......
......@@ -184,10 +184,5 @@ typedef Q_UINT8 PIXELTYPE;
#define downscale(quantum) (quantum) //((unsigned char) ((quantum)/257UL))
#define upscale(value) (value) // ((QUANTUM) (257UL*(value)))