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-09-01 04:46:04 +0400
committerCampbell Barton <ideasman42@gmail.com>2013-09-01 04:46:04 +0400
commit2924a02a3561eed7899d5087f2a7a6c31529e18f (patch)
treef7e30878a3492cd0e91e2eaa5c8010ff6f0b930a /source/blender/blenfont/intern/blf_glyph.c
parentce326e20c85bc91471e681fa77f71be528302af3 (diff)
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).
Diffstat (limited to 'source/blender/blenfont/intern/blf_glyph.c')
-rw-r--r--source/blender/blenfont/intern/blf_glyph.c54
1 files changed, 27 insertions, 27 deletions
diff --git a/source/blender/blenfont/intern/blf_glyph.c b/source/blender/blenfont/intern/blf_glyph.c
index ae8e2d17c54..2a8e91299b4 100644
--- a/source/blender/blenfont/intern/blf_glyph.c
+++ b/source/blender/blenfont/intern/blf_glyph.c
@@ -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 @@ GlyphCacheBLF *blf_glyph_cache_new(FontBLF *font)
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 @@ void blf_glyph_cache_free(GlyphCacheBLF *gc)
}
}
- 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 @@ GlyphBLF *blf_glyph_add(FontBLF *font, unsigned int index, unsigned int c)
/* 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 @@ GlyphBLF *blf_glyph_add(FontBLF *font, unsigned int index, unsigned int c)
}
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 @@ static void blf_texture5_draw(const float shadow_col[4], float uv[2][2], float x
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 @@ static void blf_texture3_draw(const float shadow_col[4], float uv[2][2], float x
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_texture3_draw(const float shadow_col[4], float uv[2][2], float x
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 @@ void blf_glyph_render(FontBLF *font, GlyphBLF *g, float x, float y)
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 @@ void blf_glyph_render(FontBLF *font, GlyphBLF *g, float x, float y)
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 @@ void 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);
+ blf_glyph_calc_rect(&rect_ofs, g,
+ x + (float)font->shadow_x,
+ y + (float)font->shadow_y);
switch (font->shadow) {
case 3: