Skip to content

Commit

Permalink
Merge pull request #8 from lowfatcode/fix-antialias-bounds
Browse files Browse the repository at this point in the history
Fix antialias bounds
  • Loading branch information
lowfatcode authored Nov 26, 2024
2 parents 80022b7 + ba9203a commit 40e8381
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
4 changes: 2 additions & 2 deletions examples/c/helpers.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@ typedef union {
uint32_t c;
} colour;

__attribute__((always_inline)) uint32_t alpha(uint32_t sa, uint32_t da) {
__attribute__((always_inline)) inline uint32_t alpha(uint32_t sa, uint32_t da) {
return ((sa + 1) * (da)) >> 8;
}

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

Expand Down
16 changes: 8 additions & 8 deletions pretty-poly.h
Original file line number Diff line number Diff line change
Expand Up @@ -571,15 +571,15 @@ pp_rect_t render_nodes(pp_rect_t *tb) {
// either 1 (at x4) or 3 (at x16) we change that to a "ceil" instead ensuring
// the full tile bounds are returned
if(_pp_antialias) {
rb.w += (_pp_antialias | 0b1);
rb.h += (_pp_antialias | 0b1);
}

rb.x >>= _pp_antialias;
rb.y >>= _pp_antialias;
rb.w >>= _pp_antialias;
rb.h >>= _pp_antialias;
int maxx = rb.x + rb.w + (_pp_antialias | 0b1);
int maxy = rb.y + rb.h + (_pp_antialias | 0b1);

rb.x >>= _pp_antialias;
rb.y >>= _pp_antialias;
rb.w = (maxx >> _pp_antialias) - rb.x;
rb.h = (maxy >> _pp_antialias) - rb.y;
}

uint8_t *p_alpha_map = _pp_alpha_map_none;
if(_pp_antialias == 1) p_alpha_map = _pp_alpha_map_x4;
if(_pp_antialias == 2) p_alpha_map = _pp_alpha_map_x16;
Expand Down

0 comments on commit 40e8381

Please sign in to comment.