From e2b2d083e0cd2c738962e2a4535acdfb17f37416 Mon Sep 17 00:00:00 2001 From: Antony Riakiotakis Date: Sun, 17 Mar 2013 18:09:09 +0000 Subject: 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. --- source/blender/blenkernel/BKE_brush.h | 2 +- source/blender/blenkernel/intern/brush.c | 16 ++++++++-------- source/blender/editors/sculpt_paint/paint_image_2d.c | 4 ++-- source/blender/imbuf/IMB_imbuf_types.h | 1 - source/blender/imbuf/intern/rectop.c | 2 +- 5 files changed, 12 insertions(+), 13 deletions(-) (limited to 'source/blender') diff --git a/source/blender/blenkernel/BKE_brush.h b/source/blender/blenkernel/BKE_brush.h index 3a4684257f6..4dfc70db952 100644 --- a/source/blender/blenkernel/BKE_brush.h +++ b/source/blender/blenkernel/BKE_brush.h @@ -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); diff --git a/source/blender/blenkernel/intern/brush.c b/source/blender/blenkernel/intern/brush.c index 6adcdbd2c3e..c594e19b960 100644 --- a/source/blender/blenkernel/intern/brush.c +++ b/source/blender/blenkernel/intern/brush.c @@ -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]; diff --git a/source/blender/editors/sculpt_paint/paint_image_2d.c b/source/blender/editors/sculpt_paint/paint_image_2d.c index ed1b25d1b4e..921ef6c2879 100644 --- a/source/blender/editors/sculpt_paint/paint_image_2d.c +++ b/source/blender/editors/sculpt_paint/paint_image_2d.c @@ -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); } diff --git a/source/blender/imbuf/IMB_imbuf_types.h b/source/blender/imbuf/IMB_imbuf_types.h index a3629d079a3..dde8d4d4ab7 100644 --- a/source/blender/imbuf/IMB_imbuf_types.h +++ b/source/blender/imbuf/IMB_imbuf_types.h @@ -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) diff --git a/source/blender/imbuf/intern/rectop.c b/source/blender/imbuf/intern/rectop.c index 8b60d1a96df..446833ccf3b 100644 --- a/source/blender/imbuf/intern/rectop.c +++ b/source/blender/imbuf/intern/rectop.c @@ -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]); } -- cgit v1.2.3