[PATCH 05/15] Reset the Burn and Dodge CompositeOps files to their original state.

Silvio Heinrich plassy at web.de
Sat Jan 8 13:09:59 CET 2011


This files are not needed anymore KoCompositeOpGeneric is used instead
---
 libs/pigment/compositeops/KoCompositeOpBurn.h  |   52 +++++++++++++----------
 libs/pigment/compositeops/KoCompositeOpDodge.h |   49 ++++++++++++----------
 2 files changed, 55 insertions(+), 46 deletions(-)

diff --git a/libs/pigment/compositeops/KoCompositeOpBurn.h b/libs/pigment/compositeops/KoCompositeOpBurn.h
index 857efea..97feaa4 100644
--- a/libs/pigment/compositeops/KoCompositeOpBurn.h
+++ b/libs/pigment/compositeops/KoCompositeOpBurn.h
@@ -20,42 +20,48 @@
 #ifndef KOCOMPOSITEOPBURN_H_
 #define KOCOMPOSITEOPBURN_H_
 
-#include "KoCompositeOpFunctions.h"
+#include "KoCompositeOpAlphaBase.h"
 
 /**
  * A template version of the burn composite operation to use in colorspaces.
  */
 template<class _CSTraits>
-class KoCompositeOpBurn : public KoCompositeOpBase< _CSTraits, KoCompositeOpBurn<_CSTraits> >
+class KoCompositeOpBurn : public KoCompositeOpAlphaBase<_CSTraits, KoCompositeOpBurn<_CSTraits>, true >
 {
     typedef typename _CSTraits::channels_type channels_type;
-    typedef typename KoColorSpaceMathsTraits<channels_type>::compositetype composite_type;
-    static const qint32 channels_nb = _CSTraits::channels_nb;
-    static const qint32 alpha_pos   = _CSTraits::alpha_pos;
-    
+    typedef typename KoColorSpaceMathsTraits<typename _CSTraits::channels_type>::compositetype compositetype;
 public:
-    KoCompositeOpBurn(const KoColorSpace* cs)
-        : KoCompositeOpBase< _CSTraits, KoCompositeOpBurn<_CSTraits> >(cs, COMPOSITE_BURN, i18n("Burn"), KoCompositeOp::categoryLight(), true) { }
+
+    KoCompositeOpBurn(const KoColorSpace * cs)
+            : KoCompositeOpAlphaBase<_CSTraits, KoCompositeOpBurn<_CSTraits>, true >(cs, COMPOSITE_BURN, i18n("Burn"), KoCompositeOp::categoryLight()) {
+    }
 
 public:
-    inline static channels_type composeColorChannels(const channels_type* src, channels_type srcAlpha,
-                                                     channels_type* dst, channels_type dstAlpha,
-                                                     channels_type opacity, const QBitArray& channelFlags) {
-        srcAlpha = mul(srcAlpha, opacity);
-        
-        channels_type newDstAlpha = unionShapeOpacy(srcAlpha, dstAlpha);
-        
-        if(newDstAlpha != KoColorSpaceMathsTraits<channels_type>::zeroValue) {
-            for(qint32 i=0; i <channels_nb; i++) {
-                if(i != alpha_pos && channelFlags.testBit(i)) {
-                    channels_type result = blend(src[i], srcAlpha, dst[i], dstAlpha, &cfColorBurn<channels_type>);
-                    dst[i] = div(result, newDstAlpha);
-                }
+    inline static channels_type selectAlpha(channels_type srcAlpha, channels_type dstAlpha) {
+        return qMin(srcAlpha, dstAlpha);
+    }
+
+    inline static void composeColorChannels(channels_type srcBlend,
+                                            const channels_type* src,
+                                            channels_type* dst,
+                                            bool allChannelFlags,
+                                            const QBitArray & channelFlags) {
+        for (uint i = 0; i < _CSTraits::channels_nb; i++) {
+            if ((int)i != _CSTraits::alpha_pos && (allChannelFlags || channelFlags.testBit(i))) {
+                compositetype srcColor = src[i];
+                compositetype dstColor = dst[i];
+
+                srcColor = qMin(((NATIVE_MAX_VALUE - dstColor) * (NATIVE_MAX_VALUE + 1)) / (srcColor + 1), (compositetype)NATIVE_MAX_VALUE);
+                if (NATIVE_MAX_VALUE - srcColor > NATIVE_MAX_VALUE) srcColor = NATIVE_MAX_VALUE;
+
+                channels_type newColor = NATIVE_MAX_VALUE - KoColorSpaceMaths<channels_type>::blend(srcColor, dstColor, srcBlend);
+
+                dst[i] = newColor;
             }
         }
-        
-        return newDstAlpha;
     }
+
+
 };
 
 #endif
diff --git a/libs/pigment/compositeops/KoCompositeOpDodge.h b/libs/pigment/compositeops/KoCompositeOpDodge.h
index 815d273..368a26b 100644
--- a/libs/pigment/compositeops/KoCompositeOpDodge.h
+++ b/libs/pigment/compositeops/KoCompositeOpDodge.h
@@ -1,7 +1,6 @@
 /*
  *  Copyright (c) 2007 Cyrille Berger <cberger at cberger.net>
- *  Copyright (c) 2011 Silvio Heinrich <plassy at web.de>
- * 
+ *
  * 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
@@ -21,40 +20,44 @@
 #ifndef _KOCOMPOSITEOPDODGE_H_
 #define _KOCOMPOSITEOPDODGE_H_
 
-#include "KoCompositeOpFunctions.h"
+#include "KoCompositeOpAlphaBase.h"
+
 
 /**
  * A template version of the dodge composite operation to use in colorspaces.
  */
 template<class _CSTraits>
-class KoCompositeOpDodge : public KoCompositeOpBase< _CSTraits, KoCompositeOpDodge<_CSTraits> >
+class KoCompositeOpDodge : public KoCompositeOpAlphaBase<_CSTraits, KoCompositeOpDodge<_CSTraits>, true >
 {
     typedef typename _CSTraits::channels_type channels_type;
-    typedef typename KoColorSpaceMathsTraits<channels_type>::compositetype composite_type;
-    static const qint32 channels_nb = _CSTraits::channels_nb;
-    static const qint32 alpha_pos   = _CSTraits::alpha_pos;
+    typedef typename KoColorSpaceMathsTraits<typename _CSTraits::channels_type>::compositetype compositetype;
 public:
+
     KoCompositeOpDodge(const KoColorSpace * cs)
-        : KoCompositeOpBase< _CSTraits, KoCompositeOpDodge<_CSTraits> >(cs, COMPOSITE_DODGE, i18n("Dodge"), KoCompositeOp::categoryLight(), true) { }
+            : KoCompositeOpAlphaBase<_CSTraits, KoCompositeOpDodge<_CSTraits>, true >(cs, COMPOSITE_DODGE, i18n("Dodge"), KoCompositeOp::categoryLight()) {
+    }
 
 public:
-    inline static channels_type composeColorChannels(const channels_type* src, channels_type srcAlpha,
-                                                     channels_type* dst, channels_type dstAlpha,
-                                                     channels_type opacity, const QBitArray& channelFlags) {
-        srcAlpha = mul(srcAlpha, opacity);
-        
-        channels_type newDstAlpha = unionShapeOpacy(srcAlpha, dstAlpha);
-        
-        if(newDstAlpha != KoColorSpaceMathsTraits<channels_type>::zeroValue) {
-            for(qint32 i=0; i <channels_nb; i++) {
-                if(i != alpha_pos && channelFlags.testBit(i)) {
-                    channels_type result = blend(src[i], srcAlpha, dst[i], dstAlpha, &cfColorDodge<channels_type>);
-                    dst[i] = div(result, newDstAlpha);
-                }
+    inline static channels_type selectAlpha(channels_type srcAlpha, channels_type dstAlpha) {
+        return qMin(srcAlpha, dstAlpha);
+    }
+    inline static void composeColorChannels(channels_type srcBlend,
+                                            const channels_type* src,
+                                            channels_type* dst,
+                                            bool allChannelFlags,
+                                            const QBitArray & channelFlags) {
+        for (uint channel = 0; channel < _CSTraits::channels_nb; channel++) {
+            if ((int)channel != _CSTraits::alpha_pos && (allChannelFlags || channelFlags.testBit(channel))) {
+                compositetype srcColor = src[channel];
+                compositetype dstColor = dst[channel];
+
+                srcColor = qMin((compositetype)(dstColor * (NATIVE_MAX_VALUE + 1)) / (NATIVE_MAX_VALUE + 1 - srcColor), (compositetype)NATIVE_MAX_VALUE);
+
+                channels_type newColor = KoColorSpaceMaths<channels_type>::blend(srcColor, dstColor, srcBlend);
+
+                dst[channel] = newColor;
             }
         }
-        
-        return newDstAlpha;
     }
 
 };
-- 
1.7.1




More information about the kimageshop mailing list