@@ -145,7 +145,7 @@ pp_rect_t pp_polygon_bounds(pp_poly_t *p);
145
145
146
146
#ifdef PP_IMPLEMENTATION
147
147
148
- pp_rect_t _pp_clip = (pp_rect_t ){0 , 0 , 320 , 240 };
148
+ pp_rect_t _pp_clip = (pp_rect_t ){- INT_MAX , - INT_MAX , INT_MAX , INT_MAX };
149
149
pp_tile_callback_t _pp_tile_callback = NULL ;
150
150
pp_antialias_t _pp_antialias = PP_AA_X4 ;
151
151
pp_mat3_t * _pp_transform = NULL ;
@@ -424,10 +424,10 @@ int compare_nodes(const void* a, const void* b) {
424
424
425
425
pp_rect_t render_nodes (pp_rect_t * tb ) {
426
426
pp_rect_t rb = {PP_TILE_BUFFER_SIZE << _pp_antialias , PP_TILE_BUFFER_SIZE << _pp_antialias , 0 , 0 }; // render bounds
427
-
427
+ int maxx = 0 , minx = PP_TILE_BUFFER_SIZE << _pp_antialias ;
428
428
debug (" + render tile %d, %d - %d, %d\n" , tb -> x , tb -> y , tb -> w , tb -> h );
429
429
430
- for (uint32_t y = 0 ; y < ((uint32_t )PP_TILE_BUFFER_SIZE << _pp_antialias ); y ++ ) {
430
+ for (int y = 0 ; y < ((int )PP_TILE_BUFFER_SIZE << _pp_antialias ); y ++ ) {
431
431
432
432
// debug(" : row %d node count %d\n", y, node_counts[y]);
433
433
@@ -437,7 +437,7 @@ pp_rect_t render_nodes(pp_rect_t *tb) {
437
437
438
438
unsigned char * row_data = & tile_buffer [(y >> _pp_antialias ) * PP_TILE_BUFFER_SIZE ];
439
439
440
- for (uint32_t i = 0 ; i < node_counts [y ]; i += 2 ) {
440
+ for (int i = 0 ; i < node_counts [y ]; i += 2 ) {
441
441
int sx = nodes [y ][i + 0 ];
442
442
int ex = nodes [y ][i + 1 ];
443
443
@@ -447,9 +447,10 @@ pp_rect_t render_nodes(pp_rect_t *tb) {
447
447
448
448
// update render bounds
449
449
rb .x = _pp_min (rb .x , sx );
450
- rb .y = _pp_min (rb .y , y );
451
- rb .w = _pp_max (rb .w , ex - rb .x );
452
- rb .h = _pp_max (rb .h , y - rb .y + 1 );
450
+ rb .y = _pp_min (rb .y , y );
451
+ minx = _pp_min (_pp_min (sx , ex ), minx );
452
+ maxx = _pp_max (_pp_max (sx , ex ), maxx );
453
+ rb .h = y - rb .y + 1 ;
453
454
454
455
//debug(" - render span at %d from %d to %d\n", y, sx, ex);
455
456
@@ -460,6 +461,8 @@ pp_rect_t render_nodes(pp_rect_t *tb) {
460
461
}
461
462
}
462
463
464
+ rb .w = maxx - minx ;
465
+
463
466
// shifting the width and height effectively "floors" the result which can
464
467
// mean we lose a pixel off the right or bottom edge of the tile. by adding
465
468
// either 1 (at x4) or 3 (at x16) we change that to a "ceil" instead ensuring
@@ -507,7 +510,7 @@ void pp_render(pp_poly_t *polygon) {
507
510
polygon_bounds = pp_rect_transform (& polygon_bounds , _pp_transform );
508
511
}
509
512
510
- debug (" - bounds %d, %d (%d x %d)\n" , polygon_bounds .x , polygon_bounds .y , polygon_bounds .w , polygon_bounds .h );
513
+ debug (" - polygon bounds %d, %d (%d x %d)\n" , polygon_bounds .x , polygon_bounds .y , polygon_bounds .w , polygon_bounds .h );
511
514
debug (" - clip %d, %d (%d x %d)\n" , _pp_clip .x , _pp_clip .y , _pp_clip .w , _pp_clip .h );
512
515
513
516
#ifdef USE_RP2040_INTERP
0 commit comments