[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [49860] trunk/blender/source/blender: fix [#32126] STAMP: Setting a background color causes color flicker

Campbell Barton ideasman42 at gmail.com
Mon Aug 13 00:50:21 CEST 2012


Revision: 49860
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=49860
Author:   campbellbarton
Date:     2012-08-12 22:50:21 +0000 (Sun, 12 Aug 2012)
Log Message:
-----------
fix [#32126] STAMP: Setting a background color causes color flicker

when rendering the sequencer can output float or char buffers which stamp wasn't accounting for.

Modified Paths:
--------------
    trunk/blender/source/blender/blenfont/BLF_api.h
    trunk/blender/source/blender/blenfont/intern/blf.c
    trunk/blender/source/blender/blenfont/intern/blf_font.c
    trunk/blender/source/blender/blenfont/intern/blf_internal_types.h
    trunk/blender/source/blender/blenkernel/intern/image.c
    trunk/blender/source/blender/imbuf/IMB_imbuf.h
    trunk/blender/source/blender/imbuf/intern/rectop.c

Modified: trunk/blender/source/blender/blenfont/BLF_api.h
===================================================================
--- trunk/blender/source/blender/blenfont/BLF_api.h	2012-08-12 22:18:20 UTC (rev 49859)
+++ trunk/blender/source/blender/blenfont/BLF_api.h	2012-08-12 22:50:21 UTC (rev 49860)
@@ -145,13 +145,13 @@
 /* Set the buffer, size and number of channels to draw, one thing to take care is call
  * this function with NULL pointer when we finish, for example:
  *
- *     BLF_buffer(my_fbuf, my_cbuf, 100, 100, 4);
+ *     BLF_buffer(my_fbuf, my_cbuf, 100, 100, 4, TRUE);
  *
  *     ... set color, position and draw ...
  *
- *     BLF_buffer(NULL, NULL, 0, 0, 0);
+ *     BLF_buffer(NULL, NULL, 0, 0, 0, FALSE);
  */
-void BLF_buffer(int fontid, float *fbuf, unsigned char *cbuf, int w, int h, int nch, int is_linear);
+void BLF_buffer(int fontid, float *fbuf, unsigned char *cbuf, int w, int h, int nch, int do_color_management);
 
 /* Set the color to be used for text. */
 void BLF_buffer_col(int fontid, float r, float g, float b, float a);

Modified: trunk/blender/source/blender/blenfont/intern/blf.c
===================================================================
--- trunk/blender/source/blender/blenfont/intern/blf.c	2012-08-12 22:18:20 UTC (rev 49859)
+++ trunk/blender/source/blender/blenfont/intern/blf.c	2012-08-12 22:50:21 UTC (rev 49860)
@@ -746,7 +746,7 @@
 	}
 }
 
-void BLF_buffer(int fontid, float *fbuf, unsigned char *cbuf, int w, int h, int nch, int is_linear)
+void BLF_buffer(int fontid, float *fbuf, unsigned char *cbuf, int w, int h, int nch, int do_color_management)
 {
 	FontBLF *font = BLF_get(fontid);
 
@@ -756,7 +756,7 @@
 		font->buf_info.w = w;
 		font->buf_info.h = h;
 		font->buf_info.ch = nch;
-		font->buf_info.is_linear = is_linear;
+		font->buf_info.do_color_management = do_color_management;
 	}
 }
 

Modified: trunk/blender/source/blender/blenfont/intern/blf_font.c
===================================================================
--- trunk/blender/source/blender/blenfont/intern/blf_font.c	2012-08-12 22:18:20 UTC (rev 49859)
+++ trunk/blender/source/blender/blenfont/intern/blf_font.c	2012-08-12 22:50:21 UTC (rev 49860)
@@ -243,7 +243,7 @@
 	blf_font_ensure_ascii_table(font);
 
 	/* another buffer spesific call for color conversion */
-	if (buf_info->is_linear) {
+	if (buf_info->do_color_management) {
 		srgb_to_linearrgb_v4(b_col_float, buf_info->col);
 	}
 	else {
@@ -304,9 +304,9 @@
 								fbuf[3] = (alphatest = (fbuf[3] + (b_col_float[3]))) < 1.0f ? alphatest : 1.0f;
 							}
 							else {
-								fbuf[0] = (b_col_float[0] * a) + (fbuf[0] * (1 - a));
-								fbuf[1] = (b_col_float[1] * a) + (fbuf[1] * (1 - a));
-								fbuf[2] = (b_col_float[2] * a) + (fbuf[2] * (1 - a));
+								fbuf[0] = (b_col_float[0] * a) + (fbuf[0] * (1.0f - a));
+								fbuf[1] = (b_col_float[1] * a) + (fbuf[1] * (1.0f - a));
+								fbuf[2] = (b_col_float[2] * a) + (fbuf[2] * (1.0f - a));
 								fbuf[3] = (alphatest = (fbuf[3] + (b_col_float[3] * a))) < 1.0f ? alphatest : 1.0f;
 							}
 						}

