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/editors/space_console
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/editors/space_console')
-rw-r--r--source/blender/editors/space_console/console_draw.c33
1 files changed, 16 insertions, 17 deletions
diff --git a/source/blender/editors/space_console/console_draw.c b/source/blender/editors/space_console/console_draw.c
index db7bb8419e8..2fab998b9b6 100644
--- a/source/blender/editors/space_console/console_draw.c
+++ b/source/blender/editors/space_console/console_draw.c
@@ -59,17 +59,16 @@
#include "console_intern.h"
+
+static int mono= -1; // XXX needs proper storage and change all the BLF_* here!
+
static void console_font_begin(SpaceConsole *sc)
{
- static int mono= -1; // XXX needs proper storage
-
if(mono == -1)
mono= BLF_load_mem("monospace", (unsigned char*)datatoc_bmonofont_ttf, datatoc_bmonofont_ttf_size);
- BLF_set(mono);
- BLF_aspect(1.0);
-
- BLF_size(sc->lheight-2, 72);
+ BLF_aspect(mono, 1.0);
+ BLF_size(mono, sc->lheight-2, 72);
}
static void console_line_color(unsigned char *fg, int type)
@@ -224,8 +223,8 @@ static int console_draw_string(ConsoleDrawContext *cdc, char *str, int str_len,
glColor3ub(fg[0], fg[1], fg[2]);
/* last part needs no clipping */
- BLF_position(cdc->xy[0], cdc->xy[1], 0);
- BLF_draw(line_stride);
+ BLF_position(mono, cdc->xy[0], cdc->xy[1], 0);
+ BLF_draw(mono, line_stride);
if(cdc->sel[0] != cdc->sel[1]) {
cdc->sel[0] += str_len - (cdc->console_width % str_len);
@@ -242,8 +241,8 @@ static int console_draw_string(ConsoleDrawContext *cdc, char *str, int str_len,
eol = line_stride[cdc->console_width];
line_stride[cdc->console_width]= '\0';
- BLF_position(cdc->xy[0], cdc->xy[1], 0);
- BLF_draw(line_stride);
+ BLF_position(mono, cdc->xy[0], cdc->xy[1], 0);
+ BLF_draw(mono, line_stride);
if(cdc->sel[0] != cdc->sel[1]) {
console_draw_sel(cdc->sel, cdc->xy, cdc->console_width, cdc->cwidth, cdc->console_width, cdc->lheight);
@@ -268,8 +267,8 @@ static int console_draw_string(ConsoleDrawContext *cdc, char *str, int str_len,
glColor3ub(fg[0], fg[1], fg[2]);
- BLF_position(cdc->xy[0], cdc->xy[1], 0);
- BLF_draw(str);
+ BLF_position(mono, cdc->xy[0], cdc->xy[1], 0);
+ BLF_draw(mono, str);
if(cdc->sel[0] != cdc->sel[1])
console_draw_sel(cdc->sel, cdc->xy, str_len, cdc->cwidth, cdc->console_width, cdc->lheight);
@@ -301,7 +300,7 @@ static int console_text_main__internal(struct SpaceConsole *sc, struct ARegion *
unsigned char fg[3];
console_font_begin(sc);
- cwidth = BLF_fixed_width();
+ cwidth = BLF_fixed_width(mono);
console_width= (ar->winx - (CONSOLE_DRAW_SCROLL + CONSOLE_DRAW_MARGIN*2) )/cwidth;
if (console_width < 8) console_width= 8;
@@ -344,11 +343,11 @@ static int console_text_main__internal(struct SpaceConsole *sc, struct ARegion *
/* command line */
if(prompt_len) {
- BLF_position(xy[0], xy[1], 0); xy[0] += cwidth * prompt_len;
- BLF_draw(sc->prompt);
+ BLF_position(mono, xy[0], xy[1], 0); xy[0] += cwidth * prompt_len;
+ BLF_draw(mono, sc->prompt);
}
- BLF_position(xy[0], xy[1], 0);
- BLF_draw(cl->line);
+ BLF_position(mono, xy[0], xy[1], 0);
+ BLF_draw(mono, cl->line);
/* cursor */
UI_GetThemeColor3ubv(TH_CONSOLE_CURSOR, (char *)fg);