18#ifndef KIS_F16HALF_BASE_COLORSPACE_H_
19#define KIS_F16HALF_BASE_COLORSPACE_H_
25#include "kis_global.h"
26#include "kis_abstract_colorspace.h"
27#include "kis_integer_maths.h"
35inline half UINT8_TO_HALF(uint c)
37 return static_cast<half
>(c) / UINT8_MAX;
40inline uint HALF_TO_UINT8(half c)
42 return static_cast<uint
>(CLAMP(
static_cast<int>(c *
static_cast<int>(UINT8_MAX) + 0.5),
43 static_cast<int>(UINT8_MIN),
static_cast<int>(UINT8_MAX)));
47inline uint HALF_TO_UINT16(half c)
49 return static_cast<uint
>(CLAMP(
static_cast<int>(c *
static_cast<int>(UINT16_MAX) + 0.5),
50 static_cast<int>(UINT16_MIN),
static_cast<int>(UINT16_MAX)));
53inline half HALF_BLEND(half a, half b, half alpha)
55 return (a - b) * alpha + b;
58#define F16HALF_OPACITY_OPAQUE ((half)1.0f)
59#define F16HALF_OPACITY_TRANSPARENT ((half)0.0f)
65 KisF16HalfBaseColorSpace(
const KisID &
id, DWORD cmType, icColorSpaceSignature colorSpaceSignature,
66 KisColorSpaceFactoryRegistry * parent,
70 m_alphaSize =
sizeof(half);
73 virtual TQ_UINT8 getAlpha(
const TQ_UINT8 * pixel)
const;
74 virtual void setAlpha(TQ_UINT8 * pixels, TQ_UINT8 alpha, TQ_INT32 nPixels)
const;
75 virtual void multiplyAlpha(TQ_UINT8 * pixels, TQ_UINT8 alpha, TQ_INT32 nPixels);
77 virtual void applyAlphaU8Mask(TQ_UINT8 * pixels, TQ_UINT8 * alpha, TQ_INT32 nPixels);
78 virtual void applyInverseAlphaU8Mask(TQ_UINT8 * pixels, TQ_UINT8 * alpha, TQ_INT32 nPixels);
80 virtual TQString channelValueText(
const TQ_UINT8 *pixel, TQ_UINT32 channelIndex)
const;
81 virtual TQString normalisedChannelValueText(
const TQ_UINT8 *pixel, TQ_UINT32 channelIndex)
const;
83 virtual TQ_UINT8 scaleToU8(
const TQ_UINT8 * srcPixel, TQ_INT32 channelPos);
84 virtual TQ_UINT16 scaleToU16(
const TQ_UINT8 * srcPixel, TQ_INT32 channelPos);
91 inline half operator()(
const half& a,
const half& b)
const {
95 struct Uint8ToF16Half {
96 inline half operator()(
const TQ_UINT8 src)
const {
97 return UINT8_TO_HALF(src);
100 struct F16HalfOpacityTest {
101 inline bool operator()(
const half& opacity)
const {
102 return opacity > F16HALF_OPACITY_TRANSPARENT + HALF_EPSILON;
A colorspace strategy is the definition of a certain color model in Chalk.
KisAbstractColorSpace(const KisID &id, DWORD cmType, icColorSpaceSignature colorSpaceSignature, KisColorSpaceFactoryRegistry *parent, KisProfile *profile)
virtual bool hasHighDynamicRange() const
Returns true if the colorspace supports channel values outside the (normalised) range 0 to 1.
virtual KisID id() const
Chalk definition for use in .kra files and internally: unchanging name + i18n'able description.