File indexing completed on 2024-05-12 15:59:29
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< 0022 channels_type, 4, 3>>(0); 0023 } else if (numChannels == 5) { 0024 KIS_ASSERT(alphaPos == 4); 0025 return createOptimizedClass< 0026 KoAlphaMaskApplicatorFactoryImpl< 0027 channels_type, 5, 4>>(0); 0028 } else if (numChannels == 2) { 0029 KIS_ASSERT(alphaPos == 1); 0030 return createOptimizedClass< 0031 KoAlphaMaskApplicatorFactoryImpl< 0032 channels_type, 2, 1>>(0); 0033 } else if (numChannels == 1) { 0034 KIS_ASSERT(alphaPos == 0); 0035 return createOptimizedClass< 0036 KoAlphaMaskApplicatorFactoryImpl< 0037 channels_type, 1, 0>>(0); 0038 } else { 0039 KIS_ASSERT(0); 0040 } 0041 0042 return 0; 0043 } 0044 }; 0045 0046 KoAlphaMaskApplicatorBase *KoAlphaMaskApplicatorFactory::create(KoID depthId, int numChannels, int alphaPos) 0047 { 0048 return channelTypeForColorDepthId<CreateApplicator>(depthId, numChannels, alphaPos); 0049 }