Skip to content

Commit

Permalink
issue olikraus#364, clip procedure pos len conversion (2)
Browse files Browse the repository at this point in the history
  • Loading branch information
olikraus committed Oct 27, 2018
1 parent 706bd4c commit 58a7d9c
Showing 1 changed file with 27 additions and 1 deletion.
28 changes: 27 additions & 1 deletion csrc/u8g2_hvline.c
Original file line number Diff line number Diff line change
Expand Up @@ -102,13 +102,39 @@ static uint8_t u8g2_clip_intersection(u8g2_uint_t *ap, u8g2_uint_t *bp, u8g2_uin
return 1;
}

/*
Description:
clip range from pos a (included) with line len (a+len excluded) agains c (included) to d (excluded)
Assumptions:
len > 0
c <= d (this is not checked)
will return 0 if there is no intersection and if a > b
optimized clipping: c is set to 0 --> 27 Oct 2018: again removed the c==0 assumption
replaced by uint8_t u8g2_clip_intersection2
*/

static uint8_t u8g2_clip_intersection2(u8g2_uint_t *ap, u8g2_uint_t *len, u8g2_uint_t c, u8g2_uint_t d)
{
u8g2_uint_t a = *ap;
u8g2_uint_t b;
b = a;
b += *len;


/*
Description:
clip range from a (included) to b (excluded) agains c (included) to d (excluded)
Assumptions:
a <= b (violation is checked and handled correctly)
c <= d (this is not checked)
will return 0 if there is no intersection and if a > b
optimized clipping: c is set to 0 --> 27 Oct 2018: again removed the c==0 assumption
replaced by uint8_t u8g2_clip_intersection2
*/

/* handle the a>b case correctly. If code and time is critical, this could */
/* be removed completly (be aware about memory curruption for wrong */
/* arguments) or return 0 for a>b (will lead to skipped lines for wrong */
Expand Down

0 comments on commit 58a7d9c

Please sign in to comment.