libnx/nxglib: Fix handling of near-horizontal lines of width 1 in nxgl_splitline(). Missing handling for degenerate condition caused width 1 lines such as (0, 0) - (100, 10) to have gaps in the drawing.

This commit is contained in:
Petteri Aimonen 2016-09-22 11:09:06 -06:00 committed by Gregory Nutt
parent 93b48ea70f
commit 69577eb0b7
2 changed files with 38 additions and 2 deletions

View File

@ -287,7 +287,7 @@ int mount(FAR const char *source, FAR const char *target,
* incremented.
*
* But is it a directory node (i.e., not a driver or other special
* node).
* node)?
*/
if (INODE_IS_SPECIAL(mountpt_inode))

View File

@ -1,7 +1,7 @@
/****************************************************************************
* graphics/nxglib/nxglib_splitline.c
*
* Copyright (C) 2011-2012 Gregory Nutt. All rights reserved.
* Copyright (C) 2011-2012, 2016 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org>
*
* Redistribution and use in source and binary forms, with or without
@ -237,6 +237,42 @@ int nxgl_splitline(FAR struct nxgl_vector_s *vector,
return 1;
}
else if (linewidth == 1)
{
b16_t pixels_per_row;
/* Close to horizontal line of width 1 */
pixels_per_row = itob16(line.pt2.x - line.pt1.x) /
(line.pt2.y - line.pt1.y);
traps[1].top.x1 = itob16(line.pt1.x);
traps[1].top.x2 = traps[1].top.x1 + pixels_per_row;
traps[1].top.y = line.pt1.y;
traps[1].bot.x2 = itob16(line.pt2.x);
traps[1].bot.x1 = traps[1].bot.x2 - pixels_per_row;
traps[1].bot.y = line.pt2.y;
if (pixels_per_row < 0)
{
b16_t tmp;
tmp = traps[1].top.x2;
traps[1].top.x2 = traps[1].top.x1;
traps[1].top.x1 = tmp;
tmp = traps[1].bot.x2;
traps[1].bot.x2 = traps[1].bot.x1;
traps[1].bot.x1 = tmp;
}
ginfo("Horizontal traps[1]: (%08x,%08x,%d),(%08x,%08x, %d)\n",
traps[1].top.x1, traps[1].top.x2, traps[1].top.y,
traps[1].bot.x1, traps[1].bot.x2, traps[1].bot.y);
return 1;
}
/* Okay, then what remains is interesting.
*