Modified: trunk/blender/source/blender/blenfont/intern/blf_internal_types.h
===================================================================
--- trunk/blender/source/blender/blenfont/intern/blf_internal_types.h	2012-08-12 22:18:20 UTC (rev 49859)
+++ trunk/blender/source/blender/blenfont/intern/blf_internal_types.h	2012-08-12 22:50:21 UTC (rev 49860)
@@ -146,7 +146,7 @@
 	int ch;
 
 	/* is the float buffer linear */
-	int is_linear;
+	int do_color_management;
 
 	/* and the color, the alphas is get from the glyph!
 	 * color is srgb space */

Modified: trunk/blender/source/blender/blenkernel/intern/image.c
===================================================================
--- trunk/blender/source/blender/blenkernel/intern/image.c	2012-08-12 22:18:20 UTC (rev 49859)
+++ trunk/blender/source/blender/blenkernel/intern/image.c	2012-08-12 22:50:21 UTC (rev 49860)
@@ -1476,6 +1476,10 @@
 	float h_fixed;
 	const int mono = blf_mono_font_render; // XXX
 
+	/* this could be an argument if we want to operate on non linear float imbuf's
+	 * for now though this is only used for renders which use scene settings */
+	const int do_color_management = (scene->r.color_mgt_flag & R_COLOR_MANAGEMENT) != 0;
+
 #define BUFF_MARGIN_X 2
 #define BUFF_MARGIN_Y 1
 
@@ -1491,7 +1495,7 @@
 	/* set before return */
 	BLF_size(mono, scene->r.stamp_font_id, 72);
 
-	BLF_buffer(mono, rectf, rect, width, height, channels, (scene->r.color_mgt_flag & R_COLOR_MANAGEMENT) != 0);
+	BLF_buffer(mono, rectf, rect, width, height, channels, do_color_management);
 	BLF_buffer_col(mono, scene->r.fg_stamp[0], scene->r.fg_stamp[1], scene->r.fg_stamp[2], 1.0);
 	pad = BLF_width_max(mono);
 
@@ -1508,7 +1512,7 @@
 		y -= h;
 
 		/* also a little of space to the background. */
