Krita Source Code Documentation
Loading...
Searching...
No Matches
RgbCompositeOpIn.h
Go to the documentation of this file.
1/*
2 * SPDX-FileCopyrightText: 2006 Boudewijn Rempt <boud@valdyas.org>
3 *
4 * SPDX-License-Identifier: LGPL-2.1-or-later
5 */
6
7#ifndef RGBCOMPOSITEOPIN_H
8#define RGBCOMPOSITEOPIN_H
9
10#include <KoCompositeOp.h>
11
12#define SCALE_TO_FLOAT( v ) KoColorSpaceMaths< channels_type, float>::scaleToA( v )
13#define SCALE_FROM_FLOAT( v ) KoColorSpaceMaths< float, channels_type>::scaleToA( v )
14
15template<class _CSTraits>
17{
18 typedef typename _CSTraits::channels_type channels_type;
20
21public:
22
27
29
30 void composite(const KoCompositeOp::ParameterInfo& params) const override
31 {
33
34 if (opacity == NATIVE_OPACITY_TRANSPARENT) {
35 return;
36 }
37
38 const quint8 *srcRowStart = params.srcRowStart;
39 quint8 *dstRowStart = params.dstRowStart;
40
41 qint32 rows = params.rows;
42
43 qint32 i;
44
45 //qreal sAlpha, dAlpha;
46 qreal alpha;
47
48 while (rows-- > 0) {
49 channels_type *d = reinterpret_cast<channels_type *>(dstRowStart);
50 const channels_type *s = reinterpret_cast<const channels_type *>(srcRowStart);
51
52 for (i = params.cols; i > 0; i--, d += _CSTraits::channels_nb, s += _CSTraits::channels_nb) {
53
54 if (s[_CSTraits::alpha_pos] == NATIVE_OPACITY_TRANSPARENT) {
55 d[_CSTraits::alpha_pos] = NATIVE_OPACITY_TRANSPARENT;
56 continue;
57 } else if (s[_CSTraits::alpha_pos] == NATIVE_OPACITY_OPAQUE) {
58 continue;
59 }
60 if (d[_CSTraits::alpha_pos] == NATIVE_OPACITY_TRANSPARENT) {
61 continue;
62 }
63
64 alpha = (qreal)(s[_CSTraits::alpha_pos]) * d[_CSTraits::alpha_pos] / NATIVE_OPACITY_OPAQUE;
65
66 if (params.channelFlags.isEmpty() || params.channelFlags.testBit(_CSTraits::alpha_pos)) {
67 d[_CSTraits::alpha_pos] = (channels_type)((d[_CSTraits::alpha_pos] * alpha / NATIVE_OPACITY_OPAQUE) + 0.5);
68 }
69
70 }
71 dstRowStart += params.dstRowStride;
72 srcRowStart += params.srcRowStride;
73 }
74 }
75};
76
77#endif
#define NATIVE_OPACITY_TRANSPARENT
#define NATIVE_OPACITY_OPAQUE
const QString COMPOSITE_IN
static _Tdst scaleToA(_T a)
KoColorSpaceMathsTraits< typename_CSTraits::channels_type >::compositetype compositetype
void composite(const KoCompositeOp::ParameterInfo &params) const override
_CSTraits::channels_type channels_type
RgbCompositeOpIn(KoColorSpace *cs)
void composite(quint8 *dstRowStart, qint32 dstRowStride, const quint8 *srcRowStart, qint32 srcRowStride, const quint8 *maskRowStart, qint32 maskRowStride, qint32 rows, qint32 numColumns, float opacity, const QBitArray &channelFlags=QBitArray()) const
Private *const d