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:
authorDiego Borghetti <bdiego@gmail.com>2010-04-22 14:56:45 +0400
committerDiego Borghetti <bdiego@gmail.com>2010-04-22 14:56:45 +0400
commita56b72fd82e5de17ad0f688857c31cf3a9623ea1 (patch)
tree496997dd98d65a3c14f70e7a8928870b6654b45a /source/blender/blenkernel/intern/image_gen.c
parentc8c22d2cf65504443574961cea0ec1773c18735e (diff)
BugFix:
[#20854] PROPERTIES STAMP: Rendering stamp flickers in output renders Blenfont was not thread safe, that is why one thread can change the font properties (size, dpi, color, etc) at the same time that the stamp draw on the image, and then the problem. To make blenfont thread safe I have to change two important things: 1) Every BLF_* function take one argument, the font id. 2) We have two new function to make font "thread safe": BLF_load_unique BLF_load_mem_unique This two function are for case like stamp, that need and own font that don't share the glyph cache, so can draw without problem in a different thread. Why the BLF_*_unique function ? Because blenfont keep only one copy of a font and keep a list of "glyph cache". Every glyph cache have size and dpi, so if two different thread access the same font at the same time, they can change value and finish with something like the stamp problem. Why don't remove the glyph cache ? Because if we do that, we finish with a font object for every size and dpi, and the stamp is really a special case that happen in the rendering process, so I really thing is better keep the glyph cache and make this two new function to handle this special case. (When I say "font object" I mean have the same freetype font multiple times just to have differents size and dpi) As Matt point we still can have one case that two thread access the BLF_*_unique function at the same time, but I am looking to fix this with some class of thread lock. For now I test and work fine, so if some one found problem, please let me know. Campbell I have to change the python api (python/generic/blf_api.c) to the new syntax, so maybe you can take a look at this.
Diffstat (limited to 'source/blender/blenkernel/intern/image_gen.c')
-rw-r--r--source/blender/blenkernel/intern/image_gen.c56
1 files changed, 28 insertions, 28 deletions
diff --git a/source/blender/blenkernel/intern/image_gen.c b/source/blender/blenkernel/intern/image_gen.c
index eb256e3775b..9248ce69280 100644
--- a/source/blender/blenkernel/intern/image_gen.c
+++ b/source/blender/blenkernel/intern/image_gen.c
@@ -24,6 +24,7 @@
*/
#include <math.h>
+#include <stdlib.h>
#include "BLI_math_color.h"
#include "BLF_api.h"
@@ -297,17 +298,17 @@ static void checker_board_grid_fill(unsigned char *rect, float *rect_float, int
}
/* defined in image.c */
-extern void stamp_font_begin(int size);
+extern int stamp_font_begin(int size);
static void checker_board_text(unsigned char *rect, float *rect_float, int width, int height, int step, int outline)
{
- int x, y;
+ int x, y, mono;
int pen_x, pen_y;
char text[3]= {'A', '1', '\0'};
/* hard coded size! */
- stamp_font_begin(54);
- BLF_buffer(rect_float, rect, width, height, 4);
+ mono= stamp_font_begin(54);
+ BLF_buffer(mono, rect_float, rect, width, height, 4);
for(y= 0; y < height; y+=step)
{
@@ -320,29 +321,29 @@ static void checker_board_text(unsigned char *rect, float *rect_float, int width
pen_y = y + 44;
/* terribly crappy outline font! */
- BLF_buffer_col(1.0, 1.0, 1.0, 1.0);
-
- BLF_position(pen_x-outline, pen_y, 0.0);
- BLF_draw_buffer(text);
- BLF_position(pen_x+outline, pen_y, 0.0);
- BLF_draw_buffer(text);
- BLF_position(pen_x, pen_y-outline, 0.0);
- BLF_draw_buffer(text);
- BLF_position(pen_x, pen_y+outline, 0.0);
- BLF_draw_buffer(text);
+ BLF_buffer_col(mono, 1.0, 1.0, 1.0, 1.0);
+
+ BLF_position(mono, pen_x-outline, pen_y, 0.0);
+ BLF_draw_buffer(mono, text);
+ BLF_position(mono, pen_x+outline, pen_y, 0.0);
+ BLF_draw_buffer(mono, text);
+ BLF_position(mono, pen_x, pen_y-outline, 0.0);
+ BLF_draw_buffer(mono, text);
+ BLF_position(mono, pen_x, pen_y+outline, 0.0);
+ BLF_draw_buffer(mono, text);
- BLF_position(pen_x-outline, pen_y-outline, 0.0);
- BLF_draw_buffer(text);
- BLF_position(pen_x+outline, pen_y+outline, 0.0);
- BLF_draw_buffer(text);
- BLF_position(pen_x-outline, pen_y+outline, 0.0);
- BLF_draw_buffer(text);
- BLF_position(pen_x+outline, pen_y-outline, 0.0);
- BLF_draw_buffer(text);
-
- BLF_buffer_col(0.0, 0.0, 0.0, 1.0);
- BLF_position(pen_x, pen_y, 0.0);
- BLF_draw_buffer(text);
+ BLF_position(mono, pen_x-outline, pen_y-outline, 0.0);
+ BLF_draw_buffer(mono, text);
+ BLF_position(mono, pen_x+outline, pen_y+outline, 0.0);
+ BLF_draw_buffer(mono, text);
+ BLF_position(mono, pen_x-outline, pen_y+outline, 0.0);
+ BLF_draw_buffer(mono, text);
+ BLF_position(mono, pen_x+outline, pen_y-outline, 0.0);
+ BLF_draw_buffer(mono, text);
+
+ BLF_buffer_col(mono, 0.0, 0.0, 0.0, 1.0);
+ BLF_position(mono, pen_x, pen_y, 0.0);
+ BLF_draw_buffer(mono, text);
text[1]++;
}
@@ -350,8 +351,7 @@ static void checker_board_text(unsigned char *rect, float *rect_float, int width
}
/* cleanup the buffer. */
- BLF_buffer(0, 0, 0, 0, 0);
-
+ BLF_buffer(mono, NULL, NULL, 0, 0, 0);
}
void BKE_image_buf_fill_checker_color(unsigned char *rect, float *rect_float, int width, int height)