aboutsummaryrefslogtreecommitdiff
path: root/nuttx/graphics/nxbe
diff options
context:
space:
mode:
authorpatacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3>2012-09-17 18:18:44 +0000
committerpatacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3>2012-09-17 18:18:44 +0000
commit57623d42ebb04f0a0b9e6eb7c0847a3ece2aa0ff (patch)
tree25d07d14e920d31c0b1947c9ca586f2a01fc32d8 /nuttx/graphics/nxbe
downloadpx4-firmware-57623d42ebb04f0a0b9e6eb7c0847a3ece2aa0ff.tar.gz
px4-firmware-57623d42ebb04f0a0b9e6eb7c0847a3ece2aa0ff.tar.bz2
px4-firmware-57623d42ebb04f0a0b9e6eb7c0847a3ece2aa0ff.zip
Resync new repository with old repo r5166
git-svn-id: http://svn.code.sf.net/p/nuttx/code/trunk@5153 42af7a65-404d-4744-a932-0658087f49c3
Diffstat (limited to 'nuttx/graphics/nxbe')
-rw-r--r--nuttx/graphics/nxbe/Make.defs41
-rw-r--r--nuttx/graphics/nxbe/nxbe.h533
-rw-r--r--nuttx/graphics/nxbe/nxbe_bitmap.c192
-rw-r--r--nuttx/graphics/nxbe/nxbe_clipper.c278
-rw-r--r--nuttx/graphics/nxbe/nxbe_closewindow.c137
-rw-r--r--nuttx/graphics/nxbe/nxbe_colormap.c155
-rw-r--r--nuttx/graphics/nxbe/nxbe_configure.c219
-rw-r--r--nuttx/graphics/nxbe/nxbe_fill.c157
-rw-r--r--nuttx/graphics/nxbe/nxbe_filltrapezoid.c173
-rw-r--r--nuttx/graphics/nxbe/nxbe_getrectangle.c138
-rw-r--r--nuttx/graphics/nxbe/nxbe_lower.c125
-rw-r--r--nuttx/graphics/nxbe/nxbe_move.c284
-rw-r--r--nuttx/graphics/nxbe/nxbe_raise.c116
-rw-r--r--nuttx/graphics/nxbe/nxbe_redraw.c139
-rw-r--r--nuttx/graphics/nxbe/nxbe_redrawbelow.c91
-rw-r--r--nuttx/graphics/nxbe/nxbe_setpixel.c158
-rw-r--r--nuttx/graphics/nxbe/nxbe_setposition.c119
-rw-r--r--nuttx/graphics/nxbe/nxbe_setsize.c121
-rw-r--r--nuttx/graphics/nxbe/nxbe_visible.c134
19 files changed, 3310 insertions, 0 deletions
diff --git a/nuttx/graphics/nxbe/Make.defs b/nuttx/graphics/nxbe/Make.defs
new file mode 100644
index 000000000..53fdf9664
--- /dev/null
+++ b/nuttx/graphics/nxbe/Make.defs
@@ -0,0 +1,41 @@
+############################################################################
+# graphics/nxbe/Make.defs
+#
+# Copyright (C) 2008, 2011 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
+# 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.
+#
+############################################################################
+
+NXBE_ASRCS =
+NXBE_CSRCS = nxbe_bitmap.c nxbe_configure.c nxbe_colormap.c nxbe_clipper.c \
+ nxbe_closewindow.c nxbe_fill.c nxbe_filltrapezoid.c \
+ nxbe_getrectangle.c nxbe_lower.c nxbe_move.c nxbe_raise.c \
+ nxbe_redraw.c nxbe_redrawbelow.c nxbe_setpixel.c nxbe_setposition.c \
+ nxbe_setsize.c nxbe_visible.c
diff --git a/nuttx/graphics/nxbe/nxbe.h b/nuttx/graphics/nxbe/nxbe.h
new file mode 100644
index 000000000..aff42d6b3
--- /dev/null
+++ b/nuttx/graphics/nxbe/nxbe.h
@@ -0,0 +1,533 @@
+/****************************************************************************
+ * graphics/nxbe/nxbe.h
+ *
+ * Copyright (C) 2008-2011 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
+ * 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.
+ *
+ ****************************************************************************/
+
+#ifndef __GRAPHICS_NXBE_NXBE_H
+#define __GRAPHICS_NXBE_NXBE_H
+
+/****************************************************************************
+ * Included Files
+ ****************************************************************************/
+
+#include <nuttx/config.h>
+
+#include <stdint.h>
+#include <stdbool.h>
+
+#include <nuttx/nx/nx.h>
+#include <nuttx/nx/nxglib.h>
+
+/****************************************************************************
+ * Pre-Processor Definitions
+ ****************************************************************************/
+
+/* Configuration ************************************************************/
+
+#ifndef CONFIG_NX_NPLANES
+# define CONFIG_NX_NPLANES 1 /* Max number of color planes supported */
+#endif
+
+#ifndef CONFIG_NX_NCOLORS
+# define CONFIG_NX_NCOLORS 256
+#endif
+
+/* NXBE Definitions *********************************************************/
+/* These are the values for the clipping order provided to nx_clipper */
+
+#define NX_CLIPORDER_TLRB (0) /* Top-left-right-bottom */
+#define NX_CLIPORDER_TRLB (1) /* Top-right-left-bottom */
+#define NX_CLIPORDER_BLRT (2) /* Bottom-left-right-top */
+#define NX_CLIPORDER_BRLT (3) /* Bottom-right-left-top */
+#define NX_CLIPORDER_DEFAULT NX_CLIPORDER_TLRB
+
+/* Window flags and helper macros */
+
+#define NXBE_WINDOW_BLOCKED (1 << 0) /* The window is blocked and will not
+ * receive further input. */
+
+#define NXBE_ISBLOCKED(wnd) (((wnd)->flags & NXBE_WINDOW_BLOCKED) != 0)
+#define NXBE_SETBLOCKED(wnd) do { (wnd)->flags |= NXBE_WINDOW_BLOCKED; } while (0)
+
+/****************************************************************************
+ * Public Types
+ ****************************************************************************/
+
+/* Rasterization ************************************************************/
+
+/* A tiny vtable of raster operation function pointers. The types of the
+ * function points must match the rasterizer types exported by nxglib
+ */
+
+struct nxbe_plane_s
+{
+ /* Raster operation callbacks for this bits-per-pixel value */
+
+ void (*setpixel)(FAR NX_PLANEINFOTYPE *pinfo,
+ FAR const struct nxgl_point_s *pos,
+ nxgl_mxpixel_t color);
+ void (*fillrectangle)(FAR NX_PLANEINFOTYPE *pinfo,
+ FAR const struct nxgl_rect_s *rect,
+ nxgl_mxpixel_t color);
+ void (*getrectangle)(FAR NX_PLANEINFOTYPE *pinfo,
+ FAR const struct nxgl_rect_s *rect,
+ FAR void *dest, unsigned int deststride);
+ void (*filltrapezoid)(FAR NX_PLANEINFOTYPE *pinfo,
+ FAR const struct nxgl_trapezoid_s *trap,
+ FAR const struct nxgl_rect_s *bounds,
+ nxgl_mxpixel_t color);
+ void (*moverectangle)(FAR NX_PLANEINFOTYPE *pinfo,
+ FAR const struct nxgl_rect_s *rect,
+ FAR struct nxgl_point_s *offset);
+ void (*copyrectangle)(FAR NX_PLANEINFOTYPE *pinfo,
+ FAR const struct nxgl_rect_s *dest,
+ FAR const void *src,
+ FAR const struct nxgl_point_s *origin,
+ unsigned int srcstride);
+
+ /* Framebuffer plane info describing destination video plane */
+
+ NX_PLANEINFOTYPE pinfo;
+};
+
+/* Clipping *****************************************************************/
+
+/* Clipping callback functions called nxbe_clipper for each visible and
+ * obscured region of a rectangle within a window.
+ */
+
+struct nxbe_clipops_s
+{
+ void (*visible)(FAR struct nxbe_clipops_s *cops,
+ FAR struct nxbe_plane_s *plane,
+ FAR const struct nxgl_rect_s *rect);
+
+ void (*obscured)(FAR struct nxbe_clipops_s *cops,
+ FAR struct nxbe_plane_s *plane,
+ FAR const struct nxgl_rect_s *rect);
+};
+
+/* Windows ******************************************************************/
+
+/* This structure represents one window. */
+
+struct nxbe_state_s;
+struct nxfe_conn_s;
+struct nxbe_window_s
+{
+ /* State information */
+
+ FAR struct nxbe_state_s *be; /* The back-end state structure */
+#ifdef CONFIG_NX_MULTIUSER
+ FAR struct nxfe_conn_s *conn; /* Connection to the window client */
+#endif
+ FAR const struct nx_callback_s *cb; /* Event handling callbacks */
+
+ /* The following links provide the window's vertical position using a
+ * singly linked list.
+ */
+
+ FAR struct nxbe_window_s *above; /* The window "above" this window */
+ FAR struct nxbe_window_s *below; /* The window "below this one */
+
+ /* Window geometry. The window is described by a rectangle in the
+ * absolute screen coordinate system (0,0)->(xres,yres)
+ */
+
+ struct nxgl_rect_s bounds; /* The bounding rectangle of window */
+
+ /* Window flags (see the NXBE_* bit definitions above) */
+
+#ifdef CONFIG_NX_MULTIUSER /* Currently used only in multi-user mode */
+ uint8_t flags;
+#endif
+
+ /* Client state information this is provide in window callbacks */
+
+ FAR void *arg;
+};
+
+/* Back-end state ***********************************************************/
+
+/* This structure describes the overall back-end window state */
+
+struct nxbe_state_s
+{
+ /* The window list (with the background window always at the bottom) */
+
+ FAR struct nxbe_window_s *topwnd; /* The window at the top of the display */
+ struct nxbe_window_s bkgd; /* The background window is always at the bottom */
+
+ /* At present, only a solid colored background is supported for refills. The
+ * following provides the background color. It would be nice to support
+ * background bitmap images as well.
+ */
+
+ nxgl_mxpixel_t bgcolor[CONFIG_NX_NPLANES];
+
+ /* vinfo describes the video controller and plane[n].pinfo describes color
+ * plane 'n' supported by the video controller. Most common color models
+ * fit in one plane, but this array provides future support for hardware
+ * with planar YUV types with 3 or 4 color planes.
+ */
+
+ struct fb_videoinfo_s vinfo;
+
+ /* Rasterizing functions selected to match the BPP reported in pinfo[] */
+
+ struct nxbe_plane_s plane[CONFIG_NX_NPLANES];
+};
+
+/****************************************************************************
+ * Public Data
+ ****************************************************************************/
+
+#undef EXTERN
+#if defined(__cplusplus)
+#define EXTERN extern "C"
+extern "C" {
+#else
+#define EXTERN extern
+#endif
+
+/****************************************************************************
+ * Public Functions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Name: nxbe_colormap
+ *
+ * Description:
+ * Set the harware color map to the palette expected by NX
+ *
+ ****************************************************************************/
+
+#ifdef CONFIG_FB_CMAP
+EXTERN int nxbe_colormap(FAR NX_DRIVERTYPE *dev);
+#endif
+
+/****************************************************************************
+ * Name: nx_configure
+ *
+ * Description:
+ * Configure the back end state structure based on information from the
+ * framebuffer or LCD driver
+ *
+ ****************************************************************************/
+
+EXTERN int nxbe_configure(FAR NX_DRIVERTYPE *dev,
+ FAR struct nxbe_state_s *be);
+
+/****************************************************************************
+ * Name: nxbe_closewindow
+ *
+ * Description:
+ * Close an existing window
+ *
+ * Input Parameters:
+ * wnd - The window to be closed (and deallocated)
+ *
+ * Return:
+ * None
+ *
+ ****************************************************************************/
+
+EXTERN void nxbe_closewindow(struct nxbe_window_s *wnd);
+
+/****************************************************************************
+ * Name: nxbe_setposition
+ *
+ * Descripton:
+ * This function checks for intersections and redraws the display after
+ * a change in the position of a window.
+ *
+ ****************************************************************************/
+
+EXTERN void nxbe_setposition(FAR struct nxbe_window_s *wnd,
+ FAR const struct nxgl_point_s *pos);
+
+/****************************************************************************
+ * Name: nxbe_setsize
+ *
+ * Descripton:
+ * This function checks for intersections and redraws the display after
+ * a change in the size of a window.
+ *
+ ****************************************************************************/
+
+EXTERN void nxbe_setsize(FAR struct nxbe_window_s *wnd,
+ FAR const struct nxgl_size_s *size);
+
+/****************************************************************************
+ * Name: nxbe_raise
+ *
+ * Description:
+ * Bring the specified window to the top of the display.
+ *
+ ****************************************************************************/
+
+EXTERN void nxbe_raise(FAR struct nxbe_window_s *wnd);
+
+/****************************************************************************
+ * Name: nxbe_lower
+ *
+ * Description:
+ * Lower the specified window to the bottom of the display.
+ *
+ ****************************************************************************/
+
+EXTERN void nxbe_lower(FAR struct nxbe_window_s *wnd);
+
+/****************************************************************************
+ * Name: nxbe_setpixel
+ *
+ * Description:
+ * Set a single pixel in the window to the specified color. This is simply
+ * a degenerate case of nxbe_fill(), but may be optimized in some architectures.
+ *
+ * Input Parameters:
+ * wnd - The window structure reference
+ * pos - The pixel location to be set
+ * col - The color to use in the set
+ *
+ * Return:
+ * None
+ *
+ ****************************************************************************/
+
+EXTERN void nxbe_setpixel(FAR struct nxbe_window_s *wnd,
+ FAR const struct nxgl_point_s *pos,
+ nxgl_mxpixel_t color[CONFIG_NX_NPLANES]);
+
+/****************************************************************************
+ * Name: nxbe_fill
+ *
+ * Description:
+ * Fill the specified rectangle in the window with the specified color
+ *
+ * Input Parameters:
+ * wnd - The window structure reference
+ * rect - The location to be filled
+ * col - The color to use in the fill
+ *
+ * Return:
+ * None
+ *
+ ****************************************************************************/
+
+EXTERN void nxbe_fill(FAR struct nxbe_window_s *wnd,
+ FAR const struct nxgl_rect_s *rect,
+ nxgl_mxpixel_t color[CONFIG_NX_NPLANES]);
+
+/****************************************************************************
+ * Name: nxbe_filltrapezoid
+ *
+ * Description:
+ * Fill the specified rectangle in the window with the specified color
+ *
+ * Input Parameters:
+ * wnd - The window structure reference
+ * clip - Clipping region (may be null)
+ * rect - The location to be filled
+ * col - The color to use in the fill
+ *
+ * Return:
+ * None
+ *
+ ****************************************************************************/
+
+EXTERN void nxbe_filltrapezoid(FAR struct nxbe_window_s *wnd,
+ FAR const struct nxgl_rect_s *clip,
+ FAR const struct nxgl_trapezoid_s *trap,
+ nxgl_mxpixel_t color[CONFIG_NX_NPLANES]);
+
+/****************************************************************************
+ * Name: nxbe_getrectangle
+ *
+ * Description:
+ * Get the raw contents of graphic memory within a rectangular region. NOTE:
+ * Since raw graphic memory is returned, the returned memory content may be
+ * the memory of windows above this one and may not necessarily belong to
+ * this window unless you assure that this is the top window.
+ *
+ * Input Parameters:
+ * wnd - The window structure reference
+ * rect - The location to be copied
+ * plane - Specifies the color plane to get from.
+ * dest - The location to copy the memory region
+ * deststride - The width, in bytes, the the dest memory
+ *
+ * Return:
+ * None
+ *
+ ****************************************************************************/
+
+EXTERN void nxbe_getrectangle(FAR struct nxbe_window_s *wnd,
+ FAR const struct nxgl_rect_s *rect,
+ unsigned int plane,
+ FAR uint8_t *dest, unsigned int deststride);
+
+/****************************************************************************
+ * Name: nxbe_move
+ *
+ * Description:
+ * Move a rectangular region within the window
+ *
+ * Input Parameters:
+ * wnd - The window within which the move is to be done
+ * rect - Describes the rectangular region to move
+ * offset - The offset to move the region
+ *
+ * Return:
+ * None
+ *
+ ****************************************************************************/
+
+EXTERN void nxbe_move(FAR struct nxbe_window_s *wnd,
+ FAR const struct nxgl_rect_s *rect,
+ FAR const struct nxgl_point_s *offset);
+
+/****************************************************************************
+ * Name: nxbe_bitmap
+ *
+ * Description:
+ * Copy a rectangular region of a larger image into the rectangle in the
+ * specified window.
+ *
+ * Input Parameters:
+ * wnd - The window that will receive the bitmap image
+ * dest - Describes the rectangular on the display that will receive the
+ * the bit map.
+ * src - The start of the source image.
+ * origin - The origin of the upper, left-most corner of the full bitmap.
+ * Both dest and origin are in window coordinates, however, origin
+ * may lie outside of the display.
+ * stride - The width of the full source image in pixels.
+ *
+ * Return:
+ * OK on success; ERROR on failure with errno set appropriately
+ *
+ ****************************************************************************/
+
+EXTERN void nxbe_bitmap(FAR struct nxbe_window_s *wnd,
+ FAR const struct nxgl_rect_s *dest,
+ FAR const void *src[CONFIG_NX_NPLANES],
+ FAR const struct nxgl_point_s *origin,
+ unsigned int stride);
+
+/****************************************************************************
+ * Name: nxbe_redraw
+ *
+ * Descripton:
+ * Re-draw the visible portions of the rectangular region for the
+ * specified window
+ *
+ ****************************************************************************/
+
+EXTERN void nxbe_redraw(FAR struct nxbe_state_s *be,
+ FAR struct nxbe_window_s *wnd,
+ FAR const struct nxgl_rect_s *rect);
+
+/****************************************************************************
+ * Name: nxbe_redrawbelow
+ *
+ * Descripton:
+ * Re-draw the visible portions of the rectangular region for all windows
+ * below (and including) the specified window. This function is called
+ * whenever a window is closed, moved, lowered or re-sized in order to
+ * expose newly visible portions of lower windows.
+ *
+ ****************************************************************************/
+
+EXTERN void nxbe_redrawbelow(FAR struct nxbe_state_s *be,
+ FAR struct nxbe_window_s *wnd,
+ 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 bool nxbe_visible(FAR struct nxbe_window_s *wnd,
+ FAR const struct nxgl_point_s *pos);
+
+/****************************************************************************
+ * Name: nxbe_clipper
+ *
+ * Descripton:
+ * Perform flexible clipping operations. Callbacks are executed for
+ * each oscured and visible portions of the window.
+ *
+ * Input Parameters:
+ * wnd - The window to be clipped.
+ * rect - The region of concern within the window
+ * order - Specifies the order to process the parts of the non-intersecting
+ * sub-rectangles.
+ * cops - The callbacks to handle obscured and visible parts of the
+ * sub-rectangles.
+ * plane - The raster operations to be used by the callback functions.
+ * These may vary with different color formats.
+ *
+ * Returned Value:
+ * None
+ *
+ ****************************************************************************/
+
+EXTERN void nxbe_clipper(FAR struct nxbe_window_s *wnd,
+ FAR const struct nxgl_rect_s *dest, uint8_t order,
+ FAR struct nxbe_clipops_s *cops,
+ FAR struct nxbe_plane_s *plane);
+
+/****************************************************************************
+ * Name: nxbe_clipnull
+ *
+ * Descripton:
+ * The do-nothing clipping callback function
+ *
+ ****************************************************************************/
+
+EXTERN void nxbe_clipnull(FAR struct nxbe_clipops_s *cops,
+ FAR struct nxbe_plane_s *plane,
+ FAR const struct nxgl_rect_s *rect);
+
+#undef EXTERN
+#if defined(__cplusplus)
+}
+#endif
+
+#endif /* __GRAPHICS_NXBE_NXBE_H */
+
diff --git a/nuttx/graphics/nxbe/nxbe_bitmap.c b/nuttx/graphics/nxbe/nxbe_bitmap.c
new file mode 100644
index 000000000..991b91d82
--- /dev/null
+++ b/nuttx/graphics/nxbe/nxbe_bitmap.c
@@ -0,0 +1,192 @@
+/****************************************************************************
+ * graphics/nxbe/nxbe_bitmap.c
+ *
+ * Copyright (C) 2008-2009, 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
+ * 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 <errno.h>
+#include <debug.h>
+
+#include <nuttx/nx/nxglib.h>
+#include "nxbe.h"
+
+/****************************************************************************
+ * Pre-Processor Definitions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Private Types
+ ****************************************************************************/
+
+struct nx_bitmap_s
+{
+ struct nxbe_clipops_s cops;
+ FAR const void *src; /* The start of the source image. */
+ struct nxgl_point_s origin; /* Offset into the source image data */
+ unsigned int stride; /* The width of the full source image in pixels. */
+};
+
+/****************************************************************************
+ * Private Data
+ ****************************************************************************/
+
+/****************************************************************************
+ * Public Data
+ ****************************************************************************/
+
+/****************************************************************************
+ * Private Functions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Name: nxs_clipcopy
+ *
+ * Description:
+ * Called from nxbe_clipper() to performed the fill operation on visible portions
+ * of the rectangle.
+ *
+ ****************************************************************************/
+
+static void nxs_clipcopy(FAR struct nxbe_clipops_s *cops,
+ FAR struct nxbe_plane_s *plane,
+ FAR const struct nxgl_rect_s *rect)
+{
+ struct nx_bitmap_s *bminfo = (struct nx_bitmap_s *)cops;
+ plane->copyrectangle(&plane->pinfo, rect, bminfo->src,
+ &bminfo->origin, bminfo->stride);
+}
+
+/****************************************************************************
+ * Public Functions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Name: nxbe_bitmap
+ *
+ * Description:
+ * Copy a rectangular region of a larger image into the rectangle in the
+ * specified window.
+ *
+ * Input Parameters:
+ * wnd - The window that will receive the bitmap image
+ * dest - Describes the rectangular on the display that will receive the
+ * the bit map.
+ * src - The start of the source image.
+ * origin - The origin of the upper, left-most corner of the full bitmap.
+ * Both dest and origin are in window coordinates, however, origin
+ * may lie outside of the display.
+ * stride - The width of the full source image in pixels.
+ *
+ * Return:
+ * OK on success; ERROR on failure with errno set appropriately
+ *
+ ****************************************************************************/
+
+void nxbe_bitmap(FAR struct nxbe_window_s *wnd, FAR const struct nxgl_rect_s *dest,
+ FAR const void *src[CONFIG_NX_NPLANES],
+ FAR const struct nxgl_point_s *origin, unsigned int stride)
+{
+ struct nx_bitmap_s info;
+ struct nxgl_rect_s bounds;
+ struct nxgl_point_s offset;
+ struct nxgl_rect_s remaining;
+ unsigned int deststride;
+ int i;
+
+#ifdef CONFIG_DEBUG
+ if (!wnd || !dest || !src || !origin)
+ {
+ return;
+ }
+#endif
+
+ /* Verify that the destination rectangle begins "below" and to the "right"
+ * of the origin
+ */
+
+ if (dest->pt1.x < origin->x || dest->pt1.y < origin->y)
+ {
+ gdbg("Bad dest start position\n");
+ return;
+ }
+
+ /* Verify that the width of the destination rectangle does not exceed the
+ * width of the source bitmap data (taking into account the bitmap origin)
+ */
+
+ deststride = (((dest->pt2.x - origin->x + 1) * wnd->be->plane[0].pinfo.bpp + 7) >> 3);
+ if (deststride > stride)
+ {
+ gdbg("Bad dest width\n");
+ return;
+ }
+
+ /* Offset the rectangle and image origin by the window origin */
+
+ nxgl_rectoffset(&bounds, dest, wnd->bounds.pt1.x, wnd->bounds.pt1.y);
+ nxgl_vectoradd(&offset, origin, &wnd->bounds.pt1);
+
+ /* Clip to the limits of the window and of the background screen */
+
+ nxgl_rectintersect(&remaining, &bounds, &wnd->bounds);
+ nxgl_rectintersect(&remaining, &remaining, &wnd->be->bkgd.bounds);
+ if (nxgl_nullrect(&remaining))
+ {
+ return;
+ }
+
+ /* Then perform the clipped fill */
+
+#if CONFIG_NX_NPLANES > 1
+ for (i = 0; i < wnd->be->vinfo.nplanes; i++)
+#else
+ i = 0;
+#endif
+ {
+ info.cops.visible = nxs_clipcopy;
+ info.cops.obscured = nxbe_clipnull;
+ info.src = src[i];
+ info.origin.x = offset.x;
+ info.origin.y = offset.y;
+ info.stride = stride;
+
+ nxbe_clipper(wnd->above, &remaining, NX_CLIPORDER_DEFAULT,
+ &info.cops, &wnd->be->plane[i]);
+ }
+}
+
diff --git a/nuttx/graphics/nxbe/nxbe_clipper.c b/nuttx/graphics/nxbe/nxbe_clipper.c
new file mode 100644
index 000000000..cdbd421c0
--- /dev/null
+++ b/nuttx/graphics/nxbe/nxbe_clipper.c
@@ -0,0 +1,278 @@
+/****************************************************************************
+ * graphics/nxbe/nxbe_clipper.c
+ *
+ * Copyright (C) 2008-2009 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
+ * 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 <stdint.h>
+#include <stdbool.h>
+#include <stdlib.h>
+#include <debug.h>
+
+#include <nuttx/nx/nxglib.h>
+#include "nxbe.h"
+
+/****************************************************************************
+ * Pre-Processor Definitions
+ ****************************************************************************/
+
+#define NX_INITIAL_STACKSIZE (32)
+
+/****************************************************************************
+ * Private Types
+ ****************************************************************************/
+
+/* This structure is a container that retains an associated between a
+ * window instance and a rectangle.
+ */
+
+struct nxbe_cliprect_s
+{
+ FAR struct nxbe_window_s *wnd;
+ struct nxgl_rect_s rect;
+};
+
+/* This is the stack of pending clip operations */
+
+struct nxbe_clipstack_s
+{
+ uint16_t npushed; /* Number of deferred rectangles in stack */
+ uint16_t mxrects; /* The capacity of the stack */
+ struct nxbe_cliprect_s *stack; /* The stack of deferred rectangles */
+};
+
+/****************************************************************************
+ * Private Data
+ ****************************************************************************/
+
+static const uint8_t g_nxcliporder[4][4] =
+{
+ { NX_TOP_NDX, NX_LEFT_NDX, NX_RIGHT_NDX, NX_BOTTOM_NDX }, /* index = NX_CLIPORDER_TLRB */
+ { NX_TOP_NDX, NX_RIGHT_NDX, NX_LEFT_NDX, NX_BOTTOM_NDX }, /* NX_CLIPORDER_TRLB */
+ { NX_BOTTOM_NDX, NX_LEFT_NDX, NX_RIGHT_NDX, NX_TOP_NDX }, /* NX_CLIPORDER_BLRT */
+ { NX_BOTTOM_NDX, NX_RIGHT_NDX, NX_LEFT_NDX, NX_TOP_NDX } /* NX_CLIPORDER_BRLT */
+};
+
+/****************************************************************************
+ * Public Data
+ ****************************************************************************/
+
+/****************************************************************************
+ * Private Functions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Name: nxbe_pushrectangle
+ ****************************************************************************/
+
+static inline void nxbe_pushrectangle(FAR struct nxbe_clipstack_s *stack,
+ FAR struct nxbe_window_s *wnd,
+ FAR const struct nxgl_rect_s *rect)
+{
+ /* Check if there is room on the stack to hold another rectangle */
+
+ if ((stack->npushed + 1) > stack->mxrects)
+ {
+ /* No then we will need to reallocate the stack to hole more */
+
+ int mxrects = stack->mxrects ? 2 * stack->mxrects : NX_INITIAL_STACKSIZE;
+ struct nxbe_cliprect_s *newstack;
+
+ newstack = realloc(stack->stack, sizeof(struct nxbe_cliprect_s) * mxrects);
+ if (!newstack)
+ {
+ gdbg("Failed to reallocate stack\n");
+ return;
+ }
+
+ stack->stack = newstack;
+ stack->mxrects = mxrects;
+ }
+
+ /* Then push the new rectangle onto the stack */
+
+ stack->stack[stack->npushed].wnd = wnd;
+ nxgl_rectcopy(&stack->stack[stack->npushed].rect, rect);
+ stack->npushed++;
+}
+
+/****************************************************************************
+ * Name: nxbe_poprectangle
+ ****************************************************************************/
+
+static inline bool nxbe_poprectangle(struct nxbe_clipstack_s *stack,
+ FAR struct nxbe_window_s **wnd,
+ struct nxgl_rect_s *rect)
+{
+ if(stack->npushed > 0)
+ {
+ stack->npushed--;
+ *wnd = stack->stack[stack->npushed].wnd;
+ nxgl_rectcopy(rect, &stack->stack[stack->npushed].rect);
+ return true;
+ }
+ return false;
+}
+
+/****************************************************************************
+ * Public Functions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Name: nxbe_clipper
+ *
+ * Descripton:
+ * Perform flexible clipping operations. Callbacks are executed for
+ * each oscured and visible portions of the window.
+ *
+ * Input Parameters:
+ * wnd - The window to be clipped.
+ * rect - The region of concern within the window
+ * order - Specifies the order to process the parts of the non-intersecting
+ * sub-rectangles.
+ * cops - The callbacks to handle obscured and visible parts of the
+ * sub-rectangles.
+ * plane - The raster operations to be used by the callback functions.
+ * These may vary with different color formats.
+ *
+ * Returned Value:
+ * None
+ *
+ ****************************************************************************/
+
+void nxbe_clipper(FAR struct nxbe_window_s *wnd,
+ FAR const struct nxgl_rect_s *dest, uint8_t order,
+ FAR struct nxbe_clipops_s *cops,
+ FAR struct nxbe_plane_s *plane)
+{
+ struct nxbe_clipstack_s stack;
+ FAR struct nxbe_window_s *currw;
+ struct nxgl_rect_s rect;
+ struct nxgl_rect_s obscuredrect;
+ struct nxgl_rect_s currbounds;
+ struct nxgl_rect_s nonoverlapped[4];
+ int i;
+
+ /* Initialize the stack where we will keep deferred rectangle operations */
+
+ stack.npushed = 0;
+ stack.mxrects = 0;
+ stack.stack = NULL;
+
+ /* Loop until there are no further pending operations */
+
+ nxgl_rectcopy(&rect, dest); /* Start with the whole dest rectangle */
+ do
+ {
+ /* Loop for every window from the current window and above. Only windows
+ * above the current window can obscure the current window
+ */
+
+ for (currw = wnd; currw; currw = currw->above)
+ {
+ /* Does the current window overlap the dest rectangle? */
+
+ currbounds = currw->bounds;
+ if (nxgl_rectoverlap(&rect, &currbounds))
+ {
+ /* Yes.. then it obscures all or part of the dest rectangle.
+ * Divide the potentially visible, non-overlapping regions into 4
+ * smaller rectangles and push them onto the stack for processing
+ * on the next time through the outer loop.
+ */
+
+ nxgl_nonintersecting(nonoverlapped, &rect, &currbounds);
+ for (i = 3; i >= 0; i--)
+ {
+ /* Push the rectangles in the order specific by the input
+ * argument of that name.
+ */
+
+ struct nxgl_rect_s *candidate = &nonoverlapped[g_nxcliporder[order][i]];
+ if (!nxgl_nullrect(candidate))
+ {
+ nxbe_pushrectangle(&stack, currw->above, candidate);
+ }
+ }
+
+ /* Now performed any required processing on the obscurred,
+ * overlapped region.
+ */
+
+ nxgl_rectintersect(&obscuredrect, &rect, &currbounds);
+ cops->obscured(cops, plane, &obscuredrect);
+
+ /* Break out of the loop to process the pushed rectangles */
+
+ break;
+ }
+ }
+
+ /* If there are no other windows overlapping this rectangle, then this
+ * rectangular region must be visible.
+ */
+
+ if (!currw && !nxgl_nullrect(&rect))
+ {
+ cops->visible(cops, plane, &rect);
+ }
+ }
+ while (nxbe_poprectangle(&stack, &wnd, &rect));
+
+ /* Done! If any stack was allocated, then free it before exit-ting */
+
+ if (stack.stack)
+ {
+ free(stack.stack);
+ }
+}
+
+/****************************************************************************
+ * Name: nxbe_clipnull
+ *
+ * Descripton:
+ * The do-nothing clipping callback function
+ *
+ ****************************************************************************/
+
+void nxbe_clipnull(FAR struct nxbe_clipops_s *cops,
+ FAR struct nxbe_plane_s *plane,
+ FAR const struct nxgl_rect_s *rect)
+{
+}
+
diff --git a/nuttx/graphics/nxbe/nxbe_closewindow.c b/nuttx/graphics/nxbe/nxbe_closewindow.c
new file mode 100644
index 000000000..e632ebf01
--- /dev/null
+++ b/nuttx/graphics/nxbe/nxbe_closewindow.c
@@ -0,0 +1,137 @@
+/****************************************************************************
+ * graphics/nxbe/nxbe_closewindow.c
+ *
+ * Copyright (C) 2008-2009, 2011 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
+ * 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 <stdlib.h>
+#include <assert.h>
+#include <debug.h>
+
+#include <nuttx/nx/nxglib.h>
+#include "nxbe.h"
+
+/****************************************************************************
+ * Pre-Processor Definitions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Private Types
+ ****************************************************************************/
+
+/****************************************************************************
+ * Private Data
+ ****************************************************************************/
+
+/****************************************************************************
+ * Public Data
+ ****************************************************************************/
+
+/****************************************************************************
+ * Private Functions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Public Functions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Name: nxbe_closewindow
+ *
+ * Description:
+ * Close an existing window
+ *
+ * Input Parameters:
+ * wnd - The window to be closed (and deallocated)
+ *
+ * Return:
+ * None
+ *
+ ****************************************************************************/
+
+void nxbe_closewindow(struct nxbe_window_s *wnd)
+{
+ FAR struct nxbe_state_s *be;
+
+#ifdef CONFIG_DEBUG
+ if (!wnd)
+ {
+ return;
+ }
+#endif
+ be = wnd->be;
+
+ /* The background window should never be closed */
+
+ DEBUGASSERT(wnd != &be->bkgd);
+
+ /* Is there a window above the one being closed? */
+
+ if (wnd->above)
+ {
+ /* Yes, now the window below that one is the window below
+ * the one being closed.
+ */
+
+ wnd->above->below = wnd->below;
+ }
+ else
+ {
+ /* No, then the top window is the one below this (which
+ * can never be NULL because the background window is
+ * always at the true bottom of the list
+ */
+
+ be->topwnd = wnd->below;
+ }
+
+ /* There is always a window below the one being closed (because
+ * the background is never closed. Now, the window above that
+ * is the window above the one that is being closed.
+ */
+
+ wnd->below->above = wnd->above;
+
+ /* Redraw the windows that were below us (and may now be exposed) */
+
+ nxbe_redrawbelow(be, wnd->below, &wnd->bounds);
+
+ /* Then discard the window structure */
+
+ free(wnd);
+}
diff --git a/nuttx/graphics/nxbe/nxbe_colormap.c b/nuttx/graphics/nxbe/nxbe_colormap.c
new file mode 100644
index 000000000..e33877382
--- /dev/null
+++ b/nuttx/graphics/nxbe/nxbe_colormap.c
@@ -0,0 +1,155 @@
+/****************************************************************************
+ * graphics/nxbe/nxbe_colormap.c
+ *
+ * Copyright (C) 2008-2009,2011 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
+ * 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 <stdint.h>
+#include <stdlib.h>
+#include <string.h>
+#include <errno.h>
+#include <debug.h>
+
+#include "nxbe.h"
+
+/****************************************************************************
+ * Pre-Processor Definitions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Private Types
+ ****************************************************************************/
+
+/****************************************************************************
+ * Private Data
+ ****************************************************************************/
+
+/****************************************************************************
+ * Public Data
+ ****************************************************************************/
+
+/****************************************************************************
+ * Private Functions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Public Functions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Name: nxbe_colormap
+ *
+ * Description:
+ * Set the harware color map to the palette expected by NX
+ *
+ ****************************************************************************/
+
+#if CONFIG_FB_CMAP
+int nxbe_colormap(FAR NX_DRIVERTYPE *dev)
+{
+ struct fb_cmap_s cmap;
+ uint8_t *alloc;
+ uint8_t *red;
+ uint8_t *green;
+ uint8_t *blue;
+ uint8_t rval;
+ uint8_t gval;
+ int size;
+ int ndx;
+ int ret;
+ int i, j, k;
+
+ /* Allocate the color map tables in one allocation:
+ *
+ * size = 3 colors x CONFIG_NX_COLORS each x 8-bits per color
+ */
+
+ size = 3 * CONFIG_NX_NCOLORS * sizeof(uint8_t);
+ alloc = (uint8_t*)malloc(size);
+ if (alloc == NULL)
+ {
+ return -ENOMEM;
+ }
+ memset(alloc, 0xff, size);
+
+ /* Then get pointers to each color table */
+
+ red = alloc;
+ green = &alloc[CONFIG_NX_NCOLORS];
+ blue = &alloc[2*CONFIG_NX_NCOLORS];
+
+ /* Initialize the color map tables. 6*6*6 = 216, the rest
+ * are (0xff, 0xfff 0xff)
+ */
+
+ ndx = 0;
+ for (i = 0; i < 6; i++)
+ {
+ rval = (i * (CONFIG_NX_NCOLORS-1) / 5) << 8;
+ for (j = 0; j < 6; j++)
+ {
+ gval = (j * (CONFIG_NX_NCOLORS-1) / 5) << 8;
+ for (k = 0; k < 6; k++)
+ {
+ red[ndx] = rval;
+ green[ndx] = gval;
+ blue[ndx] = k * (CONFIG_NX_NCOLORS-1) / 5;
+ ndx++;
+ }
+ }
+ }
+
+ /* Now configure the cmap structure */
+
+ cmap.first = 0;
+ cmap.len = CONFIG_NX_NCOLORS;
+ cmap.red = red;
+ cmap.green = green;
+ cmap.blue = blue;
+#ifdef CONFIG_FB_TRANSPARENCY
+ cmap.transp = NULL;
+#endif
+
+ /* Then set the color map */
+
+ ret = dev->putcmap(dev, &cmap);
+
+ free(alloc);
+ return ret;
+}
+#endif
diff --git a/nuttx/graphics/nxbe/nxbe_configure.c b/nuttx/graphics/nxbe/nxbe_configure.c
new file mode 100644
index 000000000..80c71db3a
--- /dev/null
+++ b/nuttx/graphics/nxbe/nxbe_configure.c
@@ -0,0 +1,219 @@
+/****************************************************************************
+ * graphics/nxbe/nxbe_configure.c
+ *
+ * Copyright (C) 2008-2010 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
+ * 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 <stddef.h>
+#include <errno.h>
+#include <debug.h>
+
+#include "nxbe.h"
+
+/****************************************************************************
+ * Pre-Processor Definitions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Private Types
+ ****************************************************************************/
+
+/****************************************************************************
+ * Private Data
+ ****************************************************************************/
+
+/****************************************************************************
+ * Public Data
+ ****************************************************************************/
+
+/****************************************************************************
+ * Private Functions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Public Functions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Name: nxbe_configure
+ *
+ * Description:
+ * Configure the back end state structure based on information from the
+ * framebuffer driver
+ *
+ ****************************************************************************/
+
+int nxbe_configure(FAR NX_DRIVERTYPE *dev, FAR struct nxbe_state_s *be)
+{
+ int ret;
+ int i;
+
+ /* Get the video controller configuration */
+
+ ret = dev->getvideoinfo(dev, &be->vinfo);
+ if (ret < 0)
+ {
+ gdbg("Failed to get vinfo\n");
+ return ret;
+ }
+
+ /* Check the number of color planes */
+
+#ifdef CONFIG_DEBUG
+ if (be->vinfo.nplanes > CONFIG_NX_NPLANES)
+ {
+ gdbg("NX configured for only %d planes, controller wants %d\n",
+ CONFIG_NX_NPLANES, be->vinfo.nplanes);
+ return -E2BIG;
+ }
+ else if (be->vinfo.nplanes < CONFIG_NX_NPLANES)
+ {
+ gdbg("NX configured for %d planes, controller only needs %d\n",
+ CONFIG_NX_NPLANES, be->vinfo.nplanes);
+ }
+#endif
+
+ /* Then get information about each color plane */
+
+ for (i = 0; i < be->vinfo.nplanes; i++)
+ {
+ ret = dev->getplaneinfo(dev, i, &be->plane[i].pinfo);
+ if (ret < 0)
+ {
+ gdbg("Failed to get pinfo[%d]\n", i);
+ return ret;
+ }
+
+ /* Select rasterizers to match the BPP reported for this plane.
+ * NOTE that there are configuration options to eliminate support
+ * for unused BPP values. If the unused BPP values are not suppressed
+ * in this way, then ALL rasterizers will be drawn into the link and
+ * will signicantly increase the size
+ */
+
+#ifndef CONFIG_NX_DISABLE_1BPP
+ if (be->plane[i].pinfo.bpp == 1)
+ {
+ be->plane[i].setpixel = nxgl_setpixel_1bpp;
+ be->plane[i].fillrectangle = nxgl_fillrectangle_1bpp;
+ be->plane[i].getrectangle = nxgl_getrectangle_1bpp;
+ be->plane[i].filltrapezoid = nxgl_filltrapezoid_1bpp;
+ be->plane[i].moverectangle = nxgl_moverectangle_1bpp;
+ be->plane[i].copyrectangle = nxgl_copyrectangle_1bpp;
+ }
+ else
+#endif
+#ifndef CONFIG_NX_DISABLE_2BPP
+ if (be->plane[i].pinfo.bpp == 2)
+ {
+ be->plane[i].setpixel = nxgl_setpixel_2bpp;
+ be->plane[i].fillrectangle = nxgl_fillrectangle_2bpp;
+ be->plane[i].getrectangle = nxgl_getrectangle_2bpp;
+ be->plane[i].filltrapezoid = nxgl_filltrapezoid_2bpp;
+ be->plane[i].moverectangle = nxgl_moverectangle_2bpp;
+ be->plane[i].copyrectangle = nxgl_copyrectangle_2bpp;
+ }
+ else
+#endif
+#ifndef CONFIG_NX_DISABLE_4BPP
+ if (be->plane[i].pinfo.bpp == 4)
+ {
+ be->plane[i].setpixel = nxgl_setpixel_4bpp;
+ be->plane[i].fillrectangle = nxgl_fillrectangle_4bpp;
+ be->plane[i].getrectangle = nxgl_getrectangle_4bpp;
+ be->plane[i].filltrapezoid = nxgl_filltrapezoid_4bpp;
+ be->plane[i].moverectangle = nxgl_moverectangle_4bpp;
+ be->plane[i].copyrectangle = nxgl_copyrectangle_4bpp;
+ }
+ else
+#endif
+#ifndef CONFIG_NX_DISABLE_8BPP
+ if (be->plane[i].pinfo.bpp == 8)
+ {
+ be->plane[i].setpixel = nxgl_setpixel_8bpp;
+ be->plane[i].fillrectangle = nxgl_fillrectangle_8bpp;
+ be->plane[i].getrectangle = nxgl_getrectangle_8bpp;
+ be->plane[i].filltrapezoid = nxgl_filltrapezoid_8bpp;
+ be->plane[i].moverectangle = nxgl_moverectangle_8bpp;
+ be->plane[i].copyrectangle = nxgl_copyrectangle_8bpp;
+ }
+ else
+#endif
+#ifndef CONFIG_NX_DISABLE_16BPP
+ if (be->plane[i].pinfo.bpp == 16)
+ {
+ be->plane[i].setpixel = nxgl_setpixel_16bpp;
+ be->plane[i].fillrectangle = nxgl_fillrectangle_16bpp;
+ be->plane[i].getrectangle = nxgl_getrectangle_16bpp;
+ be->plane[i].filltrapezoid = nxgl_filltrapezoid_16bpp;
+ be->plane[i].moverectangle = nxgl_moverectangle_16bpp;
+ be->plane[i].copyrectangle = nxgl_copyrectangle_16bpp;
+ }
+ else
+#endif
+#ifndef CONFIG_NX_DISABLE_24BPP
+ if (be->plane[i].pinfo.bpp == 24)
+ {
+ be->plane[i].setpixel = nxgl_setpixel_24bpp;
+ be->plane[i].fillrectangle = nxgl_fillrectangle_24bpp;
+ be->plane[i].getrectangle = nxgl_getrectangle_24bpp;
+ be->plane[i].filltrapezoid = nxgl_filltrapezoid_24bpp;
+ be->plane[i].moverectangle = nxgl_moverectangle_24bpp;
+ be->plane[i].copyrectangle = nxgl_copyrectangle_24bpp;
+ }
+ else
+#endif
+#ifndef CONFIG_NX_DISABLE_32BPP
+ if (be->plane[i].pinfo.bpp == 32)
+ {
+ be->plane[i].setpixel = nxgl_setpixel_32bpp;
+ be->plane[i].fillrectangle = nxgl_fillrectangle_32bpp;
+ be->plane[i].getrectangle = nxgl_getrectangle_32bpp;
+ be->plane[i].filltrapezoid = nxgl_filltrapezoid_32bpp;
+ be->plane[i].moverectangle = nxgl_moverectangle_32bpp;
+ be->plane[i].copyrectangle = nxgl_copyrectangle_32bpp;
+ }
+ else
+#endif
+ {
+ gdbg("Unsupported pinfo[%d] BPP: %d\n", i, be->plane[i].pinfo.bpp);
+ return -ENOSYS;
+ }
+ }
+ return OK;
+}
diff --git a/nuttx/graphics/nxbe/nxbe_fill.c b/nuttx/graphics/nxbe/nxbe_fill.c
new file mode 100644
index 000000000..c2b4266b0
--- /dev/null
+++ b/nuttx/graphics/nxbe/nxbe_fill.c
@@ -0,0 +1,157 @@
+/****************************************************************************
+ * graphics/nxbe/nxbe_fill.c
+ *
+ * Copyright (C) 2008-2009, 2011 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
+ * 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 <nuttx/nx/nxglib.h>
+
+#include "nxbe.h"
+
+/****************************************************************************
+ * Pre-Processor Definitions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Private Types
+ ****************************************************************************/
+
+struct nxbe_fill_s
+{
+ struct nxbe_clipops_s cops;
+ nxgl_mxpixel_t color;
+};
+
+/****************************************************************************
+ * Private Data
+ ****************************************************************************/
+
+/****************************************************************************
+ * Public Data
+ ****************************************************************************/
+
+/****************************************************************************
+ * Private Functions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Name: nxbe_clipfill
+ *
+ * Description:
+ * Called from nxbe_clipper() to performed the fill operation on visible portions
+ * of the rectangle.
+ *
+ ****************************************************************************/
+
+static void nxbe_clipfill(FAR struct nxbe_clipops_s *cops,
+ FAR struct nxbe_plane_s *plane,
+ FAR const struct nxgl_rect_s *rect)
+{
+ struct nxbe_fill_s *fillinfo = (struct nxbe_fill_s *)cops;
+ plane->fillrectangle(&plane->pinfo, rect, fillinfo->color);
+}
+
+/****************************************************************************
+ * Public Functions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Name: nxbe_fill
+ *
+ * Description:
+ * Fill the specified rectangle in the window with the specified color
+ *
+ * Input Parameters:
+ * wnd - The window structure reference
+ * rect - The location to be filled
+ * col - The color to use in the fill
+ *
+ * Return:
+ * None
+ *
+ ****************************************************************************/
+
+void nxbe_fill(FAR struct nxbe_window_s *wnd,
+ FAR const struct nxgl_rect_s *rect,
+ nxgl_mxpixel_t color[CONFIG_NX_NPLANES])
+{
+ struct nxbe_fill_s info;
+ struct nxgl_rect_s remaining;
+ int i;
+
+#ifdef CONFIG_DEBUG
+ if (!wnd || !rect)
+ {
+ return;
+ }
+#endif
+
+ /* Offset the rectangle by the window origin to convert it into a
+ * bounding box
+ */
+
+ nxgl_rectoffset(&remaining, rect, wnd->bounds.pt1.x, wnd->bounds.pt1.y);
+
+ /* Clip to the bounding box to the limits of the window and of the
+ * background screen
+ */
+
+ nxgl_rectintersect(&remaining, &remaining, &wnd->bounds);
+ nxgl_rectintersect(&remaining, &remaining, &wnd->be->bkgd.bounds);
+
+ /* Then clip the bounding box due to other windows above this one.
+ * Render the portions of the trapezoid exposed in visible regions.
+ */
+
+ if (!nxgl_nullrect(&remaining))
+ {
+#if CONFIG_NX_NPLANES > 1
+ for (i = 0; i < wnd->be->vinfo.nplanes; i++)
+#else
+ i = 0;
+#endif
+ {
+ info.cops.visible = nxbe_clipfill;
+ info.cops.obscured = nxbe_clipnull;
+ info.color = color[i];
+
+ nxbe_clipper(wnd->above, &remaining, NX_CLIPORDER_DEFAULT,
+ &info.cops, &wnd->be->plane[i]);
+ }
+ }
+}
diff --git a/nuttx/graphics/nxbe/nxbe_filltrapezoid.c b/nuttx/graphics/nxbe/nxbe_filltrapezoid.c
new file mode 100644
index 000000000..68dad838c
--- /dev/null
+++ b/nuttx/graphics/nxbe/nxbe_filltrapezoid.c
@@ -0,0 +1,173 @@
+/****************************************************************************
+ * graphics/nxbe/nxbe_filltrapezoid.c
+ *
+ * Copyright (C) 2008-2009, 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
+ * 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 <fixedmath.h>
+#include <nuttx/nx/nxglib.h>
+
+#include "nxbe.h"
+
+/****************************************************************************
+ * Pre-Processor Definitions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Private Types
+ ****************************************************************************/
+
+struct nxbe_filltrap_s
+{
+ struct nxbe_clipops_s cops;
+ struct nxgl_trapezoid_s trap;
+ nxgl_mxpixel_t color;
+};
+
+/****************************************************************************
+ * Private Data
+ ****************************************************************************/
+
+/****************************************************************************
+ * Public Data
+ ****************************************************************************/
+
+/****************************************************************************
+ * Private Functions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Name: nxbe_clipfilltrapezoid
+ *
+ * Description:
+ * Called from nxbe_clipper() to performed the fill operation on visible portions
+ * of the rectangle.
+ *
+ ****************************************************************************/
+
+static void nxbe_clipfilltrapezoid(FAR struct nxbe_clipops_s *cops,
+ FAR struct nxbe_plane_s *plane,
+ FAR const struct nxgl_rect_s *rect)
+{
+ struct nxbe_filltrap_s *fillinfo = (struct nxbe_filltrap_s *)cops;
+ plane->filltrapezoid(&plane->pinfo, &fillinfo->trap, rect, fillinfo->color);
+}
+
+/****************************************************************************
+ * Public Functions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Name: nxbe_filltrapezoid
+ *
+ * Description:
+ * Fill the specified rectangle in the window with the specified color
+ *
+ * Input Parameters:
+ * wnd - The window structure reference
+ * clip - Clipping region (in relative window coordinates)
+ * rect - The location to be filled (in relative window coordinates)
+ * col - The color to use in the fill
+ *
+ * Return:
+ * None
+ *
+ ****************************************************************************/
+
+void nxbe_filltrapezoid(FAR struct nxbe_window_s *wnd,
+ FAR const struct nxgl_rect_s *clip,
+ FAR const struct nxgl_trapezoid_s *trap,
+ nxgl_mxpixel_t color[CONFIG_NX_NPLANES])
+{
+ struct nxbe_filltrap_s info;
+ struct nxgl_rect_s remaining;
+ int i;
+
+#ifdef CONFIG_DEBUG
+ if (!wnd || !trap)
+ {
+ return;
+ }
+#endif
+
+ /* Offset the trapezoid by the window origin to position it within
+ * the framebuffer region
+ */
+
+ nxgl_trapoffset(&info.trap, trap, wnd->bounds.pt1.x, wnd->bounds.pt1.y);
+
+ /* Create a bounding box that contains the trapezoid */
+
+ remaining.pt1.x = b16toi(ngl_min(info.trap.top.x1, info.trap.bot.x1));
+ remaining.pt1.y = info.trap.top.y;
+ remaining.pt2.x = b16toi(ngl_max(info.trap.top.x2, info.trap.bot.x2));
+ remaining.pt2.y = info.trap.bot.y;
+
+ /* Clip to any user specified clipping window */
+
+ if (clip)
+ {
+ struct nxgl_rect_s tmp;
+ nxgl_rectoffset(&tmp, clip, wnd->bounds.pt1.x, wnd->bounds.pt1.y);
+ nxgl_rectintersect(&remaining, &remaining, &tmp);
+ }
+
+ /* Clip to the limits of the window and of the background screen */
+
+ nxgl_rectintersect(&remaining, &remaining, &wnd->bounds);
+ nxgl_rectintersect(&remaining, &remaining, &wnd->be->bkgd.bounds);
+
+ if (!nxgl_nullrect(&remaining))
+ {
+ info.cops.visible = nxbe_clipfilltrapezoid;
+ info.cops.obscured = nxbe_clipnull;
+
+ /* Then process each color plane */
+
+#if CONFIG_NX_NPLANES > 1
+ for (i = 0; i < wnd->be->vinfo.nplanes; i++)
+#else
+ i = 0;
+#endif
+ {
+ info.color = color[i];
+ nxbe_clipper(wnd->above, &remaining, NX_CLIPORDER_DEFAULT,
+ &info.cops, &wnd->be->plane[i]);
+ }
+ }
+}
diff --git a/nuttx/graphics/nxbe/nxbe_getrectangle.c b/nuttx/graphics/nxbe/nxbe_getrectangle.c
new file mode 100644
index 000000000..84f010cd5
--- /dev/null
+++ b/nuttx/graphics/nxbe/nxbe_getrectangle.c
@@ -0,0 +1,138 @@
+/****************************************************************************
+ * graphics/nxbe/nxbe_fill.c
+ *
+ * Copyright (C) 2011 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
+ * 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 <errno.h>
+#include <debug.h>
+
+#include <nuttx/nx/nxglib.h>
+
+#include "nxbe.h"
+
+/****************************************************************************
+ * Pre-Processor Definitions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Private Types
+ ****************************************************************************/
+
+struct nxbe_fill_s
+{
+ struct nxbe_clipops_s cops;
+ nxgl_mxpixel_t color;
+};
+
+/****************************************************************************
+ * Private Data
+ ****************************************************************************/
+
+/****************************************************************************
+ * Public Data
+ ****************************************************************************/
+
+/****************************************************************************
+ * Private Functions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Public Functions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Name: nxbe_getrectangle
+ *
+ * Description:
+ * Get the raw contents of graphic memory within a rectangular region. NOTE:
+ * Since raw graphic memory is returned, the returned memory content may be
+ * the memory of windows above this one and may not necessarily belong to
+ * this window unless you assure that this is the top window.
+ *
+ * Input Parameters:
+ * wnd - The window structure reference
+ * rect - The location to be copied
+ * plane - Specifies the color plane to get from.
+ * dest - The location to copy the memory region
+ * deststride - The width, in bytes, the the dest memory
+ *
+ * Return:
+ * None
+ *
+ ****************************************************************************/
+
+void nxbe_getrectangle(FAR struct nxbe_window_s *wnd,
+ FAR const struct nxgl_rect_s *rect, unsigned int plane,
+ FAR uint8_t *dest, unsigned int deststride)
+{
+ struct nxgl_rect_s remaining;
+
+#ifdef CONFIG_DEBUG
+ if (!wnd || !rect || ! rect || plane >= wnd->be->vinfo.nplanes)
+ {
+ gvdbg("Invalid parameters\n");
+ return;
+ }
+#endif
+
+ /* Offset the rectangle by the window origin to convert it into a
+ * bounding box
+ */
+
+ nxgl_rectoffset(&remaining, rect, wnd->bounds.pt1.x, wnd->bounds.pt1.y);
+
+ /* Clip to the bounding box to the limits of the window and of the
+ * background screen
+ */
+
+ nxgl_rectintersect(&remaining, &remaining, &wnd->bounds);
+ nxgl_rectintersect(&remaining, &remaining, &wnd->be->bkgd.bounds);
+
+ /* The return the graphics memory at this location. NOTE: Since raw
+ * graphic memory is returned, the returned memory content may be
+ * the memory of windows above this one and may not necessarily belong
+ * to this window.
+ */
+
+ if (!nxgl_nullrect(&remaining))
+ {
+ FAR struct nxbe_plane_s *pplane = &wnd->be->plane[plane];
+ pplane->getrectangle(&pplane->pinfo, &remaining, dest, deststride);
+ }
+}
diff --git a/nuttx/graphics/nxbe/nxbe_lower.c b/nuttx/graphics/nxbe/nxbe_lower.c
new file mode 100644
index 000000000..545342d5b
--- /dev/null
+++ b/nuttx/graphics/nxbe/nxbe_lower.c
@@ -0,0 +1,125 @@
+/****************************************************************************
+ * graphics/nxbe/nxbe_lower.c
+ *
+ * Copyright (C) 2008-2009, 2011 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
+ * 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 <stddef.h>
+#include <debug.h>
+
+#include <nuttx/nx/nxglib.h>
+#include "nxbe.h"
+
+/****************************************************************************
+ * Pre-Processor Definitions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Private Types
+ ****************************************************************************/
+
+/****************************************************************************
+ * Private Data
+ ****************************************************************************/
+
+/****************************************************************************
+ * Public Data
+ ****************************************************************************/
+
+/****************************************************************************
+ * Private Functions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Public Functions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Name: nxbe_lower
+ *
+ * Description:
+ * Lower the specified window to the bottom of the display.
+ *
+ ****************************************************************************/
+
+void nxbe_lower(FAR struct nxbe_window_s *wnd)
+{
+ FAR struct nxbe_state_s *be = wnd->be;
+ FAR struct nxbe_window_s *below;
+
+ /* If the window is already at the bottom, then there is nothing to do */
+
+ if (!wnd->below || wnd->below == &be->bkgd)
+ {
+ return;
+ }
+
+ /* Remove the window from its current position in the list */
+
+ wnd->below->above = wnd->above;
+
+ /* Was it at the top of the display? */
+
+ if (wnd->above)
+ {
+ /* No... it was in the middle somewhere */
+
+ wnd->above->below = wnd->below;
+ }
+ else
+ {
+ /* Yes.. set the new top window */
+
+ be->topwnd = wnd->below;
+ be->topwnd->above = NULL;
+ }
+
+ /* Remember the window that was just below us */
+
+ below = wnd->below;
+
+ /* Then put the lowered window at the bottom (just above the background window) */
+
+ wnd->below = &be->bkgd;
+ wnd->above = be->bkgd.above;
+ be->bkgd.above = wnd;
+
+ /* Redraw the windows that were below us (but now are above) */
+
+ nxbe_redrawbelow(be, below, &wnd->bounds);
+}
diff --git a/nuttx/graphics/nxbe/nxbe_move.c b/nuttx/graphics/nxbe/nxbe_move.c
new file mode 100644
index 000000000..193b174c2
--- /dev/null
+++ b/nuttx/graphics/nxbe/nxbe_move.c
@@ -0,0 +1,284 @@
+/****************************************************************************
+ * graphics/nxbe/nxbe_move.c
+ *
+ * Copyright (C) 2008-2009, 2011-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
+ * 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 <stdint.h>
+
+#include <nuttx/nx/nxglib.h>
+
+#include "nxbe.h"
+#include "nxfe.h"
+
+/****************************************************************************
+ * Pre-Processor Definitions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Private Types
+ ****************************************************************************/
+
+struct nxbe_move_s
+{
+ struct nxbe_clipops_s cops;
+ struct nxgl_point_s offset;
+ FAR struct nxbe_window_s *wnd;
+ struct nxgl_rect_s srcrect;
+ uint8_t order;
+};
+
+/****************************************************************************
+ * Private Data
+ ****************************************************************************/
+
+/****************************************************************************
+ * Public Data
+ ****************************************************************************/
+
+/****************************************************************************
+ * Private Functions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Name: nxbe_clipmovesrc
+ *
+ * Description:
+ * Called from nxbe_clipper() to performed the move operation on visible regions
+ * of the rectangle.
+ *
+ ****************************************************************************/
+
+static void nxbe_clipmovesrc(FAR struct nxbe_clipops_s *cops,
+ FAR struct nxbe_plane_s *plane,
+ FAR const struct nxgl_rect_s *rect)
+{
+ struct nxbe_move_s *info = (struct nxbe_move_s *)cops;
+ struct nxgl_point_s offset;
+
+ if (info->offset.x != 0 || info->offset.y != 0)
+ {
+ /* Offset is the destination position of the moved rectangle */
+
+ offset.x = rect->pt1.x + info->offset.x;
+ offset.y = rect->pt1.y + info->offset.y;
+
+ plane->moverectangle(&plane->pinfo, rect, &offset);
+ }
+}
+
+/****************************************************************************
+ * Name: nxbe_clipmoveobscured
+ *
+ * Description:
+ * Called from nxbe_clipper() to performed the move operation on obsrured regions
+ * of the rectangle.
+ *
+ ****************************************************************************/
+
+static void nxbe_clipmoveobscured(FAR struct nxbe_clipops_s *cops,
+ FAR struct nxbe_plane_s *plane,
+ FAR const struct nxgl_rect_s *rect)
+{
+ struct nxbe_move_s *info = (struct nxbe_move_s *)cops;
+ struct nxgl_rect_s dst;
+
+ nxgl_rectoffset(&dst, rect, info->offset.x, info->offset.y);
+ nxfe_redrawreq(info->wnd, &dst);
+}
+
+/****************************************************************************
+ * Name: nxbe_clipmovedest
+ *
+ * Description:
+ * Called from nxbe_clipper() to performed the move operation on visible
+ * regions of the source rectangle.
+ *
+ ****************************************************************************/
+
+static void nxbe_clipmovedest(FAR struct nxbe_clipops_s *cops,
+ FAR struct nxbe_plane_s *plane,
+ FAR const struct nxgl_rect_s *rect)
+{
+ struct nxbe_move_s *dstdata = (struct nxbe_move_s *)cops;
+ struct nxbe_window_s *wnd = dstdata->wnd;
+ struct nxgl_point_s offset = dstdata->offset;
+ struct nxgl_rect_s src;
+ struct nxgl_rect_s tmprect1;
+ struct nxgl_rect_s tmprect2;
+ struct nxgl_rect_s nonintersecting[4];
+ int i;
+
+ /* Redraw dest regions where the source is outside of the bounds of the
+ * background window
+ */
+
+ nxgl_rectoffset(&tmprect1, &dstdata->srcrect, offset.x, offset.y);
+ nxgl_rectintersect(&tmprect2, &tmprect1, &wnd->be->bkgd.bounds);
+ nxgl_nonintersecting(nonintersecting, rect, &tmprect2);
+
+ for (i = 0; i < 4; i++)
+ {
+ if (!nxgl_nullrect(&nonintersecting[i]))
+ {
+ nxfe_redrawreq(dstdata->wnd, &nonintersecting[i]);
+ }
+ }
+
+ /* Clip to determine what is inside the bounds */
+
+ nxgl_rectintersect(&src, rect, &dstdata->srcrect);
+
+ if (!nxgl_nullrect(&src))
+ {
+ struct nxbe_move_s srcinfo;
+
+ srcinfo.cops.visible = nxbe_clipmovesrc;
+ srcinfo.cops.obscured = nxbe_clipmoveobscured;
+ srcinfo.offset = offset;
+ srcinfo.wnd = wnd;
+
+ nxbe_clipper(dstdata->wnd->above, &src, dstdata->order,
+ &srcinfo.cops, plane);
+ }
+}
+
+/****************************************************************************
+ * Public Functions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Name: nxbe_move
+ *
+ * Description:
+ * Move a rectangular region within the window
+ *
+ * Input Parameters:
+ * wnd - The window within which the move is to be done
+ * rect - Describes the rectangular region to move
+ * offset - The offset to move the region
+ *
+ * Return:
+ * None
+ *
+ ****************************************************************************/
+
+void nxbe_move(FAR struct nxbe_window_s *wnd, FAR const struct nxgl_rect_s *rect,
+ FAR const struct nxgl_point_s *offset)
+{
+ struct nxbe_move_s info;
+ int i;
+
+#ifdef CONFIG_DEBUG
+ if (!wnd || !rect)
+ {
+ return;
+ }
+#endif
+
+ /* Offset the rectangle by the window origin to create a bounding box */
+
+ nxgl_rectoffset(&info.srcrect, rect, wnd->bounds.pt1.x, wnd->bounds.pt1.y);
+
+ /* Clip to the limits of the window and of the background screen */
+
+ nxgl_rectintersect(&info.srcrect, &info.srcrect, &wnd->bounds);
+ nxgl_rectintersect(&info.srcrect, &info.srcrect, &wnd->be->bkgd.bounds);
+
+ if (nxgl_nullrect(&info.srcrect))
+ {
+ return;
+ }
+
+ info.cops.visible = nxbe_clipmovedest;
+ info.cops.obscured = nxbe_clipnull;
+ info.offset.x = offset->x;
+ info.offset.y = offset->y;
+ info.wnd = wnd;
+
+ /* The clip order depends up the direction that the rectangle is being
+ * moved.
+ */
+
+ if (offset->y < 0)
+ {
+ /* Moving rectangle up */
+
+ if (offset->x < 0)
+ {
+ /* Moving to upper-left */
+
+ info.order = NX_CLIPORDER_TLRB; /* Top-left-right-bottom */
+ }
+ else
+ {
+ /* Moving to upper-right (or just up) */
+
+ info.order = NX_CLIPORDER_TRLB; /* Top-right-left-bottom */
+ }
+ }
+ else
+ {
+ /* Moving rectangle down (or just left/right) */
+
+ if (offset->x < 0)
+ {
+ /* Moving to lower-left */
+
+ info.order = NX_CLIPORDER_BLRT; /* Bottom-left-right-top */
+ }
+ else
+ {
+ /* Moving to lower-right */
+
+ info.order = NX_CLIPORDER_BRLT; /* Bottom-right-left-top */
+ }
+ }
+
+ /* Then perform the move */
+
+#if CONFIG_NX_NPLANES > 1
+ for (i = 0; i < wnd->be->vinfo.nplanes; i++)
+#else
+ i = 0;
+#endif
+ {
+ nxbe_clipper(wnd->above, &info.srcrect, info.order,
+ &info.cops, &wnd->be->plane[i]);
+ }
+}
diff --git a/nuttx/graphics/nxbe/nxbe_raise.c b/nuttx/graphics/nxbe/nxbe_raise.c
new file mode 100644
index 000000000..ef4c392c0
--- /dev/null
+++ b/nuttx/graphics/nxbe/nxbe_raise.c
@@ -0,0 +1,116 @@
+/****************************************************************************
+ * graphics/nxbe/nxbe_raise.c
+ *
+ * Copyright (C) 2008-2009, 2011 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
+ * 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 <nuttx/nx/nxglib.h>
+
+#include "nxbe.h"
+#include "nxfe.h"
+
+/****************************************************************************
+ * Pre-Processor Definitions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Private Types
+ ****************************************************************************/
+
+struct nxbe_raise_s
+{
+ struct nxbe_clipops_s cops;
+ FAR struct nxbe_window_s *wnd;
+};
+
+/****************************************************************************
+ * Private Data
+ ****************************************************************************/
+
+/****************************************************************************
+ * Public Data
+ ****************************************************************************/
+
+/****************************************************************************
+ * Private Functions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Public Functions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Name: nxbe_raise
+ *
+ * Description:
+ * Bring the specified window to the top of the display.
+ *
+ ****************************************************************************/
+
+void nxbe_raise(FAR struct nxbe_window_s *wnd)
+{
+ FAR struct nxbe_state_s *be = wnd->be;
+
+ /* If this window is already at the top of the display, then do nothing */
+
+ if (!wnd->above)
+ {
+ return;
+ }
+
+ /* Remove window from the list. Note that there is always
+ * some below this window (it may only be the background window)
+ */
+
+ wnd->above->below = wnd->below;
+ wnd->below->above = wnd->above;
+
+ /* Then put it back in the list at the top */
+
+ wnd->above = NULL;
+ wnd->below = be->topwnd;
+
+ be->topwnd->above = wnd;
+ be->topwnd = wnd;
+
+ /* This window is now at the top of the display, we know, therefore, that
+ * it is not obscured by another window
+ */
+
+ nxfe_redrawreq(wnd, &wnd->bounds);
+}
diff --git a/nuttx/graphics/nxbe/nxbe_redraw.c b/nuttx/graphics/nxbe/nxbe_redraw.c
new file mode 100644
index 000000000..d52ff71e5
--- /dev/null
+++ b/nuttx/graphics/nxbe/nxbe_redraw.c
@@ -0,0 +1,139 @@
+/****************************************************************************
+ * graphics/nxbe/nxbe_redraw.c
+ *
+ * Copyright (C) 2008-2009, 2011 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
+ * 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 <errno.h>
+#include <debug.h>
+
+#include <nuttx/nx/nxglib.h>
+
+#include "nxbe.h"
+#include "nxfe.h"
+
+/****************************************************************************
+ * Pre-Processor Definitions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Private Types
+ ****************************************************************************/
+
+struct nxbe_redraw_s
+{
+ struct nxbe_clipops_s cops;
+ FAR struct nxbe_window_s *wnd;
+};
+
+/****************************************************************************
+ * Private Data
+ ****************************************************************************/
+
+/****************************************************************************
+ * Public Data
+ ****************************************************************************/
+
+/****************************************************************************
+ * Private Functions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Name: nxbe_clipredraw
+ ****************************************************************************/
+
+static void nxbe_clipredraw(FAR struct nxbe_clipops_s *cops,
+ FAR struct nxbe_plane_s *plane,
+ FAR const struct nxgl_rect_s *rect)
+{
+ FAR struct nxbe_window_s *wnd = ((struct nxbe_redraw_s *)cops)->wnd;
+ if (wnd)
+ {
+ nxfe_redrawreq(wnd, rect);
+ }
+}
+
+/****************************************************************************
+ * Public Functions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Name: nxbe_redraw
+ *
+ * Descripton:
+ * Re-draw the visible portions of the rectangular region for the
+ * specified window
+ *
+ ****************************************************************************/
+
+void nxbe_redraw(FAR struct nxbe_state_s *be,
+ FAR struct nxbe_window_s *wnd,
+ FAR const struct nxgl_rect_s *rect)
+{
+ struct nxbe_redraw_s info;
+ struct nxgl_rect_s remaining;
+#if CONFIG_NX_NPLANES > 1
+ int i;
+#endif
+
+ /* Clip to the limits of the window and of the background screen */
+
+ nxgl_rectintersect(&remaining, rect, &be->bkgd.bounds);
+ nxgl_rectintersect(&remaining, &remaining, &wnd->bounds);
+ if (!nxgl_nullrect(&remaining))
+ {
+ /* Now, request to re-draw any visible rectangular regions not obscured
+ * by windows above this one.
+ */
+
+ info.cops.visible = nxbe_clipredraw;
+ info.cops.obscured = nxbe_clipnull;
+ info.wnd = wnd;
+
+#if CONFIG_NX_NPLANES > 1
+ for (i = 0; i < be->vinfo.nplanes; i++)
+ {
+ nxbe_clipper(wnd->above, &remaining, NX_CLIPORDER_DEFAULT,
+ &info.cops, &be->plane[i]);
+ }
+#else
+ nxbe_clipper(wnd->above, &remaining, NX_CLIPORDER_DEFAULT,
+ &info.cops, &be->plane[0]);
+#endif
+ }
+}
diff --git a/nuttx/graphics/nxbe/nxbe_redrawbelow.c b/nuttx/graphics/nxbe/nxbe_redrawbelow.c
new file mode 100644
index 000000000..c795e5fed
--- /dev/null
+++ b/nuttx/graphics/nxbe/nxbe_redrawbelow.c
@@ -0,0 +1,91 @@
+/****************************************************************************
+ * graphics/nxbe/nxbe_redraw.c
+ *
+ * Copyright (C) 2008-2009, 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
+ * 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 <errno.h>
+#include <debug.h>
+
+#include "nxbe.h"
+
+/****************************************************************************
+ * Pre-Processor Definitions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Private Types
+ ****************************************************************************/
+
+/****************************************************************************
+ * Private Data
+ ****************************************************************************/
+
+/****************************************************************************
+ * Public Data
+ ****************************************************************************/
+
+/****************************************************************************
+ * Private Functions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Public Functions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Name: nxbe_redrawbelow
+ *
+ * Descripton:
+ * Re-draw the visible portions of the rectangular region for all windows
+ * below (and including) the specified window. This function is called
+ * whenever a window is closed, moved, lowered or re-sized in order to
+ * expose newly visible portions of lower windows.
+ *
+ ****************************************************************************/
+
+void nxbe_redrawbelow(FAR struct nxbe_state_s *be, FAR struct nxbe_window_s *wnd,
+ FAR const struct nxgl_rect_s *rect)
+{
+ FAR struct nxbe_window_s *currwnd;
+
+ for (currwnd = wnd; currwnd; currwnd = currwnd->below)
+ {
+ nxbe_redraw(be, currwnd, rect);
+ }
+}
diff --git a/nuttx/graphics/nxbe/nxbe_setpixel.c b/nuttx/graphics/nxbe/nxbe_setpixel.c
new file mode 100644
index 000000000..d333b9b76
--- /dev/null
+++ b/nuttx/graphics/nxbe/nxbe_setpixel.c
@@ -0,0 +1,158 @@
+/****************************************************************************
+ * graphics/nxbe/nxbe_setpixel.c
+ *
+ * Copyright (C) 2011 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
+ * 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 <nuttx/nx/nxglib.h>
+
+#include "nxbe.h"
+
+/****************************************************************************
+ * Pre-Processor Definitions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Private Types
+ ****************************************************************************/
+
+struct nxbe_setpixel_s
+{
+ struct nxbe_clipops_s cops;
+ nxgl_mxpixel_t color;
+};
+
+/****************************************************************************
+ * Private Data
+ ****************************************************************************/
+
+/****************************************************************************
+ * Public Data
+ ****************************************************************************/
+
+/****************************************************************************
+ * Private Functions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Name: nxbe_clipfill
+ *
+ * Description:
+ * Called from nxbe_clipper() to performed the fill operation on visible portions
+ * of the rectangle.
+ *
+ ****************************************************************************/
+
+static void nxbe_clipfill(FAR struct nxbe_clipops_s *cops,
+ FAR struct nxbe_plane_s *plane,
+ FAR const struct nxgl_rect_s *rect)
+{
+ struct nxbe_setpixel_s *fillinfo = (struct nxbe_setpixel_s *)cops;
+ plane->setpixel(&plane->pinfo, &rect->pt1, fillinfo->color);
+}
+
+/****************************************************************************
+ * Public Functions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Name: nxbe_fill
+ *
+ * Description:
+ * Fill the specified rectangle in the window with the specified color
+ *
+ * Input Parameters:
+ * wnd - The window structure reference
+ * rect - The location to be filled
+ * col - The color to use in the fill
+ *
+ * Return:
+ * None
+ *
+ ****************************************************************************/
+
+void nxbe_setpixel(FAR struct nxbe_window_s *wnd,
+ FAR const struct nxgl_point_s *pos,
+ nxgl_mxpixel_t color[CONFIG_NX_NPLANES])
+{
+ struct nxbe_setpixel_s info;
+ struct nxgl_rect_s rect;
+ int i;
+
+#ifdef CONFIG_DEBUG
+ if (!wnd || !pos)
+ {
+ return;
+ }
+#endif
+
+ /* Offset the position by the window origin */
+
+ nxgl_vectoradd(&rect.pt1, pos, &wnd->bounds.pt1);
+
+ /* Make sure that the point is within the limits of the window
+ * and of the background screen
+ */
+
+ if (!nxgl_rectinside(&wnd->bounds, &rect.pt1) ||
+ !nxgl_rectinside(&wnd->be->bkgd.bounds, &rect.pt1))
+ {
+ return;
+ }
+
+ /* Then create a bounding box and render the point if there it
+ * is exposed.
+ */
+
+ rect.pt2.x = rect.pt1.x;
+ rect.pt2.y = rect.pt1.y;
+
+#if CONFIG_NX_NPLANES > 1
+ for (i = 0; i < wnd->be->vinfo.nplanes; i++)
+#else
+ i = 0;
+#endif
+ {
+ info.cops.visible = nxbe_clipfill;
+ info.cops.obscured = nxbe_clipnull;
+ info.color = color[i];
+
+ nxbe_clipper(wnd->above, &rect, NX_CLIPORDER_DEFAULT,
+ &info.cops, &wnd->be->plane[i]);
+ }
+}
diff --git a/nuttx/graphics/nxbe/nxbe_setposition.c b/nuttx/graphics/nxbe/nxbe_setposition.c
new file mode 100644
index 000000000..6f680df04
--- /dev/null
+++ b/nuttx/graphics/nxbe/nxbe_setposition.c
@@ -0,0 +1,119 @@
+/****************************************************************************
+ * graphics/nxbe/nxbe_setposition.c
+ *
+ * Copyright (C) 2008-2009, 2011 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
+ * 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 <nuttx/nx/nxglib.h>
+
+#include "nxbe.h"
+#include "nxfe.h"
+
+/****************************************************************************
+ * Pre-Processor Definitions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Private Types
+ ****************************************************************************/
+
+/****************************************************************************
+ * Private Data
+ ****************************************************************************/
+
+/****************************************************************************
+ * Public Data
+ ****************************************************************************/
+
+/****************************************************************************
+ * Private Functions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Public Functions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Name: nxbe_setposition
+ *
+ * Descripton:
+ * This function checks for intersections and redraws the display after
+ * a change in the position of a window.
+ *
+ ****************************************************************************/
+
+void nxbe_setposition(FAR struct nxbe_window_s *wnd,
+ FAR const struct nxgl_point_s *pos)
+{
+ struct nxgl_rect_s before;
+ struct nxgl_rect_s rect;
+
+#ifdef CONFIG_DEBUG
+ if (!wnd)
+ {
+ return;
+ }
+#endif
+
+ /* Back out the old window origin position from the bounding box */
+
+ nxgl_rectoffset(&rect, &wnd->bounds, -wnd->bounds.pt1.x, -wnd->bounds.pt1.y);
+
+ /* Add the new window origin into the bounding box */
+
+ nxgl_rectcopy(&before, &wnd->bounds);
+ nxgl_rectoffset(&wnd->bounds, &rect, pos->x, pos->y);
+
+ /* Get the union of the 'before' bounding box and the 'after' bounding
+ * this union is the region of the display that must be updated.
+ */
+
+ nxgl_rectunion(&rect, &before, &wnd->bounds);
+ nxgl_rectintersect(&rect, &rect, &wnd->be->bkgd.bounds);
+
+ /* Report the new size/position */
+
+ nxfe_reportposition(wnd);
+
+ /* Then redraw this window AND all windows below it. Having moved the
+ * window, we may have exposed previoulsy obscured portions of windows
+ * below this one.
+ */
+
+ nxbe_redrawbelow(wnd->be, wnd, &rect);
+}
diff --git a/nuttx/graphics/nxbe/nxbe_setsize.c b/nuttx/graphics/nxbe/nxbe_setsize.c
new file mode 100644
index 000000000..99775c715
--- /dev/null
+++ b/nuttx/graphics/nxbe/nxbe_setsize.c
@@ -0,0 +1,121 @@
+/****************************************************************************
+ * graphics/nxbe/nxbe_setsize.c
+ *
+ * Copyright (C) 2008-2009, 2011 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
+ * 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 <nuttx/nx/nxglib.h>
+
+#include "nxbe.h"
+#include "nxfe.h"
+
+/****************************************************************************
+ * Pre-Processor Definitions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Private Types
+ ****************************************************************************/
+
+/****************************************************************************
+ * Private Data
+ ****************************************************************************/
+
+/****************************************************************************
+ * Public Data
+ ****************************************************************************/
+
+/****************************************************************************
+ * Private Functions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Public Functions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Name: nxbe_setsize
+ *
+ * Descripton:
+ * This function checks for intersections and redraws the display after
+ * a change in the size of a window.
+ *
+ ****************************************************************************/
+
+void nxbe_setsize(FAR struct nxbe_window_s *wnd,
+ FAR const struct nxgl_size_s *size)
+{
+ struct nxgl_rect_s bounds;
+
+#ifdef CONFIG_DEBUG
+ if (!wnd)
+ {
+ return;
+ }
+#endif
+
+ /* Save the before size of the window's bounding box */
+
+ nxgl_rectcopy(&bounds, &wnd->bounds);
+
+ /* Add the window origin to the supplied size get the new window bounding box */
+
+ wnd->bounds.pt2.x = wnd->bounds.pt1.x + size->w - 1;
+ wnd->bounds.pt2.y = wnd->bounds.pt1.y + size->h - 1;
+
+ /* Clip the new bounding box so that lies within the background screen */
+
+ nxgl_rectintersect(&wnd->bounds, &wnd->bounds, &wnd->be->bkgd.bounds);
+
+ /* We need to update the larger of the two rectangles. That will be the
+ * union of the before and after sizes.
+ */
+
+ nxgl_rectunion(&bounds, &bounds, &wnd->bounds);
+
+ /* Report the new size/position */
+
+ nxfe_reportposition(wnd);
+
+ /* Then redraw this window AND all windows below it. Having resized the
+ * window, we may have exposed previoulsy obscured portions of windows
+ * below this one.
+ */
+
+ nxbe_redrawbelow(wnd->be, wnd, &bounds);
+}
diff --git a/nuttx/graphics/nxbe/nxbe_visible.c b/nuttx/graphics/nxbe/nxbe_visible.c
new file mode 100644
index 000000000..ca62aeab6
--- /dev/null
+++ b/nuttx/graphics/nxbe/nxbe_visible.c
@@ -0,0 +1,134 @@
+/****************************************************************************
+ * graphics/nxbe/nxbe_redraw.c
+ *
+ * Copyright (C) 2008-2009, 2011 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
+ * 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 <stdbool.h>
+#include <errno.h>
+#include <debug.h>
+
+#include <nuttx/nx/nxglib.h>
+
+#include "nxbe.h"
+#include "nxfe.h"
+
+/****************************************************************************
+ * Pre-Processor Definitions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Private Types
+ ****************************************************************************/
+
+struct nxbe_visible_s
+{
+ struct nxbe_clipops_s cops;
+ bool 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
+ *
+ ****************************************************************************/
+
+bool 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;
+}