Skip to content

Commit 40e8381

Browse files
authored
Merge pull request #8 from lowfatcode/fix-antialias-bounds
Fix antialias bounds
2 parents 80022b7 + ba9203a commit 40e8381

File tree

2 files changed

+10
-10
lines changed

2 files changed

+10
-10
lines changed

examples/c/helpers.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,11 @@ typedef union {
1414
uint32_t c;
1515
} colour;
1616

17-
__attribute__((always_inline)) uint32_t alpha(uint32_t sa, uint32_t da) {
17+
__attribute__((always_inline)) inline uint32_t alpha(uint32_t sa, uint32_t da) {
1818
return ((sa + 1) * (da)) >> 8;
1919
}
2020

21-
__attribute__((always_inline)) uint8_t blend_channel(uint8_t s, uint8_t d, uint8_t a) {
21+
__attribute__((always_inline)) inline uint8_t blend_channel(uint8_t s, uint8_t d, uint8_t a) {
2222
return d + ((a * (s - d) + 127) >> 8);
2323
}
2424

pretty-poly.h

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -571,15 +571,15 @@ pp_rect_t render_nodes(pp_rect_t *tb) {
571571
// either 1 (at x4) or 3 (at x16) we change that to a "ceil" instead ensuring
572572
// the full tile bounds are returned
573573
if(_pp_antialias) {
574-
rb.w += (_pp_antialias | 0b1);
575-
rb.h += (_pp_antialias | 0b1);
576-
}
577-
578-
rb.x >>= _pp_antialias;
579-
rb.y >>= _pp_antialias;
580-
rb.w >>= _pp_antialias;
581-
rb.h >>= _pp_antialias;
574+
int maxx = rb.x + rb.w + (_pp_antialias | 0b1);
575+
int maxy = rb.y + rb.h + (_pp_antialias | 0b1);
582576

577+
rb.x >>= _pp_antialias;
578+
rb.y >>= _pp_antialias;
579+
rb.w = (maxx >> _pp_antialias) - rb.x;
580+
rb.h = (maxy >> _pp_antialias) - rb.y;
581+
}
582+
583583
uint8_t *p_alpha_map = _pp_alpha_map_none;
584584
if(_pp_antialias == 1) p_alpha_map = _pp_alpha_map_x4;
585585
if(_pp_antialias == 2) p_alpha_map = _pp_alpha_map_x16;

0 commit comments

Comments
 (0)