[Bf-blender-cvs] [c67abff] master: Fix drawing text on >2gig buffers (stamp for eg)

Campbell Barton noreply at git.blender.org
Tue Jun 2 07:02:45 CEST 2015


Commit: c67abff7f034b33ba7a0916d994c3f5aba100617
Author: Campbell Barton
Date:   Tue Jun 2 14:59:31 2015 +1000
Branches: master
https://developer.blender.org/rBc67abff7f034b33ba7a0916d994c3f5aba100617

Fix drawing text on >2gig buffers (stamp for eg)

===================================================================

M	source/blender/blenfont/intern/blf_font.c

===================================================================

diff --git a/source/blender/blenfont/intern/blf_font.c b/source/blender/blenfont/intern/blf_font.c
index 8f8ee44..2057b0f 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];




More information about the Bf-blender-cvs mailing list