Fix a divide-by-zero error in the trapezoid drawing logic

git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@4807 42af7a65-404d-4744-a932-0658087f49c3
This commit is contained in:
patacongo 2012-06-06 18:07:49 +00:00
parent f0a7756f43
commit 976c9cf3ad
5 changed files with 41 additions and 11 deletions

View File

@ -2896,4 +2896,8 @@
when the work queue is enabled. This is partially because some interrupt when the work queue is enabled. This is partially because some interrupt
related logic is not built in that case. Simply disabling then re- related logic is not built in that case. Simply disabling then re-
enabling interrupts restores the proper state. enabling interrupts restores the proper state.
* graphics/nxglib/lcd/nxglib_filltrapezoid.c and fb/nxglib_filltrapezoid.c:
Fix an error when the trapezoid is only 1 line high. In this case, a
divide by zero error would occur. The fix is to draw the 1 line high
trapezoid as a run.

View File

@ -2275,7 +2275,7 @@
<p> <p>
<b>STATUS:</b> <b>STATUS:</b>
Two verified configurations are available: Two verified configurations are available:
(1) The basic OS test configuration that verfies the correctnexx port of Nuttx, and (2) an extensive <a href="NuttShell.html">NuttShell (NSH)</a> configuration. (1) The basic OS test configuration that verfies the correctness port of Nuttx, and (2) an extensive <a href="NuttShell.html">NuttShell (NSH)</a> configuration.
The NSH configuration includes: The NSH configuration includes:
(1) Full network support, (1) Full network support,
(2) Verified SPI driver, (2) Verified SPI driver,

View File

@ -65,7 +65,7 @@ ifeq ($(CONFIG_CDCACM),y)
CONFIGURED_APPS += examples/cdcacm CONFIGURED_APPS += examples/cdcacm
# Uncomment the following to enable the examples/usbterm built-in # Uncomment the following to enable the examples/usbterm built-in
# CONFIGURED_APPS += examples/usbterm # CONFIGURED_APPS += examples/usbterm
#else else
# Prolifics PL2303 emulation configurations # Prolifics PL2303 emulation configurations

View File

@ -1,8 +1,8 @@
/**************************************************************************** /****************************************************************************
* graphics/nxglib/fb/nxglib_filltrapezoid.c * graphics/nxglib/fb/nxglib_filltrapezoid.c
* *
* Copyright (C) 2008-2011 Gregory Nutt. All rights reserved. * Copyright (C) 2008-2012 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <spudmonkey@racsa.co.cr> * Author: Gregory Nutt <gnutt@nuttx.org>
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions * modification, are permitted provided that the following conditions
@ -126,8 +126,20 @@ void NXGL_FUNCNAME(nxgl_filltrapezoid,NXGLIB_SUFFIX)(
/* Calculate the slope of the left and right side of the trapezoid */ /* Calculate the slope of the left and right side of the trapezoid */
if (nrows > 1)
{
dx1dy = b16divi((trap->bot.x1 - x1), nrows - 1); dx1dy = b16divi((trap->bot.x1 - x1), nrows - 1);
dx2dy = b16divi((trap->bot.x2 - x2), nrows - 1); dx2dy = b16divi((trap->bot.x2 - x2), nrows - 1);
}
else
{
/* The trapezoid is a run! Use the average width. */
x1 = (x1 + trap->bot.x1) >> 1;
x2 = (x2 + trap->bot.x2) >> 1;
dx1dy = 0;
dx2dy = 0;
}
/* Perform vertical clipping */ /* Perform vertical clipping */

View File

@ -1,8 +1,8 @@
/**************************************************************************** /****************************************************************************
* graphics/nxglib/lcd/nxglib_filltrapezoid.c * graphics/nxglib/lcd/nxglib_filltrapezoid.c
* *
* Copyright (C) 2010-2011 Gregory Nutt. All rights reserved. * Copyright (C) 2010-2012 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <spudmonkey@racsa.co.cr> * Author: Gregory Nutt <gnutt@nuttx.org>
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions * modification, are permitted provided that the following conditions
@ -125,8 +125,22 @@ void NXGL_FUNCNAME(nxgl_filltrapezoid,NXGLIB_SUFFIX)
/* Calculate the slope of the left and right side of the trapezoid */ /* Calculate the slope of the left and right side of the trapezoid */
dy = boty - topy; dy = boty - topy;
if (dy > 0)
{
dx1dy = b16divi((botx1 - topx1), dy); dx1dy = b16divi((botx1 - topx1), dy);
dx2dy = b16divi((botx2 - topx2), dy); dx2dy = b16divi((botx2 - topx2), dy);
}
else
{
/* The trapezoid is a run! Use the average width. */
topx1 = (topx1 + botx1) >> 1;
topx2 = (topx2 + botx2) >> 1;
botx1 = topx1;
botx2 = topx2;
dx1dy = 0;
dx2dy = 0;
}
/* Perform vertical clipping */ /* Perform vertical clipping */