Krita Source Code Documentation
Loading...
Searching...
No Matches
KoCompositeOpGenericFunctorBase.h
Go to the documentation of this file.
1/*
2 * SPDX-FileCopyrightText: 2024 Dmitry Kazakov <dimula73@gmail.com>
3 *
4 * SPDX-License-Identifier: GPL-2.0-or-later
5 */
6#ifndef KOCOMPOSITEOPGENERICFUNCTORBASE_H
7#define KOCOMPOSITEOPGENERICFUNCTORBASE_H
8
9#include <KoColorSpaceMaths.h>
10
26// no clamping at all
27template <typename T>
29{
30 static inline T clampSourceChannelValue(T value) {
31 return value;
32 }
33
35 return value;
36 }
37};
38
39// clamp source channel to SDR, keep destination channel unbounded
40template <typename T>
42{
43 static inline T clampSourceChannelValue(T value) {
44 using namespace Arithmetic;
45 return clampChannelToSDR(value);
46 }
47
49 return value;
50 }
51};
52
53// make sure source and destination channels are non-negative
54template <typename T>
56{
57 static inline T clampSourceChannelValue(T value) {
58 using namespace Arithmetic;
59 return clampChannelToSDRBottom(value);
60 }
61
63 using namespace Arithmetic;
64 return clampChannelToSDRBottom(value);
65 }
66};
67
68// clamp both source and destination channels to SDR range
69template <typename T>
71{
72 static inline T clampSourceChannelValue(T value) {
73 using namespace Arithmetic;
74 return clampChannelToSDR(value);
75 }
76
78 using namespace Arithmetic;
79 return clampChannelToSDR(value);
80 }
81};
82
83// clamp source on the both sides and clamp destination on
84// the negative side only
85template <typename T>
87{
88 static inline T clampSourceChannelValue(T value) {
89 using namespace Arithmetic;
90 return clampChannelToSDR(value);
91 }
92
94 using namespace Arithmetic;
95 return clampChannelToSDRBottom(value);
96 }
97};
98
99#endif // KOCOMPOSITEOPGENERICFUNCTORBASE_H
float value(const T *src, size_t ch)