Commit b8e559a8 authored by Dmitry Kazakov's avatar Dmitry Kazakov
Browse files

Fix painting with locked alpha with colorsmudge brush

Composite copy blending mode should not try to copy the pixel
with zero alpha if alpha channel is locked. It would mean that
the destination color will be undefined.
parent 5cb02777
......@@ -125,7 +125,17 @@ struct CopyCompositor128 {
const channels_type *s = reinterpret_cast<const channels_type*>(src);
channels_type *d = reinterpret_cast<channels_type*>(dst);
float srcAlpha = s[alpha_pos];
const channels_type nativeOriginalSrcAlpha = s[alpha_pos];
// we shouldn't leak undefined color value from under the locked zero alpha
// into our destination
if (alphaLocked &&
nativeOriginalSrcAlpha == KoColorSpaceMathsTraits<channels_type>::zeroValue) {
return;
}
float srcAlpha = nativeOriginalSrcAlpha;
PixelWrapper<channels_type, _impl>::normalizeAlpha(srcAlpha);
if (haveMask) {
......@@ -136,7 +146,7 @@ struct CopyCompositor128 {
if (opacity == 0.0f) {
// noop
} else if (opacity == 1.0f) {
if (allChannelsFlag) {
if (allChannelsFlag && !alphaLocked) {
if (srcAlpha == 0.0f) {
KoStreamedMathFunctions::clearPixel<sizeof(Pixel)>(dst);
} else {
......@@ -169,7 +179,7 @@ struct CopyCompositor128 {
float newAlpha = dstAlpha + opacity * (srcAlpha - dstAlpha);
if (newAlpha == 0.0f) {
if (allChannelsFlag || dstAlpha == 0.0f) {
if ((allChannelsFlag && !alphaLocked) || dstAlpha == 0.0f) {
KoStreamedMathFunctions::clearPixel<sizeof(Pixel)>(dst);
} else {
const QBitArray &channelFlags = oparams.channelFlags;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment