diff options
author | patacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3> | 2008-12-01 18:51:48 +0000 |
---|---|---|
committer | patacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3> | 2008-12-01 18:51:48 +0000 |
commit | bcdec2b7f93ef0e4ad736ca4181e5d0762540ddc (patch) | |
tree | 69d20c1d60d4ae8fb94b2009f080931fe7a78a83 | |
parent | ddbd1c4ca59bc9adb8807abc4b1b78b2767dfbdb (diff) | |
download | px4-nuttx-bcdec2b7f93ef0e4ad736ca4181e5d0762540ddc.tar.gz px4-nuttx-bcdec2b7f93ef0e4ad736ca4181e5d0762540ddc.tar.bz2 px4-nuttx-bcdec2b7f93ef0e4ad736ca4181e5d0762540ddc.zip |
Add rectinside(), vectsubtract(), visible()
git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@1381 42af7a65-404d-4744-a932-0658087f49c3
-rw-r--r-- | nuttx/graphics/nxbe/Make.defs | 2 | ||||
-rw-r--r-- | nuttx/graphics/nxbe/nxbe.h | 12 | ||||
-rw-r--r-- | nuttx/graphics/nxbe/nxbe_visible.c | 134 | ||||
-rw-r--r-- | nuttx/graphics/nxglib/nxglib_rectinside.c | 2 | ||||
-rw-r--r-- | nuttx/graphics/nxglib/nxglib_vectsubtract.c | 8 |
5 files changed, 152 insertions, 6 deletions
diff --git a/nuttx/graphics/nxbe/Make.defs b/nuttx/graphics/nxbe/Make.defs index 647b074c4..98aaf2097 100644 --- a/nuttx/graphics/nxbe/Make.defs +++ b/nuttx/graphics/nxbe/Make.defs @@ -38,4 +38,4 @@ NXBE_CSRCS = nxbe_fbconfigure.c nxbe_colormap.c nxbe_clipper.c \ nxbe_closewindow.c \ nxbe_setposition.c nxbe_setsize.c nxbe_raise.c nxbe_lower.c \ nxbe_fill.c nxbe_filltrapezoid.c nxbe_move.c nxbe_bitmap.c \ - nxbe_redraw.c nxbe_redrawbelow.c + nxbe_redraw.c nxbe_redrawbelow.c nxbe_visible.c diff --git a/nuttx/graphics/nxbe/nxbe.h b/nuttx/graphics/nxbe/nxbe.h index b07da6793..1ba2aca61 100644 --- a/nuttx/graphics/nxbe/nxbe.h +++ b/nuttx/graphics/nxbe/nxbe.h @@ -400,6 +400,18 @@ EXTERN void nxbe_redrawbelow(FAR struct nxbe_state_s *be, FAR const struct nxgl_rect_s *rect); /**************************************************************************** + * Name: nxbe_visible + * + * Descripton: + * Return true if the point, pt, in window wnd is visible. pt is in + * absolute screen coordinates + * + ****************************************************************************/ + +EXTERN boolean nxbe_visible(FAR struct nxbe_window_s *wnd, + FAR const struct nxgl_point_s *pos); + +/**************************************************************************** * Name: nxbe_clipper * * Descripton: diff --git a/nuttx/graphics/nxbe/nxbe_visible.c b/nuttx/graphics/nxbe/nxbe_visible.c new file mode 100644 index 000000000..9132ebf1a --- /dev/null +++ b/nuttx/graphics/nxbe/nxbe_visible.c @@ -0,0 +1,134 @@ +/**************************************************************************** + * graphics/nxbe/nxbe_redraw.c + * + * Copyright (C) 2008 Gregory Nutt. All rights reserved. + * Author: Gregory Nutt <spudmonkey@racsa.co.cr> + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * 3. Neither the name NuttX nor the names of its contributors may be + * used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS + * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED + * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + ****************************************************************************/ + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include <nuttx/config.h> + +#include <sys/types.h> +#include <errno.h> +#include <debug.h> + +#include <nuttx/nxglib.h> + +#include "nxbe.h" +#include "nxfe.h" + +/**************************************************************************** + * Pre-Processor Definitions + ****************************************************************************/ + +/**************************************************************************** + * Private Types + ****************************************************************************/ + +struct nxbe_visible_s +{ + struct nxbe_clipops_s cops; + boolean visible; +}; + +/**************************************************************************** + * Private Data + ****************************************************************************/ + +/**************************************************************************** + * Public Data + ****************************************************************************/ + +/**************************************************************************** + * Private Functions + ****************************************************************************/ + +/**************************************************************************** + * Name: nxbe_clipvisible + ****************************************************************************/ + +static void nxbe_clipvisible(FAR struct nxbe_clipops_s *cops, + FAR struct nxbe_plane_s *plane, + FAR const struct nxgl_rect_s *rect) +{ + FAR struct nxbe_visible_s *info = (FAR struct nxbe_visible_s *)cops; + info->visible = TRUE; +} + +/**************************************************************************** + * Public Functions + ****************************************************************************/ + +/**************************************************************************** + * Name: nxbe_visible + * + * Descripton: + * Return true if the point, pt, in window wnd is visible. pt is in + * absolute screen coordinates + * + ****************************************************************************/ + +boolean nxbe_visible(FAR struct nxbe_window_s *wnd, + FAR const struct nxgl_point_s *pos) +{ + struct nxbe_visible_s info; + + /* Check if the absolute position lies within the window */ + + if (!nxgl_rectinside(&wnd->bounds, pos)) + { + return FALSE; + } + + /* If this is the top window, then the psition is visible */ + + if (!wnd->above) + { + return TRUE; + } + + /* The position within the window range, but the window is not at + * the top. We will have to work harder to determine if the point + * visible + */ + + info.cops.visible = nxbe_clipvisible; + info.cops.obscured = nxbe_clipnull; + info.visible = FALSE; + + nxbe_clipper(wnd->above, &wnd->bounds, NX_CLIPORDER_DEFAULT, + &info.cops, &wnd->be->plane[0]); + + return info.visible; +} diff --git a/nuttx/graphics/nxglib/nxglib_rectinside.c b/nuttx/graphics/nxglib/nxglib_rectinside.c index 5d631d533..aa09eb2d7 100644 --- a/nuttx/graphics/nxglib/nxglib_rectinside.c +++ b/nuttx/graphics/nxglib/nxglib_rectinside.c @@ -79,5 +79,5 @@ boolean nxgl_rectinside(FAR const struct nxgl_rect_s *rect, FAR const struct nxgl_point_s *pt) { return (pt->x >= rect->pt1.x && pt->x <= rect->pt2.x && - pt->x >= rect->pt1.y && pt->y <= rect->pt2.y); + pt->y >= rect->pt1.y && pt->y <= rect->pt2.y); } diff --git a/nuttx/graphics/nxglib/nxglib_vectsubtract.c b/nuttx/graphics/nxglib/nxglib_vectsubtract.c index 03b7ddc41..22ebcaa61 100644 --- a/nuttx/graphics/nxglib/nxglib_vectsubtract.c +++ b/nuttx/graphics/nxglib/nxglib_vectsubtract.c @@ -68,16 +68,16 @@ ****************************************************************************/ /**************************************************************************** - * Name: nxgl_vectorsubtract + * Name: nxgl_vectsubtract * * Description: * Add subtract vector v2 from vector v1 and return the result in vector dest * ****************************************************************************/ -void nxgl_vectorsubtract(FAR struct nxgl_point_s *dest, - FAR const struct nxgl_point_s *v1, - FAR const struct nxgl_point_s *v2) +void nxgl_vectsubtract(FAR struct nxgl_point_s *dest, + FAR const struct nxgl_point_s *v1, + FAR const struct nxgl_point_s *v2) { dest->x = v1->x - v2->x; dest->y = v1->y - v2->y; |