Krita Source Code Documentation
Loading...
Searching...
No Matches
KoCompositeOpClampPolicy.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 KOCOMPOSITEOPCLAMPPOLICY_H
7#define KOCOMPOSITEOPCLAMPPOLICY_H
8
9#include <KoColorSpaceMaths.h>
10
12{
13template <typename T>
15 using channels_type = T;
17
19 using namespace Arithmetic;
20 return clampToSDR<channels_type>(value);
21 }
22
24 using namespace Arithmetic;
25 return clampToSDR<channels_type>(value);
26 }
27
29 using namespace Arithmetic;
30 return clampToSDR<channels_type>(value);
31 }
32
36
37 static inline T clippedMaxValue() {
38 using namespace Arithmetic;
39 return unitValue<T>();
40 }
41};
42
43template <typename T>
45 using channels_type = T;
47
49 using namespace Arithmetic;
50 return clampToSDR<channels_type>(value);
51 }
52
54 using namespace Arithmetic;
55 return clampToSDR<channels_type>(value);
56 }
57
59 using namespace Arithmetic;
60 return clampToSDR<channels_type>(value);
61 }
62
64 // Constantly dividing by small numbers can quickly make the result
65 // become infinity or NaN, so we check that and correct (kind of clamping)
67 }
68
69 static inline T clippedMaxValue() {
70 using namespace Arithmetic;
71 return unitValue<T>();
72 }
73};
74
75template <typename T>
77 using channels_type = T;
79
83
85 using namespace Arithmetic;
86 return clampToSDRBottom<channels_type>(value);
87 }
88
90 using namespace Arithmetic;
91 return clampToSDRTop<channels_type>(value);
92 }
93
95 // Constantly dividing by small numbers can quickly make the result
96 // become infinity or NaN, so we check that and correct (kind of clamping)
98 }
99
100 static inline T clippedMaxValue() {
102 }
103};
104
105
106template <template <typename U,
107 template <typename V> typename Policy> typename Functor,
108 typename T>
110 std::conditional_t<std::numeric_limits<T>::is_integer,
111 Functor<T, ClampAsInteger>,
112 Functor<T, ClampAsFloatSDR>>
113{
114};
115
116}
117
118#endif // KOCOMPOSITEOPCLAMPPOLICY_H
float value(const T *src, size_t ch)
static compositetype fixInfiniteAfterDivision(compositetype value)
static channels_type clampResult(compositetype value)
typename KoColorSpaceMathsTraits< T >::compositetype compositetype
static channels_type clampResultAllowNegative(compositetype value)
static channels_type clampInvertedResult(compositetype value)
static compositetype fixInfiniteAfterDivision(compositetype value)
static channels_type clampInvertedResult(compositetype value)
static channels_type clampResultAllowNegative(compositetype value)
typename KoColorSpaceMathsTraits< T >::compositetype compositetype
static channels_type clampResult(compositetype value)
static compositetype fixInfiniteAfterDivision(compositetype value)
typename KoColorSpaceMathsTraits< T >::compositetype compositetype
static channels_type clampResult(compositetype value)
static channels_type clampInvertedResult(compositetype value)
static channels_type clampResultAllowNegative(compositetype value)