Changeset View
Changeset View
Standalone View
Standalone View
libs/pigment/KoColorSpaceMaths.h
Context not available. | |||||
249 | return (dst_compositetype(a) * KoColorSpaceMathsTraits<_Tdst>::unitValue) / b; | 249 | return (dst_compositetype(a) * KoColorSpaceMathsTraits<_Tdst>::unitValue) / b; | ||
---|---|---|---|---|---|
250 | } | 250 | } | ||
251 | 251 | | |||
252 | inline static dst_compositetype modulus(_T a, _Tdst b) { | ||||
253 | return (dst_compositetype(a) - floor(dst_compositetype(a)/((b != (KoColorSpaceMathsTraits<_T>::zeroValue - traits::epsilon) ? b : KoColorSpaceMathsTraits<_T>::zeroValue) + traits::epsilon))*(b + traits::epsilon)); | ||||
254 | } | ||||
255 | | ||||
256 | inline static dst_compositetype xor(_T a, _Tdst b) { | ||||
257 | return (int (a * std::numeric_limits<int>::max() - traits::epsilon) ^ int (b * std::numeric_limits<int>::max() - traits::epsilon)); | ||||
258 | } | ||||
259 | | ||||
260 | inline static dst_compositetype and(_T a, _Tdst b) { | ||||
261 | return (int (a * std::numeric_limits<int>::max() - traits::epsilon) & int (b * std::numeric_limits<int>::max() - traits::epsilon)); | ||||
262 | } | ||||
263 | | ||||
264 | inline static dst_compositetype or(_T a, _Tdst b) { | ||||
265 | return (int (a * std::numeric_limits<int>::max() - traits::epsilon) | int (b * std::numeric_limits<int>::max() - traits::epsilon)); | ||||
266 | } | ||||
267 | | ||||
252 | /** | 268 | /** | ||
253 | * Inversion : unitValue - a | 269 | * Inversion : unitValue - a | ||
254 | * @param a | 270 | * @param a | ||
Context not available. | |||||
575 | template<class T> | 591 | template<class T> | ||
576 | inline typename KoColorSpaceMathsTraits<T>::compositetype | 592 | inline typename KoColorSpaceMathsTraits<T>::compositetype | ||
577 | div(T a, T b) { return KoColorSpaceMaths<T>::divide(a, b); } | 593 | div(T a, T b) { return KoColorSpaceMaths<T>::divide(a, b); } | ||
578 | 594 | | |||
595 | template<class T> | ||||
596 | inline typename KoColorSpaceMathsTraits<T>::compositetype | ||||
597 | xor(T a, T b) { return KoColorSpaceMaths<T>::xor(a, b); } | ||||
598 | | ||||
599 | template<class T> | ||||
600 | inline typename KoColorSpaceMathsTraits<T>::compositetype | ||||
601 | and(T a, T b) { return KoColorSpaceMaths<T>::and(a, b); } | ||||
602 | | ||||
603 | template<class T> | ||||
604 | inline typename KoColorSpaceMathsTraits<T>::compositetype | ||||
605 | or(T a, T b) { return KoColorSpaceMaths<T>::or(a, b); } | ||||
606 | | ||||
579 | template<class T> | 607 | template<class T> | ||
580 | inline T clamp(typename KoColorSpaceMathsTraits<T>::compositetype a) { | 608 | inline T clamp(typename KoColorSpaceMathsTraits<T>::compositetype a) { | ||
581 | return KoColorSpaceMaths<T>::clamp(a); | 609 | return KoColorSpaceMaths<T>::clamp(a); | ||
Context not available. | |||||
612 | inline T blend(T src, T srcAlpha, T dst, T dstAlpha, T cfValue) { | 640 | inline T blend(T src, T srcAlpha, T dst, T dstAlpha, T cfValue) { | ||
613 | return mul(inv(srcAlpha), dstAlpha, dst) + mul(inv(dstAlpha), srcAlpha, src) + mul(dstAlpha, srcAlpha, cfValue); | 641 | return mul(inv(srcAlpha), dstAlpha, dst) + mul(inv(dstAlpha), srcAlpha, src) + mul(dstAlpha, srcAlpha, cfValue); | ||
614 | } | 642 | } | ||
643 | | ||||
644 | template<class T> | ||||
645 | inline T epsilon() { return KoColorSpaceMathsTraits<T>::epsilon; } | ||||
646 | | ||||
647 | template<class T> | ||||
648 | inline typename KoColorSpaceMathsTraits<T>::compositetype | ||||
649 | mod(T a, T b) { return KoColorSpaceMaths<T>::modulus(a, b); } | ||||
615 | } | 650 | } | ||
616 | 651 | | |||
617 | struct HSYType | 652 | struct HSYType | ||
Context not available. |