Paste P296

# Masterwork From Distant LandsActivePublicActions

Authored by dkazakov on Jan 31 2019, 6:19 PM.
Tags
None
Subscribers
None
 diff --git a/libs/pigment/compositeops/KoCompositeOpAlphaDarken.h b/libs/pigment/compositeops/KoCompositeOpAlphaDarken.h index e51e1a6..c05668e 100644 --- a/libs/pigment/compositeops/KoCompositeOpAlphaDarken.h +++ b/libs/pigment/compositeops/KoCompositeOpAlphaDarken.h @@ -91,7 +91,24 @@ public: channels_type fullFlowAlpha; channels_type averageOpacity = scale(*params.lastOpacity); + /** + * Here we calculate fullFlowAlpha, which shuold strive either to + * averageOpacity or opacity (whichever is the greater) or just keep old dstAlpha + * value, if both opacity values are not bit enough + */ if (averageOpacity > opacity) { + /** + * This crypty code is basically an optimized version of the folowing: + * fullFlowAlpha = averageOpacity * + * unionShapeOpacity(srcAlpha / averageOpacity, + * dstAlpha / averageOpacity); + * + * The main idea is: fullFlowAlpha should be as near to averageOpacity as + * maximum of srcAlpha and dstAlpha and a bit more. So that in consequent + * applications of the blending operation alpha channel would aim to + * averageOpacity. + */ + channels_type reverseBlend = KoColorSpaceMaths::divide(dstAlpha, averageOpacity); fullFlowAlpha = averageOpacity > dstAlpha ? lerp(srcAlpha, averageOpacity, reverseBlend) : dstAlpha; } else { @@ -103,8 +120,6 @@ public: } else { channels_type zeroFlowAlpha = dstAlpha; dstAlpha = lerp(zeroFlowAlpha, fullFlowAlpha, flow); - - } dst[alpha_pos] = dstAlpha;
dkazakov edited the content of this paste. (Show Details)Jan 31 2019, 6:19 PM
dkazakov changed the title of this paste from untitled to Masterwork From Distant Lands.