File indexing completed on 2025-01-05 03:58:43

0001 // SPDX-FileCopyrightText: 2010 Jens-Michael Hoffmann <jmho@c-xx.com>
0002 //
0003 // SPDX-License-Identifier: LGPL-2.1-or-later
0004 
0005 #include "BlendingFactory.h"
0006 
0007 #include "SunLightBlending.h"
0008 #include "BlendingAlgorithms.h"
0009 
0010 #include "digikam_debug.h"
0011 
0012 namespace Marble
0013 {
0014 
0015 void BlendingFactory::setLevelZeroLayout( int levelZeroColumns, int levelZeroRows )
0016 {
0017     m_sunLightBlending->setLevelZeroLayout( levelZeroColumns, levelZeroRows );
0018 }
0019 
0020 Blending const * BlendingFactory::findBlending( QString const & name ) const
0021 {
0022     if ( name.isEmpty() )
0023         return nullptr;
0024 
0025     Blending const * const result = m_blendings.value( name, 0 );
0026     if ( !result )
0027         qCWarning(DIGIKAM_MARBLE_LOG) << "Unknown blending" << name << "specified in .dgml file. Please fix the .dgml file.";
0028     return result;
0029 }
0030 
0031 BlendingFactory::BlendingFactory( const SunLocator *sunLocator )
0032     : m_sunLightBlending( new SunLightBlending( sunLocator ) )
0033 {
0034     m_blendings.insert( QString::fromUtf8("OverpaintBlending"), new OverpaintBlending );
0035 
0036     // Neutral blendings
0037     m_blendings.insert( QString::fromUtf8("AllanonBlending"), new AllanonBlending );
0038     m_blendings.insert( QString::fromUtf8("ArcusTangentBlending"), new ArcusTangentBlending );
0039     m_blendings.insert( QString::fromUtf8("GeometricMeanBlending"), new GeometricMeanBlending );
0040     m_blendings.insert( QString::fromUtf8("LinearLightBlending"), new LinearLightBlending );
0041     //m_blendings.insert( "NoiseBlending", new NoiseBlending );
0042     m_blendings.insert( QString::fromUtf8("OverlayBlending"), new OverlayBlending );
0043     //m_blendings.insert( "ParallelBlending", new ParallelBlending );
0044     //m_blendings.insert( "TextureBlending", new TextureBlending );
0045 
0046     // Darkening blendings
0047     m_blendings.insert( QString::fromUtf8("AlphaBlending"), new OverpaintBlending ); // for backwards compatibility
0048     m_blendings.insert( QString::fromUtf8("ColorBurnBlending"), new ColorBurnBlending );
0049     m_blendings.insert( QString::fromUtf8("DarkBlending"), new DarkBlending );
0050     m_blendings.insert( QString::fromUtf8("DarkenBlending"), new DarkenBlending );
0051     m_blendings.insert( QString::fromUtf8("DivideBlending"), new DivideBlending );
0052     m_blendings.insert( QString::fromUtf8("GammaDarkBlending"), new GammaDarkBlending );
0053     m_blendings.insert( QString::fromUtf8("LinearBurnBlending"), new LinearBurnBlending );
0054     m_blendings.insert( QString::fromUtf8("MultiplyBlending"), new MultiplyBlending );
0055     m_blendings.insert( QString::fromUtf8("SubtractiveBlending"), new SubtractiveBlending );
0056 
0057     // Lightening blendings
0058     m_blendings.insert( QString::fromUtf8("AdditiveBlending"), new AdditiveBlending );
0059     m_blendings.insert( QString::fromUtf8("ColorDodgeBlending"), new ColorDodgeBlending );
0060     m_blendings.insert( QString::fromUtf8("GammaLightBlending"), new GammaLightBlending );
0061     m_blendings.insert( QString::fromUtf8("HardLightBlending"), new HardLightBlending );
0062     m_blendings.insert( QString::fromUtf8("LightBlending"), new LightBlending );
0063     m_blendings.insert( QString::fromUtf8("LightenBlending"), new LightenBlending );
0064     m_blendings.insert( QString::fromUtf8("PinLightBlending"), new PinLightBlending );
0065     m_blendings.insert( QString::fromUtf8("ScreenBlending"), new ScreenBlending );
0066     m_blendings.insert( QString::fromUtf8("SoftLightBlending"), new SoftLightBlending );
0067     m_blendings.insert( QString::fromUtf8("VividLightBlending"), new VividLightBlending );
0068 
0069     // Inverter blendings
0070     //m_blendings.insert( "AdditiveSubtractiveBlending", new AdditiveSubtractiveBlending );
0071     m_blendings.insert( QString::fromUtf8("BleachBlending"), new BleachBlending );
0072     m_blendings.insert( QString::fromUtf8("DifferenceBlending"), new DifferenceBlending );
0073     m_blendings.insert( QString::fromUtf8("EquivalenceBlending"), new EquivalenceBlending );
0074     m_blendings.insert( QString::fromUtf8("HalfDifferenceBlending"), new HalfDifferenceBlending );
0075 
0076     // Special purpose blendings
0077     m_blendings.insert( QString::fromUtf8("CloudsBlending"), new CloudsBlending );
0078     m_blendings.insert( QString::fromUtf8("SunLightBlending"), m_sunLightBlending );
0079     m_blendings.insert( QString::fromUtf8("GrayscaleBlending"), new GrayscaleBlending );
0080     m_blendings.insert( QString::fromUtf8("InvertColorBlending"), new InvertColorBlending );
0081     m_blendings.insert( QString::fromUtf8("InvertHueBlending"), new InvertHueBlending );
0082 }
0083 
0084 BlendingFactory::~BlendingFactory()
0085 {
0086     m_blendings.remove( QString::fromUtf8("SunLightBlending") );
0087     delete m_sunLightBlending;
0088     qDeleteAll( m_blendings );
0089 }
0090 
0091 }