Krita Source Code Documentation
Loading...
Searching...
No Matches
CFColorDodge< T, ClampPolicy > Struct Template Reference

#include <KoCompositeOpFunctions.h>

+ Inheritance diagram for CFColorDodge< T, ClampPolicy >:

Static Public Member Functions

static T composeChannel (T src, T dst)
 
- Static Public Member Functions inherited from KoClampedSourceCompositeOpGenericFunctorBase< T >
static T clampDestinationChannelValue (T value)
 
static T clampSourceChannelValue (T value)
 

Detailed Description

template<typename T, template< typename > typename ClampPolicy>
struct CFColorDodge< T, ClampPolicy >

Definition at line 378 of file KoCompositeOpFunctions.h.

Member Function Documentation

◆ composeChannel()

template<typename T , template< typename > typename ClampPolicy>
static T CFColorDodge< T, ClampPolicy >::composeChannel ( T src,
T dst )
inlinestatic

Definition at line 379 of file KoCompositeOpFunctions.h.

379 {
380 using namespace Arithmetic;
381 using clamp_policy = ClampPolicy<T>;
382
383 // Handle the case where the denominator is 0.
384 // When src is 1 then the denominator (1 - src) becomes 0, and to avoid
385 // dividing by 0 we treat the denominator as an infinitely small number,
386 // so the result of the formula would approach infinity. As in the generic
387 // case, that result is clamped to the maximum value (which for integer
388 // types is the same as the unit value).
389 // Another special case is when both numerator and denominator are 0. In
390 // this case we also treat the denominator as an infinitely small number,
391 // and the numerator can remain as 0, so dividing 0 over a number (no matter
392 // how small it is) gives 0.
393 if (isUnitValueStrict(src)) {
394 return isZeroValueClampedStrict(dst) ? zeroValue<T>() : KoColorSpaceMathsTraits<T>::unitValue;
395 }
396
397 return clamp_policy::clampResultAllowNegative(
398 clamp_policy::fixInfiniteAfterDivision(
399 div(dst, inv(src))
400 )
401 );
402 }
bool isUnitValueStrict(T value)
bool isZeroValueClampedStrict(T value)
KoColorSpaceMathsTraits< T >::compositetype div(T a, T b)

The documentation for this struct was generated from the following file: