Commit 9cf098ce authored by Boudewijn Rempt's avatar Boudewijn Rempt

Make composite copy visible again

Commit 84e57495069833f647f7a41511d451eafae69737 dated Sep 17 2011
by  Silvio Heinrich (Replaced the old composite op ComboBox with a new one.)
replaced the dynamic userVisible method of showing/hiding composite ops
with a map.

This commit adds COMPOSITE_COPY to that map. Next commit will remove
userVisbile everywhere.
parent b19f5608
......@@ -38,18 +38,18 @@ KoCompositeOpRegistry::KoCompositeOpRegistry()
<< KoID("hsi" , i18n("HSI"))
<< KoID("hsl" , i18n("HSL"))
<< KoID("hsv" , i18n("HSV"));
m_map.insert(m_categories[0], KoID(COMPOSITE_ADD , i18n("Addition")));
m_map.insert(m_categories[0], KoID(COMPOSITE_SUBTRACT , i18n("Substract")));
m_map.insert(m_categories[0], KoID(COMPOSITE_MULT , i18n("Multiply")));
m_map.insert(m_categories[0], KoID(COMPOSITE_DIVIDE , i18n("Divide")));
m_map.insert(m_categories[0], KoID(COMPOSITE_INVERSE_SUBTRACT, i18n("Inverse Substract")));
m_map.insert(m_categories[1], KoID(COMPOSITE_BURN , i18n("Burn")));
m_map.insert(m_categories[1], KoID(COMPOSITE_LINEAR_BURN, i18n("Linear Burn")));
m_map.insert(m_categories[1], KoID(COMPOSITE_DARKEN , i18n("Darken")));
m_map.insert(m_categories[1], KoID(COMPOSITE_GAMMA_DARK , i18n("Gamma Dark")));
m_map.insert(m_categories[2], KoID(COMPOSITE_DODGE , i18n("Color Dodge")));
m_map.insert(m_categories[2], KoID(COMPOSITE_LINEAR_DODGE, i18n("Linear Dodge")));
m_map.insert(m_categories[2], KoID(COMPOSITE_LIGHTEN , i18n("Lighten")));
......@@ -60,13 +60,13 @@ KoCompositeOpRegistry::KoCompositeOpRegistry()
m_map.insert(m_categories[2], KoID(COMPOSITE_HARD_LIGHT , i18n("Hard Light")));
m_map.insert(m_categories[2], KoID(COMPOSITE_SOFT_LIGHT , i18n("Soft Light")));
m_map.insert(m_categories[2], KoID(COMPOSITE_GAMMA_LIGHT , i18n("Gamma Light")));
m_map.insert(m_categories[3], KoID(COMPOSITE_DIFF , i18n("Difference")));
m_map.insert(m_categories[3], KoID(COMPOSITE_EQUIVALENCE , i18n("Equivalence")));
m_map.insert(m_categories[3], KoID(COMPOSITE_ADDITIVE_SUBSTRACTIVE, i18n("Additive Substractive")));
m_map.insert(m_categories[3], KoID(COMPOSITE_EXCLUSION , i18n("Exclusion")));
m_map.insert(m_categories[3], KoID(COMPOSITE_ARC_TANGENT , i18n("Arcus Tangent")));
m_map.insert(m_categories[4], KoID(COMPOSITE_OVER , i18n("Normal")));
m_map.insert(m_categories[4], KoID(COMPOSITE_OVERLAY , i18n("Overlay")));
m_map.insert(m_categories[4], KoID(COMPOSITE_ERASE , i18n("Erase")));
......@@ -77,13 +77,14 @@ KoCompositeOpRegistry::KoCompositeOpRegistry()
m_map.insert(m_categories[4], KoID(COMPOSITE_PARALLEL , i18n("Parallel")));
m_map.insert(m_categories[4], KoID(COMPOSITE_ALLANON , i18n("Allanon")));
m_map.insert(m_categories[4], KoID(COMPOSITE_GEOMETRIC_MEAN, i18n("Geometric Mean")));
m_map.insert(m_categories[5], KoID(COMPOSITE_BUMPMAP , i18n("Bumpmap")));
m_map.insert(m_categories[5], KoID(COMPOSITE_DISSOLVE , i18n("Dissolve")));
m_map.insert(m_categories[5], KoID(COMPOSITE_COPY_RED , i18n("Copy Red")));
m_map.insert(m_categories[5], KoID(COMPOSITE_COPY_GREEN, i18n("Copy Green")));
m_map.insert(m_categories[5], KoID(COMPOSITE_COPY_BLUE , i18n("Copy Blue")));
m_map.insert(m_categories[5], KoID(COMPOSITE_COPY , i18n("Copy")));
m_map.insert(m_categories[6], KoID(COMPOSITE_COLOR , i18n("Color")));
m_map.insert(m_categories[6], KoID(COMPOSITE_HUE , i18n("Hue")));
m_map.insert(m_categories[6], KoID(COMPOSITE_SATURATION , i18n("Saturation")));
......@@ -92,7 +93,7 @@ KoCompositeOpRegistry::KoCompositeOpRegistry()
m_map.insert(m_categories[6], KoID(COMPOSITE_INC_SATURATION, i18n("Increase Saturation")));
m_map.insert(m_categories[6], KoID(COMPOSITE_DEC_LUMINOSITY, i18n("Decrease Luminosity")));
m_map.insert(m_categories[6], KoID(COMPOSITE_INC_LUMINOSITY, i18n("Increase Luminosity")));
m_map.insert(m_categories[7], KoID(COMPOSITE_COLOR_HSI , i18n("Color HSI")));
m_map.insert(m_categories[7], KoID(COMPOSITE_HUE_HSI , i18n("Hue HSI")));
m_map.insert(m_categories[7], KoID(COMPOSITE_SATURATION_HSI , i18n("Saturation HSI")));
......@@ -101,7 +102,7 @@ KoCompositeOpRegistry::KoCompositeOpRegistry()
m_map.insert(m_categories[7], KoID(COMPOSITE_INC_SATURATION_HSI, i18n("Increase Saturation HSI")));
m_map.insert(m_categories[7], KoID(COMPOSITE_DEC_INTENSITY , i18n("Decrease Intensity")));
m_map.insert(m_categories[7], KoID(COMPOSITE_INC_INTENSITY , i18n("Increase Intensity")));
m_map.insert(m_categories[8], KoID(COMPOSITE_COLOR_HSL , i18n("Color HSL")));
m_map.insert(m_categories[8], KoID(COMPOSITE_HUE_HSL , i18n("Hue HSL")));
m_map.insert(m_categories[8], KoID(COMPOSITE_SATURATION_HSL , i18n("Saturation HSL")));
......@@ -110,7 +111,7 @@ KoCompositeOpRegistry::KoCompositeOpRegistry()
m_map.insert(m_categories[8], KoID(COMPOSITE_INC_SATURATION_HSL, i18n("Increase Saturation HSL")));
m_map.insert(m_categories[8], KoID(COMPOSITE_DEC_LIGHTNESS , i18n("Decrease Lightness")));
m_map.insert(m_categories[8], KoID(COMPOSITE_INC_LIGHTNESS , i18n("Increase Lightness")));
m_map.insert(m_categories[9], KoID(COMPOSITE_COLOR_HSV , i18n("Color HSV")));
m_map.insert(m_categories[9], KoID(COMPOSITE_HUE_HSV , i18n("Hue HSV")));
m_map.insert(m_categories[9], KoID(COMPOSITE_SATURATION_HSV , i18n("Saturation HSV")));
......@@ -153,14 +154,14 @@ KoCompositeOpRegistry::KoIDList KoCompositeOpRegistry::getCompositeOps(const KoI
qint32 num = m_map.count(category);
KoIDMap::const_iterator beg = m_map.find(category);
KoIDMap::const_iterator end = beg + num;
KoIDList list;
#if QT_VERSION >= 0x040700
list.reserve(num);
#endif
if(colorSpace) {
for(; beg!=end; ++beg){
for(; beg!=end; ++beg){
if(colorSpace->hasCompositeOp(beg->id()))
list.push_back(*beg);
}
......@@ -169,7 +170,7 @@ KoCompositeOpRegistry::KoIDList KoCompositeOpRegistry::getCompositeOps(const KoI
for(; beg!=end; ++beg)
list.push_back(*beg);
}
return list;
}
......@@ -177,14 +178,14 @@ KoCompositeOpRegistry::KoIDList KoCompositeOpRegistry::getCompositeOps(const KoC
{
KoIDMap::const_iterator beg = m_map.begin();
KoIDMap::const_iterator end = m_map.end();
KoIDList list;
#if QT_VERSION >= 0x040700
list.reserve(m_map.size());
#endif
if(colorSpace) {
for(; beg!=end; ++beg){
for(; beg!=end; ++beg){
if(colorSpace->hasCompositeOp(beg->id()))
list.push_back(*beg);
}
......@@ -193,7 +194,7 @@ KoCompositeOpRegistry::KoIDList KoCompositeOpRegistry::getCompositeOps(const KoC
for(; beg!=end; ++beg)
list.push_back(*beg);
}
return list;
}
......
......@@ -134,10 +134,10 @@ class PIGMENTCMS_EXPORT KoCompositeOpRegistry
typedef QMultiMap<KoID,KoID> KoIDMap;
typedef QList<KoID> KoIDList;
KoCompositeOpRegistry();
public:
static const KoCompositeOpRegistry& instance();
KoID getDefaultCompositeOp() const;
KoID getKoID(const QString& compositeOpID) const;
KoIDMap getCompositeOps() const;
......@@ -145,19 +145,19 @@ public:
KoIDList getCompositeOps(const KoColorSpace* colorSpace) const;
KoIDList getCompositeOps(const KoID& category, const KoColorSpace* colorSpace=0) const;
bool colorSpaceHasCompositeOp(const KoColorSpace* colorSpace, const KoID& compositeOp) const;
template<class TKoIdIterator>
KoIDList filterCompositeOps(TKoIdIterator begin, TKoIdIterator end, const KoColorSpace* colorSpace, bool removeInvaliOps=true) const {
KoIDList list;
for(; begin!=end; ++begin){
for(; begin!=end; ++begin){
if( colorSpaceHasCompositeOp(colorSpace, *begin) == removeInvaliOps)
list.push_back(*begin);
}
return list;
}
private:
KoIDList m_categories;
KoIDMap m_map;
......@@ -170,7 +170,7 @@ class PIGMENTCMS_EXPORT KoCompositeOp
{
public:
static QString categoryColor();
static QString categoryArithmetic();
static QString categoryNegative();
static QString categoryLight();
......@@ -181,7 +181,7 @@ public:
static QString categoryHSV();
static QString categoryMix();
static QString categoryMisc();
struct ParameterInfo
{
quint8* dstRowStart;
......@@ -196,7 +196,7 @@ public:
float flow;
QBitArray channelFlags;
};
public:
/**
......@@ -230,11 +230,11 @@ public:
* @return the category associated with the composite op
*/
QString category() const;
// WARNING: A derived class needs to overwrite at least one
// of the following virtual methods or a call to
// composite(...) will lead to an endless recursion/stack overflow
/**
* @param dstRowStart pointer to the start of the byte array we will composite the source on
* @param dstRowStride length of the rows of the block of destination pixels in bytes
......@@ -255,12 +255,12 @@ public:
const quint8 *maskRowStart, qint32 maskRowStride,
qint32 rows, qint32 numColumns,
quint8 opacity, const QBitArray& channelFlags=QBitArray()) const;
/**
* Same as previous, but uses a parameter structure
*/
virtual void composite(const ParameterInfo& params) const;
private:
KoCompositeOp();
struct Private;
......
......@@ -26,21 +26,21 @@
#include "KoCompositeOpBase.h"
/**
* Generic implementation of the COPY composite op. That respect selection.
* Generic implementation of the COPY composite op which respects selection.
*/
template<class Traits>
class KoCompositeOpCopy2: public KoCompositeOpBase< Traits, KoCompositeOpCopy2<Traits> >
{
typedef KoCompositeOpBase< Traits, KoCompositeOpCopy2<Traits> > base_class;
typedef typename Traits::channels_type channels_type;
static const qint32 channels_nb = Traits::channels_nb;
static const qint32 alpha_pos = Traits::alpha_pos;
public:
KoCompositeOpCopy2(const KoColorSpace* cs)
: base_class(cs, COMPOSITE_COPY, i18n("Copy"), KoCompositeOp::categoryMisc(), false) { }
: base_class(cs, COMPOSITE_COPY, i18n("Copy"), KoCompositeOp::categoryMisc(), true) { }
public:
template<bool alphaLocked, bool allChannelFlags>
inline static channels_type composeColorChannels(const channels_type* src, channels_type srcAlpha,
......@@ -48,11 +48,11 @@ public:
channels_type opacity, const QBitArray& channelFlags) {
using namespace Arithmetic;
opacity = mul(maskAlpha, opacity);
if(dstAlpha != zeroValue<channels_type>()) {
// blend the color channels
for(qint32 i=0; i<channels_nb; ++i)
if(i != alpha_pos && (allChannelFlags || channelFlags.testBit(i)))
if(i != alpha_pos && (allChannelFlags || channelFlags.testBit(i)))
dst[i] = lerp(dst[i], src[i], opacity);
}
else {
......@@ -62,7 +62,7 @@ public:
if(i != alpha_pos && (allChannelFlags || channelFlags.testBit(i)))
dst[i] = src[i];
}
// blend the alpha channel
return lerp(dstAlpha, srcAlpha, opacity);
}
......
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