[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[freetype2-demos] master 7cd4e1b: Make compilation work with clang++.
From: |
Werner LEMBERG |
Subject: |
[freetype2-demos] master 7cd4e1b: Make compilation work with clang++. |
Date: |
Sat, 21 May 2016 10:53:16 +0000 (UTC) |
branch: master
commit 7cd4e1b897f2d7e450886dcc5db2ffef031b1ab8
Author: Werner Lemberg <address@hidden>
Commit: Werner Lemberg <address@hidden>
Make compilation work with clang++.
Also fix some warning messages.
* src/ftcommon.c (FTDemo_Display_Clear): Use proper cast.
(string_load): Replace shifts with multiplication.
* src/ftgamma.c: (bit1, bit2): Complete initializer.
(do_ptrn, do_fill): Use proper casts.
(Render_Bitmap): s/bitmap/out/, s/bit/in/, to avoid shadowing global
variable `bit'.
* src/ftgrid.c (GridStatus): Make `lcd_filter' of type
`FT_LcdFilter'.
(bitmap_scale): Use proper casts.
(grid_status_draw_outline): Fix int vs. short warnings.
(event_cff_hinting_engine_change): Add initializer.
(event_lcd_filter_change): Properly handle `status.lcd_filter'.
* src/ftmulti.c (requested_cnt, used_num_axis): Make them `unsigned
int'.
(Process_Event, main): Updated.
* src/ftstring.c (status): Complete initializer.
* src/ftvalid.c (ValidatorType): Fix enum syntax.
* src/ftview.c (event_cff_hinting_engine_change): Add initializer.
(Process_Event) <'L'>: Fix call to FT_Library_SetLcdFilter.
* src/output.c (put_ascii_string, put_unicode_be16_string): Add
casts.
---
ChangeLog | 35 +++++++++++++++++
src/ftcommon.c | 6 +--
src/ftgamma.c | 54 +++++++++++++------------
src/ftgrid.c | 120 ++++++++++++++++++++++++++++++++------------------------
src/ftmulti.c | 28 +++++++------
src/ftstring.c | 4 +-
src/ftvalid.c | 2 +-
src/ftview.c | 7 ++--
src/output.c | 16 ++++----
9 files changed, 167 insertions(+), 105 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index c5cf5b2..937c1c1 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,38 @@
+2016-05-21 Werner Lemberg <address@hidden>
+
+ Make compilation work with clang++.
+
+ Also fix some warning messages.
+
+ * src/ftcommon.c (FTDemo_Display_Clear): Use proper cast.
+ (string_load): Replace shifts with multiplication.
+
+ * src/ftgamma.c: (bit1, bit2): Complete initializer.
+ (do_ptrn, do_fill): Use proper casts.
+ (Render_Bitmap): s/bitmap/out/, s/bit/in/, to avoid shadowing global
+ variable `bit'.
+
+ * src/ftgrid.c (GridStatus): Make `lcd_filter' of type
+ `FT_LcdFilter'.
+ (bitmap_scale): Use proper casts.
+ (grid_status_draw_outline): Fix int vs. short warnings.
+ (event_cff_hinting_engine_change): Add initializer.
+ (event_lcd_filter_change): Properly handle `status.lcd_filter'.
+
+ * src/ftmulti.c (requested_cnt, used_num_axis): Make them `unsigned
+ int'.
+ (Process_Event, main): Updated.
+
+ * src/ftstring.c (status): Complete initializer.
+
+ * src/ftvalid.c (ValidatorType): Fix enum syntax.
+
+ * src/ftview.c (event_cff_hinting_engine_change): Add initializer.
+ (Process_Event) <'L'>: Fix call to FT_Library_SetLcdFilter.
+
+ * src/output.c (put_ascii_string, put_unicode_be16_string): Add
+ casts.
+
2016-05-19 Werner Lemberg <address@hidden>
[ftinspect] Use bottom left as the viewport anchor for resizing.
diff --git a/src/ftcommon.c b/src/ftcommon.c
index 700338c..1197f89 100644
--- a/src/ftcommon.c
+++ b/src/ftcommon.c
@@ -164,7 +164,7 @@
}
for ( i = 1; i < bit->rows; i++, p += pitch )
- memcpy( p, p - pitch, pitch );
+ memcpy( p, p - pitch, (size_t)pitch );
}
}
@@ -1107,9 +1107,9 @@
glyph->vadvance.y = -metrics->vertAdvance;
if ( prev_rsb_delta - face->glyph->lsb_delta >= 32 )
- glyph->delta = -1 << 6;
+ glyph->delta = -1 * 64;
else if ( prev_rsb_delta - face->glyph->lsb_delta < -32 )
- glyph->delta = 1 << 6;
+ glyph->delta = 1 * 64;
else
glyph->delta = 0;
}
diff --git a/src/ftgamma.c b/src/ftgamma.c
index 75669e7..415e91b 100644
--- a/src/ftgamma.c
+++ b/src/ftgamma.c
@@ -17,8 +17,8 @@
static FTDemo_Display* display;
- grBitmap bit1 = { 300, 600, 600, gr_pixel_mode_gray, 256 };
- grBitmap bit2 = { 300, 600, 600, gr_pixel_mode_gray, 256 };
+ grBitmap bit1 = { 300, 600, 600, gr_pixel_mode_gray, 256, NULL };
+ grBitmap bit2 = { 300, 600, 600, gr_pixel_mode_gray, 256, NULL };
grBitmap* bit;
@@ -58,7 +58,9 @@
line = bitmap->buffer + ( y + i ) * pitch + x;
for ( j = 0, k = 0; j < w; j++ )
{
- line[j] = 0.5 + 255. * pow ( p[k], 1. / (1. + 2. * j / w ) );
+ line[j] = (unsigned char)( 0.5 +
+ 255. * pow ( p[k],
+ 1. / (1. + 2. * j / w ) ) );
k++;
if ( k == 4 )
k = 0;
@@ -102,24 +104,24 @@
if ( back == 0 || back == 255 )
for ( i = 0; i < w; i++ )
- line[i + ( i & 1 ) * pitch] = back;
+ line[i + ( i & 1 ) * pitch] = (unsigned char)back;
else
for ( b = back / 255., i = 0; i < w; i++ )
line[i + ( i & 1 ) * pitch] =
- 0.5 + 255. * pow ( b, 1. / (1. + 2. * i / w ) );
+ (unsigned char)( 0.5 + 255. * pow ( b, 1. / (1. + 2. * i / w ) ) );
if ( fore == 0 || fore == 255 )
for ( i = 0; i < w; i++ )
- line[i + ( ~i & 1 ) * pitch] = fore;
+ line[i + ( ~i & 1 ) * pitch] = (unsigned char)fore;
else
for ( f = fore / 255., i = 0; i < w; i++ )
line[i + ( ~i & 1 ) * pitch] =
- 0.5 + 255. * pow ( f, 1. / (1. + 2. * i / w ) );
+ (unsigned char)( 0.5 + 255. * pow ( f, 1. / (1. + 2. * i / w ) ) );
for ( i = 2; i < h; i += 2 )
{
- memcpy( line + i * pitch, line, w );
- memcpy( line + i * pitch + pitch, line + pitch, w );
+ memcpy( line + i * pitch, line, (size_t)w );
+ memcpy( line + i * pitch + pitch, line + pitch, (size_t)w );
}
}
@@ -276,43 +278,45 @@
static void
- Render_Bitmap( grBitmap* bitmap,
- grBitmap* bit,
- int x,
- int y,
- grColor color )
+ Render_Bitmap( grBitmap* out,
+ grBitmap* in,
+ int x,
+ int y,
+ grColor color )
{
- int pitch = bitmap->pitch;
- int i, j;
+ int pitch = out->pitch;
+ int i, j;
unsigned char* src;
unsigned char* dst;
+
if ( color.chroma[0] == 255 )
- for ( src = bit->buffer, i = 0; i < bit->rows; i++ )
+ for ( src = in->buffer, i = 0; i < in->rows; i++ )
{
- dst = bitmap->buffer + ( y + i ) * pitch + 3 * x;
- for ( j = 0; j < bit->width; j++, src++, dst += 3 )
+ dst = out->buffer + ( y + i ) * pitch + 3 * x;
+ for ( j = 0; j < in->width; j++, src++, dst += 3 )
*dst = *src;
}
if ( color.chroma[1] == 255 )
- for ( src = bit->buffer, i = 0; i < bit->rows; i++ )
+ for ( src = in->buffer, i = 0; i < in->rows; i++ )
{
- dst = bitmap->buffer + ( y + i ) * pitch + 3 * x + 1;
- for ( j = 0; j < bit->width; j++, src++, dst += 3 )
+ dst = out->buffer + ( y + i ) * pitch + 3 * x + 1;
+ for ( j = 0; j < in->width; j++, src++, dst += 3 )
*dst = *src;
}
if ( color.chroma[2] == 255 )
- for ( src = bit->buffer, i = 0; i < bit->rows; i++ )
+ for ( src = in->buffer, i = 0; i < in->rows; i++ )
{
- dst = bitmap->buffer + ( y + i ) * pitch + 3 * x + 2;
- for ( j = 0; j < bit->width; j++, src++, dst += 3 )
+ dst = out->buffer + ( y + i ) * pitch + 3 * x + 2;
+ for ( j = 0; j < in->width; j++, src++, dst += 3 )
*dst = *src;
}
}
+
static int
Process_Event( grEvent* event )
{
diff --git a/src/ftgrid.c b/src/ftgrid.c
index 5f3eae6..8916b79 100644
--- a/src/ftgrid.c
+++ b/src/ftgrid.c
@@ -130,7 +130,7 @@
int do_blue_hints;
int do_segment;
- int lcd_filter;
+ FT_LcdFilter lcd_filter;
double gamma;
const char* header;
char header_buffer[BUFSIZE];
@@ -540,7 +540,8 @@
pitch = bit->pitch > 0 ? bit->pitch
: -bit->pitch;
- t = (unsigned char*)malloc( pitch * bit->rows * scale * scale );
+ t = (unsigned char*)malloc( (size_t)( pitch * bit->rows *
+ scale * scale ) );
if ( !t )
return;
@@ -558,7 +559,7 @@
line[j / 8] &= ~( 0x80 >> ( j & 7 ) );
for ( k = 1; k < scale; k++, line += pitch * scale )
- memcpy( line + pitch * scale, line, pitch * scale );
+ memcpy( line + pitch * scale, line, (size_t)( pitch * scale ) );
line += pitch * scale;
}
break;
@@ -567,10 +568,10 @@
for ( i = 0; i < bit->rows; i++ )
{
for ( j = 0; j < pitch; j++ )
- memset( line + j * scale, s[i * pitch + j], scale );
+ memset( line + j * scale, s[i * pitch + j], (size_t)scale );
for ( k = 1; k < scale; k++, line += pitch * scale )
- memcpy( line + pitch * scale, line, pitch * scale );
+ memcpy( line + pitch * scale, line, (size_t)( pitch * scale ) );
line += pitch * scale;
}
break;
@@ -588,7 +589,7 @@
}
for ( k = 1; k < scale; k++, line += pitch * scale )
- memcpy( line + pitch * scale, line, pitch * scale );
+ memcpy( line + pitch * scale, line, (size_t)( pitch * scale ) );
line += pitch * scale;
}
break;
@@ -600,15 +601,17 @@
for ( j = 0; j < pitch; j++ )
{
memset( line + j * scale,
- s[i * pitch + j], scale );
+ s[i * pitch + j], (size_t)scale );
memset( line + j * scale + pitch * scale,
- s[i * pitch + pitch + j], scale );
+ s[i * pitch + pitch + j], (size_t)scale );
memset( line + j * scale + 2 * pitch * scale,
- s[i * pitch + 2 * pitch + j], scale );
+ s[i * pitch + 2 * pitch + j], (size_t)scale );
}
for ( k = 1; k < scale; k++, line += 3 * pitch * scale )
- memcpy( line + 3 * pitch * scale, line, 3 * pitch * scale );
+ memcpy( line + 3 * pitch * scale,
+ line,
+ (size_t)( 3 * pitch * scale ) );
line += 3 * pitch * scale;
}
break;
@@ -760,7 +763,7 @@
FT_Vector* points = gimage->points;
FT_Short* contours = gimage->contours;
char* tags = gimage->tags;
- int cc;
+ short c, n;
char number_string[10];
size_t number_string_len = sizeof ( number_string );
@@ -768,9 +771,9 @@
FT_Long octant_y[8] = { 0, 724, 1024, 724, 0, -724, -1024, -724 };
- cc = 0;
- nn = 0;
- for ( ; cc < gimage->n_contours; cc++ )
+ c = 0;
+ n = 0;
+ for ( ; c < gimage->n_contours; c++ )
{
for (;;)
{
@@ -781,36 +784,36 @@
/* find previous and next point in outline */
- if ( cc == 0 )
+ if ( c == 0 )
{
- if ( contours[cc] == 0 )
+ if ( contours[c] == 0 )
{
prev = 0;
next = 0;
}
else
{
- prev = nn > 0 ? nn - 1
- : contours[cc];
- next = nn < contours[cc] ? nn + 1
- : 0;
+ prev = n > 0 ? n - 1
+ : contours[c];
+ next = n < contours[c] ? n + 1
+ : 0;
}
}
else
{
- prev = nn > ( contours[cc - 1] + 1 ) ? nn - 1
- : contours[cc];
- next = nn < contours[cc] ? nn + 1
- : contours[cc - 1] + 1;
+ prev = n > ( contours[c - 1] + 1 ) ? n - 1
+ : contours[c];
+ next = n < contours[c] ? n + 1
+ : contours[c - 1] + 1;
}
/* get vectors to previous and next point and normalize them; */
/* we use 16.16 format to improve the computation precision */
- in.x = ( points[prev].x - points[nn].x ) * 1024;
- in.y = ( points[prev].y - points[nn].y ) * 1024;
+ in.x = ( points[prev].x - points[n].x ) * 1024;
+ in.y = ( points[prev].y - points[n].y ) * 1024;
- out.x = ( points[next].x - points[nn].x ) * 1024;
- out.y = ( points[next].y - points[nn].y ) * 1024;
+ out.x = ( points[next].x - points[n].x ) * 1024;
+ out.y = ( points[next].y - points[n].y ) * 1024;
in_len = FT_Vector_Length( &in );
out_len = FT_Vector_Length( &out );
@@ -842,8 +845,8 @@
{
/* use direction based on point index for the offset */
/* if we still don't have a good value */
- middle.x = octant_x[nn % 8];
- middle.y = octant_y[nn % 8];
+ middle.x = octant_x[n % 8];
+ middle.y = octant_y[n % 8];
}
}
@@ -857,7 +860,7 @@
num_digits = snprintf( number_string,
number_string_len,
- "%d", nn );
+ "%d", n );
/* we now position the point number in the opposite */
/* direction of the `middle' vector, adding some offset */
@@ -866,19 +869,19 @@
/* pixels) */
grWriteCellString( display->bitmap,
st->x_origin +
- ( ( points[nn].x - middle.x ) >> 6 ) -
+ ( ( points[n].x - middle.x ) >> 6 ) -
( middle.x > 0 ? ( num_digits - 1 ) * 8 + 2
: 2 ),
st->y_origin -
- ( ( ( points[nn].y - middle.y ) >> 6 ) +
+ ( ( ( points[n].y - middle.y ) >> 6 ) +
8 / 2 ),
number_string,
- ( tags[nn] & FT_CURVE_TAG_ON )
+ ( tags[n] & FT_CURVE_TAG_ON )
? st->on_color
: st->off_color );
- nn++;
- if ( nn > contours[cc] )
+ n++;
+ if ( n > contours[c] )
break;
}
}
@@ -995,7 +998,7 @@
static void
event_cff_hinting_engine_change( int delta )
{
- int new_cff_hinting_engine;
+ int new_cff_hinting_engine = 0;
if ( delta )
@@ -1201,23 +1204,38 @@
const char* lcd_filter = NULL;
- status.lcd_filter++;
+ switch( status.lcd_filter )
+ {
+ case FT_LCD_FILTER_DEFAULT:
+ status.lcd_filter = FT_LCD_FILTER_LIGHT;
+ break;
+ case FT_LCD_FILTER_LIGHT:
+ status.lcd_filter = FT_LCD_FILTER_LEGACY1;
+ break;
+ case FT_LCD_FILTER_LEGACY1:
+ status.lcd_filter = FT_LCD_FILTER_NONE;
+ break;
+ case FT_LCD_FILTER_NONE:
+ default:
+ status.lcd_filter = FT_LCD_FILTER_DEFAULT;
+ break;
+ }
switch ( status.lcd_filter )
{
- case FT_LCD_FILTER_DEFAULT:
- lcd_filter = "default";
- break;
- case FT_LCD_FILTER_LIGHT:
- lcd_filter = "light";
- break;
- case FT_LCD_FILTER_LEGACY1:
- lcd_filter = "legacy";
- break;
- case FT_LCD_FILTER_NONE:
- default:
- status.lcd_filter = 0;
- lcd_filter = "none";
+ case FT_LCD_FILTER_DEFAULT:
+ lcd_filter = "default";
+ break;
+ case FT_LCD_FILTER_LIGHT:
+ lcd_filter = "light";
+ break;
+ case FT_LCD_FILTER_LEGACY1:
+ lcd_filter = "legacy";
+ break;
+ case FT_LCD_FILTER_NONE:
+ default:
+ lcd_filter = "none";
+ break;
}
sprintf( status.header_buffer, "LCD filter changed to %s",
diff --git a/src/ftmulti.c b/src/ftmulti.c
index eff0bc4..7c0153a 100644
--- a/src/ftmulti.c
+++ b/src/ftmulti.c
@@ -75,11 +75,11 @@
static int render_mode = 1;
- static FT_MM_Var *multimaster = NULL;
- static FT_Fixed design_pos [MAX_MM_AXES];
- static FT_Fixed requested_pos[MAX_MM_AXES];
- static int requested_cnt = 0;
- static int used_num_axis = 0;
+ static FT_MM_Var *multimaster = NULL;
+ static FT_Fixed design_pos [MAX_MM_AXES];
+ static FT_Fixed requested_pos[MAX_MM_AXES];
+ static unsigned int requested_cnt = 0;
+ static unsigned int used_num_axis = 0;
#define DEBUGxxx
@@ -451,7 +451,8 @@
static int
Process_Event( grEvent* event )
{
- int i, axis;
+ int i;
+ unsigned int axis;
switch ( event->key )
@@ -815,7 +816,7 @@
/* if the user specified a position, use it, otherwise */
/* set the current position to the median of each axis */
{
- int n;
+ unsigned int n;
if ( multimaster->num_axis > MAX_MM_AXES )
@@ -825,7 +826,7 @@
used_num_axis = MAX_MM_AXES;
}
else
- used_num_axis = (int)multimaster->num_axis;
+ used_num_axis = multimaster->num_axis;
for ( n = 0; n < used_num_axis; n++ )
{
@@ -905,9 +906,10 @@
sprintf( Header, "axes:" );
{
- int n;
- int limit = used_num_axis > MAX_MM_AXES / 2 ? MAX_MM_AXES / 2
- : used_num_axis;
+ unsigned int n;
+ unsigned int limit = used_num_axis > MAX_MM_AXES / 2
+ ? MAX_MM_AXES / 2
+ : used_num_axis;
for ( n = 0; n < limit; n++ )
@@ -926,8 +928,8 @@
if ( used_num_axis > MAX_MM_AXES / 2 )
{
- int n;
- int limit = used_num_axis;
+ unsigned int n;
+ unsigned int limit = used_num_axis;
sprintf( Header, " " );
diff --git a/src/ftstring.c b/src/ftstring.c
index 90dc38e..1a30d79 100644
--- a/src/ftstring.c
+++ b/src/ftstring.c
@@ -56,7 +56,9 @@
char header_buffer[256];
} status = { DIM_X, DIM_Y,
- RENDER_MODE_STRING, FT_ENCODING_UNICODE, 72, 48, GAMMA, 0 };
+ RENDER_MODE_STRING, FT_ENCODING_UNICODE, 72, 48, GAMMA, 0,
+ { 0, 0, 0, 0, NULL },
+ { 0 }, { 0, 0, 0, 0 }, 0, NULL, { 0 } };
static FTDemo_Display* display;
static FTDemo_Handle* handle;
diff --git a/src/ftvalid.c b/src/ftvalid.c
index 585f7b8..7ea7373 100644
--- a/src/ftvalid.c
+++ b/src/ftvalid.c
@@ -47,7 +47,7 @@
GX_VALIDATE,
CKERN_VALIDATE,
- LAST_VALIDATE,
+ LAST_VALIDATE
} ValidatorType;
static ValidatorType validator;
diff --git a/src/ftview.c b/src/ftview.c
index acccc74..b90366d 100644
--- a/src/ftview.c
+++ b/src/ftview.c
@@ -831,7 +831,7 @@
static int
event_cff_hinting_engine_change( unsigned int delta )
{
- unsigned int new_cff_hinting_engine;
+ unsigned int new_cff_hinting_engine = 0;
if ( delta )
@@ -1304,7 +1304,8 @@
case FT_LCD_FILTER_DEFAULT:
case FT_LCD_FILTER_LIGHT:
case FT_LCD_FILTER_LEGACY1:
- FT_Library_SetLcdFilter( handle->library, status.lcd_filter );
+ FT_Library_SetLcdFilter( handle->library,
+ (FT_LcdFilter)status.lcd_filter );
break;
default:
FT_Library_SetLcdFilter( handle->library, FT_LCD_FILTER_DEFAULT );
@@ -1340,7 +1341,7 @@
if ( status.lcd_filter < 0 )
{
FTC_Manager_RemoveFaceID( handle->cache_manager,
- handle->scaler.face_id );
+ handle->scaler.face_id );
status.filter_weights[status.fw_idx]--;
FT_Library_SetLcdFilterWeights( handle->library,
diff --git a/src/output.c b/src/output.c
index c1e6d51..a532a1a 100644
--- a/src/output.c
+++ b/src/output.c
@@ -73,7 +73,7 @@
default:
if ( string[i] < 0x80 )
- *out++ = string[i];
+ *out++ = (char)string[i];
else
{
*out++ = '\\';
@@ -237,18 +237,18 @@
*/
if ( ch < 0x80 )
- *out++ = ch;
+ *out++ = (char)ch;
else if ( ch < 0x800 )
{
- *out++ = 0xC0 | ( (FT_UInt)ch >> 6 );
- *out++ = 0x80 | ( (FT_UInt)ch & 0x3F );
+ *out++ = (char)( 0xC0 | ( (FT_UInt)ch >> 6 ) );
+ *out++ = (char)( 0x80 | ( (FT_UInt)ch & 0x3F ) );
}
else
{
/* we don't handle surrogates */
- *out++ = 0xE0 | ( (FT_UInt)ch >> 12 );
- *out++ = 0x80 | ( ( (FT_UInt)ch >> 6 ) & 0x3F );
- *out++ = 0x80 | ( (FT_UInt)ch & 0x3F );
+ *out++ = (char)( 0xE0 | ( (FT_UInt)ch >> 12 ) );
+ *out++ = (char)( 0x80 | ( ( (FT_UInt)ch >> 6 ) & 0x3F ) );
+ *out++ = (char)( 0x80 | ( (FT_UInt)ch & 0x3F ) );
}
continue;
@@ -286,7 +286,7 @@
default:
if ( ch < 128 )
- *out++ = ch;
+ *out++ = (char)ch;
else
{
*out++ = '\\';
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [freetype2-demos] master 7cd4e1b: Make compilation work with clang++.,
Werner LEMBERG <=