Fix "can't paint" bug no.1, painting with black on image editor did not

paint. Was own regression when optimizing colour operations. I will not
use an alpha bit mask since it may run into portability issues with byte
order.
This commit is contained in:
Antony Riakiotakis
2013-03-17 18:09:09 +00:00
parent 66a35e089a
commit e2b2d083e0
5 changed files with 12 additions and 13 deletions

View File

@@ -72,7 +72,7 @@ float BKE_brush_curve_strength(struct Brush *br, float p, const float len); /* u
float BKE_brush_sample_tex_3D(const Scene *scene, struct Brush *br, const float point[3],
float rgba[4], const int thread, struct ImagePool *pool);
float BKE_brush_sample_tex_2D(const struct Scene *scene, struct Brush *brush, const float xy[2],
float rgba[4], struct ImagePool *pool);
float rgba[4]);
void BKE_brush_imbuf_new(const struct Scene *scene, struct Brush *brush, short flt, short texfalloff, int size,
struct ImBuf **imbuf, int use_color_correction);

View File

@@ -563,7 +563,7 @@ float BKE_brush_sample_tex_3D(const Scene *scene, Brush *br,
/* Brush Sampling for 2D brushes. when we unify the brush systems this will be necessarily a separate function */
float BKE_brush_sample_tex_2D(const Scene *scene, Brush *brush, const float xy[2], float rgba[4], struct ImagePool *pool)
float BKE_brush_sample_tex_2D(const Scene *scene, Brush *brush, const float xy[2], float rgba[4])
{
UnifiedPaintSettings *ups = &scene->toolsettings->unified_paint_settings;
MTex *mtex = &brush->mtex;
@@ -598,7 +598,7 @@ float BKE_brush_sample_tex_2D(const Scene *scene, Brush *brush, const float xy[2
co[1] = y + brush->mtex.ofs[1];
co[2] = 0.0f;
hasrgb = externtex(mtex, co, &tin, &tr, &tg, &tb, &ta, 0, pool);
hasrgb = externtex(mtex, co, &tin, &tr, &tg, &tb, &ta, 0, NULL);
if (hasrgb) {
rgba[0] = tr;
@@ -660,15 +660,15 @@ void BKE_brush_imbuf_new(const Scene *scene, Brush *brush, short flt, short texf
dstf[3] = alpha * BKE_brush_curve_strength_clamp(brush, len_v2(xy), radius);
}
else if (texfall == 1) {
BKE_brush_sample_tex_2D(scene, brush, xy, dstf, 0);
BKE_brush_sample_tex_2D(scene, brush, xy, dstf);
}
else if (texfall == 2) {
BKE_brush_sample_tex_2D(scene, brush, xy, rgba, 0);
BKE_brush_sample_tex_2D(scene, brush, xy, rgba);
mul_v3_v3v3(dstf, rgba, brush_rgb);
dstf[3] = rgba[3] * alpha * BKE_brush_curve_strength_clamp(brush, len_v2(xy), radius);
}
else {
BKE_brush_sample_tex_2D(scene, brush, xy, rgba, 0);
BKE_brush_sample_tex_2D(scene, brush, xy, rgba);
copy_v3_v3(dstf, brush_rgb);
dstf[3] = rgba[3] * alpha * BKE_brush_curve_strength_clamp(brush, len_v2(xy), radius);
}
@@ -695,11 +695,11 @@ void BKE_brush_imbuf_new(const Scene *scene, Brush *brush, short flt, short texf
dst[3] = FTOCHAR(alpha_f);
}
else if (texfall == 1) {
BKE_brush_sample_tex_2D(scene, brush, xy, rgba, 0);
BKE_brush_sample_tex_2D(scene, brush, xy, rgba);
rgba_float_to_uchar(dst, rgba);
}
else if (texfall == 2) {
BKE_brush_sample_tex_2D(scene, brush, xy, rgba, 0);
BKE_brush_sample_tex_2D(scene, brush, xy, rgba);
mul_v3_v3(rgba, brush->rgb);
alpha_f = rgba[3] * alpha * BKE_brush_curve_strength_clamp(brush, len_v2(xy), radius);
@@ -708,7 +708,7 @@ void BKE_brush_imbuf_new(const Scene *scene, Brush *brush, short flt, short texf
dst[3] = FTOCHAR(alpha_f);
}
else {
BKE_brush_sample_tex_2D(scene, brush, xy, rgba, 0);
BKE_brush_sample_tex_2D(scene, brush, xy, rgba);
alpha_f = rgba[3] * alpha * BKE_brush_curve_strength_clamp(brush, len_v2(xy), radius);
dst[0] = crgb[0];

View File

@@ -235,7 +235,7 @@ static void brush_painter_2d_do_partial(BrushPainter *painter, ImBuf *oldtexibuf
xy[0] = x + xoff;
xy[1] = y + yoff;
BKE_brush_sample_tex_2D(scene, brush, xy, tf, NULL);
BKE_brush_sample_tex_2D(scene, brush, xy, tf);
}
bf[0] = tf[0] * mf[0];
@@ -266,7 +266,7 @@ static void brush_painter_2d_do_partial(BrushPainter *painter, ImBuf *oldtexibuf
xy[0] = x + xoff;
xy[1] = y + yoff;
BKE_brush_sample_tex_2D(scene, brush, xy, rgba, NULL);
BKE_brush_sample_tex_2D(scene, brush, xy, rgba);
rgba_float_to_uchar(t, rgba);
}

View File

@@ -179,7 +179,6 @@ typedef struct ImBuf {
* Note that the lower 11 bits is used for storing custom flags
*/
#define IB_CUSTOM_FLAGS_MASK 0x7ff
#define IB_ALPHA_MASK 0xff
#define PNG (1 << 30)
#define TGA (1 << 28)

View File

@@ -517,7 +517,7 @@ void IMB_rectblend(struct ImBuf *dbuf, struct ImBuf *sbuf, int destx,
dr = drect;
sr = srect;
for (x = width; x > 0; x--, dr++, sr++) {
if (*sr & IB_ALPHA_MASK)
if (((char *)sr)[3])
func((char *)dr, (char *)dr, (char *)sr, ((char *)sr)[3]);
}