[Marble-devel] [PATCH 06/13] Move blending related classe to src/lib/blendings.
Jens-Michael Hoffmann
jensmh at gmx.de
Tue Mar 30 20:32:13 CEST 2010
Move blending related classe to src/lib/blendings.
---
marble/src/lib/Blending.cpp | 25 --
marble/src/lib/Blending.h | 36 ---
marble/src/lib/BlendingAlgorithms.cpp | 285 --------------------
marble/src/lib/BlendingAlgorithms.h | 246 -----------------
marble/src/lib/BlendingFactory.cpp | 88 ------
marble/src/lib/BlendingFactory.h | 40 ---
marble/src/lib/CMakeLists.txt | 6 +-
marble/src/lib/StackedTile.cpp | 2 +-
marble/src/lib/blendings/Blending.cpp | 25 ++
marble/src/lib/blendings/Blending.h | 36 +++
marble/src/lib/blendings/BlendingAlgorithms.cpp | 285 ++++++++++++++++++++
marble/src/lib/blendings/BlendingAlgorithms.h | 246 +++++++++++++++++
marble/src/lib/blendings/BlendingFactory.cpp | 88 ++++++
marble/src/lib/blendings/BlendingFactory.h | 40 +++
.../handlers/dgml/DgmlBlendingTagHandler.cpp | 2 +-
15 files changed, 725 insertions(+), 725 deletions(-)
delete mode 100644 marble/src/lib/Blending.cpp
delete mode 100644 marble/src/lib/Blending.h
delete mode 100644 marble/src/lib/BlendingAlgorithms.cpp
delete mode 100644 marble/src/lib/BlendingAlgorithms.h
delete mode 100644 marble/src/lib/BlendingFactory.cpp
delete mode 100644 marble/src/lib/BlendingFactory.h
create mode 100644 marble/src/lib/blendings/Blending.cpp
create mode 100644 marble/src/lib/blendings/Blending.h
create mode 100644 marble/src/lib/blendings/BlendingAlgorithms.cpp
create mode 100644 marble/src/lib/blendings/BlendingAlgorithms.h
create mode 100644 marble/src/lib/blendings/BlendingFactory.cpp
create mode 100644 marble/src/lib/blendings/BlendingFactory.h
diff --git a/marble/src/lib/Blending.cpp b/marble/src/lib/Blending.cpp
deleted file mode 100644
index 6b3100d..0000000
--- a/marble/src/lib/Blending.cpp
+++ /dev/null
@@ -1,25 +0,0 @@
-// Copyright 2010 Jens-Michael Hoffmann <jmho at c-xx.com>
-//
-// 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
-// version 2.1 of the License, or (at your option) any later version.
-//
-// This library 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
-// Lesser General Public License for more details.
-//
-// You should have received a copy of the GNU Lesser General Public
-// License along with this library. If not, see <http://www.gnu.org/licenses/>.
-
-#include "Blending.h"
-
-namespace Marble
-{
-
-Blending::~Blending()
-{
-}
-
-}
diff --git a/marble/src/lib/Blending.h b/marble/src/lib/Blending.h
deleted file mode 100644
index e9e3b42..0000000
--- a/marble/src/lib/Blending.h
+++ /dev/null
@@ -1,36 +0,0 @@
-// Copyright 2010 Jens-Michael Hoffmann <jmho at c-xx.com>
-//
-// 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
-// version 2.1 of the License, or (at your option) any later version.
-//
-// This library 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
-// Lesser General Public License for more details.
-//
-// You should have received a copy of the GNU Lesser General Public
-// License along with this library. If not, see <http://www.gnu.org/licenses/>.
-
-#ifndef MARBLE_BLENDING_H
-#define MARBLE_BLENDING_H
-
-#include <QtCore/QSharedPointer>
-
-class QImage;
-
-namespace Marble
-{
-class TextureTile;
-
-class Blending
-{
- public:
- virtual ~Blending();
- virtual void blend( QImage * const bottom, QSharedPointer<TextureTile> const & top ) const = 0;
-};
-
-}
-
-#endif
diff --git a/marble/src/lib/BlendingAlgorithms.cpp b/marble/src/lib/BlendingAlgorithms.cpp
deleted file mode 100644
index a11bd2e..0000000
--- a/marble/src/lib/BlendingAlgorithms.cpp
+++ /dev/null
@@ -1,285 +0,0 @@
-// Copyright 2010 Jens-Michael Hoffmann <jmho at c-xx.com>
-//
-// 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
-// version 2.1 of the License, or (at your option) any later version.
-//
-// This library 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
-// Lesser General Public License for more details.
-//
-// You should have received a copy of the GNU Lesser General Public
-// License along with this library. If not, see <http://www.gnu.org/licenses/>.
-
-#include "BlendingAlgorithms.h"
-
-#include "TextureTile.h"
-
-#include <cmath>
-
-#include <QtGui/QImage>
-
-namespace Marble
-{
-
-void IndependentChannelBlending::blend( QImage * const bottom, QSharedPointer<TextureTile> const & top ) const
-{
- QImage const * const topImage = top->image();
- Q_ASSERT( topImage );
- Q_ASSERT( bottom->size() == topImage->size() );
- int const width = bottom->width();
- int const height = bottom->height();
- for ( int y = 0; y < height; ++y ) {
- for ( int x = 0; x < width; ++x ) {
- QRgb const bottomPixel = bottom->pixel( x, y );
- QRgb const topPixel = topImage->pixel( x, y );
- qreal const resultRed = blendChannel( qRed( bottomPixel ) / 255.0,
- qRed( topPixel ) / 255.0 );
- qreal const resultGreen = blendChannel( qGreen( bottomPixel ) / 255.0,
- qGreen( topPixel ) / 255.0 );
- qreal const resultBlue = blendChannel( qBlue( bottomPixel ) / 255.0,
- qBlue( topPixel ) / 255.0 );
- bottom->setPixel( x, y, qRgb( resultRed * 255.0,
- resultGreen * 255.0,
- resultBlue * 255.0 ));
- }
- }
-}
-
-
-// Neutral blendings
-
-qreal AllanonBlending::blendChannel( qreal const bottomColorIntensity,
- qreal const topColorIntensity ) const
-{
- return ( bottomColorIntensity + topColorIntensity ) / 2.0;
-}
-
-qreal ArcusTangentBlending::blendChannel( qreal const bottomColorIntensity,
- qreal const topColorIntensity ) const
-{
- return 2.0 * atan( topColorIntensity / bottomColorIntensity ) / M_PI;
-}
-
-qreal GeometricMeanBlending::blendChannel( qreal const bottomColorIntensity,
- qreal const topColorIntensity ) const
-{
- return sqrt( bottomColorIntensity * topColorIntensity );
-}
-
-qreal LinearLightBlending::blendChannel( qreal const bottomColorIntensity,
- qreal const topColorIntensity ) const
-{
- return qMin( 1.0, qMax( 0.0, ( bottomColorIntensity + 2.0 * topColorIntensity ) - 1.0 ));
-}
-
-qreal OverlayBlending::blendChannel( qreal const bottomColorIntensity,
- qreal const topColorIntensity ) const
-{
- if ( bottomColorIntensity < 0.5 )
- return 2.0 * bottomColorIntensity * topColorIntensity;
- else
- return 1.0 - 2.0 * ( 1.0 - bottomColorIntensity ) * ( 1.0 - topColorIntensity );
-}
-
-qreal ParallelBlending::blendChannel( qreal const bottomColorIntensity,
- qreal const topColorIntensity ) const
-{
- // FIXME: return qMin( qMax( 2.0 / ( 1.0 / bottomColorIntensity + 1.0 / topColorIntensity )), 0.0, 1.0 );
- return 0.0;
-}
-
-qreal TextureBlending::blendChannel( qreal const bottomColorIntensity,
- qreal const topColorIntensity ) const
-{
- // FIXME: return qMax( qMin( topColorIntensity + bottomColorIntensity ) - 0.5 ), 1.0 ), 0.0 );
- return 0.0;
-}
-
-
-// Darkening blendings
-
-qreal ColorBurnBlending::blendChannel( qreal const bottomColorIntensity,
- qreal const topColorIntensity ) const
-{
- // FIXME: check if this formula makes sense
- return qMin( 1.0, qMax( 0.0, 1.0 - ( 1.0 - bottomColorIntensity ) / topColorIntensity ));
-}
-
-qreal DarkBlending::blendChannel( qreal const bottomColorIntensity,
- qreal const topColorIntensity ) const
-{
- return ( bottomColorIntensity + 1.0 - topColorIntensity ) * topColorIntensity;
-}
-
-qreal DarkenBlending::blendChannel( qreal const bottomColorIntensity,
- qreal const topColorIntensity ) const
-{
- // FIXME: is this really ok? not vice versa?
- return bottomColorIntensity > topColorIntensity ? topColorIntensity : bottomColorIntensity;
-}
-
-qreal DivideBlending::blendChannel( qreal const bottomColorIntensity,
- qreal const topColorIntensity ) const
-{
- return log2( 1.0 + bottomColorIntensity / ( 1.0 - topColorIntensity ) / 8.0 );
-}
-
-qreal GammaDarkBlending::blendChannel( qreal const bottomColorIntensity,
- qreal const topColorIntensity ) const
-{
- return pow( bottomColorIntensity, 1.0 / topColorIntensity );
-}
-
-qreal LinearBurnBlending::blendChannel( qreal const bottomColorIntensity,
- qreal const topColorIntensity ) const
-{
- return qMax( 0.0, bottomColorIntensity + topColorIntensity - 1.0 );
-}
-
-qreal MultiplyBlending::blendChannel( qreal const bottomColorIntensity,
- qreal const topColorIntensity ) const
-{
- return bottomColorIntensity * topColorIntensity;
-}
-
-qreal SubtractiveBlending::blendChannel( qreal const bottomColorIntensity,
- qreal const topColorIntensity ) const
-{
- return qMax( bottomColorIntensity - topColorIntensity, 0.0 );
-}
-
-
-// Lightening blendings
-
-qreal AdditiveBlending::blendChannel( qreal const bottomColorIntensity,
- qreal const topColorIntensity ) const
-{
- return qMin( topColorIntensity + bottomColorIntensity, 1.0 );
-}
-
-qreal ColorDodgeBlending::blendChannel( qreal const bottomColorIntensity,
- qreal const topColorIntensity ) const
-{
- return qMin( 1.0, qMax( 0.0, bottomColorIntensity / ( 1.0 - topColorIntensity )));
-}
-
-qreal GammaLightBlending::blendChannel( qreal const bottomColorIntensity,
- qreal const topColorIntensity ) const
-{
- return pow( bottomColorIntensity, topColorIntensity );
-}
-
-qreal HardLightBlending::blendChannel( qreal const bottomColorIntensity,
- qreal const topColorIntensity ) const
-{
- return topColorIntensity < 0.5
- ? 2.0 * bottomColorIntensity * topColorIntensity
- : 1.0 - 2.0 * ( 1.0 - bottomColorIntensity ) * ( 1.0 - topColorIntensity );
-}
-
-qreal LightBlending::blendChannel( qreal const bottomColorIntensity,
- qreal const topColorIntensity ) const
-{
- return bottomColorIntensity * ( 1.0 - topColorIntensity ) + pow( topColorIntensity, 2 );
-}
-
-qreal LightenBlending::blendChannel( qreal const bottomColorIntensity,
- qreal const topColorIntensity ) const
-{
- // is this ok?
- return bottomColorIntensity < topColorIntensity ? topColorIntensity : bottomColorIntensity;
-}
-
-qreal PinLightBlending::blendChannel( qreal const bottomColorIntensity,
- qreal const topColorIntensity ) const
-{
- return qMax( 0.0, qMax( 2.0 + topColorIntensity - 1.0,
- qMin( bottomColorIntensity, 2.0 * topColorIntensity )));
-}
-
-qreal ScreenBlending::blendChannel( qreal const bottomColorIntensity,
- qreal const topColorIntensity ) const
-{
- return 1.0 - ( 1.0 - bottomColorIntensity ) * ( 1.0 - topColorIntensity );
-}
-
-qreal SoftLightBlending::blendChannel( qreal const bottomColorIntensity,
- qreal const topColorIntensity ) const
-{
- return pow( bottomColorIntensity, pow( 2.0, ( 2.0 * ( 0.5 - topColorIntensity ))));
-}
-
-qreal VividLightBlending::blendChannel( qreal const bottomColorIntensity,
- qreal const topColorIntensity ) const
-{
- return topColorIntensity < 0.5
- ? qMin( 1.0, qMax( 0.0, 1.0 - ( 1.0 - bottomColorIntensity ) / ( 2.0 * topColorIntensity )))
- : qMin( 1.0, qMax( 0.0, bottomColorIntensity / ( 2.0 * ( 1.0 - topColorIntensity ))));
-}
-
-
-// Inverter blendings
-
-qreal AdditiveSubtractiveBlending::blendChannel( qreal const bottomColorIntensity,
- qreal const topColorIntensity ) const
-{
- // FIXME:
- // return qMin( 1.0, qMax( 0.0, abs( bottomColorIntensity * bottomColorIntensity
- // - topColorIntensity * topColorIntensity )));
- return 0.0;
-}
-
-qreal BleachBlending::blendChannel( qreal const bottomColorIntensity,
- qreal const topColorIntensity ) const
-{
- // FIXME: "why this is the same formula as Screen Blending? Please correct.)"
- return 1.0 - ( 1.0 - bottomColorIntensity ) * ( 1.0 - topColorIntensity );
-}
-
-qreal DifferenceBlending::blendChannel( qreal const bottomColorIntensity,
- qreal const topColorIntensity ) const
-{
- return qMax( qMin( 1.0, bottomColorIntensity - topColorIntensity + 0.5 ), 0.0 );
-}
-
-qreal EquivalenceBlending::blendChannel( qreal const bottomColorIntensity,
- qreal const topColorIntensity ) const
-{
- return 1.0 - abs( bottomColorIntensity - topColorIntensity );
-}
-
-qreal HalfDifferenceBlending::blendChannel( qreal const bottomColorIntensity,
- qreal const topColorIntensity ) const
-{
- return bottomColorIntensity + topColorIntensity
- - 2.0 * ( bottomColorIntensity * topColorIntensity );
-}
-
-
-// Special purpose blendings
-
-void CloudsBlending::blend( QImage * const bottom, QSharedPointer<TextureTile> const & top ) const
-{
- QImage const * const topImage = top->image();
- Q_ASSERT( topImage );
- Q_ASSERT( bottom->size() == topImage->size() );
- int const width = bottom->width();
- int const height = bottom->height();
- for ( int y = 0; y < height; ++y ) {
- for ( int x = 0; x < width; ++x ) {
- qreal const c = qRed( topImage->pixel( x, y )) / 255.0;
- QRgb const bottomPixel = bottom->pixel( x, y );
- int const bottomRed = qRed( bottomPixel );
- int const bottomGreen = qGreen( bottomPixel );
- int const bottomBlue = qBlue( bottomPixel );
- bottom->setPixel( x, y, qRgb(( int )( bottomRed + ( 255 - bottomRed ) * c ),
- ( int )( bottomGreen + ( 255 - bottomGreen ) * c ),
- ( int )( bottomBlue + ( 255 - bottomBlue ) * c )));
- }
- }
-}
-
-}
diff --git a/marble/src/lib/BlendingAlgorithms.h b/marble/src/lib/BlendingAlgorithms.h
deleted file mode 100644
index a2987f3..0000000
--- a/marble/src/lib/BlendingAlgorithms.h
+++ /dev/null
@@ -1,246 +0,0 @@
-// Copyright 2010 Jens-Michael Hoffmann <jmho at c-xx.com>
-//
-// 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
-// version 2.1 of the License, or (at your option) any later version.
-//
-// This library 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
-// Lesser General Public License for more details.
-//
-// You should have received a copy of the GNU Lesser General Public
-// License along with this library. If not, see <http://www.gnu.org/licenses/>.
-
-#ifndef MARBLE_BLENDING_ALGORITHMS_H
-#define MARBLE_BLENDING_ALGORITHMS_H
-
-#include <QtCore/QtGlobal>
-
-#include "Blending.h"
-
-namespace Marble
-{
-
-class IndependentChannelBlending: public Blending
-{
- public:
- virtual void blend( QImage * const bottom, QSharedPointer<TextureTile> const & top ) const;
- private:
- // bottomColorIntensity: intensity of one color channel (of one pixel) of the bottom image
- // topColorIntensity: intensity of one color channel (of one pixel) of the top image
- // return: intensity of the color channel (of a given pixel) of the result image
- // all color intensity values are in the range 0..1
- virtual qreal blendChannel( qreal const bottomColorIntensity,
- qreal const topColorIntensity ) const = 0;
-};
-
-
-// Neutral blendings
-
-class AllanonBlending: public IndependentChannelBlending
-{
- virtual qreal blendChannel( qreal const bottomColorIntensity,
- qreal const topColorIntensity ) const;
-};
-
-class ArcusTangentBlending: public IndependentChannelBlending
-{
- virtual qreal blendChannel( qreal const bottomColorIntensity,
- qreal const topColorIntensity ) const;
-};
-
-class GeometricMeanBlending: public IndependentChannelBlending
-{
- virtual qreal blendChannel( qreal const bottomColorIntensity,
- qreal const topColorIntensity ) const;
-};
-
-class LinearLightBlending: public IndependentChannelBlending
-{
- virtual qreal blendChannel( qreal const bottomColorIntensity,
- qreal const topColorIntensity ) const;
-};
-
-class NoiseBlending: public Blending // or IndependentChannelBlending?
-{
-};
-
-class OverlayBlending: public IndependentChannelBlending
-{
- virtual qreal blendChannel( qreal const bottomColorIntensity,
- qreal const topColorIntensity ) const;
-};
-
-class ParallelBlending: public IndependentChannelBlending
-{
- virtual qreal blendChannel( qreal const bottomColorIntensity,
- qreal const topColorIntensity ) const;
-};
-
-class TextureBlending: public IndependentChannelBlending
-{
- virtual qreal blendChannel( qreal const bottomColorIntensity,
- qreal const topColorIntensity ) const;
-};
-
-
-// Darkening blendings
-
-class ColorBurnBlending: public IndependentChannelBlending
-{
- virtual qreal blendChannel( qreal const bottomColorIntensity,
- qreal const topColorIntensity ) const;
-};
-
-class DarkBlending: public IndependentChannelBlending
-{
- virtual qreal blendChannel( qreal const bottomColorIntensity,
- qreal const topColorIntensity ) const;
-};
-
-class DarkenBlending: public IndependentChannelBlending
-{
- virtual qreal blendChannel( qreal const bottomColorIntensity,
- qreal const topColorIntensity ) const;
-};
-
-class DivideBlending: public IndependentChannelBlending
-{
- virtual qreal blendChannel( qreal const bottomColorIntensity,
- qreal const topColorIntensity ) const;
-};
-
-class GammaDarkBlending: public IndependentChannelBlending
-{
- virtual qreal blendChannel( qreal const bottomColorIntensity,
- qreal const topColorIntensity ) const;
-};
-
-class LinearBurnBlending: public IndependentChannelBlending
-{
- virtual qreal blendChannel( qreal const bottomColorIntensity,
- qreal const topColorIntensity ) const;
-};
-
-class MultiplyBlending: public IndependentChannelBlending
-{
- virtual qreal blendChannel( qreal const bottomColorIntensity,
- qreal const topColorIntensity ) const;
-};
-
-class SubtractiveBlending: public IndependentChannelBlending
-{
- virtual qreal blendChannel( qreal const bottomColorIntensity,
- qreal const topColorIntensity ) const;
-};
-
-
-// Lightening blendings
-
-class AdditiveBlending: public IndependentChannelBlending
-{
- virtual qreal blendChannel( qreal const bottomColorIntensity,
- qreal const topColorIntensity ) const;
-};
-
-class ColorDodgeBlending: public IndependentChannelBlending
-{
- virtual qreal blendChannel( qreal const bottomColorIntensity,
- qreal const topColorIntensity ) const;
-};
-
-class GammaLightBlending: public IndependentChannelBlending
-{
- virtual qreal blendChannel( qreal const bottomColorIntensity,
- qreal const topColorIntensity ) const;
-};
-
-class HardLightBlending: public IndependentChannelBlending
-{
- virtual qreal blendChannel( qreal const bottomColorIntensity,
- qreal const topColorIntensity ) const;
-};
-
-class LightBlending: public IndependentChannelBlending
-{
- virtual qreal blendChannel( qreal const bottomColorIntensity,
- qreal const topColorIntensity ) const;
-};
-
-class LightenBlending: public IndependentChannelBlending
-{
- virtual qreal blendChannel( qreal const bottomColorIntensity,
- qreal const topColorIntensity ) const;
-};
-
-class PinLightBlending: public IndependentChannelBlending
-{
- virtual qreal blendChannel( qreal const bottomColorIntensity,
- qreal const topColorIntensity ) const;
-};
-
-class ScreenBlending: public IndependentChannelBlending
-{
- virtual qreal blendChannel( qreal const bottomColorIntensity,
- qreal const topColorIntensity ) const;
-};
-
-class SoftLightBlending: public IndependentChannelBlending
-{
- virtual qreal blendChannel( qreal const bottomColorIntensity,
- qreal const topColorIntensity ) const;
-};
-
-class VividLightBlending: public IndependentChannelBlending
-{
- virtual qreal blendChannel( qreal const bottomColorIntensity,
- qreal const topColorIntensity ) const;
-};
-
-
-// Inverter blendings
-
-class AdditiveSubtractiveBlending: public IndependentChannelBlending
-{
- virtual qreal blendChannel( qreal const bottomColorIntensity,
- qreal const topColorIntensity ) const;
-};
-
-class BleachBlending: public IndependentChannelBlending
-{
- virtual qreal blendChannel( qreal const bottomColorIntensity,
- qreal const topColorIntensity ) const;
-};
-
-class DifferenceBlending: public IndependentChannelBlending
-{
- virtual qreal blendChannel( qreal const bottomColorIntensity,
- qreal const topColorIntensity ) const;
-};
-
-class EquivalenceBlending: public IndependentChannelBlending
-{
- virtual qreal blendChannel( qreal const bottomColorIntensity,
- qreal const topColorIntensity ) const;
-};
-
-class HalfDifferenceBlending: public IndependentChannelBlending
-{
- virtual qreal blendChannel( qreal const bottomColorIntensity,
- qreal const topColorIntensity ) const;
-};
-
-
-// Special purpose blendings
-
-class CloudsBlending: public Blending
-{
- public:
- virtual void blend( QImage * const bottom, QSharedPointer<TextureTile> const & top ) const;
-};
-
-}
-
-#endif
diff --git a/marble/src/lib/BlendingFactory.cpp b/marble/src/lib/BlendingFactory.cpp
deleted file mode 100644
index c9247a3..0000000
--- a/marble/src/lib/BlendingFactory.cpp
+++ /dev/null
@@ -1,88 +0,0 @@
-// Copyright 2010 Jens-Michael Hoffmann <jmho at c-xx.com>
-//
-// 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
-// version 2.1 of the License, or (at your option) any later version.
-//
-// This library 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
-// Lesser General Public License for more details.
-//
-// You should have received a copy of the GNU Lesser General Public
-// License along with this library. If not, see <http://www.gnu.org/licenses/>.
-
-#include "BlendingFactory.h"
-
-#include "blendings/SunLightBlending.h"
-#include "BlendingAlgorithms.h"
-#include "MarbleDebug.h"
-
-namespace Marble
-{
-
-BlendingFactory const * BlendingFactory::s_instance = 0;
-
-BlendingFactory const * BlendingFactory::instance()
-{
- if ( s_instance == 0 )
- s_instance = new BlendingFactory;
- return s_instance;
-}
-
-Blending const * BlendingFactory::findBlending( QString const & name ) const
-{
- Blending const * const result = m_blendings.value( name, 0 );
- if ( !result )
- mDebug() << "BlendingFactory::findBlending: unknown blending:" << name;
- return result;
-}
-
-BlendingFactory::BlendingFactory()
-{
- // Neutral blendings
- m_blendings.insert( "AllanonBlending", new AllanonBlending );
- m_blendings.insert( "ArcusTangentBlending", new ArcusTangentBlending );
- m_blendings.insert( "GeometricMeanBlending", new GeometricMeanBlending );
- m_blendings.insert( "LinearLightBlending", new LinearLightBlending );
- //m_blendings.insert( "NoiseBlending", new NoiseBlending );
- m_blendings.insert( "OverlayBlending", new OverlayBlending );
- m_blendings.insert( "ParallelBlending", new ParallelBlending );
- m_blendings.insert( "TextureBlending", new TextureBlending );
-
- // Darkening blendings
- m_blendings.insert( "ColorBurnBlending", new ColorBurnBlending );
- m_blendings.insert( "DarkBlending", new DarkBlending );
- m_blendings.insert( "DarkenBlending", new DarkenBlending );
- m_blendings.insert( "DivideBlending", new DivideBlending );
- m_blendings.insert( "GammaDarkBlending", new GammaDarkBlending );
- m_blendings.insert( "LinearBurnBlending", new LinearBurnBlending );
- m_blendings.insert( "MultiplyBlending", new MultiplyBlending );
- m_blendings.insert( "SubtractiveBlending", new SubtractiveBlending );
-
- // Lightening blendings
- m_blendings.insert( "AdditiveBlending", new AdditiveBlending );
- m_blendings.insert( "ColorDodgeBlending", new ColorDodgeBlending );
- m_blendings.insert( "GammaLightBlending", new GammaLightBlending );
- m_blendings.insert( "HardLightBlending", new HardLightBlending );
- m_blendings.insert( "LightBlending", new LightBlending );
- m_blendings.insert( "LightenBlending", new LightenBlending );
- m_blendings.insert( "PinLightBlending", new PinLightBlending );
- m_blendings.insert( "ScreenBlending", new ScreenBlending );
- m_blendings.insert( "SoftLightBlending", new SoftLightBlending );
- m_blendings.insert( "VividLightBlending", new VividLightBlending );
-
- // Inverter blendings
- m_blendings.insert( "AdditiveSubtractiveBlending", new AdditiveSubtractiveBlending );
- m_blendings.insert( "BleachBlending", new BleachBlending );
- m_blendings.insert( "DifferenceBlending", new DifferenceBlending );
- m_blendings.insert( "EquivalenceBlending", new EquivalenceBlending );
- m_blendings.insert( "HalfDifferenceBlending", new HalfDifferenceBlending );
-
- // Special purpose blendings
- m_blendings.insert( "CloudsBlending", new CloudsBlending );
- m_blendings.insert( "SunLightBlending", new SunLightBlending );
-}
-
-}
diff --git a/marble/src/lib/BlendingFactory.h b/marble/src/lib/BlendingFactory.h
deleted file mode 100644
index d1bfc68..0000000
--- a/marble/src/lib/BlendingFactory.h
+++ /dev/null
@@ -1,40 +0,0 @@
-// Copyright 2010 Jens-Michael Hoffmann <jmho at c-xx.com>
-//
-// 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
-// version 2.1 of the License, or (at your option) any later version.
-//
-// This library 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
-// Lesser General Public License for more details.
-//
-// You should have received a copy of the GNU Lesser General Public
-// License along with this library. If not, see <http://www.gnu.org/licenses/>.
-
-#ifndef MARBLE_BLENDING_FACTORY_H
-#define MARBLE_BLENDING_FACTORY_H
-
-#include <QtCore/QHash>
-#include <QtCore/QString>
-
-namespace Marble
-{
-class Blending;
-
-class BlendingFactory
-{
- public:
- static BlendingFactory const * instance();
- Blending const * findBlending( QString const & name ) const;
-
- private:
- static BlendingFactory const * s_instance;
- BlendingFactory();
- QHash<QString, Blending const *> m_blendings;
-};
-
-}
-
-#endif
diff --git a/marble/src/lib/CMakeLists.txt b/marble/src/lib/CMakeLists.txt
index 59e4505..88a84c4 100644
--- a/marble/src/lib/CMakeLists.txt
+++ b/marble/src/lib/CMakeLists.txt
@@ -59,10 +59,10 @@ set(marblewidget_SRCS
${geodata_SRCS}
${graphicsview_SRCS}
${screengraphicsitem_SRCS}
+ blendings/Blending.cpp
+ blendings/BlendingAlgorithms.cpp
+ blendings/BlendingFactory.cpp
blendings/SunLightBlending.cpp
- Blending.cpp
- BlendingAlgorithms.cpp
- BlendingFactory.cpp
MarbleWidget.cpp
MarbleModel.cpp
MarbleMap.cpp
diff --git a/marble/src/lib/StackedTile.cpp b/marble/src/lib/StackedTile.cpp
index c3cb0ef..0c2778e 100644
--- a/marble/src/lib/StackedTile.cpp
+++ b/marble/src/lib/StackedTile.cpp
@@ -17,7 +17,7 @@
#include <cmath>
-#include "Blending.h"
+#include "blendings/Blending.h"
#include "GeoSceneTexture.h"
#include "MarbleDebug.h"
#include "TextureTile.h"
diff --git a/marble/src/lib/blendings/Blending.cpp b/marble/src/lib/blendings/Blending.cpp
new file mode 100644
index 0000000..6b3100d
--- /dev/null
+++ b/marble/src/lib/blendings/Blending.cpp
@@ -0,0 +1,25 @@
+// Copyright 2010 Jens-Michael Hoffmann <jmho at c-xx.com>
+//
+// 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
+// version 2.1 of the License, or (at your option) any later version.
+//
+// This library 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
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library. If not, see <http://www.gnu.org/licenses/>.
+
+#include "Blending.h"
+
+namespace Marble
+{
+
+Blending::~Blending()
+{
+}
+
+}
diff --git a/marble/src/lib/blendings/Blending.h b/marble/src/lib/blendings/Blending.h
new file mode 100644
index 0000000..e9e3b42
--- /dev/null
+++ b/marble/src/lib/blendings/Blending.h
@@ -0,0 +1,36 @@
+// Copyright 2010 Jens-Michael Hoffmann <jmho at c-xx.com>
+//
+// 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
+// version 2.1 of the License, or (at your option) any later version.
+//
+// This library 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
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library. If not, see <http://www.gnu.org/licenses/>.
+
+#ifndef MARBLE_BLENDING_H
+#define MARBLE_BLENDING_H
+
+#include <QtCore/QSharedPointer>
+
+class QImage;
+
+namespace Marble
+{
+class TextureTile;
+
+class Blending
+{
+ public:
+ virtual ~Blending();
+ virtual void blend( QImage * const bottom, QSharedPointer<TextureTile> const & top ) const = 0;
+};
+
+}
+
+#endif
diff --git a/marble/src/lib/blendings/BlendingAlgorithms.cpp b/marble/src/lib/blendings/BlendingAlgorithms.cpp
new file mode 100644
index 0000000..a11bd2e
--- /dev/null
+++ b/marble/src/lib/blendings/BlendingAlgorithms.cpp
@@ -0,0 +1,285 @@
+// Copyright 2010 Jens-Michael Hoffmann <jmho at c-xx.com>
+//
+// 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
+// version 2.1 of the License, or (at your option) any later version.
+//
+// This library 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
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library. If not, see <http://www.gnu.org/licenses/>.
+
+#include "BlendingAlgorithms.h"
+
+#include "TextureTile.h"
+
+#include <cmath>
+
+#include <QtGui/QImage>
+
+namespace Marble
+{
+
+void IndependentChannelBlending::blend( QImage * const bottom, QSharedPointer<TextureTile> const & top ) const
+{
+ QImage const * const topImage = top->image();
+ Q_ASSERT( topImage );
+ Q_ASSERT( bottom->size() == topImage->size() );
+ int const width = bottom->width();
+ int const height = bottom->height();
+ for ( int y = 0; y < height; ++y ) {
+ for ( int x = 0; x < width; ++x ) {
+ QRgb const bottomPixel = bottom->pixel( x, y );
+ QRgb const topPixel = topImage->pixel( x, y );
+ qreal const resultRed = blendChannel( qRed( bottomPixel ) / 255.0,
+ qRed( topPixel ) / 255.0 );
+ qreal const resultGreen = blendChannel( qGreen( bottomPixel ) / 255.0,
+ qGreen( topPixel ) / 255.0 );
+ qreal const resultBlue = blendChannel( qBlue( bottomPixel ) / 255.0,
+ qBlue( topPixel ) / 255.0 );
+ bottom->setPixel( x, y, qRgb( resultRed * 255.0,
+ resultGreen * 255.0,
+ resultBlue * 255.0 ));
+ }
+ }
+}
+
+
+// Neutral blendings
+
+qreal AllanonBlending::blendChannel( qreal const bottomColorIntensity,
+ qreal const topColorIntensity ) const
+{
+ return ( bottomColorIntensity + topColorIntensity ) / 2.0;
+}
+
+qreal ArcusTangentBlending::blendChannel( qreal const bottomColorIntensity,
+ qreal const topColorIntensity ) const
+{
+ return 2.0 * atan( topColorIntensity / bottomColorIntensity ) / M_PI;
+}
+
+qreal GeometricMeanBlending::blendChannel( qreal const bottomColorIntensity,
+ qreal const topColorIntensity ) const
+{
+ return sqrt( bottomColorIntensity * topColorIntensity );
+}
+
+qreal LinearLightBlending::blendChannel( qreal const bottomColorIntensity,
+ qreal const topColorIntensity ) const
+{
+ return qMin( 1.0, qMax( 0.0, ( bottomColorIntensity + 2.0 * topColorIntensity ) - 1.0 ));
+}
+
+qreal OverlayBlending::blendChannel( qreal const bottomColorIntensity,
+ qreal const topColorIntensity ) const
+{
+ if ( bottomColorIntensity < 0.5 )
+ return 2.0 * bottomColorIntensity * topColorIntensity;
+ else
+ return 1.0 - 2.0 * ( 1.0 - bottomColorIntensity ) * ( 1.0 - topColorIntensity );
+}
+
+qreal ParallelBlending::blendChannel( qreal const bottomColorIntensity,
+ qreal const topColorIntensity ) const
+{
+ // FIXME: return qMin( qMax( 2.0 / ( 1.0 / bottomColorIntensity + 1.0 / topColorIntensity )), 0.0, 1.0 );
+ return 0.0;
+}
+
+qreal TextureBlending::blendChannel( qreal const bottomColorIntensity,
+ qreal const topColorIntensity ) const
+{
+ // FIXME: return qMax( qMin( topColorIntensity + bottomColorIntensity ) - 0.5 ), 1.0 ), 0.0 );
+ return 0.0;
+}
+
+
+// Darkening blendings
+
+qreal ColorBurnBlending::blendChannel( qreal const bottomColorIntensity,
+ qreal const topColorIntensity ) const
+{
+ // FIXME: check if this formula makes sense
+ return qMin( 1.0, qMax( 0.0, 1.0 - ( 1.0 - bottomColorIntensity ) / topColorIntensity ));
+}
+
+qreal DarkBlending::blendChannel( qreal const bottomColorIntensity,
+ qreal const topColorIntensity ) const
+{
+ return ( bottomColorIntensity + 1.0 - topColorIntensity ) * topColorIntensity;
+}
+
+qreal DarkenBlending::blendChannel( qreal const bottomColorIntensity,
+ qreal const topColorIntensity ) const
+{
+ // FIXME: is this really ok? not vice versa?
+ return bottomColorIntensity > topColorIntensity ? topColorIntensity : bottomColorIntensity;
+}
+
+qreal DivideBlending::blendChannel( qreal const bottomColorIntensity,
+ qreal const topColorIntensity ) const
+{
+ return log2( 1.0 + bottomColorIntensity / ( 1.0 - topColorIntensity ) / 8.0 );
+}
+
+qreal GammaDarkBlending::blendChannel( qreal const bottomColorIntensity,
+ qreal const topColorIntensity ) const
+{
+ return pow( bottomColorIntensity, 1.0 / topColorIntensity );
+}
+
+qreal LinearBurnBlending::blendChannel( qreal const bottomColorIntensity,
+ qreal const topColorIntensity ) const
+{
+ return qMax( 0.0, bottomColorIntensity + topColorIntensity - 1.0 );
+}
+
+qreal MultiplyBlending::blendChannel( qreal const bottomColorIntensity,
+ qreal const topColorIntensity ) const
+{
+ return bottomColorIntensity * topColorIntensity;
+}
+
+qreal SubtractiveBlending::blendChannel( qreal const bottomColorIntensity,
+ qreal const topColorIntensity ) const
+{
+ return qMax( bottomColorIntensity - topColorIntensity, 0.0 );
+}
+
+
+// Lightening blendings
+
+qreal AdditiveBlending::blendChannel( qreal const bottomColorIntensity,
+ qreal const topColorIntensity ) const
+{
+ return qMin( topColorIntensity + bottomColorIntensity, 1.0 );
+}
+
+qreal ColorDodgeBlending::blendChannel( qreal const bottomColorIntensity,
+ qreal const topColorIntensity ) const
+{
+ return qMin( 1.0, qMax( 0.0, bottomColorIntensity / ( 1.0 - topColorIntensity )));
+}
+
+qreal GammaLightBlending::blendChannel( qreal const bottomColorIntensity,
+ qreal const topColorIntensity ) const
+{
+ return pow( bottomColorIntensity, topColorIntensity );
+}
+
+qreal HardLightBlending::blendChannel( qreal const bottomColorIntensity,
+ qreal const topColorIntensity ) const
+{
+ return topColorIntensity < 0.5
+ ? 2.0 * bottomColorIntensity * topColorIntensity
+ : 1.0 - 2.0 * ( 1.0 - bottomColorIntensity ) * ( 1.0 - topColorIntensity );
+}
+
+qreal LightBlending::blendChannel( qreal const bottomColorIntensity,
+ qreal const topColorIntensity ) const
+{
+ return bottomColorIntensity * ( 1.0 - topColorIntensity ) + pow( topColorIntensity, 2 );
+}
+
+qreal LightenBlending::blendChannel( qreal const bottomColorIntensity,
+ qreal const topColorIntensity ) const
+{
+ // is this ok?
+ return bottomColorIntensity < topColorIntensity ? topColorIntensity : bottomColorIntensity;
+}
+
+qreal PinLightBlending::blendChannel( qreal const bottomColorIntensity,
+ qreal const topColorIntensity ) const
+{
+ return qMax( 0.0, qMax( 2.0 + topColorIntensity - 1.0,
+ qMin( bottomColorIntensity, 2.0 * topColorIntensity )));
+}
+
+qreal ScreenBlending::blendChannel( qreal const bottomColorIntensity,
+ qreal const topColorIntensity ) const
+{
+ return 1.0 - ( 1.0 - bottomColorIntensity ) * ( 1.0 - topColorIntensity );
+}
+
+qreal SoftLightBlending::blendChannel( qreal const bottomColorIntensity,
+ qreal const topColorIntensity ) const
+{
+ return pow( bottomColorIntensity, pow( 2.0, ( 2.0 * ( 0.5 - topColorIntensity ))));
+}
+
+qreal VividLightBlending::blendChannel( qreal const bottomColorIntensity,
+ qreal const topColorIntensity ) const
+{
+ return topColorIntensity < 0.5
+ ? qMin( 1.0, qMax( 0.0, 1.0 - ( 1.0 - bottomColorIntensity ) / ( 2.0 * topColorIntensity )))
+ : qMin( 1.0, qMax( 0.0, bottomColorIntensity / ( 2.0 * ( 1.0 - topColorIntensity ))));
+}
+
+
+// Inverter blendings
+
+qreal AdditiveSubtractiveBlending::blendChannel( qreal const bottomColorIntensity,
+ qreal const topColorIntensity ) const
+{
+ // FIXME:
+ // return qMin( 1.0, qMax( 0.0, abs( bottomColorIntensity * bottomColorIntensity
+ // - topColorIntensity * topColorIntensity )));
+ return 0.0;
+}
+
+qreal BleachBlending::blendChannel( qreal const bottomColorIntensity,
+ qreal const topColorIntensity ) const
+{
+ // FIXME: "why this is the same formula as Screen Blending? Please correct.)"
+ return 1.0 - ( 1.0 - bottomColorIntensity ) * ( 1.0 - topColorIntensity );
+}
+
+qreal DifferenceBlending::blendChannel( qreal const bottomColorIntensity,
+ qreal const topColorIntensity ) const
+{
+ return qMax( qMin( 1.0, bottomColorIntensity - topColorIntensity + 0.5 ), 0.0 );
+}
+
+qreal EquivalenceBlending::blendChannel( qreal const bottomColorIntensity,
+ qreal const topColorIntensity ) const
+{
+ return 1.0 - abs( bottomColorIntensity - topColorIntensity );
+}
+
+qreal HalfDifferenceBlending::blendChannel( qreal const bottomColorIntensity,
+ qreal const topColorIntensity ) const
+{
+ return bottomColorIntensity + topColorIntensity
+ - 2.0 * ( bottomColorIntensity * topColorIntensity );
+}
+
+
+// Special purpose blendings
+
+void CloudsBlending::blend( QImage * const bottom, QSharedPointer<TextureTile> const & top ) const
+{
+ QImage const * const topImage = top->image();
+ Q_ASSERT( topImage );
+ Q_ASSERT( bottom->size() == topImage->size() );
+ int const width = bottom->width();
+ int const height = bottom->height();
+ for ( int y = 0; y < height; ++y ) {
+ for ( int x = 0; x < width; ++x ) {
+ qreal const c = qRed( topImage->pixel( x, y )) / 255.0;
+ QRgb const bottomPixel = bottom->pixel( x, y );
+ int const bottomRed = qRed( bottomPixel );
+ int const bottomGreen = qGreen( bottomPixel );
+ int const bottomBlue = qBlue( bottomPixel );
+ bottom->setPixel( x, y, qRgb(( int )( bottomRed + ( 255 - bottomRed ) * c ),
+ ( int )( bottomGreen + ( 255 - bottomGreen ) * c ),
+ ( int )( bottomBlue + ( 255 - bottomBlue ) * c )));
+ }
+ }
+}
+
+}
diff --git a/marble/src/lib/blendings/BlendingAlgorithms.h b/marble/src/lib/blendings/BlendingAlgorithms.h
new file mode 100644
index 0000000..a2987f3
--- /dev/null
+++ b/marble/src/lib/blendings/BlendingAlgorithms.h
@@ -0,0 +1,246 @@
+// Copyright 2010 Jens-Michael Hoffmann <jmho at c-xx.com>
+//
+// 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
+// version 2.1 of the License, or (at your option) any later version.
+//
+// This library 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
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library. If not, see <http://www.gnu.org/licenses/>.
+
+#ifndef MARBLE_BLENDING_ALGORITHMS_H
+#define MARBLE_BLENDING_ALGORITHMS_H
+
+#include <QtCore/QtGlobal>
+
+#include "Blending.h"
+
+namespace Marble
+{
+
+class IndependentChannelBlending: public Blending
+{
+ public:
+ virtual void blend( QImage * const bottom, QSharedPointer<TextureTile> const & top ) const;
+ private:
+ // bottomColorIntensity: intensity of one color channel (of one pixel) of the bottom image
+ // topColorIntensity: intensity of one color channel (of one pixel) of the top image
+ // return: intensity of the color channel (of a given pixel) of the result image
+ // all color intensity values are in the range 0..1
+ virtual qreal blendChannel( qreal const bottomColorIntensity,
+ qreal const topColorIntensity ) const = 0;
+};
+
+
+// Neutral blendings
+
+class AllanonBlending: public IndependentChannelBlending
+{
+ virtual qreal blendChannel( qreal const bottomColorIntensity,
+ qreal const topColorIntensity ) const;
+};
+
+class ArcusTangentBlending: public IndependentChannelBlending
+{
+ virtual qreal blendChannel( qreal const bottomColorIntensity,
+ qreal const topColorIntensity ) const;
+};
+
+class GeometricMeanBlending: public IndependentChannelBlending
+{
+ virtual qreal blendChannel( qreal const bottomColorIntensity,
+ qreal const topColorIntensity ) const;
+};
+
+class LinearLightBlending: public IndependentChannelBlending
+{
+ virtual qreal blendChannel( qreal const bottomColorIntensity,
+ qreal const topColorIntensity ) const;
+};
+
+class NoiseBlending: public Blending // or IndependentChannelBlending?
+{
+};
+
+class OverlayBlending: public IndependentChannelBlending
+{
+ virtual qreal blendChannel( qreal const bottomColorIntensity,
+ qreal const topColorIntensity ) const;
+};
+
+class ParallelBlending: public IndependentChannelBlending
+{
+ virtual qreal blendChannel( qreal const bottomColorIntensity,
+ qreal const topColorIntensity ) const;
+};
+
+class TextureBlending: public IndependentChannelBlending
+{
+ virtual qreal blendChannel( qreal const bottomColorIntensity,
+ qreal const topColorIntensity ) const;
+};
+
+
+// Darkening blendings
+
+class ColorBurnBlending: public IndependentChannelBlending
+{
+ virtual qreal blendChannel( qreal const bottomColorIntensity,
+ qreal const topColorIntensity ) const;
+};
+
+class DarkBlending: public IndependentChannelBlending
+{
+ virtual qreal blendChannel( qreal const bottomColorIntensity,
+ qreal const topColorIntensity ) const;
+};
+
+class DarkenBlending: public IndependentChannelBlending
+{
+ virtual qreal blendChannel( qreal const bottomColorIntensity,
+ qreal const topColorIntensity ) const;
+};
+
+class DivideBlending: public IndependentChannelBlending
+{
+ virtual qreal blendChannel( qreal const bottomColorIntensity,
+ qreal const topColorIntensity ) const;
+};
+
+class GammaDarkBlending: public IndependentChannelBlending
+{
+ virtual qreal blendChannel( qreal const bottomColorIntensity,
+ qreal const topColorIntensity ) const;
+};
+
+class LinearBurnBlending: public IndependentChannelBlending
+{
+ virtual qreal blendChannel( qreal const bottomColorIntensity,
+ qreal const topColorIntensity ) const;
+};
+
+class MultiplyBlending: public IndependentChannelBlending
+{
+ virtual qreal blendChannel( qreal const bottomColorIntensity,
+ qreal const topColorIntensity ) const;
+};
+
+class SubtractiveBlending: public IndependentChannelBlending
+{
+ virtual qreal blendChannel( qreal const bottomColorIntensity,
+ qreal const topColorIntensity ) const;
+};
+
+
+// Lightening blendings
+
+class AdditiveBlending: public IndependentChannelBlending
+{
+ virtual qreal blendChannel( qreal const bottomColorIntensity,
+ qreal const topColorIntensity ) const;
+};
+
+class ColorDodgeBlending: public IndependentChannelBlending
+{
+ virtual qreal blendChannel( qreal const bottomColorIntensity,
+ qreal const topColorIntensity ) const;
+};
+
+class GammaLightBlending: public IndependentChannelBlending
+{
+ virtual qreal blendChannel( qreal const bottomColorIntensity,
+ qreal const topColorIntensity ) const;
+};
+
+class HardLightBlending: public IndependentChannelBlending
+{
+ virtual qreal blendChannel( qreal const bottomColorIntensity,
+ qreal const topColorIntensity ) const;
+};
+
+class LightBlending: public IndependentChannelBlending
+{
+ virtual qreal blendChannel( qreal const bottomColorIntensity,
+ qreal const topColorIntensity ) const;
+};
+
+class LightenBlending: public IndependentChannelBlending
+{
+ virtual qreal blendChannel( qreal const bottomColorIntensity,
+ qreal const topColorIntensity ) const;
+};
+
+class PinLightBlending: public IndependentChannelBlending
+{
+ virtual qreal blendChannel( qreal const bottomColorIntensity,
+ qreal const topColorIntensity ) const;
+};
+
+class ScreenBlending: public IndependentChannelBlending
+{
+ virtual qreal blendChannel( qreal const bottomColorIntensity,
+ qreal const topColorIntensity ) const;
+};
+
+class SoftLightBlending: public IndependentChannelBlending
+{
+ virtual qreal blendChannel( qreal const bottomColorIntensity,
+ qreal const topColorIntensity ) const;
+};
+
+class VividLightBlending: public IndependentChannelBlending
+{
+ virtual qreal blendChannel( qreal const bottomColorIntensity,
+ qreal const topColorIntensity ) const;
+};
+
+
+// Inverter blendings
+
+class AdditiveSubtractiveBlending: public IndependentChannelBlending
+{
+ virtual qreal blendChannel( qreal const bottomColorIntensity,
+ qreal const topColorIntensity ) const;
+};
+
+class BleachBlending: public IndependentChannelBlending
+{
+ virtual qreal blendChannel( qreal const bottomColorIntensity,
+ qreal const topColorIntensity ) const;
+};
+
+class DifferenceBlending: public IndependentChannelBlending
+{
+ virtual qreal blendChannel( qreal const bottomColorIntensity,
+ qreal const topColorIntensity ) const;
+};
+
+class EquivalenceBlending: public IndependentChannelBlending
+{
+ virtual qreal blendChannel( qreal const bottomColorIntensity,
+ qreal const topColorIntensity ) const;
+};
+
+class HalfDifferenceBlending: public IndependentChannelBlending
+{
+ virtual qreal blendChannel( qreal const bottomColorIntensity,
+ qreal const topColorIntensity ) const;
+};
+
+
+// Special purpose blendings
+
+class CloudsBlending: public Blending
+{
+ public:
+ virtual void blend( QImage * const bottom, QSharedPointer<TextureTile> const & top ) const;
+};
+
+}
+
+#endif
diff --git a/marble/src/lib/blendings/BlendingFactory.cpp b/marble/src/lib/blendings/BlendingFactory.cpp
new file mode 100644
index 0000000..c9247a3
--- /dev/null
+++ b/marble/src/lib/blendings/BlendingFactory.cpp
@@ -0,0 +1,88 @@
+// Copyright 2010 Jens-Michael Hoffmann <jmho at c-xx.com>
+//
+// 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
+// version 2.1 of the License, or (at your option) any later version.
+//
+// This library 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
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library. If not, see <http://www.gnu.org/licenses/>.
+
+#include "BlendingFactory.h"
+
+#include "blendings/SunLightBlending.h"
+#include "BlendingAlgorithms.h"
+#include "MarbleDebug.h"
+
+namespace Marble
+{
+
+BlendingFactory const * BlendingFactory::s_instance = 0;
+
+BlendingFactory const * BlendingFactory::instance()
+{
+ if ( s_instance == 0 )
+ s_instance = new BlendingFactory;
+ return s_instance;
+}
+
+Blending const * BlendingFactory::findBlending( QString const & name ) const
+{
+ Blending const * const result = m_blendings.value( name, 0 );
+ if ( !result )
+ mDebug() << "BlendingFactory::findBlending: unknown blending:" << name;
+ return result;
+}
+
+BlendingFactory::BlendingFactory()
+{
+ // Neutral blendings
+ m_blendings.insert( "AllanonBlending", new AllanonBlending );
+ m_blendings.insert( "ArcusTangentBlending", new ArcusTangentBlending );
+ m_blendings.insert( "GeometricMeanBlending", new GeometricMeanBlending );
+ m_blendings.insert( "LinearLightBlending", new LinearLightBlending );
+ //m_blendings.insert( "NoiseBlending", new NoiseBlending );
+ m_blendings.insert( "OverlayBlending", new OverlayBlending );
+ m_blendings.insert( "ParallelBlending", new ParallelBlending );
+ m_blendings.insert( "TextureBlending", new TextureBlending );
+
+ // Darkening blendings
+ m_blendings.insert( "ColorBurnBlending", new ColorBurnBlending );
+ m_blendings.insert( "DarkBlending", new DarkBlending );
+ m_blendings.insert( "DarkenBlending", new DarkenBlending );
+ m_blendings.insert( "DivideBlending", new DivideBlending );
+ m_blendings.insert( "GammaDarkBlending", new GammaDarkBlending );
+ m_blendings.insert( "LinearBurnBlending", new LinearBurnBlending );
+ m_blendings.insert( "MultiplyBlending", new MultiplyBlending );
+ m_blendings.insert( "SubtractiveBlending", new SubtractiveBlending );
+
+ // Lightening blendings
+ m_blendings.insert( "AdditiveBlending", new AdditiveBlending );
+ m_blendings.insert( "ColorDodgeBlending", new ColorDodgeBlending );
+ m_blendings.insert( "GammaLightBlending", new GammaLightBlending );
+ m_blendings.insert( "HardLightBlending", new HardLightBlending );
+ m_blendings.insert( "LightBlending", new LightBlending );
+ m_blendings.insert( "LightenBlending", new LightenBlending );
+ m_blendings.insert( "PinLightBlending", new PinLightBlending );
+ m_blendings.insert( "ScreenBlending", new ScreenBlending );
+ m_blendings.insert( "SoftLightBlending", new SoftLightBlending );
+ m_blendings.insert( "VividLightBlending", new VividLightBlending );
+
+ // Inverter blendings
+ m_blendings.insert( "AdditiveSubtractiveBlending", new AdditiveSubtractiveBlending );
+ m_blendings.insert( "BleachBlending", new BleachBlending );
+ m_blendings.insert( "DifferenceBlending", new DifferenceBlending );
+ m_blendings.insert( "EquivalenceBlending", new EquivalenceBlending );
+ m_blendings.insert( "HalfDifferenceBlending", new HalfDifferenceBlending );
+
+ // Special purpose blendings
+ m_blendings.insert( "CloudsBlending", new CloudsBlending );
+ m_blendings.insert( "SunLightBlending", new SunLightBlending );
+}
+
+}
diff --git a/marble/src/lib/blendings/BlendingFactory.h b/marble/src/lib/blendings/BlendingFactory.h
new file mode 100644
index 0000000..d1bfc68
--- /dev/null
+++ b/marble/src/lib/blendings/BlendingFactory.h
@@ -0,0 +1,40 @@
+// Copyright 2010 Jens-Michael Hoffmann <jmho at c-xx.com>
+//
+// 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
+// version 2.1 of the License, or (at your option) any later version.
+//
+// This library 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
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library. If not, see <http://www.gnu.org/licenses/>.
+
+#ifndef MARBLE_BLENDING_FACTORY_H
+#define MARBLE_BLENDING_FACTORY_H
+
+#include <QtCore/QHash>
+#include <QtCore/QString>
+
+namespace Marble
+{
+class Blending;
+
+class BlendingFactory
+{
+ public:
+ static BlendingFactory const * instance();
+ Blending const * findBlending( QString const & name ) const;
+
+ private:
+ static BlendingFactory const * s_instance;
+ BlendingFactory();
+ QHash<QString, Blending const *> m_blendings;
+};
+
+}
+
+#endif
diff --git a/marble/src/lib/geodata/handlers/dgml/DgmlBlendingTagHandler.cpp b/marble/src/lib/geodata/handlers/dgml/DgmlBlendingTagHandler.cpp
index f085366..1a2aaf3 100644
--- a/marble/src/lib/geodata/handlers/dgml/DgmlBlendingTagHandler.cpp
+++ b/marble/src/lib/geodata/handlers/dgml/DgmlBlendingTagHandler.cpp
@@ -15,7 +15,7 @@
#include "DgmlBlendingTagHandler.h"
-#include "BlendingFactory.h"
+#include "blendings/BlendingFactory.h"
#include "DgmlAttributeDictionary.h"
#include "DgmlElementDictionary.h"
#include "GeoParser.h"
--
1.7.0.3
More information about the Marble-devel
mailing list