[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[freetype2] master c9bbc24 1/2: Add internal functions `FT_Trace_Disable
From: |
Werner LEMBERG |
Subject: |
[freetype2] master c9bbc24 1/2: Add internal functions `FT_Trace_Disable' and `FT_Trace_Enable'. |
Date: |
Wed, 8 Aug 2018 12:16:20 -0400 (EDT) |
branch: master
commit c9bbc2419ae7d3cf73a597afbf02cb335ede952f
Author: Werner Lemberg <address@hidden>
Commit: Werner Lemberg <address@hidden>
Add internal functions `FT_Trace_Disable' and `FT_Trace_Enable'.
It sometimes makes sense to suppress tracing informations, for
example, if it outputs identical messages again and again.
* include/freetype/internal/ftdebug.h: Make `ft_trace_levels' a
pointer.
(FT_Trace_Disable, FT_Trace_Enable): New declarations.
* src/base/ftdebug.c (ft_trace_levels): Rename to...
(ft_trace_levels_enabled): ... this.
(ft_trace_levels_disabled): New array.
(ft_trace_levels): New pointer.
(FT_Trace_Disable, FT_Trace_Enable): Implement.
(ft_debug_init): Updated.
---
ChangeLog | 18 +++++++++++++
include/freetype/internal/ftdebug.h | 40 +++++++++++++++++++++++------
src/base/ftdebug.c | 51 ++++++++++++++++++++++++++++++++++---
3 files changed, 97 insertions(+), 12 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 91bb37a..73259c6 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,23 @@
2018-08-08 Werner Lemberg <address@hidden>
+ Add internal functions `FT_Trace_Disable' and `FT_Trace_Enable'.
+
+ It sometimes makes sense to suppress tracing informations, for
+ example, if it outputs identical messages again and again.
+
+ * include/freetype/internal/ftdebug.h: Make `ft_trace_levels' a
+ pointer.
+ (FT_Trace_Disable, FT_Trace_Enable): New declarations.
+
+ * src/base/ftdebug.c (ft_trace_levels): Rename to...
+ (ft_trace_levels_enabled): ... this.
+ (ft_trace_levels_disabled): New array.
+ (ft_trace_levels): New pointer.
+ (FT_Trace_Disable, FT_Trace_Enable): Implement.
+ (ft_debug_init): Updated.
+
+2018-08-08 Werner Lemberg <address@hidden>
+
Debugging improvements.
* src/base/ftobjs.c (pixel_modes): Move this array to top level
diff --git a/include/freetype/internal/ftdebug.h
b/include/freetype/internal/ftdebug.h
index 1b4f699..d6e8a3a 100644
--- a/include/freetype/internal/ftdebug.h
+++ b/include/freetype/internal/ftdebug.h
@@ -62,8 +62,9 @@ FT_BEGIN_HEADER
} FT_Trace;
- /* defining the array of trace levels, provided by `src/base/ftdebug.c' */
- extern int ft_trace_levels[trace_count];
+ /* a pointer to the array of trace levels, */
+ /* provided by `src/base/ftdebug.c' */
+ extern int* ft_trace_levels;
#undef FT_TRACE_DEF
@@ -111,7 +112,7 @@ FT_BEGIN_HEADER
*
* @note:
* This function may be useful if you want to access elements of
- * the internal `ft_trace_levels' array by an index.
+ * the internal trace levels array by an index.
*/
FT_BASE( FT_Int )
FT_Trace_Get_Count( void );
@@ -130,15 +131,12 @@ FT_BEGIN_HEADER
*
* @return:
* The name of the trace component. This is a statically allocated
- * C string, so do not free it after use. NULL if FreeType 2 is not
- * built with FT_DEBUG_LEVEL_TRACE definition.
+ * C~string, so do not free it after use. NULL if FreeType is not built
+ * with FT_DEBUG_LEVEL_TRACE definition.
*
* @note:
* Use @FT_Trace_Get_Count to get the number of available trace
* components.
- *
- * This function may be useful if you want to control FreeType 2's
- * debug level in your application.
*/
FT_BASE( const char* )
FT_Trace_Get_Name( FT_Int idx );
@@ -146,6 +144,32 @@ FT_BEGIN_HEADER
/**************************************************************************
*
+ * @function:
+ * FT_Trace_Disable
+ *
+ * @description:
+ * Switch off tracing temporarily. It can be activated again with
+ * @FT_Trace_Enable.
+ */
+ FT_BASE( void )
+ FT_Trace_Disable( void );
+
+
+ /**************************************************************************
+ *
+ * @function:
+ * FT_Trace_Enable
+ *
+ * @description:
+ * Activate tracing. Use it after tracing has been switched off with
+ * @FT_Trace_Disable.
+ */
+ FT_BASE( void )
+ FT_Trace_Enable( void );
+
+
+ /**************************************************************************
+ *
* You need two opening and closing parentheses!
*
* Example: FT_TRACE0(( "Value is %i", foo ))
diff --git a/src/base/ftdebug.c b/src/base/ftdebug.c
index a5fae27..8c7e51c 100644
--- a/src/base/ftdebug.c
+++ b/src/base/ftdebug.c
@@ -100,9 +100,16 @@
#ifdef FT_DEBUG_LEVEL_TRACE
- /* array of trace levels, initialized to 0 */
- int ft_trace_levels[trace_count];
+ /* array of trace levels, initialized to 0; */
+ /* this gets adjusted at run-time */
+ int ft_trace_levels_enabled[trace_count];
+ /* array of trace levels, always initialized to 0 */
+ int ft_trace_levels_disabled[trace_count];
+
+ /* a pointer to either `ft_trace_levels_enabled' */
+ /* or `ft_trace_levels_disabled' */
+ int* ft_trace_levels;
/* define array of trace toggle names */
#define FT_TRACE_DEF( x ) #x ,
@@ -140,6 +147,24 @@
}
+ /* documentation is in ftdebug.h */
+
+ FT_BASE_DEF( void )
+ FT_Trace_Disable( void )
+ {
+ ft_trace_levels = ft_trace_levels_disabled;
+ }
+
+
+ /* documentation is in ftdebug.h */
+
+ FT_BASE_DEF( void )
+ FT_Trace_Enable( void )
+ {
+ ft_trace_levels = ft_trace_levels_enabled;
+ }
+
+
/**************************************************************************
*
* Initialize the tracing sub-system. This is done by retrieving the
@@ -223,14 +248,16 @@
{
/* special case for `any' */
for ( n = 0; n < trace_count; n++ )
- ft_trace_levels[n] = level;
+ ft_trace_levels_enabled[n] = level;
}
else
- ft_trace_levels[found] = level;
+ ft_trace_levels_enabled[found] = level;
}
}
}
}
+
+ ft_trace_levels = ft_trace_levels_enabled;
}
@@ -260,6 +287,22 @@
}
+ FT_BASE_DEF( void )
+ FT_Trace_Disable( void )
+ {
+ /* nothing */
+ }
+
+
+ /* documentation is in ftdebug.h */
+
+ FT_BASE_DEF( void )
+ FT_Trace_Enable( void )
+ {
+ /* nothing */
+ }
+
+
#endif /* !FT_DEBUG_LEVEL_TRACE */
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [freetype2] master c9bbc24 1/2: Add internal functions `FT_Trace_Disable' and `FT_Trace_Enable'.,
Werner LEMBERG <=