[sdf] Remove custom memory tracker. The internal FreeType memory tracker is sufficient. * src/sdf/ftsdf.c (FT_DEBUG_INNER, FT_ASSIGNP_INNER, SDF_MemoryUser, sdf_alloc, sdf_free, SDF_ALLOC, SDF_FREE, SDF_MEMORY_TRACKER_DECLARE, SDF_MEMORY_TRACKER_SETUP, SDF_MEMORY_TRACKER_DONE): Removed. s/SDF_ALLOC/FT_ALLOC/. s/SDF_FREE/FT_FREE/. Other updates.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356
diff --git a/ChangeLog b/ChangeLog
index 0ab12ff..afa2129 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,19 @@
+2020-12-26 Anuj Verma <anujv@iitbhilai.ac.in>
+
+ [sdf] Remove custom memory tracker.
+
+ The internal FreeType memory tracker is sufficient.
+
+ * src/sdf/ftsdf.c (FT_DEBUG_INNER, FT_ASSIGNP_INNER, SDF_MemoryUser,
+ sdf_alloc, sdf_free, SDF_ALLOC, SDF_FREE,
+ SDF_MEMORY_TRACKER_DECLARE, SDF_MEMORY_TRACKER_SETUP,
+ SDF_MEMORY_TRACKER_DONE): Removed.
+
+ s/SDF_ALLOC/FT_ALLOC/.
+ s/SDF_FREE/FT_FREE/.
+
+ Other updates.
+
2020-12-24 Werner Lemberg <wl@gnu.org>
[sdf] Fix `make multi`.
@@ -132,7 +148,7 @@
[sdf] Add function to generate SDF.
- * src/sdf/ftsdf.c (sdf_generate): New function, currently disabled.
+ * src/sdf/ftsdf.c (sdf_generate): New function, currently disabled.
This is a proof-of-concept implementation: It doesn't use any
optimization, it simply checks all grid points against all contours.
@@ -1547,7 +1563,7 @@
security or bug fixes will be provided for those versions. See
https://devguide.python.org/#status-of-python-branches
-
+
for more information.
* Jamfile (RefDoc): Add `site' parameter.
diff --git a/src/sdf/ftsdf.c b/src/sdf/ftsdf.c
index 175d372..604ea4a 100644
--- a/src/sdf/ftsdf.c
+++ b/src/sdf/ftsdf.c
@@ -89,10 +89,10 @@
* }
* ```
*
- * (4) After running this algorithm the bitmap contain sinformation about the closest
- * point from each point to the outline of the shape. Of course,
- * while this is the most straightforward way of generating SDF, we
- * use various optimizations in this rasterizer. See the
+ * (4) After running this algorithm the bitmap contains information about
+ * the shortest distance from each point to the outline of the shape.
+ * Of course, while this is the most straightforward way of generating
+ * SDF, we use various optimizations in our implementation. See the
* `sdf_generate_*' functions in this file for all details.
*
* The optimization currently used by default is subdivision; see
@@ -116,123 +116,6 @@
/**************************************************************************
*
- * for tracking used memory
- *
- */
-
- /* The memory tracker only works when `FT_DEBUG_MEMORY` is defined; */
- /* we need some variables such as `_ft_debug_file`, which aren't */
- /* available otherwise. */
-#if defined( FT_DEBUG_LEVEL_TRACE ) && defined( FT_DEBUG_MEMORY )
-
-
-#undef FT_DEBUG_INNER
-#undef FT_ASSIGNP_INNER
-
-#define FT_DEBUG_INNER( exp ) ( _ft_debug_file = __FILE__, \
- _ft_debug_lineno = line, \
- (exp) )
-#define FT_ASSIGNP_INNER( p, exp ) ( _ft_debug_file = __FILE__, \
- _ft_debug_lineno = line, \
- FT_ASSIGNP( p, exp ) )
-
-
- /* To be used with `FT_Memory::user' in order to track */
- /* memory allocations. */
- typedef struct SDF_MemoryUser_
- {
- void* prev_user;
- FT_Long total_usage;
-
- } SDF_MemoryUser;
-
-
- /*
- * These functions are used while allocating and deallocating memory.
- * They restore the previous user pointer before calling the allocation
- * functions.
- */
-
- static FT_Pointer
- sdf_alloc( FT_Memory memory,
- FT_Long size,
- FT_Error* err,
- FT_Int line )
- {
- SDF_MemoryUser* current_user;
- FT_Pointer ptr;
- FT_Error error;
-
-
- current_user = (SDF_MemoryUser*)memory->user;
- memory->user = current_user->prev_user;
-
- if ( !FT_QALLOC( ptr, size ) )
- current_user->total_usage += size;
-
- memory->user = (void*)current_user;
- *err = error;
-
- return ptr;
- }
-
-
- static void
- sdf_free( FT_Memory memory,
- FT_Pointer ptr,
- FT_Int line )
- {
- SDF_MemoryUser* current_user;
-
-
- current_user = (SDF_MemoryUser*)memory->user;
- memory->user = current_user->prev_user;
-
- FT_FREE( ptr );
-
- memory->user = (void*)current_user;
- }
-
-
-#define SDF_ALLOC( ptr, size ) \
- ( ptr = sdf_alloc( memory, size, \
- &error, __LINE__ ), \
- error != 0 )
-
-#define SDF_FREE( ptr ) \
- sdf_free( memory, ptr, __LINE__ )
-
-#define SDF_MEMORY_TRACKER_DECLARE() SDF_MemoryUser sdf_memory_user
-
-#define SDF_MEMORY_TRACKER_SETUP() \
- sdf_memory_user.prev_user = memory->user; \
- sdf_memory_user.total_usage = 0; \
- memory->user = &sdf_memory_user
-
-#define SDF_MEMORY_TRACKER_DONE() \
- memory->user = sdf_memory_user.prev_user; \
- \
- FT_TRACE0(( "[sdf] sdf_raster_render:" \
- " Total memory used = %ld\n", \
- sdf_memory_user.total_usage ))
-
-
-#else /* !FT_DEBUG_LEVEL_TRACE */
-
-
-#define SDF_ALLOC FT_QALLOC
-#define SDF_FREE FT_FREE
-
-#define SDF_MEMORY_TRACKER_DECLARE() FT_DUMMY_STMNT
-#define SDF_MEMORY_TRACKER_SETUP() FT_DUMMY_STMNT
-#define SDF_MEMORY_TRACKER_DONE() FT_DUMMY_STMNT
-
-
-#endif /* !FT_DEBUG_LEVEL_TRACE */
-
-
- /**************************************************************************
- *
* definitions
*
*/
@@ -612,7 +495,7 @@
goto Exit;
}
- if ( !SDF_ALLOC( ptr, sizeof ( *ptr ) ) )
+ if ( !FT_ALLOC( ptr, sizeof ( *ptr ) ) )
{
*ptr = null_edge;
*edge = ptr;
@@ -631,7 +514,7 @@
if ( !memory || !edge || !*edge )
return;
- SDF_FREE( *edge );
+ FT_FREE( *edge );
}
@@ -651,7 +534,7 @@
goto Exit;
}
- if ( !SDF_ALLOC( ptr, sizeof ( *ptr ) ) )
+ if ( !FT_ALLOC( ptr, sizeof ( *ptr ) ) )
{
*ptr = null_contour;
*contour = ptr;
@@ -686,7 +569,7 @@
sdf_edge_done( memory, &temp );
}
- SDF_FREE( *contour );
+ FT_FREE( *contour );
}
@@ -706,7 +589,7 @@
goto Exit;
}
- if ( !SDF_ALLOC( ptr, sizeof ( *ptr ) ) )
+ if ( !FT_ALLOC( ptr, sizeof ( *ptr ) ) )
{
*ptr = null_shape;
ptr->memory = memory;
@@ -747,7 +630,7 @@
}
/* release the allocated shape struct */
- SDF_FREE( *shape );
+ FT_FREE( *shape );
}
@@ -3344,11 +3227,9 @@
rows = (FT_Int)bitmap->rows;
buffer = (FT_Short*)bitmap->buffer;
- if ( SDF_ALLOC( dists, width * rows * sizeof ( *dists ) ) )
+ if ( FT_ALLOC( dists, width * rows * sizeof ( *dists ) ) )
goto Exit;
- FT_MEM_ZERO( dists, width * rows * sizeof ( *dists ) );
-
if ( USE_SQUARED_DISTANCES )
sp_sq = FT_INT_16D16( spread * spread );
else
@@ -3484,7 +3365,7 @@
}
Exit:
- SDF_FREE( dists );
+ FT_FREE( dists );
return error;
}
@@ -3649,19 +3530,13 @@
}
/* allocate the bitmaps to generate SDF for separate contours */
- if ( SDF_ALLOC( bitmaps, num_contours * sizeof ( *bitmaps ) ) )
+ if ( FT_ALLOC( bitmaps, num_contours * sizeof ( *bitmaps ) ) )
goto Exit;
- /* zero the memory */
- ft_memset( bitmaps, 0, num_contours * sizeof ( *bitmaps ) );
-
/* allocate array to hold orientation for all contours */
- if ( SDF_ALLOC( orientations, num_contours * sizeof ( *orientations ) ) )
+ if ( FT_ALLOC( orientations, num_contours * sizeof ( *orientations ) ) )
goto Exit;
- /* zero the memory */
- ft_memset( orientations, 0, num_contours * sizeof ( *orientations ) );
-
/* Disable `flip_sign` to avoid extra complication */
/* during the combination phase. */
flip_sign = internal_params.flip_sign;
@@ -3682,7 +3557,7 @@
bitmaps[i].pixel_mode = bitmap->pixel_mode;
/* allocate memory for the buffer */
- if ( SDF_ALLOC( bitmaps[i].buffer, bitmap->rows * bitmap->pitch ) )
+ if ( FT_ALLOC( bitmaps[i].buffer, bitmap->rows * bitmap->pitch ) )
goto Exit;
/* determine the orientation */
@@ -3789,7 +3664,7 @@
Exit:
/* deallocate orientations array */
if ( orientations )
- SDF_FREE( orientations );
+ FT_FREE( orientations );
/* deallocate temporary bitmaps */
if ( bitmaps )
@@ -3799,9 +3674,9 @@
else
{
for ( i = 0; i < num_contours; i++ )
- SDF_FREE( bitmaps[i].buffer );
+ FT_FREE( bitmaps[i].buffer );
- SDF_FREE( bitmaps );
+ FT_FREE( bitmaps );
}
}
@@ -3875,8 +3750,6 @@
SDF_Shape* shape = NULL;
SDF_Params internal_params;
- SDF_MEMORY_TRACKER_DECLARE();
-
/* check for valid arguments */
if ( !sdf_raster || !sdf_params )
@@ -3943,12 +3816,6 @@
internal_params.flip_y = sdf_params->flip_y;
internal_params.overload_sign = 0;
- /* assign a custom user pointer to `FT_Memory`; */
- /* also keep a reference of the old user pointer */
- /* in order to debug the memory while compiling */
- /* with `FT_DEBUG_MEMORY`. */
- SDF_MEMORY_TRACKER_SETUP();
-
FT_CALL( sdf_shape_new( memory, &shape ) );
FT_CALL( sdf_outline_decompose( outline, shape ) );
@@ -3965,9 +3832,6 @@
if ( shape )
sdf_shape_done( &shape );
- /* restore the memory->user */
- SDF_MEMORY_TRACKER_DONE();
-
Exit:
return error;
}
@@ -3977,10 +3841,6 @@
sdf_raster_done( FT_Raster raster )
{
FT_Memory memory = (FT_Memory)((SDF_TRaster*)raster)->memory;
- FT_Int line = __LINE__;
-
- /* in non-debugging mode this is not used */
- FT_UNUSED( line );
FT_FREE( raster );