Commit 4a218a1e authored by Casper Boemann's avatar Casper Boemann

Change inheritance of colorspaces.

KisAbstractColorSpace is now known as KisLcmsBaseColorSpace, and the 
idea is that not every colorspace will use that
KisColorSpace is now a virtual base of both lcmsbase and each of the U08 
type bases

So say rgb08 would inherit from both KisLcmsBaseColorSpace and 
KisU08BaseColorSpace

With diamond shaped inheritance final colorspaces (like rgb) has to call 
the constructor of KisColorSpace.

Also the conversion colorspace used as fallback is now Lab. meaning that 
_every_ colorspace _must_ implement to and from Lab function.


svn path=/trunk/koffice/; revision=547735
parent f036e475
......@@ -41,7 +41,9 @@ namespace {
}
KisCmykU16ColorSpace::KisCmykU16ColorSpace(KisColorSpaceFactoryRegistry * parent, KisProfile *p) :
KisU16BaseColorSpace(KisID("CMYKA16", i18n("CMYK (16-bit integer/channel)")), TYPE_CMYK5_16, icSigCmykData, parent, p)
KisColorSpace(KisID("CMYKA16", i18n("CMYK (16-bit integer/channel)")), parent)
, KisU16BaseColorSpace(PIXEL_ALPHA * sizeof(quint16))
, KisLcmsBaseColorSpace(TYPE_CMYK5_16, icSigCmykData, p)
{
m_channels.push_back(new KisChannelInfo(i18n("Cyan"), 0 * sizeof(quint16), KisChannelInfo::COLOR, KisChannelInfo::UINT16, sizeof(quint16), Qt::cyan));
m_channels.push_back(new KisChannelInfo(i18n("Magenta"), 1 * sizeof(quint16), KisChannelInfo::COLOR, KisChannelInfo::UINT16, sizeof(quint16), Qt::magenta));
......@@ -49,8 +51,6 @@ KisCmykU16ColorSpace::KisCmykU16ColorSpace(KisColorSpaceFactoryRegistry * parent
m_channels.push_back(new KisChannelInfo(i18n("Black"), 3 * sizeof(quint16), KisChannelInfo::COLOR, KisChannelInfo::UINT16, sizeof(quint16), Qt::black));
m_channels.push_back(new KisChannelInfo(i18n("Alpha"), 4 * sizeof(quint16), KisChannelInfo::ALPHA, KisChannelInfo::UINT16, sizeof(quint16)));
m_alphaPos = PIXEL_ALPHA * sizeof(quint16);
init();
}
......@@ -158,14 +158,14 @@ void KisCmykU16ColorSpace::applyAdjustment(const quint8 *src, quint8 *dst, KisCo
quint8 * tmpPtr = tmp;
memcpy(tmp, dst, nPixels * psize);
KisAbstractColorSpace::applyAdjustment(src, dst, adj, nPixels);
KisLcmsBaseColorSpace::applyAdjustment(src, dst, adj, nPixels);
// Copy the alpha, which lcms doesn't do for us, grumble.
while (nPixels--)
{
quint16 *pixelAlphaSrc = reinterpret_cast<quint16 *>(tmpPtr + m_alphaPos);
quint16 *pixelAlphaDst = reinterpret_cast<quint16 *>(dst + m_alphaPos);
quint16 *pixelAlphaSrc = reinterpret_cast<quint16 *>(tmpPtr + 8);
quint16 *pixelAlphaDst = reinterpret_cast<quint16 *>(dst + 8);
*pixelAlphaDst= *pixelAlphaSrc;
......
......@@ -24,10 +24,11 @@
#include "kis_global.h"
#include "kis_u16_base_colorspace.h"
#include "kis_lcms_base_colorspace.h"
#include "kis_integer_maths.h"
class KRITACOLOR_EXPORT KisCmykU16ColorSpace : public KisU16BaseColorSpace {
class KRITACOLOR_EXPORT KisCmykU16ColorSpace : public KisU16BaseColorSpace, public KisLcmsBaseColorSpace {
public:
struct Pixel {
......
......@@ -38,7 +38,9 @@ namespace cmyk {
}
KisCmykColorSpace::KisCmykColorSpace(KisColorSpaceFactoryRegistry * parent, KisProfile *p) :
KisU8BaseColorSpace(KisID("CMYK", i18n("CMYK")), TYPE_CMYK5_8, icSigCmykData, parent, p)
KisColorSpace(KisID("CMYK", i18n("CMYK")), parent)
, KisU8BaseColorSpace(PIXEL_CMYK_ALPHA)
, KisLcmsBaseColorSpace(TYPE_CMYK5_8, icSigCmykData, p)
{
m_channels.push_back(new KisChannelInfo(i18n("Cyan"), 0, KisChannelInfo::COLOR, KisChannelInfo::UINT8, 1, Qt::cyan));
m_channels.push_back(new KisChannelInfo(i18n("Magenta"), 1, KisChannelInfo::COLOR, KisChannelInfo::UINT8, 1, Qt::magenta));
......@@ -46,8 +48,6 @@ KisCmykColorSpace::KisCmykColorSpace(KisColorSpaceFactoryRegistry * parent, KisP
m_channels.push_back(new KisChannelInfo(i18n("Black"), 3, KisChannelInfo::COLOR, KisChannelInfo::UINT8, 1, Qt::black));
m_channels.push_back(new KisChannelInfo(i18n("Alpha"), 4, KisChannelInfo::ALPHA, KisChannelInfo::UINT8, 1, Qt::white));
m_alphaPos = PIXEL_CMYK_ALPHA;
init();
}
......@@ -159,7 +159,7 @@ void KisCmykColorSpace::applyAdjustment(const quint8 *src, quint8 *dst, KisColor
quint8 * tmpPtr = tmp;
memcpy(tmp, dst, nPixels * psize);
KisAbstractColorSpace::applyAdjustment(src, dst, adj, nPixels);
KisLcmsBaseColorSpace::applyAdjustment(src, dst, adj, nPixels);
// Copy the alpha, which lcms doesn't do for us, grumble.
......
......@@ -22,9 +22,10 @@
#include <QMap>
#include <krita_export.h>
#include "kis_global.h"
#include "kis_lcms_base_colorspace.h"
#include "kis_u8_base_colorspace.h"
class KRITACOLOR_EXPORT KisCmykColorSpace : public KisU8BaseColorSpace {
class KRITACOLOR_EXPORT KisCmykColorSpace : public KisU8BaseColorSpace, public KisLcmsBaseColorSpace {
public:
......
......@@ -40,7 +40,9 @@ namespace {
}
KisGrayU16ColorSpace::KisGrayU16ColorSpace(KisColorSpaceFactoryRegistry * parent, KisProfile *p) :
KisU16BaseColorSpace(KisID("GRAYA16", i18n("Grayscale (16-bit integer/channel)")), TYPE_GRAYA_16, icSigGrayData, parent, p)
KisColorSpace(KisID("GRAYA16", i18n("Grayscale (16-bit integer/channel)")), parent)
, KisU16BaseColorSpace(PIXEL_ALPHA * sizeof(quint16))
, KisLcmsBaseColorSpace(TYPE_GRAYA_16, icSigGrayData, p)
{
m_channels.push_back(new KisChannelInfo(i18n("Gray"), PIXEL_GRAY * sizeof(quint16), KisChannelInfo::COLOR, KisChannelInfo::UINT16, sizeof(quint16)));
m_channels.push_back(new KisChannelInfo(i18n("Alpha"), PIXEL_ALPHA * sizeof(quint16), KisChannelInfo::ALPHA, KisChannelInfo::UINT16, sizeof(quint16)));
......@@ -50,8 +52,6 @@ KisGrayU16ColorSpace::KisGrayU16ColorSpace(KisColorSpaceFactoryRegistry * parent
cmsFreeGamma(Gamma);
*/
m_alphaPos = PIXEL_ALPHA * sizeof(quint16);
init();
}
......
......@@ -25,10 +25,11 @@
#include "kis_global.h"
#include "kis_u16_base_colorspace.h"
#include "kis_lcms_base_colorspace.h"
#include "kis_integer_maths.h"
class KRITACOLOR_EXPORT KisGrayU16ColorSpace : public KisU16BaseColorSpace {
class KRITACOLOR_EXPORT KisGrayU16ColorSpace : public KisU16BaseColorSpace, public KisLcmsBaseColorSpace {
public:
struct Pixel {
......
......@@ -30,27 +30,24 @@
#include <kdebug.h>
#include <kglobal.h>
#include "kis_abstract_colorspace.h"
#include "kis_lcms_base_colorspace.h"
#include "kis_u8_base_colorspace.h"
#include "kis_gray_colorspace.h"
#include "kis_integer_maths.h"
#define downscale(quantum) (quantum) //((unsigned char) ((quantum)/257UL))
#define upscale(value) (value) // ((quint8) (257UL*(value)))
namespace {
const qint32 MAX_CHANNEL_GRAYSCALE = 1;
const qint32 MAX_CHANNEL_GRAYSCALEA = 2;
}
KisGrayColorSpace::KisGrayColorSpace(KisColorSpaceFactoryRegistry * parent, KisProfile *p) :
KisU8BaseColorSpace(KisID("GRAYA", i18n("Grayscale")), TYPE_GRAYA_8, icSigGrayData, parent, p)
KisColorSpace(KisID("GRAYA", i18n("Grayscale")), parent)
, KisU8BaseColorSpace(PIXEL_GRAY_ALPHA)
, KisLcmsBaseColorSpace(TYPE_GRAYA_8, icSigGrayData, p)
{
m_channels.push_back(new KisChannelInfo(i18n("Gray"), 0, KisChannelInfo::COLOR, KisChannelInfo::UINT8));
m_channels.push_back(new KisChannelInfo(i18n("Alpha"), 1, KisChannelInfo::ALPHA, KisChannelInfo::UINT8));
m_alphaPos = PIXEL_GRAY_ALPHA;
init();
}
......
......@@ -24,10 +24,10 @@
#include <krita_export.h>
#include "kis_global.h"
#include "kis_abstract_colorspace.h"
#include "kis_lcms_base_colorspace.h"
#include "kis_u8_base_colorspace.h"
class KRITACOLOR_EXPORT KisGrayColorSpace : public KisU8BaseColorSpace {
class KRITACOLOR_EXPORT KisGrayColorSpace : public KisU8BaseColorSpace, public KisLcmsBaseColorSpace {
public:
KisGrayColorSpace(KisColorSpaceFactoryRegistry * parent, KisProfile *p);
virtual ~KisGrayColorSpace();
......
......@@ -49,14 +49,14 @@ namespace {
// disable the lcms handling by setting profile=0
KisLmsF32ColorSpace::KisLmsF32ColorSpace(KisColorSpaceFactoryRegistry * parent, KisProfile */*p*/) :
KisF32BaseColorSpace(KisID("LMSAF32", i18n("LMS (32-bit float/channel)")), F32_LCMS_TYPE, icSig3colorData, parent, 0)
KisColorSpace(KisID("LMSAF32", i18n("LMS (32-bit float/channel)")), parent)
, KisF32BaseColorSpace(PIXEL_ALPHA * sizeof(float))
, KisLcmsBaseColorSpace(F32_LCMS_TYPE, icSig3colorData, 0)
{
m_channels.push_back(new KisChannelInfo(i18n("Long"), PIXEL_LONGWAVE * sizeof(float), KisChannelInfo::COLOR, KisChannelInfo::FLOAT32, sizeof(float)));
m_channels.push_back(new KisChannelInfo(i18n("Middle"), PIXEL_MIDDLEWAVE * sizeof(float), KisChannelInfo::COLOR, KisChannelInfo::FLOAT32, sizeof(float)));
m_channels.push_back(new KisChannelInfo(i18n("Short"), PIXEL_SHORTWAVE * sizeof(float), KisChannelInfo::COLOR, KisChannelInfo::FLOAT32, sizeof(float)));
m_channels.push_back(new KisChannelInfo(i18n("Alpha"), PIXEL_ALPHA * sizeof(float), KisChannelInfo::ALPHA, KisChannelInfo::FLOAT32, sizeof(float)));
m_alphaPos = PIXEL_ALPHA * sizeof(float);
}
KisLmsF32ColorSpace::~KisLmsF32ColorSpace()
......
......@@ -29,10 +29,11 @@
#include "kis_global.h"
#include "kis_f32_base_colorspace.h"
#include "kis_lcms_base_colorspace.h"
class KisColorSpaceFactoryRegistry;
class KRITACOLOR_EXPORT KisLmsF32ColorSpace : public KisF32BaseColorSpace {
class KRITACOLOR_EXPORT KisLmsF32ColorSpace : public KisF32BaseColorSpace, public KisLcmsBaseColorSpace {
public:
KisLmsF32ColorSpace(KisColorSpaceFactoryRegistry * parent, KisProfile *p);
virtual ~KisLmsF32ColorSpace();
......
......@@ -51,7 +51,9 @@ namespace {
#define RGBAF16HALF_LCMS_TYPE TYPE_BGRA_16
KisRgbF16HalfColorSpace::KisRgbF16HalfColorSpace(KisColorSpaceFactoryRegistry * parent, KisProfile *p) :
KisF16HalfBaseColorSpace(KisID("RGBAF16HALF", i18n("RGB (16-bit float/channel)")), RGBAF16HALF_LCMS_TYPE, icSigRgbData, parent, p)
KisColorSpace(KisID("RGBAF16HALF", i18n("RGB (16-bit float/channel)")), parent)
, KisF16HalfBaseColorSpace(PIXEL_ALPHA * sizeof(half))
, KisLcmsBaseColorSpace(RGBAF16HALF_LCMS_TYPE, icSigRgbData, p)
{
m_channels.push_back(new KisChannelInfo(i18n("Red"), PIXEL_RED * sizeof(half), KisChannelInfo::COLOR, KisChannelInfo::FLOAT16, sizeof(half)));
m_channels.push_back(new KisChannelInfo(i18n("Green"), PIXEL_GREEN * sizeof(half), KisChannelInfo::COLOR, KisChannelInfo::FLOAT16, sizeof(half)));
......@@ -60,8 +62,6 @@ KisRgbF16HalfColorSpace::KisRgbF16HalfColorSpace(KisColorSpaceFactoryRegistry *
//cmsHPROFILE hProfile = cmsCreate_sRGBProfile();
//setDefaultProfile( new KisProfile(hProfile, RGBAF16HALF_LCMS_TYPE) );
m_alphaPos = PIXEL_ALPHA * sizeof(half);
}
KisRgbF16HalfColorSpace::~KisRgbF16HalfColorSpace()
......
......@@ -27,9 +27,10 @@
#include "kis_global.h"
#include "kis_f16half_base_colorspace.h"
#include "kis_lcms_base_colorspace.h"
class KRITACOLOR_EXPORT KisRgbF16HalfColorSpace : public KisF16HalfBaseColorSpace {
class KRITACOLOR_EXPORT KisRgbF16HalfColorSpace : public KisF16HalfBaseColorSpace, public KisLcmsBaseColorSpace {
public:
KisRgbF16HalfColorSpace(KisColorSpaceFactoryRegistry * parent, KisProfile *p);
virtual ~KisRgbF16HalfColorSpace();
......@@ -47,6 +48,8 @@ public:
void setPixel(quint8 *pixel, half red, half green, half blue, half alpha) const;
void getPixel(const quint8 *pixel, half *red, half *green, half *blue, half *alpha) const;
virtual bool hasHighDynamicRange() const { return true; }
virtual void fromQColor(const QColor& c, quint8 *dst, KisProfile * profile = 0);
virtual void fromQColor(const QColor& c, quint8 opacity, quint8 *dst, KisProfile * profile = 0);
......
......@@ -53,14 +53,14 @@ namespace {
// disable the lcms handling by setting profile=0
KisRgbF32ColorSpace::KisRgbF32ColorSpace(KisColorSpaceFactoryRegistry * parent, KisProfile */*p*/) :
KisF32BaseColorSpace(KisID("RGBAF32", i18n("RGB (32-bit float/channel)")), F32_LCMS_TYPE, icSigRgbData, parent, 0)
KisColorSpace(KisID("RGBAF32", i18n("RGB (32-bit float/channel)")), parent)
, KisF32BaseColorSpace(PIXEL_ALPHA * sizeof(float))
, KisLcmsBaseColorSpace(F32_LCMS_TYPE, icSigRgbData, 0)
{
m_channels.push_back(new KisChannelInfo(i18n("Red"), PIXEL_RED * sizeof(float), KisChannelInfo::COLOR, KisChannelInfo::FLOAT32, sizeof(float)));
m_channels.push_back(new KisChannelInfo(i18n("Green"), PIXEL_GREEN * sizeof(float), KisChannelInfo::COLOR, KisChannelInfo::FLOAT32, sizeof(float)));
m_channels.push_back(new KisChannelInfo(i18n("Blue"), PIXEL_BLUE * sizeof(float), KisChannelInfo::COLOR, KisChannelInfo::FLOAT32, sizeof(float)));
m_channels.push_back(new KisChannelInfo(i18n("Alpha"), PIXEL_ALPHA * sizeof(float), KisChannelInfo::ALPHA, KisChannelInfo::FLOAT32, sizeof(float)));
m_alphaPos = PIXEL_ALPHA * sizeof(float);
}
KisRgbF32ColorSpace::~KisRgbF32ColorSpace()
......
......@@ -28,10 +28,11 @@
#include "kis_global.h"
#include "kis_f32_base_colorspace.h"
#include "kis_lcms_base_colorspace.h"
class KisColorSpaceFactoryRegistry;
class KRITACOLOR_EXPORT KisRgbF32ColorSpace : public KisF32BaseColorSpace {
class KRITACOLOR_EXPORT KisRgbF32ColorSpace : public KisF32BaseColorSpace, public KisLcmsBaseColorSpace {
public:
KisRgbF32ColorSpace(KisColorSpaceFactoryRegistry * parent, KisProfile *p);
virtual ~KisRgbF32ColorSpace();
......@@ -50,6 +51,8 @@ public:
void setPixel(quint8 *pixel, float red, float green, float blue, float alpha) const;
void getPixel(const quint8 *pixel, float *red, float *green, float *blue, float *alpha) const;
virtual bool hasHighDynamicRange() const { return true; }
virtual void fromQColor(const QColor& c, quint8 *dst, KisProfile * profile = 0);
virtual void fromQColor(const QColor& c, quint8 opacity, quint8 *dst, KisProfile * profile = 0);
......
......@@ -45,15 +45,15 @@ namespace {
//const quint16 KisRgbU16ColorSpace::U16_OPACITY_TRANSPARENT;
KisRgbU16ColorSpace::KisRgbU16ColorSpace(KisColorSpaceFactoryRegistry * parent, KisProfile *p) :
KisU16BaseColorSpace(KisID("RGBA16", i18n("RGB (16-bit integer/channel)")), TYPE_BGRA_16, icSigRgbData, parent, p)
KisColorSpace(KisID("RGBA16", i18n("RGB (16-bit integer/channel)")), parent)
, KisU16BaseColorSpace(PIXEL_ALPHA * sizeof(quint16))
, KisLcmsBaseColorSpace(TYPE_BGRA_16, icSigRgbData, p)
{
m_channels.push_back(new KisChannelInfo(i18n("Red"), PIXEL_RED * sizeof(quint16), KisChannelInfo::COLOR, KisChannelInfo::UINT16, sizeof(quint16), QColor(255,0,0)));
m_channels.push_back(new KisChannelInfo(i18n("Green"), PIXEL_GREEN * sizeof(quint16), KisChannelInfo::COLOR, KisChannelInfo::UINT16, sizeof(quint16), QColor(0,255,0)));
m_channels.push_back(new KisChannelInfo(i18n("Blue"), PIXEL_BLUE * sizeof(quint16), KisChannelInfo::COLOR, KisChannelInfo::UINT16, sizeof(quint16), QColor(0,0,255)));
m_channels.push_back(new KisChannelInfo(i18n("Alpha"), PIXEL_ALPHA * sizeof(quint16), KisChannelInfo::ALPHA, KisChannelInfo::UINT16, sizeof(quint16)));
m_alphaPos = PIXEL_ALPHA * sizeof(quint16);
init();
}
......
......@@ -28,7 +28,7 @@
#include "kis_integer_maths.h"
class KRITACOLOR_EXPORT KisRgbU16ColorSpace : public KisU16BaseColorSpace {
class KRITACOLOR_EXPORT KisRgbU16ColorSpace : public KisU16BaseColorSpace, public KisLcmsBaseColorSpace {
public:
struct Pixel {
......
......@@ -45,14 +45,15 @@ namespace {
}
KisRgbColorSpace::KisRgbColorSpace(KisColorSpaceFactoryRegistry * parent, KisProfile *p) :
KisU8BaseColorSpace(KisID("RGBA", i18n("RGB (8-bit integer/channel)")), TYPE_BGRA_8, icSigRgbData, parent, p)
KisColorSpace(KisID("RGBA", i18n("RGB (8-bit integer/channel)")), parent)
,KisU8BaseColorSpace(PIXEL_ALPHA)
,KisLcmsBaseColorSpace(TYPE_BGRA_8, icSigRgbData, p)
{
m_channels.push_back(new KisChannelInfo(i18n("Red"), 2, KisChannelInfo::COLOR, KisChannelInfo::UINT8, 1, QColor(255,0,0)));
m_channels.push_back(new KisChannelInfo(i18n("Green"), 1, KisChannelInfo::COLOR, KisChannelInfo::UINT8, 1, QColor(0,255,0)));
m_channels.push_back(new KisChannelInfo(i18n("Blue"), 0, KisChannelInfo::COLOR, KisChannelInfo::UINT8, 1, QColor(0,0,255)));
m_channels.push_back(new KisChannelInfo(i18n("Alpha"), 3, KisChannelInfo::ALPHA, KisChannelInfo::UINT8));
m_alphaPos = PIXEL_ALPHA;
init();
}
......@@ -60,22 +61,6 @@ KisRgbColorSpace::~KisRgbColorSpace()
{
}
void KisRgbColorSpace::setPixel(quint8 *pixel, quint8 red, quint8 green, quint8 blue, quint8 alpha) const
{
pixel[PIXEL_RED] = red;
pixel[PIXEL_GREEN] = green;
pixel[PIXEL_BLUE] = blue;
pixel[PIXEL_ALPHA] = alpha;
}
void KisRgbColorSpace::getPixel(const quint8 *pixel, quint8 *red, quint8 *green, quint8 *blue, quint8 *alpha) const
{
*red = pixel[PIXEL_RED];
*green = pixel[PIXEL_GREEN];
*blue = pixel[PIXEL_BLUE];
*alpha = pixel[PIXEL_ALPHA];
}
void KisRgbColorSpace::mixColors(const quint8 **colors, const quint8 *weights, quint32 nColors, quint8 *dst) const
{
quint32 totalRed = 0, totalGreen = 0, totalBlue = 0, totalAlpha = 0;
......
......@@ -22,6 +22,7 @@
#include "kis_global.h"
#include "kis_u8_base_colorspace.h"
#include "kis_lcms_base_colorspace.h"
#include "krita_export.h"
const quint8 PIXEL_BLUE = 0;
......@@ -29,7 +30,7 @@ const quint8 PIXEL_GREEN = 1;
const quint8 PIXEL_RED = 2;
const quint8 PIXEL_ALPHA = 3;
class KRITACOLOR_EXPORT KisRgbColorSpace : public KisU8BaseColorSpace {
class KRITACOLOR_EXPORT KisRgbColorSpace : public KisU8BaseColorSpace, public KisLcmsBaseColorSpace {
public:
KisRgbColorSpace(KisColorSpaceFactoryRegistry * parent, KisProfile *p);
virtual ~KisRgbColorSpace();
......@@ -41,9 +42,6 @@ public:
public:
void setPixel(quint8 *pixel, quint8 red, quint8 green, quint8 blue, quint8 alpha) const;
void getPixel(const quint8 *pixel, quint8 *red, quint8 *green, quint8 *blue, quint8 *alpha) const;
virtual void mixColors(const quint8 **colors, const quint8 *weights, quint32 nColors, quint8 *dst) const;
virtual void convolveColors(quint8** colors, qint32* kernelValues, KisChannelInfo::enumChannelFlags channelFlags, quint8 *dst, qint32 factor, qint32 offset, qint32 nColors) const;
virtual void invertColor(quint8 * src, qint32 nPixels);
......
......@@ -29,7 +29,7 @@
#include <klocale.h>
#include <kdebug.h>
#include <kis_debug_areas.h>
#include "kis_abstract_colorspace.h"
#include "kis_lcms_base_colorspace.h"
#include "kis_colorspace_factory_registry.h"
#include "kis_image.h"
#include "kis_wet_colorspace.h"
......@@ -112,7 +112,8 @@ int getH(int r, int g, int b)
}
KisWetColorSpace::KisWetColorSpace(KisColorSpaceFactoryRegistry * parent, KisProfile *p) :
KisAbstractColorSpace(KisID("WET", i18n("Watercolors")), 0, icMaxEnumData, parent, p)
KisColorSpace(KisID("WET", i18n("Watercolors")), parent)
, KisLcmsBaseColorSpace(0, icMaxEnumData, p)
{
wet_init_render_tab();
......
......@@ -24,7 +24,7 @@
#include <QMap>
#include "kis_global.h"
#include "kis_abstract_colorspace.h"
#include "kis_lcms_base_colorspace.h"
class KisFilter;
......@@ -91,7 +91,7 @@ void wetPixToDouble(WetPixDbl * dst, WetPix *src);
void wetPixFromDouble(WetPix * dst, WetPixDbl *src);
class KisWetColorSpace : public KisAbstractColorSpace {
class KisWetColorSpace : public KisLcmsBaseColorSpace {
public:
KisWetColorSpace(KisColorSpaceFactoryRegistry * parent, KisProfile *p);
virtual ~KisWetColorSpace();
......
......@@ -26,7 +26,7 @@ set(kritacolor_LIB_SRCS
kis_profile.cc
kis_histogram_producer.cc
kis_basic_histogram_producers.cc
kis_abstract_colorspace.cc
kis_lcms_base_colorspace.cc
kis_colorspace_factory_registry.cc
kis_color_conversions.cc
kis_u8_base_colorspace.cc
......
......@@ -40,10 +40,11 @@ namespace {
KisAlphaColorSpace::KisAlphaColorSpace(KisColorSpaceFactoryRegistry * parent,
KisProfile *p) :
KisU8BaseColorSpace(KisID("ALPHA", i18n("Alpha mask")), TYPE_GRAY_8, icSigGrayData, parent, p)
KisColorSpace(KisID("ALPHA", i18n("Alpha mask")), parent)
, KisU8BaseColorSpace(0)
, KisLcmsBaseColorSpace(TYPE_GRAY_8, icSigGrayData, p)
{
m_channels.push_back(new KisChannelInfo(i18n("Alpha"), 0, KisChannelInfo::ALPHA, KisChannelInfo::UINT8));
m_alphaPos = 0;
}
KisAlphaColorSpace::~KisAlphaColorSpace()
......@@ -102,7 +103,7 @@ Q3ValueVector<KisChannelInfo *> KisAlphaColorSpace::channels() const
}
bool KisAlphaColorSpace::convertPixelsTo(const quint8 *src,
quint8 *dst, KisAbstractColorSpace * dstColorSpace,
quint8 *dst, KisColorSpace * dstColorSpace,
quint32 numPixels,
qint32 /*renderingIntent*/)
{
......
......@@ -22,12 +22,13 @@
#include "kis_global.h"
#include "kis_u8_base_colorspace.h"
#include "kis_lcms_base_colorspace.h"
/**
* The alpha mask is a special color strategy that treats all pixels as
* alpha value with a colour common to the mask. The default color is white.
*/
class KisAlphaColorSpace : public KisU8BaseColorSpace {
class KisAlphaColorSpace : public KisU8BaseColorSpace, public KisLcmsBaseColorSpace {
public:
KisAlphaColorSpace(KisColorSpaceFactoryRegistry * parent,
KisProfile *p);
......@@ -69,7 +70,7 @@ protected:
* Returns false if the conversion failed, true if it succeeded
*/
virtual bool convertPixelsTo(const quint8 *src,
quint8 *dst, KisAbstractColorSpace * dstColorSpace,
quint8 *dst, KisColorSpace * dstColorSpace,
quint32 numPixels,
qint32 renderingIntent = INTENT_PERCEPTUAL);
......
......@@ -34,9 +34,11 @@
#include "kis_integer_maths.h"
KisLabColorSpace::KisLabColorSpace(KisColorSpaceFactoryRegistry * parent, KisProfile *p)
: KisU16BaseColorSpace(KisID("LABA", i18n("L*a*b* (16-bit integer/channel)")),
: KisColorSpace(KisID("LABA", i18n("L*a*b* (16-bit integer/channel)")), parent)
, KisU16BaseColorSpace(CHANNEL_ALPHA * sizeof(quint16))
, KisLcmsBaseColorSpace(
COLORSPACE_SH(PT_Lab)|CHANNELS_SH(3)|BYTES_SH(2)|EXTRA_SH(1),
icSigLabData, parent, p)
icSigLabData, p)
{
m_channels.push_back(new KisChannelInfo(i18n("Lightness"), CHANNEL_L * sizeof(quint16), KisChannelInfo::COLOR, KisChannelInfo::UINT16, sizeof(quint16), QColor(100,100,100)));
......@@ -44,8 +46,6 @@ KisLabColorSpace::KisLabColorSpace(KisColorSpaceFactoryRegistry * parent, KisPro
m_channels.push_back(new KisChannelInfo(i18n("b*"), CHANNEL_B * sizeof(quint16), KisChannelInfo::COLOR, KisChannelInfo::UINT16, sizeof(quint16), QColor(200,200,200)));
m_channels.push_back(new KisChannelInfo(i18n("Alpha"), CHANNEL_ALPHA * sizeof(quint16), KisChannelInfo::ALPHA, KisChannelInfo::UINT16, sizeof(quint16)));
m_alphaPos = CHANNEL_ALPHA * sizeof(quint16);
init();
}
......@@ -53,18 +53,14 @@ KisLabColorSpace::~KisLabColorSpace()
{
}
quint8 * KisLabColorSpace::toLabA16(const quint8 * data, const quint32 nPixels) const
void KisLabColorSpace::toLabA16(const quint8 * src, quint8 *dst, const quint32 nPixels) const
{
quint8 * pixels = new quint8[nPixels * pixelSize()];
memcpy( pixels, data, nPixels * pixelSize() );
return pixels;
memcpy( dst, src, nPixels * pixelSize() );
}
quint8 * KisLabColorSpace::fromLabA16(const quint8 * labData, const quint32 nPixels) const
void KisLabColorSpace::fromLabA16(const quint8 *src, quint8 *dst, const quint32 nPixels) const
{
quint8 * pixels = new quint8[nPixels * pixelSize()];
memcpy( pixels, labData, nPixels * pixelSize() );
return pixels;
memcpy( dst, src, nPixels * pixelSize() );
}
......@@ -154,7 +150,7 @@ void KisLabColorSpace::convolveColors(quint8** colors, qint32 * kernelValues, Ki
quint8 *dst, qint32 factor, qint32 offset, qint32 nColors) const
{
// XXX: Either do this native, or do this in 16 bit rgba, not this, which is going back to QColor!
KisAbstractColorSpace::convolveColors(colors, kernelValues, channelFlags, dst, factor, offset, nColors);
KisLcmsBaseColorSpace::convolveColors(colors, kernelValues, channelFlags, dst, factor, offset, nColors);
}
void KisLabColorSpace::darken(const quint8 * src, quint8 * dst, qint32 shade, bool compensate, double compensation, qint32 nPixels) const
......
......@@ -27,7 +27,7 @@
#include "kis_integer_maths.h"
#include "kis_u16_base_colorspace.h"
class KisLabColorSpace : public KisU16BaseColorSpace {
class KisLabColorSpace : public KisU16BaseColorSpace, public KisLcmsBaseColorSpace {
public:
KisLabColorSpace(KisColorSpaceFactoryRegistry * parent, KisProfile *p);
virtual ~KisLabColorSpace();
......@@ -35,16 +35,16 @@ public:
public:
/**
* Return a COPY of the provided data. This method is provided to provide consistency,
* simply COPY the provided data. This method is provided to provide consistency,
* but you really don't want to be calling it.
*/
virtual quint8 * toLabA16(const quint8 * data, const quint32 nPixels) const;
virtual void toLabA16(const quint8 *src, quint8 * dst, const quint32 nPixels) const;
/**
* Return a COPY of the provided data. This method is provided for consistency,
* simply COPY the provided data. This method is provided for consistency,
* but you really don't want to call it.
*/
virtual quint8 * fromLabA16(const quint8 * labData, const quint32 nPixels) const;
virtual void fromLabA16(const quint8 *src, quint8 * dst, const quint32 nPixels) const;
......
......@@ -19,7 +19,9 @@
#include "kis_colorspace.h"
#include "kis_colorspace_iface.h"
KisColorSpace::KisColorSpace()
KisColorSpace::KisColorSpace(const KisID &id, KisColorSpaceFactoryRegistry * parent)
: m_id(id)
, m_parent( parent )
{
m_dcop = 0;
}
......@@ -37,3 +39,25 @@ DCOPObject * KisColorSpace::dcopObject()
}
return m_dcop;
}
quint8 *KisColorSpace::allocPixelBuffer(quint32 numPixels) const
{
return new quint8[pixelSize()*numPixels];
}
bool KisColorSpace::convertPixelsTo(const quint8 * src,
quint8 * dst,
KisColorSpace * dstColorSpace,
quint32 numPixels,
qint32 renderingIntent)
{
// 4 channels: labA, 2 bytes per lab channel
quint8 *pixels = new quint8[2*4*numPixels];
toLabA16(src, pixels,numPixels);
dstColorSpace->fromLabA16(pixels, dst,numPixels);
delete [] pixels;
return true;
}
......@@ -57,10 +57,13 @@ enum ColorSpaceIndependence {