[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [59695] trunk/blender/source/blender: move strict compiler checks into a header so its easier to manage in one place (pragmas were copied around).
Campbell Barton
ideasman42 at gmail.com
Sun Sep 1 02:46:05 CEST 2013
Revision: 59695
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=59695
Author: campbellbarton
Date: 2013-09-01 00:46:04 +0000 (Sun, 01 Sep 2013)
Log Message:
-----------
move strict compiler checks into a header so its easier to manage in one place (pragmas were copied around).
also enable more strict warnings for BLF (which had some incorrect casts).
Modified Paths:
--------------
trunk/blender/source/blender/blenfont/intern/blf_font.c
trunk/blender/source/blender/blenfont/intern/blf_glyph.c
trunk/blender/source/blender/blenfont/intern/blf_internal_types.h
trunk/blender/source/blender/blenkernel/intern/mask_rasterize.c
trunk/blender/source/blender/blenlib/intern/BLI_ghash.c
trunk/blender/source/blender/blenlib/intern/BLI_heap.c
trunk/blender/source/blender/blenlib/intern/BLI_memarena.c
trunk/blender/source/blender/blenlib/intern/BLI_mempool.c
trunk/blender/source/blender/blenlib/intern/edgehash.c
trunk/blender/source/blender/blenlib/intern/smallhash.c
trunk/blender/source/blender/bmesh/intern/bmesh_inline.h
trunk/blender/source/blender/bmesh/intern/bmesh_operator_api_inline.h
trunk/blender/source/blender/bmesh/tools/bmesh_bisect_plane.c
trunk/blender/source/blender/bmesh/tools/bmesh_edgenet.c
Added Paths:
-----------
trunk/blender/source/blender/blenlib/BLI_strict_flags.h
Modified: trunk/blender/source/blender/blenfont/intern/blf_font.c
===================================================================
--- trunk/blender/source/blender/blenfont/intern/blf_font.c 2013-08-31 19:37:25 UTC (rev 59694)
+++ trunk/blender/source/blender/blenfont/intern/blf_font.c 2013-09-01 00:46:04 UTC (rev 59695)
@@ -50,6 +50,7 @@
#include "BLI_string_utf8.h"
#include "BLI_threads.h"
#include "BLI_linklist.h" /* linknode */
+#include "BLI_strict_flags.h"
#include "BIF_gl.h"
#include "BLF_api.h"
@@ -59,10 +60,6 @@
#include "blf_internal_types.h"
#include "blf_internal.h"
-#ifdef __GNUC__
-# pragma GCC diagnostic error "-Wsign-conversion"
-#endif
-
/* freetype2 handle ONLY for this file!. */
static FT_Library ft_lib;
static SpinLock ft_lib_mutex;
@@ -163,7 +160,7 @@
_kern_mode, \
&(_delta)) == 0) \
{ \
- _pen_x += _delta.x >> 6; \
+ _pen_x += (int)_delta.x >> 6; \
} \
} \
} (void)0
@@ -194,7 +191,7 @@
/* do not return this loop if clipped, we want every character tested */
blf_glyph_render(font, g, (float)pen_x, (float)pen_y);
- pen_x += g->advance;
+ pen_x += (int)g->advance;
g_prev = g;
}
}
@@ -221,7 +218,7 @@
/* do not return this loop if clipped, we want every character tested */
blf_glyph_render(font, g, (float)pen_x, (float)pen_y);
- pen_x += g->advance;
+ pen_x += (int)g->advance;
g_prev = g;
}
}
@@ -273,10 +270,11 @@
/* buffer specific vars */
FontBufInfoBLF *buf_info = &font->buf_info;
float b_col_float[4];
- const unsigned char b_col_char[4] = {buf_info->col[0] * 255,
- buf_info->col[1] * 255,
- buf_info->col[2] * 255,
- buf_info->col[3] * 255};
+ const unsigned char b_col_char[4] = {
+ (unsigned char)(buf_info->col[0] * 255),
+ (unsigned char)(buf_info->col[1] * 255),
+ (unsigned char)(buf_info->col[2] * 255),
+ (unsigned char)(buf_info->col[3] * 255)};
unsigned char *cbuf;
int chx, chy;
@@ -378,14 +376,15 @@
cbuf[0] = b_col_char[0];
cbuf[1] = b_col_char[1];
cbuf[2] = b_col_char[2];
- cbuf[3] = (alphatest = ((int)cbuf[3] + (int)b_col_char[3])) < 255 ? alphatest : 255;
+ cbuf[3] = (alphatest = ((int)cbuf[3] + (int)b_col_char[3])) < 255 ?
+ (unsigned char)(alphatest) : 255;
}
else {
- cbuf[0] = (b_col_char[0] * a) + (cbuf[0] * (1.0f - a));
- cbuf[1] = (b_col_char[1] * a) + (cbuf[1] * (1.0f - a));
- cbuf[2] = (b_col_char[2] * a) + (cbuf[2] * (1.0f - a));
- cbuf[3] = (alphatest = ((int)cbuf[3] + (int)((b_col_float[3] * a) * 255.0f))) <
- 255 ? alphatest : 255;
+ cbuf[0] = (unsigned char)((b_col_char[0] * a) + (cbuf[0] * (1.0f - a)));
+ cbuf[1] = (unsigned char)((b_col_char[1] * a) + (cbuf[1] * (1.0f - a)));
+ cbuf[2] = (unsigned char)((b_col_char[2] * a) + (cbuf[2] * (1.0f - a)));
+ cbuf[3] = (alphatest = ((int)cbuf[3] + (int)((b_col_float[3] * a) * 255.0f))) < 255 ?
+ (unsigned char)(alphatest) : 255;
}
}
}
@@ -398,7 +397,7 @@
}
}
- pen_x += g->advance;
+ pen_x += (int)g->advance;
g_prev = g;
}
}
@@ -433,10 +432,10 @@
if (has_kerning)
BLF_KERNING_STEP(font, kern_mode, g_prev, g, delta, pen_x);
- gbox.xmin = pen_x;
- gbox.xmax = pen_x + g->advance;
- gbox.ymin = g->box.ymin + pen_y;
- gbox.ymax = g->box.ymax + pen_y;
+ gbox.xmin = (float)pen_x;
+ gbox.xmax = (float)pen_x + g->advance;
+ gbox.ymin = g->box.ymin + (float)pen_y;
+ gbox.ymax = g->box.ymax + (float)pen_y;
if (gbox.xmin < box->xmin) box->xmin = gbox.xmin;
if (gbox.ymin < box->ymin) box->ymin = gbox.ymin;
@@ -444,7 +443,7 @@
if (gbox.xmax > box->xmax) box->xmax = gbox.xmax;
if (gbox.ymax > box->ymax) box->ymax = gbox.ymax;
- pen_x += g->advance;
+ pen_x += (int)g->advance;
g_prev = g;
}
Modified: trunk/blender/source/blender/blenfont/intern/blf_glyph.c
===================================================================
--- trunk/blender/source/blender/blenfont/intern/blf_glyph.c 2013-08-31 19:37:25 UTC (rev 59694)
+++ trunk/blender/source/blender/blenfont/intern/blf_glyph.c 2013-09-01 00:46:04 UTC (rev 59695)
@@ -56,9 +56,7 @@
#include "blf_internal_types.h"
#include "blf_internal.h"
-#ifdef __GNUC__
-# pragma GCC diagnostic error "-Wsign-conversion"
-#endif
+#include "BLI_strict_flags.h"
GlyphCacheBLF *blf_glyph_cache_find(FontBLF *font, unsigned int size, unsigned int dpi)
{
@@ -89,28 +87,28 @@
gc->textures = (GLuint *)MEM_mallocN(sizeof(GLuint) * 256, __func__);
gc->ntex = 256;
- gc->cur_tex = -1;
+ gc->cur_tex = BLF_CURTEX_UNSET;
gc->x_offs = 0;
gc->y_offs = 0;
gc->pad = 3;
- gc->num_glyphs = font->face->num_glyphs;
- gc->rem_glyphs = font->face->num_glyphs;
+ gc->num_glyphs = (int)font->face->num_glyphs;
+ gc->rem_glyphs = (int)font->face->num_glyphs;
gc->ascender = ((float)font->face->size->metrics.ascender) / 64.0f;
gc->descender = ((float)font->face->size->metrics.descender) / 64.0f;
if (FT_IS_SCALABLE(font->face)) {
- gc->max_glyph_width = (float)((font->face->bbox.xMax - font->face->bbox.xMin) *
- (((float)font->face->size->metrics.x_ppem) /
- ((float)font->face->units_per_EM)));
+ gc->max_glyph_width = (int)((float)(font->face->bbox.xMax - font->face->bbox.xMin) *
+ (((float)font->face->size->metrics.x_ppem) /
+ ((float)font->face->units_per_EM)));
- gc->max_glyph_height = (float)((font->face->bbox.yMax - font->face->bbox.yMin) *
- (((float)font->face->size->metrics.y_ppem) /
- ((float)font->face->units_per_EM)));
+ gc->max_glyph_height = (int)((float)(font->face->bbox.yMax - font->face->bbox.yMin) *
+ (((float)font->face->size->metrics.y_ppem) /
+ ((float)font->face->units_per_EM)));
}
else {
- gc->max_glyph_width = ((float)font->face->size->metrics.max_advance) / 64.0f;
- gc->max_glyph_height = ((float)font->face->size->metrics.height) / 64.0f;
+ gc->max_glyph_width = (int)(((float)font->face->size->metrics.max_advance) / 64.0f);
+ gc->max_glyph_height = (int)(((float)font->face->size->metrics.height) / 64.0f);
}
gc->p2_width = 0;
@@ -148,8 +146,8 @@
}
}
- if (gc->cur_tex > -1)
- glDeleteTextures(gc->cur_tex + 1, gc->textures);
+ if (gc->cur_tex != BLF_CURTEX_UNSET)
+ glDeleteTextures((int)gc->cur_tex + 1, gc->textures);
MEM_freeN((void *)gc->textures);
MEM_freeN(gc);
}
@@ -283,7 +281,7 @@
/* Font buffer uses only 0 or 1 values, Blender expects full 0..255 range */
int i;
for (i = 0; i < (g->width * g->height); i++) {
- bitmap.buffer[i] = 255 * bitmap.buffer[i];
+ bitmap.buffer[i] = bitmap.buffer[i] ? 255 : 0;
}
}
@@ -292,8 +290,8 @@
}
g->advance = ((float)slot->advance.x) / 64.0f;
- g->pos_x = slot->bitmap_left;
- g->pos_y = slot->bitmap_top;
+ g->pos_x = (float)slot->bitmap_left;
+ g->pos_y = (float)slot->bitmap_top;
g->pitch = slot->bitmap.pitch;
FT_Outline_Get_CBox(&(slot->outline), &bbox);
@@ -347,7 +345,7 @@
const float *fp = soft;
float color[4];
- int dx, dy;
+ float dx, dy;
color[0] = shadow_col[0];
color[1] = shadow_col[1];
@@ -372,7 +370,7 @@
const float *fp = soft;
float color[4];
- int dx, dy;
+ float dx, dy;
color[0] = shadow_col[0];
color[1] = shadow_col[1];
@@ -391,10 +389,10 @@
static void blf_glyph_calc_rect(rctf *rect, GlyphBLF *g, float x, float y)
{
- rect->xmin = floor(x + g->pos_x);
- rect->xmax = rect->xmin + g->width;
+ rect->xmin = (float)floor(x + g->pos_x);
+ rect->xmax = rect->xmin + (float)g->width;
rect->ymin = y + g->pos_y;
- rect->ymax = y + g->pos_y - g->height;
+ rect->ymax = y + g->pos_y - (float)g->height;
}
void blf_glyph_render(FontBLF *font, GlyphBLF *g, float x, float y)
@@ -410,7 +408,7 @@
if (font->max_tex_size == -1)
glGetIntegerv(GL_MAX_TEXTURE_SIZE, (GLint *)&font->max_tex_size);
- if (gc->cur_tex == -1) {
+ if (gc->cur_tex == BLF_CURTEX_UNSET) {
blf_glyph_cache_texture(font, gc);
gc->x_offs = gc->pad;
gc->y_offs = 0;
@@ -458,7 +456,7 @@
g->uv[1][1] = ((float)(g->yoff + g->height)) / ((float)gc->p2_height);
/* update the x offset for the next glyph. */
- gc->x_offs += (int)(BLI_rctf_size_x(&g->box) + gc->pad);
+ gc->x_offs += (int)BLI_rctf_size_x(&g->box) + gc->pad;
gc->rem_glyphs--;
g->build_tex = 1;
@@ -482,7 +480,9 @@
if (font->flags & BLF_SHADOW) {
rctf rect_ofs;
- blf_glyph_calc_rect(&rect_ofs, g, x + font->shadow_x, y + font->shadow_y);
+ blf_glyph_calc_rect(&rect_ofs, g,
+ x + (float)font->shadow_x,
+ y + (float)font->shadow_y);
switch (font->shadow) {
case 3:
Modified: trunk/blender/source/blender/blenfont/intern/blf_internal_types.h
===================================================================
--- trunk/blender/source/blender/blenfont/intern/blf_internal_types.h 2013-08-31 19:37:25 UTC (rev 59694)
+++ trunk/blender/source/blender/blenfont/intern/blf_internal_types.h 2013-09-01 00:46:04 UTC (rev 59695)
@@ -54,7 +54,7 @@
unsigned int ntex;
/* and the last texture, aka. the current texture. */
- int cur_tex;
+ unsigned int cur_tex;
/* like bftgl, we draw every glyph in a big texture, so this is the
* current position inside the texture.
@@ -235,4 +235,6 @@
char *path;
} DirBLF;
+#define BLF_CURTEX_UNSET ((unsigned int)-1)
+
#endif /* __BLF_INTERNAL_TYPES_H__ */
Modified: trunk/blender/source/blender/blenkernel/intern/mask_rasterize.c
===================================================================
--- trunk/blender/source/blender/blenkernel/intern/mask_rasterize.c 2013-08-31 19:37:25 UTC (rev 59694)
+++ trunk/blender/source/blender/blenkernel/intern/mask_rasterize.c 2013-09-01 00:46:04 UTC (rev 59695)
@@ -82,17 +82,10 @@
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list