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:
authorCampbell Barton <ideasman42@gmail.com>2013-06-07 01:43:52 +0400
committerCampbell Barton <ideasman42@gmail.com>2013-06-07 01:43:52 +0400
commit9b5be450d8aa635d5e1d0b82ea8331da66a87cbf (patch)
tree3adb5cc1f86ee9e0c38ea7cd2f2f228aa26f9a3a /source/blender/blenfont
parent5ed9ede71cd6bc779dc2fb58a83d11b8093978e8 (diff)
text rendering: shadow offset was causing text to clip, now check for clipping without the shadow since not-drawing characters because of subtle effect is rather annoying.
Diffstat (limited to 'source/blender/blenfont')
-rw-r--r--source/blender/blenfont/intern/blf_glyph.c70
-rw-r--r--source/blender/blenfont/intern/blf_internal.h2
2 files changed, 29 insertions, 43 deletions
diff --git a/source/blender/blenfont/intern/blf_glyph.c b/source/blender/blenfont/intern/blf_glyph.c
index d683378c7ce..4812f8f23f7 100644
--- a/source/blender/blenfont/intern/blf_glyph.c
+++ b/source/blender/blenfont/intern/blf_glyph.c
@@ -371,14 +371,20 @@ static void blf_texture3_draw(const float shadow_col[4], float uv[2][2], float x
glColor4fv(color);
}
-int blf_glyph_render(FontBLF *font, GlyphBLF *g, float x, float y)
+static void blf_glyph_calc_rect(rctf *rect, GlyphBLF *g, float x, float y)
{
- float dx, dx1;
- float y1, y2;
- float xo, yo;
+ rect->xmin = floor(x + g->pos_x);
+ rect->xmax = rect->xmin + g->width;
+ rect->ymin = y + g->pos_y;
+ rect->ymax = y + g->pos_y - g->height;
+}
+
+void blf_glyph_render(FontBLF *font, GlyphBLF *g, float x, float y)
+{
+ rctf rect;
if ((!g->width) || (!g->height))
- return 1;
+ return;
if (g->build_tex == 0) {
GlyphCacheBLF *gc = font->glyph_cache;
@@ -440,30 +446,16 @@ int blf_glyph_render(FontBLF *font, GlyphBLF *g, float x, float y)
g->build_tex = 1;
}
- xo = 0.0f;
- yo = 0.0f;
-
- if (font->flags & BLF_SHADOW) {
- xo = x;
- yo = y;
- x += font->shadow_x;
- y += font->shadow_y;
- }
-
- dx = floor(x + g->pos_x);
- dx1 = dx + g->width;
- y1 = y + g->pos_y;
- y2 = y + g->pos_y - g->height;
+ blf_glyph_calc_rect(&rect, g, x, y);
if (font->flags & BLF_CLIPPING) {
- if (!BLI_rctf_isect_pt(&font->clip_rec, dx + font->pos[0], y1 + font->pos[1]))
- return 0;
- if (!BLI_rctf_isect_pt(&font->clip_rec, dx + font->pos[0], y2 + font->pos[1]))
- return 0;
- if (!BLI_rctf_isect_pt(&font->clip_rec, dx1 + font->pos[0], y2 + font->pos[1]))
- return 0;
- if (!BLI_rctf_isect_pt(&font->clip_rec, dx1 + font->pos[0], y1 + font->pos[1]))
- return 0;
+ /* intentionally check clipping without shadow offset */
+ rctf rect_test = rect;
+ BLI_rctf_translate(&rect_test, font->pos[0], font->pos[1]);
+
+ if (!BLI_rctf_inside_rctf(&font->clip_rec, &rect_test)) {
+ return;
+ }
}
if (font->tex_bind_state != g->tex) {
@@ -471,42 +463,36 @@ int blf_glyph_render(FontBLF *font, GlyphBLF *g, float x, float y)
}
if (font->flags & BLF_SHADOW) {
+ rctf rect_ofs;
+ blf_glyph_calc_rect(&rect_ofs, g, x + font->shadow_x, y + font->shadow_y);
switch (font->shadow) {
case 3:
- blf_texture3_draw(font->shadow_col, g->uv, dx, y1, dx1, y2);
+ blf_texture3_draw(font->shadow_col, g->uv, rect_ofs.xmin, rect_ofs.ymin, rect_ofs.xmax, rect_ofs.ymax);
break;
case 5:
- blf_texture5_draw(font->shadow_col, g->uv, dx, y1, dx1, y2);
+ blf_texture5_draw(font->shadow_col, g->uv, rect_ofs.xmin, rect_ofs.ymin, rect_ofs.xmax, rect_ofs.ymax);
break;
default:
glColor4fv(font->shadow_col);
- blf_texture_draw(g->uv, dx, y1, dx1, y2);
+ blf_texture_draw(g->uv, rect_ofs.xmin, rect_ofs.ymin, rect_ofs.xmax, rect_ofs.ymax);
break;
}
glColor4fv(font->orig_col);
-
- x = xo;
- y = yo;
-
- dx = floor(x + g->pos_x);
- dx1 = dx + g->width;
- y1 = y + g->pos_y;
- y2 = y + g->pos_y - g->height;
}
switch (font->blur) {
case 3:
- blf_texture3_draw(font->orig_col, g->uv, dx, y1, dx1, y2);
+ blf_texture3_draw(font->orig_col, g->uv, rect.xmin, rect.ymin, rect.xmax, rect.ymax);
break;
case 5:
- blf_texture5_draw(font->orig_col, g->uv, dx, y1, dx1, y2);
+ blf_texture5_draw(font->orig_col, g->uv, rect.xmin, rect.ymin, rect.xmax, rect.ymax);
break;
default:
- blf_texture_draw(g->uv, dx, y1, dx1, y2);
+ blf_texture_draw(g->uv, rect.xmin, rect.ymin, rect.xmax, rect.ymax);
break;
}
- return 1;
+ return;
}
diff --git a/source/blender/blenfont/intern/blf_internal.h b/source/blender/blenfont/intern/blf_internal.h
index 2cb453cdf55..7d4b39dd337 100644
--- a/source/blender/blenfont/intern/blf_internal.h
+++ b/source/blender/blenfont/intern/blf_internal.h
@@ -71,6 +71,6 @@ struct GlyphBLF *blf_glyph_search(struct GlyphCacheBLF *gc, unsigned int c);
struct GlyphBLF *blf_glyph_add(struct FontBLF *font, unsigned int index, unsigned int c);
void blf_glyph_free(struct GlyphBLF *g);
-int blf_glyph_render(struct FontBLF *font, struct GlyphBLF *g, float x, float y);
+void blf_glyph_render(struct FontBLF *font, struct GlyphBLF *g, float x, float y);
#endif /* __BLF_INTERNAL_H__ */