[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[freetype2-demos] master b739ac0: Fix compilation errors and (some) warn
From: |
Werner Lemberg |
Subject: |
[freetype2-demos] master b739ac0: Fix compilation errors and (some) warnings for clang++. |
Date: |
Sat, 29 May 2021 05:04:54 -0400 (EDT) |
branch: master
commit b739ac0a954dca931c4e2718cc516757fe3d7fbf
Author: Werner Lemberg <wl@gnu.org>
Commit: Werner Lemberg <wl@gnu.org>
Fix compilation errors and (some) warnings for clang++.
* graph/gblblit.c (GRGB5[56]5_TO_{RED,GREEN,BLUE}): Add casts.
(GDST_STOREP): Use `while {} (0)`.
* graph/gblender.h (GBLENDER_LOOKUP, GBLENDER_LOOKUP_[GBR]): Use
`while {} (0)`.
(GBLENDER_CLOSE, GBLENDER_CHANNEL_CLOSE): Remove final semicolon.
* graph/grblit.c (compose_pixel_full): Use `while {} (0)`.
(extract5[56]5): Remove final semicolon.
(blit_gray8_to_24): Fix typo.
* graph/grfont.c (font): Make it static.
* src/ftcommon.c (FTDemo_Icon): Don't use obfuscating comma
operator.
* src/ftsdf.c (main): Move definition of `flip_y` before `goto`
instructions.
---
ChangeLog | 19 +++++++++++
graph/gblblit.c | 98 ++++++++++++++++++++++++++++++++++----------------------
graph/gblender.h | 80 +++++++++++++++++++++++++--------------------
graph/grblit.c | 35 ++++++++++----------
graph/grfont.c | 4 +--
src/ftcommon.c | 10 ++++--
src/ftsdf.c | 6 ++--
7 files changed, 156 insertions(+), 96 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index c6f7ae4..3f4045e 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,22 @@
+2021-05-29 Werner Lemberg <wl@gnu.org>
+
+ Fix compilation errors and (some) warnings for clang++.
+
+ * graph/gblblit.c (GRGB5[56]5_TO_{RED,GREEN,BLUE}): Add casts.
+ (GDST_STOREP): Use `while {} (0)`.
+ * graph/gblender.h (GBLENDER_LOOKUP, GBLENDER_LOOKUP_[GBR]): Use
+ `while {} (0)`.
+ (GBLENDER_CLOSE, GBLENDER_CHANNEL_CLOSE): Remove final semicolon.
+ * graph/grblit.c (compose_pixel_full): Use `while {} (0)`.
+ (extract5[56]5): Remove final semicolon.
+ (blit_gray8_to_24): Fix typo.
+ * graph/grfont.c (font): Make it static.
+
+ * src/ftcommon.c (FTDemo_Icon): Don't use obfuscating comma
+ operator.
+ * src/ftsdf.c (main): Move definition of `flip_y` before `goto`
+ instructions.
+
2021-05-28 Alexei Podtelezhnikov <apodtele@gmail.com>
[graph/win32] Fix double-dealing of some keystrokes.
diff --git a/graph/gblblit.c b/graph/gblblit.c
index f626b16..54c30ab 100644
--- a/graph/gblblit.c
+++ b/graph/gblblit.c
@@ -28,44 +28,60 @@
/* */
-#define GRGB_TO_RGB565(r,g,b) ((unsigned short)( (((r) << 8) & 0xF800) | \
- (((g) << 3) & 0x07E0) | \
- (((b) >> 3) & 0x001F) ) )
-
-#define GRGB565_TO_RED(p) ( ((p) >> 8 & 0xF8) | ((p) >> 13 & 0x07) )
-#define GRGB565_TO_GREEN(p) ( ((p) >> 3 & 0xFC) | ((p) >> 9 & 0x03) )
-#define GRGB565_TO_BLUE(p) ( ((p) << 3 & 0xF8) | ((p) >> 2 & 0x07) )
-
-#define GRGB565_TO_RGB24(p) ( ( ((p) << 8) & 0xF80000 ) | \
- ( ((p) << 3) & 0x0700F8 ) | \
- ( ((p) << 5) & 0x00FC00 ) | \
- ( ((p) >> 1) & 0x000300 ) | \
- ( ((p) >> 2) & 0x000007 ) )
-
-#define GRGB24_TO_RGB565(p) ( (unsigned short)( (((p) >> 8) & 0xF800 ) | \
- (((p) >> 5) & 0x07E0 ) | \
- (((p) >> 3) & 0x001F ) ) )
+#define GRGB_TO_RGB565(r,g,b) \
+ (unsigned short)( ( ( (r) << 8 ) & 0xF800) | \
+ ( ( (g) << 3 ) & 0x07E0) | \
+ ( ( (b) >> 3 ) & 0x001F) )
+
+#define GRGB565_TO_RED(p) \
+ (unsigned short)( ( (p) >> 8 & 0xF8 ) | \
+ ( (p) >> 13 & 0x07 ) )
+#define GRGB565_TO_GREEN(p) \
+ (unsigned short)( ( (p) >> 3 & 0xFC ) | \
+ ( (p) >> 9 & 0x03 ) )
+#define GRGB565_TO_BLUE(p) \
+ (unsigned short)( ( (p) << 3 & 0xF8 ) | \
+ ( (p) >> 2 & 0x07 ) )
+
+#define GRGB565_TO_RGB24(p) ( ( ( (p) << 8 ) & 0xF80000 ) | \
+ ( ( (p) << 3 ) & 0x0700F8 ) | \
+ ( ( (p) << 5 ) & 0x00FC00 ) | \
+ ( ( (p) >> 1 ) & 0x000300 ) | \
+ ( ( (p) >> 2 ) & 0x000007 ) )
+
+#define GRGB24_TO_RGB565(p) \
+ (unsigned short)( ( ( (p) >> 8 ) & 0xF800 ) | \
+ ( ( (p) >> 5 ) & 0x07E0 ) | \
+ ( ( (p) >> 3 ) & 0x001F ) )
/* */
-#define GRGB_TO_RGB555(r,g,b) ((unsigned short)( (((r) << 7) & 0x7C00) | \
- (((g) << 2) & 0x03E0) | \
- (((b) >> 3) & 0x001F) ) )
-
-#define GRGB555_TO_RED(p) ( ((p) >> 7 & 0xF8) | ((p) >> 12 & 0x07) )
-#define GRGB555_TO_GREEN(p) ( ((p) >> 2 & 0xF8) | ((p) >> 7 & 0x07) )
-#define GRGB555_TO_BLUE(p) ( ((p) << 3 & 0xF8) | ((p) >> 2 & 0x07) )
-
-#define GRGB555_TO_RGB24(p) ( ( ((p) << 9) & 0xF80000 ) | \
- ( ((p) << 4) & 0x070000 ) | \
- ( ((p) << 6) & 0x00F800 ) | \
- ( ((p) << 1) & 0x000700 ) | \
- ( ((p) << 3) & 0x0000F8 ) | \
- ( ((p) >> 2) & 0x000007 ) )
-
-#define GRGB24_TO_RGB555(p) ( (unsigned short)( (((p) >> 9) & 0x7C00 ) | \
- (((p) >> 6) & 0x03E0 ) | \
- (((p) >> 3) & 0x001F ) ) )
+#define GRGB_TO_RGB555(r,g,b) \
+ (unsigned short)( ( ( (r) << 7 ) & 0x7C00) | \
+ ( ( (g) << 2 ) & 0x03E0) | \
+ ( ( (b) >> 3 ) & 0x001F) )
+
+#define GRGB555_TO_RED(p) \
+ (unsigned short)( ( (p) >> 7 & 0xF8 ) | \
+ ( (p) >> 12 & 0x07 ) )
+#define GRGB555_TO_GREEN(p) \
+ (unsigned short)( ( (p) >> 2 & 0xF8 ) | \
+ ( (p) >> 7 & 0x07 ) )
+#define GRGB555_TO_BLUE(p) \
+ (unsigned short)( ( (p) << 3 & 0xF8 ) | \
+ ( (p) >> 2 & 0x07 ) )
+
+#define GRGB555_TO_RGB24(p) ( ( ( (p) << 9 ) & 0xF80000 ) | \
+ ( ( (p) << 4 ) & 0x070000 ) | \
+ ( ( (p) << 6 ) & 0x00F800 ) | \
+ ( ( (p) << 1 ) & 0x000700 ) | \
+ ( ( (p) << 3 ) & 0x0000F8 ) | \
+ ( ( (p) >> 2 ) & 0x000007 ) )
+
+#define GRGB24_TO_RGB555(p) \
+ (unsigned short)( ( ( (p) >> 9 ) & 0x7C00 ) | \
+ ( ( (p) >> 6 ) & 0x03E0 ) | \
+ ( ( (p) >> 3 ) & 0x001F ) )
/* */
@@ -122,11 +138,12 @@
}
#define GDST_STOREP(d,cells,a) \
+ do \
{ \
GBlenderPixel _pix = (cells)[(a)]; \
\
GDST_STORE3(d,_pix >> 16,_pix >> 8,_pix); \
- }
+ } while ( 0 )
#include "gblany.h"
@@ -149,11 +166,12 @@
}
#define GDST_STOREP(d,cells,a) \
+ do \
{ \
GBlenderPixel _pix = (cells)[(a)]; \
\
*(unsigned short*)(d) = GRGB24_TO_RGB565(_pix); \
- }
+ } while ( 0 )
#define GDST_STOREC(d,r,g,b) *(unsigned short*)(d) = GRGB_TO_RGB565(r,g,b)
@@ -177,11 +195,12 @@
}
#define GDST_STOREP(d,cells,a) \
+ do \
{ \
GBlenderPixel _pix = (cells)[(a)]; \
\
*(unsigned short*)(d) = GRGB24_TO_RGB555(_pix); \
- }
+ } while ( 0 )
#define GDST_STOREC(d,r,g,b) *(unsigned short*)(d) = GRGB_TO_RGB555(r,g,b)
@@ -205,11 +224,12 @@
}
#define GDST_STOREP(d,cells,a) \
+ do \
{ \
GBlenderPixel _pix = (cells)[(a)]; \
\
*(d) = GRGB24_TO_GRAY8(_pix); \
- }
+ } while ( 0 )
#define GDST_STOREC(d,r,g,b) *(d) = GRGB_TO_GRAY8(r,g,b)
diff --git a/graph/gblender.h b/graph/gblender.h
index 67ea230..443e371 100644
--- a/graph/gblender.h
+++ b/graph/gblender.h
@@ -161,18 +161,21 @@
GBlenderCell* _gcells = ( (_fore) == (_gb)->cache_fore ?
(_gb)->cache_cells : gblender_lookup( (_gb), _gback, _fore ) ); \
GBlenderPixel _gfore = (_fore)
-#define GBLENDER_LOOKUP(gb,back) \
- GBLENDER_STAT_HIT(gb); \
- if ( _gback != (GBlenderPixel)(back) ) \
- { \
- _gback = (GBlenderPixel)(back); \
- _gcells = gblender_lookup( (gb), _gback, _gfore ); \
- }
+#define GBLENDER_LOOKUP(gb,back) \
+ GBLENDER_STAT_HIT(gb); \
+ do \
+ { \
+ if ( _gback != (GBlenderPixel)(back) ) \
+ { \
+ _gback = (GBlenderPixel)(back); \
+ _gcells = gblender_lookup( (gb), _gback, _gfore ); \
+ } \
+ } while ( 0 )
#define GBLENDER_CLOSE(_gb) \
(_gb)->cache_back = _gback; \
(_gb)->cache_fore = _gfore; \
- (_gb)->cache_cells = _gcells;
+ (_gb)->cache_cells = _gcells
@@ -197,32 +200,41 @@
(_gb)->cache_g_cells = _ggcells; \
(_gb)->cache_b_back = _gbback; \
(_gb)->cache_b_fore = _gbfore; \
- (_gb)->cache_b_cells = _gbcells;
-
-
-#define GBLENDER_LOOKUP_R(gb,back) \
- GBLENDER_STAT_HIT(gb); \
- if ( _grback != (back) ) \
- { \
- _grback = (GBlenderPixel)(back); \
- _grcells = gblender_lookup_channel( (gb), _grback, _grfore ); \
- }
-
-#define GBLENDER_LOOKUP_G(gb,back) \
- GBLENDER_STAT_HIT(gb); \
- if ( _ggback != (back) ) \
- { \
- _ggback = (GBlenderPixel)(back); \
- _ggcells = gblender_lookup_channel( (gb), _ggback, _ggfore ); \
- }
-
-#define GBLENDER_LOOKUP_B(gb,back) \
- GBLENDER_STAT_HIT(gb); \
- if ( _gbback != (back) ) \
- { \
- _gbback = (GBlenderPixel)(back); \
- _gbcells = gblender_lookup_channel( (gb), _gbback, _gbfore ); \
- }
+ (_gb)->cache_b_cells = _gbcells
+
+
+#define GBLENDER_LOOKUP_R(gb,back) \
+ GBLENDER_STAT_HIT(gb); \
+ do \
+ { \
+ if ( _grback != (back) ) \
+ { \
+ _grback = (GBlenderPixel)(back); \
+ _grcells = gblender_lookup_channel( (gb), _grback, _grfore ); \
+ } \
+ } while ( 0 )
+
+#define GBLENDER_LOOKUP_G(gb,back) \
+ GBLENDER_STAT_HIT(gb); \
+ do \
+ { \
+ if ( _ggback != (back) ) \
+ { \
+ _ggback = (GBlenderPixel)(back); \
+ _ggcells = gblender_lookup_channel( (gb), _ggback, _ggfore ); \
+ } \
+ } while ( 0 )
+
+#define GBLENDER_LOOKUP_B(gb,back) \
+ GBLENDER_STAT_HIT(gb); \
+ do \
+ { \
+ if ( _gbback != (back) ) \
+ { \
+ _gbback = (GBlenderPixel)(back); \
+ _gbcells = gblender_lookup_channel( (gb), _gbback, _gbfore ); \
+ } \
+ } while ( 0 )
#endif /* GBLENDER_H_ */
diff --git a/graph/grblit.c b/graph/grblit.c
index f93367f..62f913c 100644
--- a/graph/grblit.c
+++ b/graph/grblit.c
@@ -786,20 +786,21 @@
-#define compose_pixel_full( a, b, n0, n1, n2, max ) \
- { \
- int d, half = max >> 1; \
- \
- \
- d = (int)b.chroma[0] - a.chroma[0]; \
- a.chroma[0] += (unsigned char)((n0*d + half)/max); \
- \
- d = (int)b.chroma[1] - a.chroma[1]; \
- a.chroma[1] += (unsigned char)((n1*d + half)/max); \
- \
- d = (int)b.chroma[2] - a.chroma[2]; \
- a.chroma[2] += (unsigned char)((n2*d + half)/max); \
- }
+#define compose_pixel_full( a, b, n0, n1, n2, max ) \
+ do \
+ { \
+ int d, half = max >> 1; \
+ \
+ \
+ d = (int)b.chroma[0] - a.chroma[0]; \
+ a.chroma[0] += (unsigned char)((n0*d + half)/max); \
+ \
+ d = (int)b.chroma[1] - a.chroma[1]; \
+ a.chroma[1] += (unsigned char)((n1*d + half)/max); \
+ \
+ d = (int)b.chroma[2] - a.chroma[2]; \
+ a.chroma[2] += (unsigned char)((n2*d + half)/max); \
+ } while ( 0 )
#define compose_pixel( a, b, n, max ) \
compose_pixel_full( a, b, n, n, n, max )
@@ -808,13 +809,13 @@
#define extract555( pixel, color ) \
color.chroma[0] = (unsigned char)((pixel >> 10) & 0x1F); \
color.chroma[1] = (unsigned char)((pixel >> 5) & 0x1F); \
- color.chroma[2] = (unsigned char)((pixel ) & 0x1F);
+ color.chroma[2] = (unsigned char)((pixel ) & 0x1F)
#define extract565( pixel, color ) \
color.chroma[0] = (unsigned char)((pixel >> 11) & 0x1F); \
color.chroma[1] = (unsigned char)((pixel >> 5) & 0x3F); \
- color.chroma[2] = (unsigned char)((pixel ) & 0x1F);
+ color.chroma[2] = (unsigned char)((pixel ) & 0x1F)
#define inject555( color ) \
@@ -1133,7 +1134,7 @@
db += ((sb-db)*val) >> 8;
_write[0] = (unsigned char)dr;
- _write[1] = (unsigned char)dg,
+ _write[1] = (unsigned char)dg;
_write[2] = (unsigned char)db;
}
}
diff --git a/graph/grfont.c b/graph/grfont.c
index c394332..4f6275a 100644
--- a/graph/grfont.c
+++ b/graph/grfont.c
@@ -268,7 +268,7 @@
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
};
- unsigned char (*font)[8] = (unsigned char (*)[8])font_8x8;
+ static unsigned char (*font)[8] = (unsigned char (*)[8])font_8x8;
#elif GR_FONT_SIZE == 14
@@ -534,7 +534,7 @@
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00
};
- unsigned char (*font)[14] = (unsigned char (*)[14])font_8x14;
+ static unsigned char (*font)[14] = (unsigned char (*)[14])font_8x14;
#endif
diff --git a/src/ftcommon.c b/src/ftcommon.c
index d24236c..d5baf91 100644
--- a/src/ftcommon.c
+++ b/src/ftcommon.c
@@ -502,12 +502,18 @@
memset( icon.buffer, 0, (size_t)icon.rows * (size_t)icon.pitch );
for ( i = 0; i < FT.n_points; i++ )
- FT.points[i].x *= size, FT.points[i].y *= size;
+ {
+ FT.points[i].x *= size;
+ FT.points[i].y *= size;
+ }
FT_Outline_Render( handle->library, &FT, ¶ms );
for ( i = 0; i < FT.n_points; i++ )
- FT.points[i].x /= size, FT.points[i].y /= size;
+ {
+ FT.points[i].x /= size;
+ FT.points[i].y /= size;
+ }
picon = &icon;
}
diff --git a/src/ftsdf.c b/src/ftsdf.c
index a638c3e..472ebd4 100644
--- a/src/ftsdf.c
+++ b/src/ftsdf.c
@@ -664,6 +664,10 @@
FT_Error err = FT_Err_Ok;
char* exec_name = NULL;
+#ifdef __linux__
+ int flip_y = 1;
+#endif
+
exec_name = ft_basename( argv[0] );
@@ -687,8 +691,6 @@
}
#ifdef __linux__
- int flip_y = 1;
-
FT_CALL( FT_Property_Set( handle->library, "sdf", "flip_y", &flip_y ) );
FT_CALL( FT_Property_Set( handle->library, "bsdf", "flip_y", &flip_y ) );
#endif
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [freetype2-demos] master b739ac0: Fix compilation errors and (some) warnings for clang++.,
Werner Lemberg <=