Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBrecht Van Lommel <brechtvanlommel@pandora.be>2013-04-30 20:07:52 +0400
committerBrecht Van Lommel <brechtvanlommel@pandora.be>2013-04-30 20:07:52 +0400
commit576e579925d205a44dd347fca3646f5c749a60a6 (patch)
tree3184282505f00cb7514384d2f1b6bdfc433ede6e /source/blender/blenlib/intern/math_color_blend_inline.c
parent7a0bdbc55016d287278b6818f26dc096eeb9c098 (diff)
More painting fixes:
* 2D image painting with textures that contained alpha did not work correctly, had been broken for a while. * 2D image panels texture (mask) panels showed wrong buttons for texture overlay. * Texture map mode 3D now also uses masking, like Tiled and Stencil the texture does not move along with the brush so it works fine. * 2D image paint View mapping did not work correct, especially noticeable with Rake rotation. * Masking is now disabled for the smear tool, this can't really work because the original image is constantly changing and gave artifacts.
Diffstat (limited to 'source/blender/blenlib/intern/math_color_blend_inline.c')
-rw-r--r--source/blender/blenlib/intern/math_color_blend_inline.c33
1 files changed, 33 insertions, 0 deletions
diff --git a/source/blender/blenlib/intern/math_color_blend_inline.c b/source/blender/blenlib/intern/math_color_blend_inline.c
index 121750fe919..52947fcee08 100644
--- a/source/blender/blenlib/intern/math_color_blend_inline.c
+++ b/source/blender/blenlib/intern/math_color_blend_inline.c
@@ -242,6 +242,28 @@ MINLINE void blend_color_add_alpha_byte(unsigned char dst[4], const unsigned cha
}
}
+MINLINE void blend_color_interpolate_byte(unsigned char dst[4], const unsigned char src1[4], const unsigned char src2[4], float ft)
+{
+ /* do color interpolation, but in premultiplied space so that RGB colors
+ * from zero alpha regions have no influence */
+ const int t = (int)(255 * ft);
+ const int mt = 255 - t;
+ int tmp = (mt * src1[3] + t * src2[3]);
+
+ if (tmp > 0) {
+ dst[0] = divide_round_i(mt * src1[0] * src1[3] + t * src2[0] * src2[3], tmp);
+ dst[1] = divide_round_i(mt * src1[1] * src1[3] + t * src2[1] * src2[3], tmp);
+ dst[2] = divide_round_i(mt * src1[2] * src1[3] + t * src2[2] * src2[3], tmp);
+ dst[3] = divide_round_i(tmp, 255);
+ }
+ else {
+ dst[0] = src1[0];
+ dst[1] = src1[1];
+ dst[2] = src1[2];
+ dst[3] = src1[3];
+ }
+}
+
/* premultiplied alpha float blending modes */
MINLINE void blend_color_mix_float(float dst[4], const float src1[4], const float src2[4])
@@ -420,4 +442,15 @@ MINLINE void blend_color_add_alpha_float(float dst[4], const float src1[4], cons
}
}
+MINLINE void blend_color_interpolate_float(float dst[4], const float src1[4], const float src2[4], float t)
+{
+ /* interpolation, colors are premultiplied so it goes fine */
+ float mt = 1.0f - t;
+
+ dst[0] = mt * src1[0] + t * src2[0];
+ dst[1] = mt * src1[1] + t * src2[1];
+ dst[2] = mt * src1[2] + t * src2[2];
+ dst[3] = mt * src1[3] + t * src2[3];
+}
+
#endif /* __MATH_COLOR_BLEND_INLINE_C__ */