-		buf_rectfill_area(rect, rectf, width, height, scene->r.bg_stamp,
+		buf_rectfill_area(rect, rectf, width, height, scene->r.bg_stamp, do_color_management,
 						  x - BUFF_MARGIN_X, y - BUFF_MARGIN_Y, w + BUFF_MARGIN_X, y + h + BUFF_MARGIN_Y);
 
 		/* and draw the text. */
@@ -1525,7 +1529,7 @@
 		y -= h;
 
 		/* and space for background. */
-		buf_rectfill_area(rect, rectf, width, height, scene->r.bg_stamp,
+		buf_rectfill_area(rect, rectf, width, height, scene->r.bg_stamp, do_color_management,
 						  0, y - BUFF_MARGIN_Y, w + BUFF_MARGIN_X, y + h + BUFF_MARGIN_Y);
 
 		BLF_position(mono, x, y + y_ofs, 0.0);
@@ -1541,7 +1545,7 @@
 		y -= h;
 
 		/* and space for background. */
-		buf_rectfill_area(rect, rectf, width, height, scene->r.bg_stamp,
+		buf_rectfill_area(rect, rectf, width, height, scene->r.bg_stamp, do_color_management,
 						  0, y - BUFF_MARGIN_Y, w + BUFF_MARGIN_X, y + h + BUFF_MARGIN_Y);
 
 		BLF_position(mono, x, y + y_ofs, 0.0);
@@ -1557,7 +1561,7 @@
 		y -= h;
 
 		/* and space for background. */
-		buf_rectfill_area(rect, rectf, width, height, scene->r.bg_stamp,
+		buf_rectfill_area(rect, rectf, width, height, scene->r.bg_stamp, do_color_management,
 						  0, y - BUFF_MARGIN_Y, w + BUFF_MARGIN_X, y + h + BUFF_MARGIN_Y);
 
 		BLF_position(mono, x, y + y_ofs, 0.0);
@@ -1572,7 +1576,7 @@
 		BLF_width_and_height(mono, stamp_data.marker, &w, &h); h = h_fixed;
 
 		/* extra space for background. */
-		buf_rectfill_area(rect, rectf, width, height, scene->r.bg_stamp,
+		buf_rectfill_area(rect, rectf, width, height, scene->r.bg_stamp,  do_color_management,
 						  x - BUFF_MARGIN_X, y - BUFF_MARGIN_Y, w + BUFF_MARGIN_X, y + h + BUFF_MARGIN_Y);
 
 		/* and pad the text. */
@@ -1588,7 +1592,7 @@
 		BLF_width_and_height(mono, stamp_data.time, &w, &h); h = h_fixed;
 
 		/* extra space for background */
-		buf_rectfill_area(rect, rectf, width, height, scene->r.bg_stamp,
+		buf_rectfill_area(rect, rectf, width, height, scene->r.bg_stamp, do_color_management,
 						  x - BUFF_MARGIN_X, y, x + w + BUFF_MARGIN_X, y + h + BUFF_MARGIN_Y);
 
 		/* and pad the text. */
@@ -1603,7 +1607,7 @@
 		BLF_width_and_height(mono, stamp_data.frame, &w, &h); h = h_fixed;
 
 		/* extra space for background. */
-		buf_rectfill_area(rect, rectf, width, height, scene->r.bg_stamp,
+		buf_rectfill_area(rect, rectf, width, height, scene->r.bg_stamp, do_color_management,
 						  x - BUFF_MARGIN_X, y - BUFF_MARGIN_Y, x + w + BUFF_MARGIN_X, y + h + BUFF_MARGIN_Y);
 
 		/* and pad the text. */
@@ -1618,7 +1622,7 @@
 		BLF_width_and_height(mono, stamp_data.camera, &w, &h); h = h_fixed;
 
 		/* extra space for background. */
-		buf_rectfill_area(rect, rectf, width, height, scene->r.bg_stamp,
+		buf_rectfill_area(rect, rectf, width, height, scene->r.bg_stamp, do_color_management,
 						  x - BUFF_MARGIN_X, y - BUFF_MARGIN_Y, x + w + BUFF_MARGIN_X, y + h + BUFF_MARGIN_Y);
 		BLF_position(mono, x, y + y_ofs, 0.0);
 		BLF_draw_buffer(mono, stamp_data.camera);
@@ -1631,7 +1635,7 @@
 		BLF_width_and_height(mono, stamp_data.cameralens, &w, &h); h = h_fixed;
 
 		/* extra space for background. */
-		buf_rectfill_area(rect, rectf, width, height, scene->r.bg_stamp,
+		buf_rectfill_area(rect, rectf, width, height, scene->r.bg_stamp, do_color_management,
 						  x - BUFF_MARGIN_X, y - BUFF_MARGIN_Y, x + w + BUFF_MARGIN_X, y + h + BUFF_MARGIN_Y);
 		BLF_position(mono, x, y + y_ofs, 0.0);
 		BLF_draw_buffer(mono, stamp_data.cameralens);
@@ -1644,7 +1648,7 @@
 		x = width - w - 2;
 
 		/* extra space for background. */
-		buf_rectfill_area(rect, rectf, width, height, scene->r.bg_stamp,
+		buf_rectfill_area(rect, rectf, width, height, scene->r.bg_stamp, do_color_management,
 						  x - BUFF_MARGIN_X, y - BUFF_MARGIN_Y, x + w + BUFF_MARGIN_X, y + h + BUFF_MARGIN_Y);
 
 		/* and pad the text. */
@@ -1660,7 +1664,7 @@
 		y = height - h;
 
 		/* extra space for background. */
-		buf_rectfill_area(rect, rectf, width, height, scene->r.bg_stamp,
+		buf_rectfill_area(rect, rectf, width, height, scene->r.bg_stamp, do_color_management,
 						  x - BUFF_MARGIN_X, y - BUFF_MARGIN_Y, x + w + BUFF_MARGIN_X, y + h + BUFF_MARGIN_Y);
 
 		BLF_position(mono, x, y + y_ofs, 0.0);

Modified: trunk/blender/source/blender/imbuf/IMB_imbuf.h
===================================================================
--- trunk/blender/source/blender/imbuf/IMB_imbuf.h	2012-08-12 22:18:20 UTC (rev 49859)
+++ trunk/blender/source/blender/imbuf/IMB_imbuf.h	2012-08-12 22:50:21 UTC (rev 49860)
@@ -482,7 +482,9 @@
 void IMB_rectfill_alpha(struct ImBuf *ibuf, const float value);
 
 /* this should not be here, really, we needed it for operating on render data, IMB_rectfill_area calls it */
-void buf_rectfill_area(unsigned char *rect, float *rectf, int width, int height, const float col[4], int x1, int y1, int x2, int y2);
+void buf_rectfill_area(unsigned char *rect, float *rectf, int width, int height,
+					   const float col[4], const int do_color_management,
+					   int x1, int y1, int x2, int y2);
 
 /* defined in metadata.c */
 int IMB_metadata_change_field(struct ImBuf *img, const char *key, const char *field);

Modified: trunk/blender/source/blender/imbuf/intern/rectop.c
===================================================================
--- trunk/blender/source/blender/imbuf/intern/rectop.c	2012-08-12 22:18:20 UTC (rev 49859)
+++ trunk/blender/source/blender/imbuf/intern/rectop.c	2012-08-12 22:50:21 UTC (rev 49860)
@@ -31,9 +31,11 @@
  *  \ingroup imbuf
  */
 
+#include <stdlib.h>
 
-#include "BLI_blenlib.h"
 #include "BLI_utildefines.h"
+#include "BLI_math_color.h"

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list