40 const bool haveOpacity = opacity != 1.0f;
41 const float_v opacity_norm_vec(opacity);
43 const float_v uint8Max(255.0f);
44 const float_v uint8MaxRec1(1.0f / 255.0f);
45 const float_v zeroValue(0);
46 const float_v oneValue(1);
48 src_alpha *= opacity_norm_vec;
52 src_alpha *= mask_vec * uint8MaxRec1;
57 if (xsimd::all(src_alpha == zeroValue)) {
76 if (xsimd::all(dst_alpha == uint8Max)) {
77 new_alpha = dst_alpha;
78 src_blend = src_alpha * uint8MaxRec1;
79 }
else if (xsimd::all(dst_alpha == zeroValue)) {
80 new_alpha = src_alpha;
89 new_alpha = dst_alpha + (uint8Max - dst_alpha) * src_alpha * uint8MaxRec1;
97 if (!xsimd::all(src_blend == oneValue)) {
100 dst_c1 = src_blend * (src_c1 - dst_c1) + dst_c1;
101 dst_c2 = src_blend * (src_c2 - dst_c2) + dst_c2;
102 dst_c3 = src_blend * (src_c3 - dst_c3) + dst_c3;
105 if (!haveMask && !haveOpacity) {
106 memcpy(dst, src, 4 * float_v::size);
124 const qint32 alpha_pos = 3;
126 const float uint8Rec1 = 1.0f / 255.0f;
127 const float uint8Max = 255.0f;
129 float srcAlpha = src[alpha_pos];
133 srcAlpha *= float(*mask) * uint8Rec1;
136 if (srcAlpha != 0.0f) {
138 float dstAlpha = dst[alpha_pos];
139 float srcBlendNorm = NAN;
141 if (alphaLocked || dstAlpha == uint8Max) {
142 srcBlendNorm = srcAlpha * uint8Rec1;
143 }
else if (dstAlpha == 0.0f) {
147 if (!allChannelsFlag) {
148 auto *d =
reinterpret_cast<pixel_type*
>(dst);
152 dstAlpha += (uint8Max - dstAlpha) * srcAlpha * uint8Rec1;
158 if(allChannelsFlag) {
159 if (srcBlendNorm == 1.0f) {
161 const auto *s =
reinterpret_cast<const pixel_type*
>(src);
162 auto *d =
reinterpret_cast<pixel_type*
>(dst);
169 }
else if (srcBlendNorm != 0.0f){
177 if (srcBlendNorm == 1.0f) {
178 if(channelFlags.at(0)) dst[0] = src[0];
179 if(channelFlags.at(1)) dst[1] = src[1];
180 if(channelFlags.at(2)) dst[2] = src[2];
181 }
else if (srcBlendNorm != 0.0f) {