From c67abff7f034b33ba7a0916d994c3f5aba100617 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Tue, 2 Jun 2015 14:59:31 +1000 Subject: [PATCH] Fix drawing text on >2gig buffers (stamp for eg) --- source/blender/blenfont/intern/blf_font.c | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/source/blender/blenfont/intern/blf_font.c b/source/blender/blenfont/intern/blf_font.c index 8f8ee445ef9..2057b0f6bbf 100644 --- a/source/blender/blenfont/intern/blf_font.c +++ b/source/blender/blenfont/intern/blf_font.c @@ -286,10 +286,9 @@ void blf_font_buffer(FontBLF *font, const char *str) (unsigned char)(buf_info->col[2] * 255), (unsigned char)(buf_info->col[3] * 255)}; - unsigned char *cbuf; int chx, chy; int y, x; - float a, *fbuf; + float a; BLF_KERNING_VARS(font, has_kerning, kern_mode); @@ -349,8 +348,12 @@ void blf_font_buffer(FontBLF *font, const char *str) a = *(g->bitmap + x + (yb * g->pitch)) / 255.0f; if (a > 0.0f) { + const size_t buf_ofs = ( + ((size_t)(chx + x) + ((size_t)(pen_y + y) * (size_t)buf_info->w)) * + (size_t)buf_info->ch); + float *fbuf = buf_info->fbuf + buf_ofs; float alphatest; - fbuf = buf_info->fbuf + buf_info->ch * ((chx + x) + ((pen_y + y) * buf_info->w)); + if (a >= 1.0f) { fbuf[0] = b_col_float[0]; fbuf[1] = b_col_float[1]; @@ -380,8 +383,12 @@ void blf_font_buffer(FontBLF *font, const char *str) a = *(g->bitmap + x + (yb * g->pitch)) / 255.0f; if (a > 0.0f) { + const size_t buf_ofs = ( + ((size_t)(chx + x) + ((size_t)(pen_y + y) * (size_t)buf_info->w)) * + (size_t)buf_info->ch); + unsigned char *cbuf = buf_info->cbuf + buf_ofs; int alphatest; - cbuf = buf_info->cbuf + buf_info->ch * ((chx + x) + ((pen_y + y) * buf_info->w)); + if (a >= 1.0f) { cbuf[0] = b_col_char[0]; cbuf[1] = b_col_char[1];