Krita Source Code Documentation
Loading...
Searching...
No Matches
KoCompositeOpCopyChannel.h
Go to the documentation of this file.
1/*
2 * SPDX-FileCopyrightText: 2011 Silvio Heinrich <plassy@web.de>
3 *
4 * SPDX-License-Identifier: LGPL-2.1-or-later
5*/
6
7#ifndef _KOCOMPOSITEOP_COPY_CHANNEL_H_
8#define _KOCOMPOSITEOP_COPY_CHANNEL_H_
9
10#include "KoCompositeOpBase.h"
11
20template<class Traits, qint32 channel_pos>
21class KoCompositeOpCopyChannel: public KoCompositeOpBase< Traits, KoCompositeOpCopyChannel<Traits,channel_pos> >
22{
24 typedef typename Traits::channels_type channels_type;
26
27 static const qint32 alpha_pos = Traits::alpha_pos;
28
29public:
30 KoCompositeOpCopyChannel(const KoColorSpace* cs, const QString& id, const QString& category)
31 : base_class(cs, id, category) { }
32
33public:
34 template<bool alphaLocked, bool allChannelFlags>
36 channels_type* dst, channels_type dstAlpha, channels_type maskAlpha,
37 channels_type opacity, const QBitArray& channelFlags) {
38 using namespace Arithmetic;
39 opacity = mul(opacity, maskAlpha);
40
41 if(allChannelFlags || channelFlags.testBit(channel_pos)) {
42 if(channel_pos == alpha_pos)
43 return lerp(dstAlpha, srcAlpha, opacity);
44
45 srcAlpha = mul(srcAlpha, opacity);
46 dst[channel_pos] = lerp(dst[channel_pos], src[channel_pos], srcAlpha);
47 }
48
49 return dstAlpha;
50 }
51};
52
53#endif // _KOCOMPOSITEOP_COPY_CHANNEL_H_
QPointF lerp(const QPointF &p1, const QPointF &p2, qreal t)
KoColorSpaceMathsTraits< channels_type >::compositetype composite_type
KoCompositeOpBase< Traits, KoCompositeOpCopyChannel< Traits, channel_pos > > base_class
static channels_type composeColorChannels(const channels_type *src, channels_type srcAlpha, channels_type *dst, channels_type dstAlpha, channels_type maskAlpha, channels_type opacity, const QBitArray &channelFlags)
KoCompositeOpCopyChannel(const KoColorSpace *cs, const QString &id, const QString &category)
Traits::channels_type channels_type