summaryrefslogtreecommitdiff
path: root/nuttx/graphics
diff options
context:
space:
mode:
authorpatacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3>2010-08-08 13:33:10 +0000
committerpatacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3>2010-08-08 13:33:10 +0000
commit5b2f479177d15e64b2ab6d07a3306ada6e60027c (patch)
treee7a8175367db8c302ad4ca704815afef39298b40 /nuttx/graphics
parent27ff8784e794d5385d80e413fb74aa514249abe3 (diff)
downloadpx4-nuttx-5b2f479177d15e64b2ab6d07a3306ada6e60027c.tar.gz
px4-nuttx-5b2f479177d15e64b2ab6d07a3306ada6e60027c.tar.bz2
px4-nuttx-5b2f479177d15e64b2ab6d07a3306ada6e60027c.zip
Fix rectangle logic
git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@2831 42af7a65-404d-4744-a932-0658087f49c3
Diffstat (limited to 'nuttx/graphics')
-rw-r--r--nuttx/graphics/nxglib/fb/nxglib_moverectangle.c51
1 files changed, 39 insertions, 12 deletions
diff --git a/nuttx/graphics/nxglib/fb/nxglib_moverectangle.c b/nuttx/graphics/nxglib/fb/nxglib_moverectangle.c
index 4b426a10b..9f804c044 100644
--- a/nuttx/graphics/nxglib/fb/nxglib_moverectangle.c
+++ b/nuttx/graphics/nxglib/fb/nxglib_moverectangle.c
@@ -174,44 +174,71 @@ void NXGL_FUNCNAME(nxgl_moverectangle,NXGLIB_SUFFIX)
# endif
#endif
- /* Case 1: The destination position (offset) is above the displayed
- * position (rect)
+ /* sline = address of the first pixel in the top row of the source in
+ * framebuffer memory
*/
- if (offset->y < rect->pt1.y)
- {
- /* Copy the rectangle from top down. */
+ sline = pinfo->fbmem + rect->pt1.y * stride + NXGL_SCALEX(rect->pt1.x);
+
+ /* dline = address of the first pixel in the top row of the destination
+ * in framebuffer memory. We get dline by subtract the offset from the
+ * source position.
+ */
+
+ dline = (FAR uint8_t*)sline - offset->y * stride - NXGL_SCALEX(offset->x);
- sline = pinfo->fbmem + rect->pt1.y * stride + NXGL_SCALEX(rect->pt1.x);
- dline = (FAR uint8_t*)sline - offset->y * stride - NXGL_SCALEX(offset->x);
+ /* Case 1: Is the destination position above the displayed position?
+ * If the Y offset is negative, then the destination is offset to a
+ * postion below (or to the right) in the source in framebuffer memory.
+ */
+
+ if (offset->y < 0)
+ {
+ /* Yes.. Copy the rectangle from top down (i.e., adding the stride
+ * to move to the next, lower row) */
while (rows--)
{
+ /* Copy the row */
+
#if NXGLIB_BITSPERPIXEL < 8
nxgl_lowresmemcpy(dline, sline, width, leadmask, tailmask);
#else
NXGL_MEMCPY(dline, sline, width);
#endif
+ /* Point to the next source/dest row below the current one */
+
dline += stride;
sline += stride;
}
}
- /* Case 2: The destination position (offset) is below the displayed
- * position (rect)
+ /* Case 2: No.. the destination position is above (or to the left of)
+ * the displayed source position
*/
else
{
- /* Copy the rectangle from the bottom up */
+ /* Adjust sline and dline to point to the bottom row (+1) of the
+ * source and destination rectangles in framebuffer memory.
+ */
+
+ unsigned int hoffset = rows * stride;
+ sline += hoffset;
+ dline += hoffset;
- sline = pinfo->fbmem + rect->pt2.y * stride + NXGL_SCALEX(rect->pt1.x);
- dline = (FAR uint8_t*)sline - offset->y * stride - NXGL_SCALEX(offset->x);
+ /* Copy the rectangle from the bottom up (i.e., subtracting stride
+ * to re-position to the previous, higher row) */
while (rows--)
{
+ /* Point to the next source/dest row above the current one */
+
dline -= stride;
sline -= stride;
+
+ /* Copy the row */
+
#if NXGLIB_BITSPERPIXEL < 8
nxgl_lowresmemcpy(dline, sline, width, leadmask, tailmask);
#else