Krita Source Code Documentation
Loading...
Searching...
No Matches
RgbCompositeOpOut.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 RGBCOMPOSITEOPOUT_H
8#define RGBCOMPOSITEOPOUT_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 const channels_type *s = reinterpret_cast<const channels_type *>(srcRowStart);
50 channels_type *d = reinterpret_cast<channels_type *>(dstRowStart);
51
52 for (i = params.cols; i > 0; --i, d += _CSTraits::channels_nb, s += _CSTraits::channels_nb) {
53 if (s[_CSTraits::alpha_pos] == NATIVE_OPACITY_TRANSPARENT) {
54 continue;
55 } else if (s[_CSTraits::alpha_pos] == NATIVE_OPACITY_OPAQUE) {
56 d[_CSTraits::alpha_pos] = NATIVE_OPACITY_TRANSPARENT;
57 continue;
58 }
59 if (d[_CSTraits::alpha_pos] == NATIVE_OPACITY_TRANSPARENT) {
60 continue;
61 }
62
63 alpha = (channels_type)(s[_CSTraits::alpha_pos]) * d[_CSTraits::alpha_pos] / NATIVE_OPACITY_OPAQUE;
64 if (params.channelFlags.isEmpty() || params.channelFlags.testBit(_CSTraits::alpha_pos)) {
65 d[_CSTraits::alpha_pos] = (channels_type)((d[_CSTraits::alpha_pos] * (NATIVE_OPACITY_OPAQUE - alpha) / NATIVE_OPACITY_OPAQUE) + 0.5);
66 }
67 }
68 dstRowStart += params.dstRowStride;
69 srcRowStart += params.srcRowStride;
70 }
71
72 }
73};
74
75#endif
#define NATIVE_OPACITY_TRANSPARENT
#define NATIVE_OPACITY_OPAQUE
const QString COMPOSITE_OUT
static _Tdst scaleToA(_T a)
_CSTraits::channels_type channels_type
KoColorSpaceMathsTraits< typename_CSTraits::channels_type >::compositetype compositetype
RgbCompositeOpOut(KoColorSpace *cs)
void composite(const KoCompositeOp::ParameterInfo &params) const override
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