File indexing completed on 2024-12-22 04:11:38

0001 /*
0002  *  SPDX-FileCopyrightText: 2023 Dmitry Kazakov <dimula73@gmail.com>
0003  *
0004  *  SPDX-License-Identifier: GPL-2.0-or-later
0005  */
0006 #include "KoColorSpaceBlendingPolicy.h"
0007 
0008 #include <KoCompositeOpRegistry.h>
0009 #include <ksharedconfig.h>
0010 #include <kconfiggroup.h>
0011 
0012 bool useSubtractiveBlendingForCmykColorSpaces()
0013 {
0014     static bool isConfigInitialized = false;
0015     static bool useSubtractiveBlending = true;
0016 
0017     if (!isConfigInitialized) {
0018         KConfigGroup cfg = KSharedConfig::openConfig()->group("");
0019         useSubtractiveBlending = cfg.readEntry("useSubtractiveBlendingForCmykColorSpaces", true);
0020         isConfigInitialized = true;
0021 
0022         if (!useSubtractiveBlending) {
0023             qInfo() << "INFO: requested old version of CMYK blending mode. Switching...";
0024         }
0025     }
0026 
0027     return useSubtractiveBlending;
0028 }
0029 
0030 QStringList subtractiveBlendingModesInCmyk()
0031 {
0032     /**
0033      * Here is the list of blendmodes which are not invariant
0034      * to color channel inversion, therefore they cannot work in
0035      * CMYK properly. These modes automatically invert the channels
0036      * before blending when used for CMYK color space.
0037      *
0038      * This is a behavior-change in Krita 5.2
0039      */
0040 
0041     QStringList ids;
0042 
0043     ids << COMPOSITE_BEHIND;
0044     ids << COMPOSITE_GREATER;
0045 
0046     ids << COMPOSITE_OVERLAY;
0047     ids << COMPOSITE_GRAIN_MERGE;
0048     ids << COMPOSITE_GRAIN_EXTRACT;
0049     ids << COMPOSITE_HARD_MIX;
0050     ids << COMPOSITE_HARD_MIX_PHOTOSHOP;
0051     ids << COMPOSITE_HARD_MIX_SOFTER_PHOTOSHOP;
0052     ids << COMPOSITE_GEOMETRIC_MEAN;
0053     ids << COMPOSITE_PARALLEL;
0054     ids << COMPOSITE_ALLANON;
0055     ids << COMPOSITE_HARD_OVERLAY;
0056     ids << COMPOSITE_INTERPOLATION;
0057     ids << COMPOSITE_INTERPOLATIONB;
0058     ids << COMPOSITE_PENUMBRAA;
0059     ids << COMPOSITE_PENUMBRAB;
0060     ids << COMPOSITE_PENUMBRAC;
0061     ids << COMPOSITE_PENUMBRAD;
0062     ids << COMPOSITE_SCREEN;
0063     ids << COMPOSITE_DODGE;
0064     ids << COMPOSITE_LINEAR_DODGE;
0065     ids << COMPOSITE_LIGHTEN;
0066     ids << COMPOSITE_HARD_LIGHT;
0067     ids << COMPOSITE_SOFT_LIGHT_IFS_ILLUSIONS;
0068     ids << COMPOSITE_SOFT_LIGHT_PEGTOP_DELPHI;
0069     ids << COMPOSITE_SOFT_LIGHT_SVG;
0070     ids << COMPOSITE_SOFT_LIGHT_PHOTOSHOP;
0071     ids << COMPOSITE_GAMMA_LIGHT;
0072     ids << COMPOSITE_GAMMA_ILLUMINATION;
0073     ids << COMPOSITE_VIVID_LIGHT;
0074     ids << COMPOSITE_FLAT_LIGHT;
0075     ids << COMPOSITE_PIN_LIGHT;
0076     ids << COMPOSITE_LINEAR_LIGHT;
0077     ids << COMPOSITE_PNORM_A;
0078     ids << COMPOSITE_PNORM_B;
0079     ids << COMPOSITE_SUPER_LIGHT;
0080     ids << COMPOSITE_TINT_IFS_ILLUSIONS;
0081     ids << COMPOSITE_FOG_LIGHTEN_IFS_ILLUSIONS;
0082     ids << COMPOSITE_EASY_DODGE;
0083     ids << COMPOSITE_BURN;
0084     ids << COMPOSITE_LINEAR_BURN;
0085     ids << COMPOSITE_DARKEN;
0086     ids << COMPOSITE_GAMMA_DARK;
0087     ids << COMPOSITE_SHADE_IFS_ILLUSIONS;
0088     ids << COMPOSITE_FOG_DARKEN_IFS_ILLUSIONS;
0089     ids << COMPOSITE_EASY_BURN;
0090     ids << COMPOSITE_ADD;
0091     ids << COMPOSITE_SUBTRACT;
0092     ids << COMPOSITE_INVERSE_SUBTRACT;
0093     ids << COMPOSITE_MULT;
0094     ids << COMPOSITE_DIVIDE;
0095     ids << COMPOSITE_MOD;
0096     ids << COMPOSITE_MOD_CON;
0097     ids << COMPOSITE_DIVISIVE_MOD;
0098     ids << COMPOSITE_DIVISIVE_MOD_CON;
0099     ids << COMPOSITE_MODULO_SHIFT;
0100     ids << COMPOSITE_MODULO_SHIFT_CON;
0101     ids << COMPOSITE_ARC_TANGENT;
0102     ids << COMPOSITE_DIFF;
0103     ids << COMPOSITE_EXCLUSION;
0104     ids << COMPOSITE_EQUIVALENCE;
0105     ids << COMPOSITE_ADDITIVE_SUBTRACTIVE;
0106     ids << COMPOSITE_NEGATION;
0107 
0108     ids << COMPOSITE_XOR;
0109     ids << COMPOSITE_OR;
0110     ids << COMPOSITE_AND;
0111     ids << COMPOSITE_NAND;
0112     ids << COMPOSITE_NOR;
0113     ids << COMPOSITE_XNOR;
0114     ids << COMPOSITE_IMPLICATION;
0115     ids << COMPOSITE_NOT_IMPLICATION;
0116     ids << COMPOSITE_CONVERSE;
0117     ids << COMPOSITE_NOT_CONVERSE;
0118 
0119     ids << COMPOSITE_REFLECT;
0120     ids << COMPOSITE_GLOW;
0121     ids << COMPOSITE_FREEZE;
0122     ids << COMPOSITE_HEAT;
0123     ids << COMPOSITE_GLEAT;
0124     ids << COMPOSITE_HELOW;
0125     ids << COMPOSITE_REEZE;
0126     ids << COMPOSITE_FRECT;
0127     ids << COMPOSITE_FHYRD;
0128 
0129     ids << COMPOSITE_LUMINOSITY_SAI;
0130 
0131     return ids;
0132 }