diff options
author | patacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3> | 2012-06-06 18:07:49 +0000 |
---|---|---|
committer | patacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3> | 2012-06-06 18:07:49 +0000 |
commit | 92fb15bdfedc185a9749f8cfae846ded9a729da5 (patch) | |
tree | 6a2af7b265afcc60bdab2d22ebc23649e424056e /nuttx/graphics/nxglib/lcd | |
parent | 1bc2fa2af9ccdc3217d54bd4c3219797217dd946 (diff) | |
download | px4-nuttx-92fb15bdfedc185a9749f8cfae846ded9a729da5.tar.gz px4-nuttx-92fb15bdfedc185a9749f8cfae846ded9a729da5.tar.bz2 px4-nuttx-92fb15bdfedc185a9749f8cfae846ded9a729da5.zip |
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
Diffstat (limited to 'nuttx/graphics/nxglib/lcd')
-rw-r--r-- | nuttx/graphics/nxglib/lcd/nxglib_filltrapezoid.c | 24 |
1 files changed, 19 insertions, 5 deletions
diff --git a/nuttx/graphics/nxglib/lcd/nxglib_filltrapezoid.c b/nuttx/graphics/nxglib/lcd/nxglib_filltrapezoid.c index 0653da413..3ba44b34a 100644 --- a/nuttx/graphics/nxglib/lcd/nxglib_filltrapezoid.c +++ b/nuttx/graphics/nxglib/lcd/nxglib_filltrapezoid.c @@ -1,8 +1,8 @@ /**************************************************************************** * graphics/nxglib/lcd/nxglib_filltrapezoid.c * - * Copyright (C) 2010-2011 Gregory Nutt. All rights reserved. - * Author: Gregory Nutt <spudmonkey@racsa.co.cr> + * Copyright (C) 2010-2012 Gregory Nutt. All rights reserved. + * Author: Gregory Nutt <gnutt@nuttx.org> * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -124,9 +124,23 @@ void NXGL_FUNCNAME(nxgl_filltrapezoid,NXGLIB_SUFFIX) /* Calculate the slope of the left and right side of the trapezoid */ - dy = boty - topy; - dx1dy = b16divi((botx1 - topx1), dy); - dx2dy = b16divi((botx2 - topx2), dy); + dy = boty - topy; + if (dy > 0) + { + dx1dy = b16divi((botx1 - topx1), 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 */ |