File indexing completed on 2024-05-19 04:27:19

0001 /*
0002  *  SPDX-FileCopyrightText: 2020 Dmitry Kazakov <dimula73@gmail.com>
0003  *
0004  *  SPDX-License-Identifier: GPL-2.0-or-later
0005  */
0006 
0007 #include "KoAlphaMaskApplicatorFactory.h"
0008 
0009 #include <KoColorModelStandardIdsUtils.h>
0010 #include <kis_assert.h>
0011 
0012 #include "KoAlphaMaskApplicatorFactoryImpl.h"
0013 
0014 template <typename channels_type>
0015 struct CreateApplicator
0016 {
0017     KoAlphaMaskApplicatorBase *operator() (int numChannels, int alphaPos) {
0018         if (numChannels == 4) {
0019             KIS_ASSERT(alphaPos == 3);
0020             return createOptimizedClass<
0021                 KoAlphaMaskApplicatorFactoryImpl<channels_type, 4, 3>>();
0022         } else if (numChannels == 5) {
0023             KIS_ASSERT(alphaPos == 4);
0024             return createOptimizedClass<
0025                 KoAlphaMaskApplicatorFactoryImpl<channels_type, 5, 4>>();
0026         } else if (numChannels == 2) {
0027             KIS_ASSERT(alphaPos == 1);
0028             return createOptimizedClass<
0029                 KoAlphaMaskApplicatorFactoryImpl<channels_type, 2, 1>>();
0030         } else if (numChannels == 1) {
0031             KIS_ASSERT(alphaPos == 0);
0032             return createOptimizedClass<
0033                 KoAlphaMaskApplicatorFactoryImpl<channels_type, 1, 0>>();
0034         } else {
0035             KIS_ASSERT(0);
0036         }
0037 
0038         return 0;
0039     }
0040 };
0041 
0042 KoAlphaMaskApplicatorBase *KoAlphaMaskApplicatorFactory::create(KoID depthId, int numChannels, int alphaPos)
0043 {
0044     return channelTypeForColorDepthId<CreateApplicator>(depthId, numChannels, alphaPos);
0045 }