Krita Source Code Documentation
Loading...
Searching...
No Matches
RgbCompositeOpBumpmap.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 RGBCOMPOSITEOPBUMPMAP_H
8#define RGBCOMPOSITEOPBUMPMAP_H
9
11
12template<class _CSTraits>
13class RgbCompositeOpBumpmap : public KoCompositeOpAlphaBase<_CSTraits, RgbCompositeOpBumpmap<_CSTraits>, true >
14{
15 typedef typename _CSTraits::channels_type channels_type;
17
18public:
19
24
25 inline static channels_type selectAlpha(channels_type srcAlpha, channels_type dstAlpha)
26 {
27 return qMin(srcAlpha, dstAlpha);
28 }
29
30 inline static void composeColorChannels(channels_type srcBlend,
31 const channels_type *src,
32 channels_type *dst,
33 bool allChannelFlags,
34 const QBitArray &channelFlags)
35 {
36 qreal intensity;
37
38 // And I'm not sure whether this is correct, either.
39 intensity = ((qreal)306.0 * src[_CSTraits::red_pos] +
40 (qreal)601.0 * src[_CSTraits::green_pos] +
41 (qreal)117.0 * src[_CSTraits::blue_pos]) / 1024.0;
42
43 for (uint i = 0; i < _CSTraits::channels_nb; i++) {
44 if ((int)i != _CSTraits::alpha_pos && (allChannelFlags || channelFlags.testBit(i))) {
45 channels_type srcChannel = (channels_type)(((qreal)
46 intensity * dst[i]) / NATIVE_OPACITY_OPAQUE + 0.5);
47 channels_type dstChannel = dst[i];
48
49 dst[i] = KoColorSpaceMaths<channels_type>::blend(srcChannel, dstChannel, srcBlend);
50 }
51 }
52 }
53
54};
55
56#endif
#define NATIVE_OPACITY_OPAQUE
const QString COMPOSITE_BUMPMAP
unsigned int uint
static _T blend(_T a, _T b, _T alpha)
static channels_type selectAlpha(channels_type srcAlpha, channels_type dstAlpha)
KoColorSpaceMathsTraits< typename_CSTraits::channels_type >::compositetype compositetype
RgbCompositeOpBumpmap(KoColorSpace *cs)
_CSTraits::channels_type channels_type
static void composeColorChannels(channels_type srcBlend, const channels_type *src, channels_type *dst, bool allChannelFlags, const QBitArray &channelFlags)
static QString categoryMisc()