Krita Source Code Documentation
Loading...
Searching...
No Matches
KoCompositeOpDestinationAtop.h
Go to the documentation of this file.
1/*
2 * SPDX-FileCopyrightText: 2016 Wolthera van Hövell tot Westerflier <griffinvalley@gmail.com>
3 * SPDX-FileCopyrightText: 2012 José Luis Vergara <pentalis@gmail.com>
4 *
5 * SPDX-License-Identifier: LGPL-2.1-or-later
6*/
7
8#ifndef _KOCOMPOSITEOPDESTINATIONATOP_H_
9#define _KOCOMPOSITEOPDESTINATIONATOP_H_
10
11#include "KoCompositeOpBase.h"
12
18template<class CS_Traits>
19class KoCompositeOpDestinationAtop : public KoCompositeOpBase<CS_Traits, KoCompositeOpDestinationAtop<CS_Traits> >
20{
22 typedef typename CS_Traits::channels_type channels_type;
23
24 static const qint8 channels_nb = CS_Traits::channels_nb;
25 static const qint8 alpha_pos = CS_Traits::alpha_pos;
26
27public:
30
31public:
32 template<bool alphaLocked, bool allChannelFlags>
34 channels_type* dst, channels_type dstAlpha,
35 channels_type maskAlpha, channels_type opacity,
36 const QBitArray& channelFlags ) {
37 using namespace Arithmetic;
38
39 channels_type appliedAlpha = mul(maskAlpha, srcAlpha, opacity);
40
41 channels_type newDstAlpha = appliedAlpha;
42
43 if (dstAlpha != zeroValue<channels_type>() && srcAlpha != zeroValue<channels_type>()) {
44 // blend the color channels as if we were painting on the layer below
45 for (qint8 channel = 0; channel < channels_nb; ++channel)
46 if(channel != alpha_pos && (allChannelFlags || channelFlags.testBit(channel))) {
47 dst[channel] = lerp(src[channel],dst[channel],dstAlpha);
48 }
49 }
50 else if (srcAlpha != zeroValue<channels_type>()) {
51 // don't blend if the color of the destination is undefined (has zero opacity)
52 // copy the source channel instead
53 for (qint8 channel = 0; channel < channels_nb; ++channel)
54 if(channel != alpha_pos && (allChannelFlags || channelFlags.testBit(channel)))
55 dst[channel] = src[channel];
56 }
57
58 return newDstAlpha;
59 }
60};
61
62#endif // _KOCOMPOSITEOPDESTINATIONATOP_H_
const QString COMPOSITE_DESTINATION_ATOP
QPointF lerp(const QPointF &p1, const QPointF &p2, qreal t)
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)
KoCompositeOpDestinationAtop(const KoColorSpace *cs)
KoCompositeOpBase< CS_Traits, KoCompositeOpDestinationAtop< CS_Traits > > base_class
static QString categoryMix()