... |
... |
@@ -52,7 +52,7 @@ dense_move_to( const FT_Vector* to, dense_worker* worker ) |
52
|
52
|
static int
|
53
|
53
|
dense_line_to( const FT_Vector* to, dense_worker* worker )
|
54
|
54
|
{
|
55
|
|
- // printf( "dense_line_to: %d, %d\n", to->x, to->y );
|
|
55
|
+ //printf( "dense_line_to: %d, %d\n", to->x, to->y );
|
56
|
56
|
dense_render_line( worker, UPSCALE( to->x ), UPSCALE( to->y ) );
|
57
|
57
|
dense_move_to( to, worker );
|
58
|
58
|
return 0;
|
... |
... |
@@ -76,6 +76,8 @@ swapold( unsigned char* a, unsigned char* b ) |
76
|
76
|
void
|
77
|
77
|
dense_render_line( dense_worker* worker, TPos to_x, TPos to_y )
|
78
|
78
|
{
|
|
79
|
+ // printf("line from: %d, %d to %d, %d\n", worker->prev_x, worker->prev_y,
|
|
80
|
+ // to_x, to_y);
|
79
|
81
|
TPos from_x = worker->prev_x;
|
80
|
82
|
TPos from_y = worker->prev_y;
|
81
|
83
|
if ( from_y == to_y )
|
... |
... |
@@ -238,6 +240,7 @@ dense_conic_to( const FT_Vector* control, |
238
|
240
|
const FT_Vector* to,
|
239
|
241
|
dense_worker* worker )
|
240
|
242
|
{
|
|
243
|
+ //printf( "dense_conic_to: %d, %d\n", to->x, to->y );
|
241
|
244
|
dense_render_quadratic( worker, control, to );
|
242
|
245
|
return 0;
|
243
|
246
|
}
|
... |
... |
@@ -259,9 +262,9 @@ dense_render_quadratic( dense_worker* worker, |
259
|
262
|
The division by four is omitted to save time.
|
260
|
263
|
*/
|
261
|
264
|
|
262
|
|
- FT_Vector aP0 = { worker->prev_x, worker->prev_y };
|
263
|
|
- FT_Vector aP1 = { UPSCALE( control->x ), UPSCALE( control->y ) };
|
264
|
|
- FT_Vector aP2 = { UPSCALE( to->x ), UPSCALE( to->y ) };
|
|
265
|
+ FT_Vector aP0 = { DOWNSCALE( worker->prev_x ), DOWNSCALE( worker->prev_y ) };
|
|
266
|
+ FT_Vector aP1 = { control->x, control->y };
|
|
267
|
+ FT_Vector aP2 = { to->x, to->y };
|
265
|
268
|
|
266
|
269
|
float devx = aP0.x - aP1.x - aP1.x + aP2.x;
|
267
|
270
|
float devy = aP0.y - aP1.y - aP1.y + aP2.y;
|
... |
... |
@@ -269,9 +272,7 @@ dense_render_quadratic( dense_worker* worker, |
269
|
272
|
|
270
|
273
|
if ( devsq < 0.333f )
|
271
|
274
|
{
|
272
|
|
- dense_render_line( worker, aP2.x, aP2.y );
|
273
|
|
- worker->prev_x = aP2.x;
|
274
|
|
- worker->prev_y = aP2.y;
|
|
275
|
+ dense_line_to( &aP2, worker );
|
275
|
276
|
return;
|
276
|
277
|
}
|
277
|
278
|
|
... |
... |
@@ -285,24 +286,23 @@ dense_render_quadratic( dense_worker* worker, |
285
|
286
|
expected to be 33% more in the limit".
|
286
|
287
|
*/
|
287
|
288
|
|
288
|
|
- const float tol = 3.0f;
|
289
|
|
- int n = (int)floor( sqrt( sqrt( tol * devsq ) ) );
|
290
|
|
- FT_Vector p = aP0;
|
291
|
|
- float nrecip = 1.0f / ( n + 1.0f );
|
292
|
|
- float t = 0.0f;
|
|
289
|
+ const float tol = 3.0f;
|
|
290
|
+ int n = (int)floor( sqrt( sqrt( tol * devsq ) ) )/8;
|
|
291
|
+ //printf( "n is %d\n", n );
|
|
292
|
+ FT_Vector p = aP0;
|
|
293
|
+ float nrecip = 1.0f / ( n + 1.0f );
|
|
294
|
+ float t = 0.0f;
|
293
|
295
|
for ( int i = 0; i < n; i++ )
|
294
|
296
|
{
|
295
|
297
|
t += nrecip;
|
296
|
298
|
FT_Vector next = Lerp( t, Lerp( t, aP0, aP1 ), Lerp( t, aP1, aP2 ) );
|
297
|
|
- dense_render_line( worker, next.x, next.y );
|
298
|
|
- worker->prev_x = next.x;
|
299
|
|
- worker->prev_y = next.y;
|
|
299
|
+ dense_line_to(&next, worker );
|
300
|
300
|
p = next;
|
301
|
301
|
}
|
302
|
302
|
|
303
|
|
- dense_render_line( worker, aP2.x, aP2.y );
|
304
|
|
- worker->prev_x = aP2.x;
|
305
|
|
- worker->prev_y = aP2.y;
|
|
303
|
+ dense_line_to( &aP2, worker );
|
|
304
|
+ // worker->prev_x = aP2.x;
|
|
305
|
+ // worker->prev_y = aP2.y;
|
306
|
306
|
}
|
307
|
307
|
|
308
|
308
|
static int
|
... |
... |
@@ -375,7 +375,6 @@ dense_raster_new( FT_Memory memory, dense_PRaster* araster ) |
375
|
375
|
static void
|
376
|
376
|
dense_raster_done( FT_Raster raster )
|
377
|
377
|
{
|
378
|
|
-
|
379
|
378
|
FT_Memory memory = (FT_Memory)( (dense_PRaster)raster )->memory;
|
380
|
379
|
|
381
|
380
|
FT_FREE( raster );
|
... |
... |
@@ -455,11 +454,10 @@ dense_render_glyph( dense_worker* worker, const FT_Bitmap* target ) |
455
|
454
|
static int
|
456
|
455
|
dense_raster_render( FT_Raster raster, const FT_Raster_Params* params )
|
457
|
456
|
{
|
458
|
|
-
|
459
|
457
|
const FT_Outline* outline = (const FT_Outline*)params->source;
|
460
|
458
|
const FT_Bitmap* target_map = params->target;
|
461
|
459
|
|
462
|
|
- //dense_worker* worker = malloc( sizeof( dense_worker ) );
|
|
460
|
+ // dense_worker* worker = malloc( sizeof( dense_worker ) );
|
463
|
461
|
dense_worker worker[1];
|
464
|
462
|
|
465
|
463
|
if ( !raster )
|