From 44626834914016d6bc35945ad02421ed2be838d3 Mon Sep 17 00:00:00 2001 From: Gregory Nutt Date: Fri, 27 Dec 2013 14:30:13 -0600 Subject: Decoupling NX user interfaces to support NX kernel build (phase 2) --- nuttx/graphics/nxmu/Make.defs | 9 +- nuttx/graphics/nxmu/nx_bitmap.c | 157 --------------------------- nuttx/graphics/nxmu/nx_fill.c | 116 -------------------- nuttx/graphics/nxmu/nx_filltrapezoid.c | 142 ------------------------- nuttx/graphics/nxmu/nx_getposition.c | 114 -------------------- nuttx/graphics/nxmu/nx_getrectangle.c | 150 -------------------------- nuttx/graphics/nxmu/nx_lower.c | 98 ----------------- nuttx/graphics/nxmu/nx_move.c | 114 -------------------- nuttx/graphics/nxmu/nx_openwindow.c | 131 ----------------------- nuttx/graphics/nxmu/nx_raise.c | 98 ----------------- nuttx/graphics/nxmu/nx_setpixel.c | 118 --------------------- nuttx/graphics/nxmu/nx_setposition.c | 108 ------------------- nuttx/graphics/nxmu/nx_setsize.c | 108 ------------------- nuttx/graphics/nxmu/nxfe.h | 3 - nuttx/graphics/nxmu/nxmu_semtake.c | 87 --------------- nuttx/graphics/nxmu/nxmu_sendclientwindow.c | 113 ++++++++++++++++++++ nuttx/graphics/nxmu/nxmu_sendwindow.c | 158 ---------------------------- nuttx/include/nuttx/nx/nxmu.h | 4 + nuttx/libc/nx/Make.defs | 11 +- nuttx/libc/nx/lib_nx_bitmap.c | 156 +++++++++++++++++++++++++++ nuttx/libc/nx/lib_nx_fill.c | 116 ++++++++++++++++++++ nuttx/libc/nx/lib_nx_filltrapezoid.c | 142 +++++++++++++++++++++++++ nuttx/libc/nx/lib_nx_getposition.c | 115 ++++++++++++++++++++ nuttx/libc/nx/lib_nx_getrectangle.c | 150 ++++++++++++++++++++++++++ nuttx/libc/nx/lib_nx_lower.c | 99 +++++++++++++++++ nuttx/libc/nx/lib_nx_move.c | 115 ++++++++++++++++++++ nuttx/libc/nx/lib_nx_openwindow.c | 132 +++++++++++++++++++++++ nuttx/libc/nx/lib_nx_raise.c | 99 +++++++++++++++++ nuttx/libc/nx/lib_nx_setpixel.c | 118 +++++++++++++++++++++ nuttx/libc/nx/lib_nx_setposition.c | 109 +++++++++++++++++++ nuttx/libc/nx/lib_nx_setsize.c | 109 +++++++++++++++++++ nuttx/libc/nx/lib_nxmu_semtake.c | 87 +++++++++++++++ nuttx/libc/nx/lib_nxmu_sendwindow.c | 115 ++++++++++++++++++++ 33 files changed, 1790 insertions(+), 1711 deletions(-) delete mode 100644 nuttx/graphics/nxmu/nx_bitmap.c delete mode 100644 nuttx/graphics/nxmu/nx_fill.c delete mode 100644 nuttx/graphics/nxmu/nx_filltrapezoid.c delete mode 100644 nuttx/graphics/nxmu/nx_getposition.c delete mode 100644 nuttx/graphics/nxmu/nx_getrectangle.c delete mode 100644 nuttx/graphics/nxmu/nx_lower.c delete mode 100644 nuttx/graphics/nxmu/nx_move.c delete mode 100644 nuttx/graphics/nxmu/nx_openwindow.c delete mode 100644 nuttx/graphics/nxmu/nx_raise.c delete mode 100644 nuttx/graphics/nxmu/nx_setpixel.c delete mode 100644 nuttx/graphics/nxmu/nx_setposition.c delete mode 100644 nuttx/graphics/nxmu/nx_setsize.c delete mode 100644 nuttx/graphics/nxmu/nxmu_semtake.c create mode 100644 nuttx/graphics/nxmu/nxmu_sendclientwindow.c delete mode 100644 nuttx/graphics/nxmu/nxmu_sendwindow.c create mode 100644 nuttx/libc/nx/lib_nx_bitmap.c create mode 100644 nuttx/libc/nx/lib_nx_fill.c create mode 100644 nuttx/libc/nx/lib_nx_filltrapezoid.c create mode 100644 nuttx/libc/nx/lib_nx_getposition.c create mode 100644 nuttx/libc/nx/lib_nx_getrectangle.c create mode 100644 nuttx/libc/nx/lib_nx_lower.c create mode 100644 nuttx/libc/nx/lib_nx_move.c create mode 100644 nuttx/libc/nx/lib_nx_openwindow.c create mode 100644 nuttx/libc/nx/lib_nx_raise.c create mode 100644 nuttx/libc/nx/lib_nx_setpixel.c create mode 100644 nuttx/libc/nx/lib_nx_setposition.c create mode 100644 nuttx/libc/nx/lib_nx_setsize.c create mode 100644 nuttx/libc/nx/lib_nxmu_semtake.c create mode 100644 nuttx/libc/nx/lib_nxmu_sendwindow.c diff --git a/nuttx/graphics/nxmu/Make.defs b/nuttx/graphics/nxmu/Make.defs index 8c75ad6e1..666caeb45 100644 --- a/nuttx/graphics/nxmu/Make.defs +++ b/nuttx/graphics/nxmu/Make.defs @@ -35,14 +35,11 @@ NX_ASRCS = -NXAPI_CSRCS = nx_bitmap.c nx_eventhandler.c nx_eventnotify.c nx_fill.c -NXAPI_CSRCS += nx_filltrapezoid.c nx_getposition.c nx_getrectangle.c -NXAPI_CSRCS += nx_lower.c nx_move.c nx_openwindow.c nx_raise.c -NXAPI_CSRCS += nx_setpixel.c nx_setsize.c nx_setposition.c nx_drawcircle.c -NXAPI_CSRCS += nx_drawline.c nx_fillcircle.c +NXAPI_CSRCS = nx_eventhandler.c nx_eventnotify.c +NXAPI_CSRCS += nx_drawcircle.c nx_drawline.c nx_fillcircle.c NXMU_CSRCS = nxmu_kbdin.c nxmu_mouse.c nxmu_openwindow.c nxmu_redrawreq.c NXMU_CSRCS += nxmu_releasebkgd.c nxmu_requestbkgd.c nxmu_reportposition.c -NXMU_CSRCS += nxmu_sendclient.c nxmu_sendwindow.c nxmu_semtake.c nxmu_server.c +NXMU_CSRCS += nxmu_sendclient.c nxmu_sendclientwindow.c nxmu_server.c NX_CSRCS = $(NXAPI_CSRCS) $(NXMU_CSRCS) diff --git a/nuttx/graphics/nxmu/nx_bitmap.c b/nuttx/graphics/nxmu/nx_bitmap.c deleted file mode 100644 index a0bd748b0..000000000 --- a/nuttx/graphics/nxmu/nx_bitmap.c +++ /dev/null @@ -1,157 +0,0 @@ -/**************************************************************************** - * graphics/nxmu/nx_bitmap.c - * - * Copyright (C) 2008-2009, 2011-2012 Gregory Nutt. All rights reserved. - * Author: Gregory Nutt - * - * 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 - -#include -#include - -#include - -#include "nxbe.h" -#include "nxfe.h" - -/**************************************************************************** - * Pre-Processor Definitions - ****************************************************************************/ - -/**************************************************************************** - * Private Types - ****************************************************************************/ - -/**************************************************************************** - * Private Data - ****************************************************************************/ - -/**************************************************************************** - * Public Data - ****************************************************************************/ - -/**************************************************************************** - * Private Functions - ****************************************************************************/ - -/**************************************************************************** - * Public Functions - ****************************************************************************/ - -/**************************************************************************** - * Name: nx_bitmap - * - * Description: - * Copy a rectangular region of a larger image into the rectangle in the - * specified window. - * - * Input Parameters: - * hwnd - The window that will receive the bitmap image - * dest - Describes the rectangular region 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 - * - ****************************************************************************/ - -int nx_bitmap(NXWINDOW hwnd, FAR const struct nxgl_rect_s *dest, - FAR const void *src[CONFIG_NX_NPLANES], - FAR const struct nxgl_point_s *origin, unsigned int stride) -{ - FAR struct nxbe_window_s *wnd = (FAR struct nxbe_window_s *)hwnd; - struct nxsvrmsg_bitmap_s outmsg; - int i; - int ret; - sem_t sem_done; - -#ifdef CONFIG_DEBUG - if (!wnd || !dest || !src || !origin) - { - errno = EINVAL; - return ERROR; - } -#endif - - /* Format the bitmap command */ - - outmsg.msgid = NX_SVRMSG_BITMAP; - outmsg.wnd = wnd; - outmsg.stride = stride; - - for (i = 0; i < CONFIG_NX_NPLANES; i++) - { - outmsg.src[i] = src[i]; - } - - outmsg.origin.x = origin->x; - outmsg.origin.y = origin->y; - nxgl_rectcopy(&outmsg.dest, dest); - - - /* Create a semaphore for tracking command completion */ - - outmsg.sem_done = &sem_done; - ret = sem_init(&sem_done, 0, 0); - - if (ret != OK) - { - gdbg("sem_init failed: %d\n", errno); - return ret; - } - - /* Forward the fill command to the server */ - - ret = nxmu_sendwindow(wnd, &outmsg, sizeof(struct nxsvrmsg_bitmap_s)); - - /* Wait that the command is completed, so that caller can release the buffer. */ - - if (ret == OK) - { - ret = sem_wait(&sem_done); - } - - /* Destroy the semaphore and return. */ - - sem_destroy(&sem_done); - - return ret; -} diff --git a/nuttx/graphics/nxmu/nx_fill.c b/nuttx/graphics/nxmu/nx_fill.c deleted file mode 100644 index 969acdace..000000000 --- a/nuttx/graphics/nxmu/nx_fill.c +++ /dev/null @@ -1,116 +0,0 @@ -/**************************************************************************** - * graphics/nxmu/nx_fill.c - * - * Copyright (C) 2008-2009, 2011-2012 Gregory Nutt. All rights reserved. - * Author: Gregory Nutt - * - * 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 - -#include -#include -#include - -#include -#include - -#include "nxfe.h" - -/**************************************************************************** - * Pre-Processor Definitions - ****************************************************************************/ - -/**************************************************************************** - * Private Types - ****************************************************************************/ - -/**************************************************************************** - * Private Data - ****************************************************************************/ - -/**************************************************************************** - * Public Data - ****************************************************************************/ - -/**************************************************************************** - * Private Functions - ****************************************************************************/ - -/**************************************************************************** - * Public Functions - ****************************************************************************/ - -/**************************************************************************** - * Name: nx_fill - * - * Description: - * Fill the specified rectangle in the window with the specified color - * - * Input Parameters: - * hwnd - The window handle - * rect - The location to be filled - * color - The color to use in the fill - * - * Return: - * OK on success; ERROR on failure with errno set appropriately - * - ****************************************************************************/ - -int nx_fill(NXWINDOW hwnd, FAR const struct nxgl_rect_s *rect, - nxgl_mxpixel_t color[CONFIG_NX_NPLANES]) -{ - FAR struct nxbe_window_s *wnd = (FAR struct nxbe_window_s *)hwnd; - struct nxsvrmsg_fill_s outmsg; - -#ifdef CONFIG_DEBUG - if (!wnd || !rect || !color) - { - errno = EINVAL; - return ERROR; - } -#endif - - /* Format the fill command */ - - outmsg.msgid = NX_SVRMSG_FILL; - outmsg.wnd = wnd; - - nxgl_rectcopy(&outmsg.rect, rect); - nxgl_colorcopy(outmsg.color, color); - - /* Forward the fill command to the server */ - - return nxmu_sendwindow(wnd, &outmsg, sizeof(struct nxsvrmsg_fill_s)); -} diff --git a/nuttx/graphics/nxmu/nx_filltrapezoid.c b/nuttx/graphics/nxmu/nx_filltrapezoid.c deleted file mode 100644 index bf289179e..000000000 --- a/nuttx/graphics/nxmu/nx_filltrapezoid.c +++ /dev/null @@ -1,142 +0,0 @@ -/**************************************************************************** - * graphics/nxmu/nx_filltrapezoid.c - * - * Copyright (C) 2008-2009, 2011-2012 Gregory Nutt. All rights reserved. - * Author: Gregory Nutt - * - * 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 - -#include -#include -#include -#include - -#include - -#include "nxfe.h" - -/**************************************************************************** - * Pre-Processor Definitions - ****************************************************************************/ - -/**************************************************************************** - * Private Types - ****************************************************************************/ - -/**************************************************************************** - * Private Data - ****************************************************************************/ - -/**************************************************************************** - * Public Data - ****************************************************************************/ - -/**************************************************************************** - * Private Functions - ****************************************************************************/ - -/**************************************************************************** - * Public Functions - ****************************************************************************/ - -/**************************************************************************** - * Name: nx_filltrapezoid - * - * Description: - * Fill the specified trapezoidal region in the window with the specified color - * - * Input Parameters: - * hwnd - The window handle - * clip - Clipping region (may be null) - * trap - The trapezoidal region to be filled - * color - The color to use in the fill - * - * Return: - * OK on success; ERROR on failure with errno set appropriately - * - ****************************************************************************/ - -int nx_filltrapezoid(NXWINDOW hwnd, FAR const struct nxgl_rect_s *clip, - FAR const struct nxgl_trapezoid_s *trap, - nxgl_mxpixel_t color[CONFIG_NX_NPLANES]) -{ - FAR struct nxbe_window_s *wnd = (FAR struct nxbe_window_s *)hwnd; - struct nxsvrmsg_filltrapezoid_s outmsg; - int i; - - /* Some debug-only sanity checks */ - -#ifdef CONFIG_DEBUG - if (!wnd || !trap || !color) - { - errno = EINVAL; - return ERROR; - } -#endif - - /* Format the fill command */ - - outmsg.msgid = NX_SVRMSG_FILLTRAP; - outmsg.wnd = wnd; - - /* If no clipping window was provided, then use the size of the entire window */ - - if (clip) - { - nxgl_rectcopy(&outmsg.clip, clip); - } - else - { - nxgl_rectcopy(&outmsg.clip, &wnd->bounds); - } - - /* Copy the trapezod and the color into the message */ - - nxgl_trapcopy(&outmsg.trap, trap); - -#if CONFIG_NX_NPLANES > 1 - for (i = 0; i < CONFIG_NX_NPLANES; i++) -#else - i = 0; -#endif - { - outmsg.color[i] = color[i]; - } - - /* Forward the trapezoid fill command to the server */ - - return nxmu_sendwindow(wnd, &outmsg, sizeof(struct nxsvrmsg_filltrapezoid_s)); -} diff --git a/nuttx/graphics/nxmu/nx_getposition.c b/nuttx/graphics/nxmu/nx_getposition.c deleted file mode 100644 index 06ad2c6aa..000000000 --- a/nuttx/graphics/nxmu/nx_getposition.c +++ /dev/null @@ -1,114 +0,0 @@ -/**************************************************************************** - * graphics/nxmu/nx_getposition.c - * - * Copyright (C) 2008-2009, 2011-2012 Gregory Nutt. All rights reserved. - * Author: Gregory Nutt - * - * 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 - -#include -#include - -#include -#include "nxfe.h" - -/**************************************************************************** - * Pre-Processor Definitions - ****************************************************************************/ - -/**************************************************************************** - * Private Types - ****************************************************************************/ - -/**************************************************************************** - * Private Data - ****************************************************************************/ - -/**************************************************************************** - * Public Data - ****************************************************************************/ - -/**************************************************************************** - * Private Functions - ****************************************************************************/ - -/**************************************************************************** - * Public Functions - ****************************************************************************/ - -/**************************************************************************** - * Name: nx_getposition - * - * Description: - * Request the position and size information for the selected window. The - * values will be return asynchronously through the client callback function - * pointer. - * - * Input Parameters: - * hwnd - The window handle - * - * Return: - * OK on success; ERROR on failure with errno set appropriately - * - ****************************************************************************/ - -int nx_getposition(NXWINDOW hwnd) -{ - FAR struct nxbe_window_s *wnd = (FAR struct nxbe_window_s *)hwnd; - struct nxsvrmsg_getposition_s outmsg; - -#ifdef CONFIG_DEBUG - if (!wnd) - { - errno = EINVAL; - return ERROR; - } -#endif - - /* Request the size/position info. - * - * It is tempting to just take the positional information from the window - * structure that we have in our hands now. However, we need to run this through - * the server to keep things serialized. There might, for example, be a pending - * size/position change and, in that case, this function would return the - * wrong info. - */ - - outmsg.msgid = NX_SVRMSG_GETPOSITION; - outmsg.wnd = wnd; - - return nxmu_sendwindow(wnd, &outmsg, sizeof(struct nxsvrmsg_getposition_s)); -} diff --git a/nuttx/graphics/nxmu/nx_getrectangle.c b/nuttx/graphics/nxmu/nx_getrectangle.c deleted file mode 100644 index fea01fcd2..000000000 --- a/nuttx/graphics/nxmu/nx_getrectangle.c +++ /dev/null @@ -1,150 +0,0 @@ -/**************************************************************************** - * graphics/nxmu/nx_getrectangle.c - * - * Copyright (C) 2011-2012 Gregory Nutt. All rights reserved. - * Author: Gregory Nutt - * - * 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 - -#include -#include -#include - -#include - -#include "nxfe.h" - -/**************************************************************************** - * Pre-Processor Definitions - ****************************************************************************/ - -/**************************************************************************** - * Private Types - ****************************************************************************/ - -/**************************************************************************** - * Private Data - ****************************************************************************/ - -/**************************************************************************** - * Public Data - ****************************************************************************/ - -/**************************************************************************** - * Private Functions - ****************************************************************************/ - -/**************************************************************************** - * Public Functions - ****************************************************************************/ - -/**************************************************************************** - * Name: nx_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, of the dest memory - * - * Return: - * OK on success; ERROR on failure with errno set appropriately - * - ****************************************************************************/ - -int nx_getrectangle(NXWINDOW hwnd, FAR const struct nxgl_rect_s *rect, - unsigned int plane, FAR uint8_t *dest, - unsigned int deststride) -{ - FAR struct nxbe_window_s *wnd = (FAR struct nxbe_window_s *)hwnd; - struct nxsvrmsg_getrectangle_s outmsg; - int ret; - sem_t sem_done; - -#ifdef CONFIG_DEBUG - if (!hwnd || !rect || !dest) - { - gvdbg("Invalid parameters\n"); - set_errno(EINVAL); - return ERROR; - } -#endif - - /* Format the fill command */ - - outmsg.msgid = NX_SVRMSG_GETRECTANGLE; - outmsg.wnd = wnd; - outmsg.plane = plane; - outmsg.dest = dest; - outmsg.deststride = deststride; - - nxgl_rectcopy(&outmsg.rect, rect); - - /* Create a semaphore for tracking command completion */ - - outmsg.sem_done = &sem_done; - ret = sem_init(&sem_done, 0, 0); - - if (ret != OK) - { - gdbg("sem_init failed: %d\n", errno); - return ret; - } - - /* Forward the fill command to the server */ - - ret = nxmu_sendwindow(wnd, &outmsg, sizeof(struct nxsvrmsg_getrectangle_s)); - - /* Wait that the command is completed, so that caller can release the buffer. */ - - if (ret == OK) - { - ret = sem_wait(&sem_done); - } - - /* Destroy the semaphore and return. */ - - sem_destroy(&sem_done); - - return ret; -} diff --git a/nuttx/graphics/nxmu/nx_lower.c b/nuttx/graphics/nxmu/nx_lower.c deleted file mode 100644 index c9505ca49..000000000 --- a/nuttx/graphics/nxmu/nx_lower.c +++ /dev/null @@ -1,98 +0,0 @@ -/**************************************************************************** - * graphics/nxmu/nx_lower.c - * - * Copyright (C) 2008-2009, 2011-2012 Gregory Nutt. All rights reserved. - * Author: Gregory Nutt - * - * 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 - -#include -#include - -#include -#include "nxfe.h" - -/**************************************************************************** - * Pre-Processor Definitions - ****************************************************************************/ - -/**************************************************************************** - * Private Types - ****************************************************************************/ - -/**************************************************************************** - * Private Data - ****************************************************************************/ - -/**************************************************************************** - * Public Data - ****************************************************************************/ - -/**************************************************************************** - * Private Functions - ****************************************************************************/ - -/**************************************************************************** - * Public Functions - ****************************************************************************/ - -/**************************************************************************** - * Name: nx_raise - * - * Description: - * Lower the specified window to the bottom of the display. - * - * Input parameters: - * hwnd - the window to be lowered - * - * Returned value: - * OK on success; ERROR on failure with errno set appropriately - * - ****************************************************************************/ - -int nx_lower(NXWINDOW hwnd) -{ - FAR struct nxbe_window_s *wnd = (FAR struct nxbe_window_s *)hwnd; - struct nxsvrmsg_lower_s outmsg; - - /* Send the RAISE message */ - - outmsg.msgid = NX_SVRMSG_LOWER; - outmsg.wnd = wnd; - - return nxmu_sendwindow(wnd, &outmsg, sizeof(struct nxsvrmsg_lower_s)); -} - diff --git a/nuttx/graphics/nxmu/nx_move.c b/nuttx/graphics/nxmu/nx_move.c deleted file mode 100644 index c8d4d3dfd..000000000 --- a/nuttx/graphics/nxmu/nx_move.c +++ /dev/null @@ -1,114 +0,0 @@ -/**************************************************************************** - * graphics/nxmu/nx_move.c - * - * Copyright (C) 2008-2009, 2012 Gregory Nutt. All rights reserved. - * Author: Gregory Nutt - * - * 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 - -#include -#include - -#include -#include "nxfe.h" - -/**************************************************************************** - * Pre-Processor Definitions - ****************************************************************************/ - -/**************************************************************************** - * Private Types - ****************************************************************************/ - -/**************************************************************************** - * Private Data - ****************************************************************************/ - -/**************************************************************************** - * Public Data - ****************************************************************************/ - -/**************************************************************************** - * Private Functions - ****************************************************************************/ - -/**************************************************************************** - * Public Functions - ****************************************************************************/ - -/**************************************************************************** - * Name: nx_move - * - * Description: - * Move a rectangular region within the window - * - * Input Parameters: - * hwnd - 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: - * OK on success; ERROR on failure with errno set appropriately - * - ****************************************************************************/ - -int nx_move(NXWINDOW hwnd, FAR const struct nxgl_rect_s *rect, - FAR const struct nxgl_point_s *offset) -{ - FAR struct nxbe_window_s *wnd = (FAR struct nxbe_window_s *)hwnd; - struct nxsvrmsg_move_s outmsg; - -#ifdef CONFIG_DEBUG - if (!wnd) - { - errno = EINVAL; - return ERROR; - } -#endif - - /* Format the fill command */ - - outmsg.msgid = NX_SVRMSG_MOVE; - outmsg.wnd = wnd; - outmsg.offset.x = offset->x; - outmsg.offset.y = offset->y; - - nxgl_rectcopy(&outmsg.rect, rect); - - /* Forward the fill command to the server */ - - return nxmu_sendwindow(wnd, &outmsg, sizeof(struct nxsvrmsg_move_s)); -} diff --git a/nuttx/graphics/nxmu/nx_openwindow.c b/nuttx/graphics/nxmu/nx_openwindow.c deleted file mode 100644 index 2975e365a..000000000 --- a/nuttx/graphics/nxmu/nx_openwindow.c +++ /dev/null @@ -1,131 +0,0 @@ -/**************************************************************************** - * graphics/nxmu/nx_openwindow.c - * - * Copyright (C) 2008-2009, 2011-2012 Gregory Nutt. All rights reserved. - * Author: Gregory Nutt - * - * 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 - -#include -#include - -#include -#include - -#include "nxfe.h" - -/**************************************************************************** - * Pre-Processor Definitions - ****************************************************************************/ - -/**************************************************************************** - * Private Types - ****************************************************************************/ - -/**************************************************************************** - * Private Data - ****************************************************************************/ - -/**************************************************************************** - * Public Data - ****************************************************************************/ - -/**************************************************************************** - * Private Functions - ****************************************************************************/ - -/**************************************************************************** - * Public Functions - ****************************************************************************/ - -/**************************************************************************** - * Name: nx_openwindow - * - * Description: - * Create a new window. - * - * Input Parameters: - * handle - The handle returned by nx_connect - * cb - Callbacks used to process windo events - * arg - User provided value that will be returned with NX callbacks. - * - * Return: - * Success: A non-NULL handle used with subsequent NX accesses - * Failure: NULL is returned and errno is set appropriately - * - ****************************************************************************/ - -NXWINDOW nx_openwindow(NXHANDLE handle, FAR const struct nx_callback_s *cb, - FAR void *arg) -{ - FAR struct nxbe_window_s *wnd; - int ret; - -#ifdef CONFIG_DEBUG - if (!handle || !cb) - { - errno = EINVAL; - return NULL; - } -#endif - - /* Pre-allocate the window structure */ - - wnd = (FAR struct nxbe_window_s *)kzalloc(sizeof(struct nxbe_window_s)); - if (!wnd) - { - errno = ENOMEM; - return NULL; - } - - /* Then let nxfe_constructwindow do the rest */ - - ret = nxfe_constructwindow(handle, wnd, cb, arg); - if (ret < 0) - { - /* An error occurred, the window has been freed */ - - return NULL; - } - - /* Return the uninitialized window reference. Since the server - * serializes all operations, we can be assured that the window will - * be initialized before the first operation on the window. - */ - - return (NXWINDOW)wnd; -} - diff --git a/nuttx/graphics/nxmu/nx_raise.c b/nuttx/graphics/nxmu/nx_raise.c deleted file mode 100644 index 4f51810f1..000000000 --- a/nuttx/graphics/nxmu/nx_raise.c +++ /dev/null @@ -1,98 +0,0 @@ -/**************************************************************************** - * graphics/nxmu/nx_raise.c - * - * Copyright (C) 2008-2009, 2011-2012 Gregory Nutt. All rights reserved. - * Author: Gregory Nutt - * - * 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 - -#include -#include - -#include -#include "nxfe.h" - -/**************************************************************************** - * Pre-Processor Definitions - ****************************************************************************/ - -/**************************************************************************** - * Private Types - ****************************************************************************/ - -/**************************************************************************** - * Private Data - ****************************************************************************/ - -/**************************************************************************** - * Public Data - ****************************************************************************/ - -/**************************************************************************** - * Private Functions - ****************************************************************************/ - -/**************************************************************************** - * Public Functions - ****************************************************************************/ - -/**************************************************************************** - * Name: nx_raise - * - * Description: - * Bring the specified window to the top of the display. - * - * Input parameters: - * hwnd - the window to be raised - * - * Returned value: - * OK on success; ERROR on failure with errno set appropriately - * - ****************************************************************************/ - -int nx_raise(NXWINDOW hwnd) -{ - FAR struct nxbe_window_s *wnd = (FAR struct nxbe_window_s *)hwnd; - struct nxsvrmsg_raise_s outmsg; - - /* Send the RAISE message */ - - outmsg.msgid = NX_SVRMSG_RAISE; - outmsg.wnd = wnd; - - return nxmu_sendwindow(wnd, &outmsg, sizeof(struct nxsvrmsg_raise_s)); -} - diff --git a/nuttx/graphics/nxmu/nx_setpixel.c b/nuttx/graphics/nxmu/nx_setpixel.c deleted file mode 100644 index 57fc12cc6..000000000 --- a/nuttx/graphics/nxmu/nx_setpixel.c +++ /dev/null @@ -1,118 +0,0 @@ -/**************************************************************************** - * graphics/nxmu/nx_setpixel.c - * - * Copyright (C) 2011-2012 Gregory Nutt. All rights reserved. - * Author: Gregory Nutt - * - * 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 - -#include -#include -#include - -#include -#include - -#include "nxfe.h" - -/**************************************************************************** - * Pre-Processor Definitions - ****************************************************************************/ - -/**************************************************************************** - * Private Types - ****************************************************************************/ - -/**************************************************************************** - * Private Data - ****************************************************************************/ - -/**************************************************************************** - * Public Data - ****************************************************************************/ - -/**************************************************************************** - * Private Functions - ****************************************************************************/ - -/**************************************************************************** - * Public Functions - ****************************************************************************/ - -/**************************************************************************** - * Name: nx_setpixel - * - * Description: - * Set a single pixel in the window to the specified color. This is simply - * a degenerate case of nx_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: - * OK on success; ERROR on failure with errno set appropriately - * - ****************************************************************************/ - -int nx_setpixel(NXWINDOW hwnd, FAR const struct nxgl_point_s *pos, - nxgl_mxpixel_t color[CONFIG_NX_NPLANES]) -{ - FAR struct nxbe_window_s *wnd = (FAR struct nxbe_window_s *)hwnd; - struct nxsvrmsg_setpixel_s outmsg; - -#ifdef CONFIG_DEBUG - if (!wnd || !pos || !color) - { - set_errno(EINVAL); - return ERROR; - } -#endif - - /* Format the fill command */ - - outmsg.msgid = NX_SVRMSG_SETPIXEL; - outmsg.wnd = wnd; - outmsg.pos.x = pos->x; - outmsg.pos.y = pos->y; - - nxgl_colorcopy(outmsg.color, color); - - /* Forward the fill command to the server */ - - return nxmu_sendwindow(wnd, &outmsg, sizeof(struct nxsvrmsg_setpixel_s)); -} diff --git a/nuttx/graphics/nxmu/nx_setposition.c b/nuttx/graphics/nxmu/nx_setposition.c deleted file mode 100644 index 75b33757a..000000000 --- a/nuttx/graphics/nxmu/nx_setposition.c +++ /dev/null @@ -1,108 +0,0 @@ -/**************************************************************************** - * graphics/nxmu/nx_setposition.c - * - * Copyright (C) 2008-2009, 2011-2012 Gregory Nutt. All rights reserved. - * Author: Gregory Nutt - * - * 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 - -#include -#include - -#include -#include "nxfe.h" - -/**************************************************************************** - * Pre-Processor Definitions - ****************************************************************************/ - -/**************************************************************************** - * Private Types - ****************************************************************************/ - -/**************************************************************************** - * Private Data - ****************************************************************************/ - -/**************************************************************************** - * Public Data - ****************************************************************************/ - -/**************************************************************************** - * Private Functions - ****************************************************************************/ - -/**************************************************************************** - * Public Functions - ****************************************************************************/ - -/**************************************************************************** - * Name: nx_setposition - * - * Description: - * Set the position and size for the selected window - * - * Input Parameters: - * hwnd - The window handle - * pos - The new position of the window - * - * Return: - * OK on success; ERROR on failure with errno set appropriately - * - ****************************************************************************/ - -int nx_setposition(NXWINDOW hwnd, FAR const struct nxgl_point_s *pos) -{ - FAR struct nxbe_window_s *wnd = (FAR struct nxbe_window_s *)hwnd; - struct nxsvrmsg_setposition_s outmsg; - -#ifdef CONFIG_DEBUG - if (!wnd || !pos) - { - errno = EINVAL; - return ERROR; - } -#endif - - /* Inform the server of the changed position */ - - outmsg.msgid = NX_SVRMSG_SETPOSITION; - outmsg.wnd = wnd; - outmsg.pos.x = pos->x; - outmsg.pos.y = pos->y; - - return nxmu_sendwindow(wnd, &outmsg, sizeof(struct nxsvrmsg_setposition_s)); -} diff --git a/nuttx/graphics/nxmu/nx_setsize.c b/nuttx/graphics/nxmu/nx_setsize.c deleted file mode 100644 index 5f538bccc..000000000 --- a/nuttx/graphics/nxmu/nx_setsize.c +++ /dev/null @@ -1,108 +0,0 @@ -/**************************************************************************** - * graphics/nxmu/nx_setsize.c - * - * Copyright (C) 2008-2009, 2011-2012 Gregory Nutt. All rights reserved. - * Author: Gregory Nutt - * - * 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 - -#include -#include - -#include -#include "nxfe.h" - -/**************************************************************************** - * Pre-Processor Definitions - ****************************************************************************/ - -/**************************************************************************** - * Private Types - ****************************************************************************/ - -/**************************************************************************** - * Private Data - ****************************************************************************/ - -/**************************************************************************** - * Public Data - ****************************************************************************/ - -/**************************************************************************** - * Private Functions - ****************************************************************************/ - -/**************************************************************************** - * Public Functions - ****************************************************************************/ - -/**************************************************************************** - * Name: nx_setsize - * - * Description: - * Set the size of the selected window - * - * Input Parameters: - * hwnd - The window handle - * size - The new size of the window. - * - * Return: - * OK on success; ERROR on failure with errno set appropriately - * - ****************************************************************************/ - -int nx_setsize(NXWINDOW hwnd, FAR const struct nxgl_size_s *size) -{ - FAR struct nxbe_window_s *wnd = (FAR struct nxbe_window_s *)hwnd; - struct nxsvrmsg_setsize_s outmsg; - -#ifdef CONFIG_DEBUG - if (!wnd || !size) - { - errno = EINVAL; - return ERROR; - } -#endif - - /* Then inform the server of the changed position */ - - outmsg.msgid = NX_SVRMSG_SETSIZE; - outmsg.wnd = wnd; - outmsg.size.w = size->w; - outmsg.size.h = size->h; - - return nxmu_sendwindow(wnd, &outmsg, sizeof(struct nxsvrmsg_setsize_s)); -} diff --git a/nuttx/graphics/nxmu/nxfe.h b/nuttx/graphics/nxmu/nxfe.h index a455f478d..34d680b2a 100644 --- a/nuttx/graphics/nxmu/nxfe.h +++ b/nuttx/graphics/nxmu/nxfe.h @@ -55,9 +55,6 @@ /**************************************************************************** * Pre-Processor Definitions ****************************************************************************/ -/* Handy macros */ - -#define nxmu_semgive(sem) sem_post(sem) /* To match nxmu_semtake() */ /**************************************************************************** * Public Types diff --git a/nuttx/graphics/nxmu/nxmu_semtake.c b/nuttx/graphics/nxmu/nxmu_semtake.c deleted file mode 100644 index 164a099b8..000000000 --- a/nuttx/graphics/nxmu/nxmu_semtake.c +++ /dev/null @@ -1,87 +0,0 @@ -/**************************************************************************** - * graphics/nxmu/nxmu_semtake.c - * - * Copyright (C) 2008-2009, 2011 Gregory Nutt. All rights reserved. - * Author: Gregory Nutt - * - * 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 - -#include -#include -#include - -#include -#include "nxfe.h" - -/**************************************************************************** - * Pre-Processor Definitions - ****************************************************************************/ - -/**************************************************************************** - * Private Types - ****************************************************************************/ - -/**************************************************************************** - * Private Data - ****************************************************************************/ - -/**************************************************************************** - * Public Data - ****************************************************************************/ - -/**************************************************************************** - * Private Functions - ****************************************************************************/ - -/**************************************************************************** - * Public Functions - ****************************************************************************/ - -/**************************************************************************** - * Name: nxmu_semtake - ****************************************************************************/ - -void nxmu_semtake(sem_t *sem) -{ - while (sem_wait(sem) != 0) - { - /* The only case that an error should occur here is if the wait was - * awakened by a signal. - */ - - ASSERT(errno == EINTR); - } -} diff --git a/nuttx/graphics/nxmu/nxmu_sendclientwindow.c b/nuttx/graphics/nxmu/nxmu_sendclientwindow.c new file mode 100644 index 000000000..655d815c9 --- /dev/null +++ b/nuttx/graphics/nxmu/nxmu_sendclientwindow.c @@ -0,0 +1,113 @@ +/**************************************************************************** + * graphics/nxmu/nxmu_sendclientwindow.c + * + * Copyright (C) 2012-2013 Gregory Nutt. All rights reserved. + * Author: Gregory Nutt + * + * 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 + +#include +#include +#include + +#include "nxfe.h" + +/**************************************************************************** + * Pre-Processor Definitions + ****************************************************************************/ + +/**************************************************************************** + * Private Types + ****************************************************************************/ + +/**************************************************************************** + * Private Data + ****************************************************************************/ + +/**************************************************************************** + * Public Data + ****************************************************************************/ + +/**************************************************************************** + * Private Functions + ****************************************************************************/ + +/**************************************************************************** + * Public Functions + ****************************************************************************/ + +/**************************************************************************** + * Name: nxmu_sendclientwindow + * + * Description: + * Send a message to the client at NX_CLIMSG_PRIO priority + * + * Input Parameters: + * wnd - A pointer to the back-end window structure + * msg - A pointer to the message to send + * msglen - The length of the message in bytes. + * + * Return: + * OK on success; ERROR on failure with errno set appropriately + * + ****************************************************************************/ + +int nxmu_sendclientwindow(FAR struct nxbe_window_s *wnd, FAR const void *msg, + size_t msglen) +{ + int ret = OK; + + /* Sanity checking */ + +#ifdef CONFIG_DEBUG + if (!wnd || !wnd->conn) + { + set_errno(EINVAL); + return ERROR; + } +#endif + + /* Ignore messages destined to a blocked window (no errors reported) */ + + if (!NXBE_ISBLOCKED(wnd)) + { + /* Send the message to the server */ + + ret = nxmu_sendclient(wnd->conn, msg, msglen); + } + + return ret; +} diff --git a/nuttx/graphics/nxmu/nxmu_sendwindow.c b/nuttx/graphics/nxmu/nxmu_sendwindow.c deleted file mode 100644 index 57fdd6b77..000000000 --- a/nuttx/graphics/nxmu/nxmu_sendwindow.c +++ /dev/null @@ -1,158 +0,0 @@ -/**************************************************************************** - * graphics/nxmu/nxmu_sendserver.c - * - * Copyright (C) 2012 Gregory Nutt. All rights reserved. - * Author: Gregory Nutt - * - * 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 - -#include -#include -#include - -#include "nxfe.h" - -/**************************************************************************** - * Pre-Processor Definitions - ****************************************************************************/ - -/**************************************************************************** - * Private Types - ****************************************************************************/ - -/**************************************************************************** - * Private Data - ****************************************************************************/ - -/**************************************************************************** - * Public Data - ****************************************************************************/ - -/**************************************************************************** - * Private Functions - ****************************************************************************/ - -/**************************************************************************** - * Public Functions - ****************************************************************************/ - -/**************************************************************************** - * Name: nxmu_sendwindow - * - * Description: - * Send a message to the server destined for a specific window at - * NX_SVRMSG_PRIO priority - * - * Input Parameters: - * wnd - A pointer to the back-end window structure - * msg - A pointer to the message to send - * msglen - The length of the message in bytes. - * - * Return: - * OK on success; ERROR on failure with errno set appropriately - * - ****************************************************************************/ - -int nxmu_sendwindow(FAR struct nxbe_window_s *wnd, FAR const void *msg, - size_t msglen) -{ - int ret = OK; - - /* Sanity checking */ - -#ifdef CONFIG_DEBUG - if (!wnd || !wnd->conn) - { - errno = EINVAL; - return ERROR; - } -#endif - - /* Ignore messages destined to a blocked window (no errors reported) */ - - if (!NXBE_ISBLOCKED(wnd)) - { - /* Send the message to the server */ - - ret = nxmu_sendserver(wnd->conn, msg, msglen); - } - - return ret; -} - -/**************************************************************************** - * Name: nxmu_sendclientwindow - * - * Description: - * Send a message to the client at NX_CLIMSG_PRIO priority - * - * Input Parameters: - * wnd - A pointer to the back-end window structure - * msg - A pointer to the message to send - * msglen - The length of the message in bytes. - * - * Return: - * OK on success; ERROR on failure with errno set appropriately - * - ****************************************************************************/ - -int nxmu_sendclientwindow(FAR struct nxbe_window_s *wnd, FAR const void *msg, - size_t msglen) -{ - int ret = OK; - - /* Sanity checking */ - -#ifdef CONFIG_DEBUG - if (!wnd || !wnd->conn) - { - errno = EINVAL; - return ERROR; - } -#endif - - /* Ignore messages destined to a blocked window (no errors reported) */ - - if (!NXBE_ISBLOCKED(wnd)) - { - /* Send the message to the server */ - - ret = nxmu_sendclient(wnd->conn, msg, msglen); - } - - return ret; -} - diff --git a/nuttx/include/nuttx/nx/nxmu.h b/nuttx/include/nuttx/nx/nxmu.h index 55c33c612..a6a7ac145 100644 --- a/nuttx/include/nuttx/nx/nxmu.h +++ b/nuttx/include/nuttx/nx/nxmu.h @@ -83,6 +83,10 @@ #define NX_CLIMSG_PRIO 42 #define NX_SVRMSG_PRIO 42 +/* Handy macros */ + +#define nxmu_semgive(sem) sem_post(sem) /* To match nxmu_semtake() */ + /**************************************************************************** * Public Types ****************************************************************************/ diff --git a/nuttx/libc/nx/Make.defs b/nuttx/libc/nx/Make.defs index 57f97f65a..8ac8adb48 100644 --- a/nuttx/libc/nx/Make.defs +++ b/nuttx/libc/nx/Make.defs @@ -42,10 +42,15 @@ ifeq ($(CONFIG_NX),y) # build (single use mode cannot be used with the kernel build) ifeq ($(CONFIG_NX_MULTIUSER),y) -CSRCS += lib_nxmu_sendserver.c lib_nx_connect.c lib_nx_disconnect.c lib_nx_block.c +CSRCS += lib_nxmu_sendserver.c lib_nx_connect.c lib_nx_disconnect.c +CSRCS += lib_nxmu_semtake.c lib_nx_block.c CSRCS += lib_nx_kbdchin.c lib_nx_kbdin.c lib_nx_mousein.c -CSRCS += lib_nx_closewindow.c lib_nxmu_constructwindow.c lib_nx_releasebkgd.c -CSRCS += lib_nx_requestbkgd.c lib_nx_setbgcolor.c +CSRCS += lib_nx_releasebkgd.c lib_nx_requestbkgd.c lib_nx_setbgcolor.c + +CSRCS += lib_nxmu_sendwindow.c lib_nx_closewindow.c lib_nxmu_constructwindow.c +CSRCS += lib_nx_bitmap.c lib_nx_fill.c lib_nx_filltrapezoid.c lib_nx_getposition.c +CSRCS += lib_nx_getrectangle.c lib_nx_lower.c lib_nx_move.c lib_nx_openwindow.c +CSRCS += lib_nx_raise.c lib_nx_setpixel.c lib_nx_setposition.c lib_nx_setsize.c endif # Add the nx/ directory to the build diff --git a/nuttx/libc/nx/lib_nx_bitmap.c b/nuttx/libc/nx/lib_nx_bitmap.c new file mode 100644 index 000000000..fdd0b9717 --- /dev/null +++ b/nuttx/libc/nx/lib_nx_bitmap.c @@ -0,0 +1,156 @@ +/**************************************************************************** + * libc/nx/lib_nx_bitmap.c + * + * Copyright (C) 2008-2009, 2011-2013 Gregory Nutt. All rights reserved. + * Author: Gregory Nutt + * + * 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 + +#include +#include + +#include +#include +#include + +/**************************************************************************** + * Pre-Processor Definitions + ****************************************************************************/ + +/**************************************************************************** + * Private Types + ****************************************************************************/ + +/**************************************************************************** + * Private Data + ****************************************************************************/ + +/**************************************************************************** + * Public Data + ****************************************************************************/ + +/**************************************************************************** + * Private Functions + ****************************************************************************/ + +/**************************************************************************** + * Public Functions + ****************************************************************************/ + +/**************************************************************************** + * Name: nx_bitmap + * + * Description: + * Copy a rectangular region of a larger image into the rectangle in the + * specified window. + * + * Input Parameters: + * hwnd - The window that will receive the bitmap image + * dest - Describes the rectangular region 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 + * + ****************************************************************************/ + +int nx_bitmap(NXWINDOW hwnd, FAR const struct nxgl_rect_s *dest, + FAR const void *src[CONFIG_NX_NPLANES], + FAR const struct nxgl_point_s *origin, unsigned int stride) +{ + FAR struct nxbe_window_s *wnd = (FAR struct nxbe_window_s *)hwnd; + struct nxsvrmsg_bitmap_s outmsg; + int i; + int ret; + sem_t sem_done; + +#ifdef CONFIG_DEBUG + if (!wnd || !dest || !src || !origin) + { + set_errno(EINVAL); + return ERROR; + } +#endif + + /* Format the bitmap command */ + + outmsg.msgid = NX_SVRMSG_BITMAP; + outmsg.wnd = wnd; + outmsg.stride = stride; + + for (i = 0; i < CONFIG_NX_NPLANES; i++) + { + outmsg.src[i] = src[i]; + } + + outmsg.origin.x = origin->x; + outmsg.origin.y = origin->y; + nxgl_rectcopy(&outmsg.dest, dest); + + + /* Create a semaphore for tracking command completion */ + + outmsg.sem_done = &sem_done; + ret = sem_init(&sem_done, 0, 0); + + if (ret != OK) + { + gdbg("sem_init failed: %d\n", errno); + return ret; + } + + /* Forward the fill command to the server */ + + ret = nxmu_sendwindow(wnd, &outmsg, sizeof(struct nxsvrmsg_bitmap_s)); + + /* Wait that the command is completed, so that caller can release the buffer. */ + + if (ret == OK) + { + ret = sem_wait(&sem_done); + } + + /* Destroy the semaphore and return. */ + + sem_destroy(&sem_done); + + return ret; +} diff --git a/nuttx/libc/nx/lib_nx_fill.c b/nuttx/libc/nx/lib_nx_fill.c new file mode 100644 index 000000000..bc0307622 --- /dev/null +++ b/nuttx/libc/nx/lib_nx_fill.c @@ -0,0 +1,116 @@ +/**************************************************************************** + * libc/nx/lib_nx_fill.c + * + * Copyright (C) 2008-2009, 2011-2013 Gregory Nutt. All rights reserved. + * Author: Gregory Nutt + * + * 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 + +#include +#include +#include + +#include +#include +#include +#include + +/**************************************************************************** + * Pre-Processor Definitions + ****************************************************************************/ + +/**************************************************************************** + * Private Types + ****************************************************************************/ + +/**************************************************************************** + * Private Data + ****************************************************************************/ + +/**************************************************************************** + * Public Data + ****************************************************************************/ + +/**************************************************************************** + * Private Functions + ****************************************************************************/ + +/**************************************************************************** + * Public Functions + ****************************************************************************/ + +/**************************************************************************** + * Name: nx_fill + * + * Description: + * Fill the specified rectangle in the window with the specified color + * + * Input Parameters: + * hwnd - The window handle + * rect - The location to be filled + * color - The color to use in the fill + * + * Return: + * OK on success; ERROR on failure with errno set appropriately + * + ****************************************************************************/ + +int nx_fill(NXWINDOW hwnd, FAR const struct nxgl_rect_s *rect, + nxgl_mxpixel_t color[CONFIG_NX_NPLANES]) +{ + FAR struct nxbe_window_s *wnd = (FAR struct nxbe_window_s *)hwnd; + struct nxsvrmsg_fill_s outmsg; + +#ifdef CONFIG_DEBUG + if (!wnd || !rect || !color) + { + set_errno(EINVAL); + return ERROR; + } +#endif + + /* Format the fill command */ + + outmsg.msgid = NX_SVRMSG_FILL; + outmsg.wnd = wnd; + + nxgl_rectcopy(&outmsg.rect, rect); + nxgl_colorcopy(outmsg.color, color); + + /* Forward the fill command to the server */ + + return nxmu_sendwindow(wnd, &outmsg, sizeof(struct nxsvrmsg_fill_s)); +} diff --git a/nuttx/libc/nx/lib_nx_filltrapezoid.c b/nuttx/libc/nx/lib_nx_filltrapezoid.c new file mode 100644 index 000000000..0d6b826ec --- /dev/null +++ b/nuttx/libc/nx/lib_nx_filltrapezoid.c @@ -0,0 +1,142 @@ +/**************************************************************************** + * libc/nx/lib_nx_filltrapezoid.c + * + * Copyright (C) 2008-2009, 2011-2013 Gregory Nutt. All rights reserved. + * Author: Gregory Nutt + * + * 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 + +#include +#include +#include +#include + +#include +#include +#include + +/**************************************************************************** + * Pre-Processor Definitions + ****************************************************************************/ + +/**************************************************************************** + * Private Types + ****************************************************************************/ + +/**************************************************************************** + * Private Data + ****************************************************************************/ + +/**************************************************************************** + * Public Data + ****************************************************************************/ + +/**************************************************************************** + * Private Functions + ****************************************************************************/ + +/**************************************************************************** + * Public Functions + ****************************************************************************/ + +/**************************************************************************** + * Name: nx_filltrapezoid + * + * Description: + * Fill the specified trapezoidal region in the window with the specified color + * + * Input Parameters: + * hwnd - The window handle + * clip - Clipping region (may be null) + * trap - The trapezoidal region to be filled + * color - The color to use in the fill + * + * Return: + * OK on success; ERROR on failure with errno set appropriately + * + ****************************************************************************/ + +int nx_filltrapezoid(NXWINDOW hwnd, FAR const struct nxgl_rect_s *clip, + FAR const struct nxgl_trapezoid_s *trap, + nxgl_mxpixel_t color[CONFIG_NX_NPLANES]) +{ + FAR struct nxbe_window_s *wnd = (FAR struct nxbe_window_s *)hwnd; + struct nxsvrmsg_filltrapezoid_s outmsg; + int i; + + /* Some debug-only sanity checks */ + +#ifdef CONFIG_DEBUG + if (!wnd || !trap || !color) + { + set_errno(EINVAL); + return ERROR; + } +#endif + + /* Format the fill command */ + + outmsg.msgid = NX_SVRMSG_FILLTRAP; + outmsg.wnd = wnd; + + /* If no clipping window was provided, then use the size of the entire window */ + + if (clip) + { + nxgl_rectcopy(&outmsg.clip, clip); + } + else + { + nxgl_rectcopy(&outmsg.clip, &wnd->bounds); + } + + /* Copy the trapezod and the color into the message */ + + nxgl_trapcopy(&outmsg.trap, trap); + +#if CONFIG_NX_NPLANES > 1 + for (i = 0; i < CONFIG_NX_NPLANES; i++) +#else + i = 0; +#endif + { + outmsg.color[i] = color[i]; + } + + /* Forward the trapezoid fill command to the server */ + + return nxmu_sendwindow(wnd, &outmsg, sizeof(struct nxsvrmsg_filltrapezoid_s)); +} diff --git a/nuttx/libc/nx/lib_nx_getposition.c b/nuttx/libc/nx/lib_nx_getposition.c new file mode 100644 index 000000000..4a0ae30b9 --- /dev/null +++ b/nuttx/libc/nx/lib_nx_getposition.c @@ -0,0 +1,115 @@ +/**************************************************************************** + * libc/nx/lib_nx_getposition.c + * + * Copyright (C) 2008-2009, 2011-2013 Gregory Nutt. All rights reserved. + * Author: Gregory Nutt + * + * 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 + +#include +#include + +#include +#include +#include + +/**************************************************************************** + * Pre-Processor Definitions + ****************************************************************************/ + +/**************************************************************************** + * Private Types + ****************************************************************************/ + +/**************************************************************************** + * Private Data + ****************************************************************************/ + +/**************************************************************************** + * Public Data + ****************************************************************************/ + +/**************************************************************************** + * Private Functions + ****************************************************************************/ + +/**************************************************************************** + * Public Functions + ****************************************************************************/ + +/**************************************************************************** + * Name: nx_getposition + * + * Description: + * Request the position and size information for the selected window. The + * values will be return asynchronously through the client callback function + * pointer. + * + * Input Parameters: + * hwnd - The window handle + * + * Return: + * OK on success; ERROR on failure with errno set appropriately + * + ****************************************************************************/ + +int nx_getposition(NXWINDOW hwnd) +{ + FAR struct nxbe_window_s *wnd = (FAR struct nxbe_window_s *)hwnd; + struct nxsvrmsg_getposition_s outmsg; + +#ifdef CONFIG_DEBUG + if (!wnd) + { + set_errno(EINVAL); + return ERROR; + } +#endif + + /* Request the size/position info. + * + * It is tempting to just take the positional information from the window + * structure that we have in our hands now. However, we need to run this through + * the server to keep things serialized. There might, for example, be a pending + * size/position change and, in that case, this function would return the + * wrong info. + */ + + outmsg.msgid = NX_SVRMSG_GETPOSITION; + outmsg.wnd = wnd; + + return nxmu_sendwindow(wnd, &outmsg, sizeof(struct nxsvrmsg_getposition_s)); +} diff --git a/nuttx/libc/nx/lib_nx_getrectangle.c b/nuttx/libc/nx/lib_nx_getrectangle.c new file mode 100644 index 000000000..e815e5a17 --- /dev/null +++ b/nuttx/libc/nx/lib_nx_getrectangle.c @@ -0,0 +1,150 @@ +/**************************************************************************** + * libc/nx/lib_nx_getrectangle.c + * + * Copyright (C) 2011-2013 Gregory Nutt. All rights reserved. + * Author: Gregory Nutt + * + * 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 + +#include +#include +#include + +#include +#include +#include + +/**************************************************************************** + * Pre-Processor Definitions + ****************************************************************************/ + +/**************************************************************************** + * Private Types + ****************************************************************************/ + +/**************************************************************************** + * Private Data + ****************************************************************************/ + +/**************************************************************************** + * Public Data + ****************************************************************************/ + +/**************************************************************************** + * Private Functions + ****************************************************************************/ + +/**************************************************************************** + * Public Functions + ****************************************************************************/ + +/**************************************************************************** + * Name: nx_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, of the dest memory + * + * Return: + * OK on success; ERROR on failure with errno set appropriately + * + ****************************************************************************/ + +int nx_getrectangle(NXWINDOW hwnd, FAR const struct nxgl_rect_s *rect, + unsigned int plane, FAR uint8_t *dest, + unsigned int deststride) +{ + FAR struct nxbe_window_s *wnd = (FAR struct nxbe_window_s *)hwnd; + struct nxsvrmsg_getrectangle_s outmsg; + int ret; + sem_t sem_done; + +#ifdef CONFIG_DEBUG + if (!hwnd || !rect || !dest) + { + gvdbg("Invalid parameters\n"); + set_errno(EINVAL); + return ERROR; + } +#endif + + /* Format the fill command */ + + outmsg.msgid = NX_SVRMSG_GETRECTANGLE; + outmsg.wnd = wnd; + outmsg.plane = plane; + outmsg.dest = dest; + outmsg.deststride = deststride; + + nxgl_rectcopy(&outmsg.rect, rect); + + /* Create a semaphore for tracking command completion */ + + outmsg.sem_done = &sem_done; + ret = sem_init(&sem_done, 0, 0); + + if (ret != OK) + { + gdbg("sem_init failed: %d\n", errno); + return ret; + } + + /* Forward the fill command to the server */ + + ret = nxmu_sendwindow(wnd, &outmsg, sizeof(struct nxsvrmsg_getrectangle_s)); + + /* Wait that the command is completed, so that caller can release the buffer. */ + + if (ret == OK) + { + ret = sem_wait(&sem_done); + } + + /* Destroy the semaphore and return. */ + + sem_destroy(&sem_done); + + return ret; +} diff --git a/nuttx/libc/nx/lib_nx_lower.c b/nuttx/libc/nx/lib_nx_lower.c new file mode 100644 index 000000000..64a8b5848 --- /dev/null +++ b/nuttx/libc/nx/lib_nx_lower.c @@ -0,0 +1,99 @@ +/**************************************************************************** + * libc/nx/lib_nx_lower.c + * + * Copyright (C) 2008-2009, 2011-2013 Gregory Nutt. All rights reserved. + * Author: Gregory Nutt + * + * 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 + +#include +#include + +#include +#include +#include + +/**************************************************************************** + * Pre-Processor Definitions + ****************************************************************************/ + +/**************************************************************************** + * Private Types + ****************************************************************************/ + +/**************************************************************************** + * Private Data + ****************************************************************************/ + +/**************************************************************************** + * Public Data + ****************************************************************************/ + +/**************************************************************************** + * Private Functions + ****************************************************************************/ + +/**************************************************************************** + * Public Functions + ****************************************************************************/ + +/**************************************************************************** + * Name: nx_raise + * + * Description: + * Lower the specified window to the bottom of the display. + * + * Input parameters: + * hwnd - the window to be lowered + * + * Returned value: + * OK on success; ERROR on failure with errno set appropriately + * + ****************************************************************************/ + +int nx_lower(NXWINDOW hwnd) +{ + FAR struct nxbe_window_s *wnd = (FAR struct nxbe_window_s *)hwnd; + struct nxsvrmsg_lower_s outmsg; + + /* Send the RAISE message */ + + outmsg.msgid = NX_SVRMSG_LOWER; + outmsg.wnd = wnd; + + return nxmu_sendwindow(wnd, &outmsg, sizeof(struct nxsvrmsg_lower_s)); +} + diff --git a/nuttx/libc/nx/lib_nx_move.c b/nuttx/libc/nx/lib_nx_move.c new file mode 100644 index 000000000..30ab33259 --- /dev/null +++ b/nuttx/libc/nx/lib_nx_move.c @@ -0,0 +1,115 @@ +/**************************************************************************** + * libc/nx/lib_nx_move.c + * + * Copyright (C) 2008-2009, 2012-2013 Gregory Nutt. All rights reserved. + * Author: Gregory Nutt + * + * 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 + +#include +#include + +#include +#include +#include + +/**************************************************************************** + * Pre-Processor Definitions + ****************************************************************************/ + +/**************************************************************************** + * Private Types + ****************************************************************************/ + +/**************************************************************************** + * Private Data + ****************************************************************************/ + +/**************************************************************************** + * Public Data + ****************************************************************************/ + +/**************************************************************************** + * Private Functions + ****************************************************************************/ + +/**************************************************************************** + * Public Functions + ****************************************************************************/ + +/**************************************************************************** + * Name: nx_move + * + * Description: + * Move a rectangular region within the window + * + * Input Parameters: + * hwnd - 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: + * OK on success; ERROR on failure with errno set appropriately + * + ****************************************************************************/ + +int nx_move(NXWINDOW hwnd, FAR const struct nxgl_rect_s *rect, + FAR const struct nxgl_point_s *offset) +{ + FAR struct nxbe_window_s *wnd = (FAR struct nxbe_window_s *)hwnd; + struct nxsvrmsg_move_s outmsg; + +#ifdef CONFIG_DEBUG + if (!wnd) + { + set_errno(EINVAL); + return ERROR; + } +#endif + + /* Format the fill command */ + + outmsg.msgid = NX_SVRMSG_MOVE; + outmsg.wnd = wnd; + outmsg.offset.x = offset->x; + outmsg.offset.y = offset->y; + + nxgl_rectcopy(&outmsg.rect, rect); + + /* Forward the fill command to the server */ + + return nxmu_sendwindow(wnd, &outmsg, sizeof(struct nxsvrmsg_move_s)); +} diff --git a/nuttx/libc/nx/lib_nx_openwindow.c b/nuttx/libc/nx/lib_nx_openwindow.c new file mode 100644 index 000000000..a663b6493 --- /dev/null +++ b/nuttx/libc/nx/lib_nx_openwindow.c @@ -0,0 +1,132 @@ +/**************************************************************************** + * libc/nx/lib_nx_openwindow.c + * + * Copyright (C) 2008-2009, 2011-2013 Gregory Nutt. All rights reserved. + * Author: Gregory Nutt + * + * 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 + +#include +#include + +#include +#include +#include + +#include "lib_internal.h" + +/**************************************************************************** + * Pre-Processor Definitions + ****************************************************************************/ + +/**************************************************************************** + * Private Types + ****************************************************************************/ + +/**************************************************************************** + * Private Data + ****************************************************************************/ + +/**************************************************************************** + * Public Data + ****************************************************************************/ + +/**************************************************************************** + * Private Functions + ****************************************************************************/ + +/**************************************************************************** + * Public Functions + ****************************************************************************/ + +/**************************************************************************** + * Name: nx_openwindow + * + * Description: + * Create a new window. + * + * Input Parameters: + * handle - The handle returned by nx_connect + * cb - Callbacks used to process windo events + * arg - User provided value that will be returned with NX callbacks. + * + * Return: + * Success: A non-NULL handle used with subsequent NX accesses + * Failure: NULL is returned and errno is set appropriately + * + ****************************************************************************/ + +NXWINDOW nx_openwindow(NXHANDLE handle, FAR const struct nx_callback_s *cb, + FAR void *arg) +{ + FAR struct nxbe_window_s *wnd; + int ret; + +#ifdef CONFIG_DEBUG + if (!handle || !cb) + { + set_errno(EINVAL); + return NULL; + } +#endif + + /* Pre-allocate the window structure */ + + wnd = (FAR struct nxbe_window_s *)lib_zalloc(sizeof(struct nxbe_window_s)); + if (!wnd) + { + set_errno(ENOMEM); + return NULL; + } + + /* Then let nxfe_constructwindow do the rest */ + + ret = nxfe_constructwindow(handle, wnd, cb, arg); + if (ret < 0) + { + /* An error occurred, the window has been freed */ + + return NULL; + } + + /* Return the uninitialized window reference. Since the server + * serializes all operations, we can be assured that the window will + * be initialized before the first operation on the window. + */ + + return (NXWINDOW)wnd; +} + diff --git a/nuttx/libc/nx/lib_nx_raise.c b/nuttx/libc/nx/lib_nx_raise.c new file mode 100644 index 000000000..6f35fc7cd --- /dev/null +++ b/nuttx/libc/nx/lib_nx_raise.c @@ -0,0 +1,99 @@ +/**************************************************************************** + * libc/nx/lib_nx_raise.c + * + * Copyright (C) 2008-2009, 2011-2013 Gregory Nutt. All rights reserved. + * Author: Gregory Nutt + * + * 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 + +#include +#include + +#include +#include +#include + +/**************************************************************************** + * Pre-Processor Definitions + ****************************************************************************/ + +/**************************************************************************** + * Private Types + ****************************************************************************/ + +/**************************************************************************** + * Private Data + ****************************************************************************/ + +/**************************************************************************** + * Public Data + ****************************************************************************/ + +/**************************************************************************** + * Private Functions + ****************************************************************************/ + +/**************************************************************************** + * Public Functions + ****************************************************************************/ + +/**************************************************************************** + * Name: nx_raise + * + * Description: + * Bring the specified window to the top of the display. + * + * Input parameters: + * hwnd - the window to be raised + * + * Returned value: + * OK on success; ERROR on failure with errno set appropriately + * + ****************************************************************************/ + +int nx_raise(NXWINDOW hwnd) +{ + FAR struct nxbe_window_s *wnd = (FAR struct nxbe_window_s *)hwnd; + struct nxsvrmsg_raise_s outmsg; + + /* Send the RAISE message */ + + outmsg.msgid = NX_SVRMSG_RAISE; + outmsg.wnd = wnd; + + return nxmu_sendwindow(wnd, &outmsg, sizeof(struct nxsvrmsg_raise_s)); +} + diff --git a/nuttx/libc/nx/lib_nx_setpixel.c b/nuttx/libc/nx/lib_nx_setpixel.c new file mode 100644 index 000000000..7712f034f --- /dev/null +++ b/nuttx/libc/nx/lib_nx_setpixel.c @@ -0,0 +1,118 @@ +/**************************************************************************** + * libc/nx/lib_nx_setpixel.c + * + * Copyright (C) 2011-2013 Gregory Nutt. All rights reserved. + * Author: Gregory Nutt + * + * 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 + +#include +#include +#include + +#include +#include +#include +#include + +/**************************************************************************** + * Pre-Processor Definitions + ****************************************************************************/ + +/**************************************************************************** + * Private Types + ****************************************************************************/ + +/**************************************************************************** + * Private Data + ****************************************************************************/ + +/**************************************************************************** + * Public Data + ****************************************************************************/ + +/**************************************************************************** + * Private Functions + ****************************************************************************/ + +/**************************************************************************** + * Public Functions + ****************************************************************************/ + +/**************************************************************************** + * Name: nx_setpixel + * + * Description: + * Set a single pixel in the window to the specified color. This is simply + * a degenerate case of nx_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: + * OK on success; ERROR on failure with errno set appropriately + * + ****************************************************************************/ + +int nx_setpixel(NXWINDOW hwnd, FAR const struct nxgl_point_s *pos, + nxgl_mxpixel_t color[CONFIG_NX_NPLANES]) +{ + FAR struct nxbe_window_s *wnd = (FAR struct nxbe_window_s *)hwnd; + struct nxsvrmsg_setpixel_s outmsg; + +#ifdef CONFIG_DEBUG + if (!wnd || !pos || !color) + { + set_errno(EINVAL); + return ERROR; + } +#endif + + /* Format the fill command */ + + outmsg.msgid = NX_SVRMSG_SETPIXEL; + outmsg.wnd = wnd; + outmsg.pos.x = pos->x; + outmsg.pos.y = pos->y; + + nxgl_colorcopy(outmsg.color, color); + + /* Forward the fill command to the server */ + + return nxmu_sendwindow(wnd, &outmsg, sizeof(struct nxsvrmsg_setpixel_s)); +} diff --git a/nuttx/libc/nx/lib_nx_setposition.c b/nuttx/libc/nx/lib_nx_setposition.c new file mode 100644 index 000000000..d83da41a7 --- /dev/null +++ b/nuttx/libc/nx/lib_nx_setposition.c @@ -0,0 +1,109 @@ +/**************************************************************************** + * libc/nx/lib_nx_setposition.c + * + * Copyright (C) 2008-2009, 2011-2013 Gregory Nutt. All rights reserved. + * Author: Gregory Nutt + * + * 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 + +#include +#include + +#include +#include +#include + +/**************************************************************************** + * Pre-Processor Definitions + ****************************************************************************/ + +/**************************************************************************** + * Private Types + ****************************************************************************/ + +/**************************************************************************** + * Private Data + ****************************************************************************/ + +/**************************************************************************** + * Public Data + ****************************************************************************/ + +/**************************************************************************** + * Private Functions + ****************************************************************************/ + +/**************************************************************************** + * Public Functions + ****************************************************************************/ + +/**************************************************************************** + * Name: nx_setposition + * + * Description: + * Set the position and size for the selected window + * + * Input Parameters: + * hwnd - The window handle + * pos - The new position of the window + * + * Return: + * OK on success; ERROR on failure with errno set appropriately + * + ****************************************************************************/ + +int nx_setposition(NXWINDOW hwnd, FAR const struct nxgl_point_s *pos) +{ + FAR struct nxbe_window_s *wnd = (FAR struct nxbe_window_s *)hwnd; + struct nxsvrmsg_setposition_s outmsg; + +#ifdef CONFIG_DEBUG + if (!wnd || !pos) + { + set_errno(EINVAL); + return ERROR; + } +#endif + + /* Inform the server of the changed position */ + + outmsg.msgid = NX_SVRMSG_SETPOSITION; + outmsg.wnd = wnd; + outmsg.pos.x = pos->x; + outmsg.pos.y = pos->y; + + return nxmu_sendwindow(wnd, &outmsg, sizeof(struct nxsvrmsg_setposition_s)); +} diff --git a/nuttx/libc/nx/lib_nx_setsize.c b/nuttx/libc/nx/lib_nx_setsize.c new file mode 100644 index 000000000..860d5bd1e --- /dev/null +++ b/nuttx/libc/nx/lib_nx_setsize.c @@ -0,0 +1,109 @@ +/**************************************************************************** + * libc/nx/lib_nx_setsize.c + * + * Copyright (C) 2008-2009, 2011-2013 Gregory Nutt. All rights reserved. + * Author: Gregory Nutt + * + * 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 + +#include +#include + +#include +#include +#include + +/**************************************************************************** + * Pre-Processor Definitions + ****************************************************************************/ + +/**************************************************************************** + * Private Types + ****************************************************************************/ + +/**************************************************************************** + * Private Data + ****************************************************************************/ + +/**************************************************************************** + * Public Data + ****************************************************************************/ + +/**************************************************************************** + * Private Functions + ****************************************************************************/ + +/**************************************************************************** + * Public Functions + ****************************************************************************/ + +/**************************************************************************** + * Name: nx_setsize + * + * Description: + * Set the size of the selected window + * + * Input Parameters: + * hwnd - The window handle + * size - The new size of the window. + * + * Return: + * OK on success; ERROR on failure with errno set appropriately + * + ****************************************************************************/ + +int nx_setsize(NXWINDOW hwnd, FAR const struct nxgl_size_s *size) +{ + FAR struct nxbe_window_s *wnd = (FAR struct nxbe_window_s *)hwnd; + struct nxsvrmsg_setsize_s outmsg; + +#ifdef CONFIG_DEBUG + if (!wnd || !size) + { + set_errno(EINVAL); + return ERROR; + } +#endif + + /* Then inform the server of the changed position */ + + outmsg.msgid = NX_SVRMSG_SETSIZE; + outmsg.wnd = wnd; + outmsg.size.w = size->w; + outmsg.size.h = size->h; + + return nxmu_sendwindow(wnd, &outmsg, sizeof(struct nxsvrmsg_setsize_s)); +} diff --git a/nuttx/libc/nx/lib_nxmu_semtake.c b/nuttx/libc/nx/lib_nxmu_semtake.c new file mode 100644 index 000000000..2d5ad181d --- /dev/null +++ b/nuttx/libc/nx/lib_nxmu_semtake.c @@ -0,0 +1,87 @@ +/**************************************************************************** + * graphics/nxmu/nxmu_semtake.c + * + * Copyright (C) 2008-2009, 2011, 2013 Gregory Nutt. All rights reserved. + * Author: Gregory Nutt + * + * 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 + +#include +#include +#include + +#include +#include + +/**************************************************************************** + * Pre-Processor Definitions + ****************************************************************************/ + +/**************************************************************************** + * Private Types + ****************************************************************************/ + +/**************************************************************************** + * Private Data + ****************************************************************************/ + +/**************************************************************************** + * Public Data + ****************************************************************************/ + +/**************************************************************************** + * Private Functions + ****************************************************************************/ + +/**************************************************************************** + * Public Functions + ****************************************************************************/ + +/**************************************************************************** + * Name: nxmu_semtake + ****************************************************************************/ + +void nxmu_semtake(sem_t *sem) +{ + while (sem_wait(sem) != 0) + { + /* The only case that an error should occur here is if the wait was + * awakened by a signal. + */ + + ASSERT(errno == EINTR); + } +} diff --git a/nuttx/libc/nx/lib_nxmu_sendwindow.c b/nuttx/libc/nx/lib_nxmu_sendwindow.c new file mode 100644 index 000000000..e7602005c --- /dev/null +++ b/nuttx/libc/nx/lib_nxmu_sendwindow.c @@ -0,0 +1,115 @@ +/**************************************************************************** + * libc/nx/lib_nxmu_sendserver.c + * + * Copyright (C) 2012-2013 Gregory Nutt. All rights reserved. + * Author: Gregory Nutt + * + * 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 + +#include +#include +#include + +#include +#include + +/**************************************************************************** + * Pre-Processor Definitions + ****************************************************************************/ + +/**************************************************************************** + * Private Types + ****************************************************************************/ + +/**************************************************************************** + * Private Data + ****************************************************************************/ + +/**************************************************************************** + * Public Data + ****************************************************************************/ + +/**************************************************************************** + * Private Functions + ****************************************************************************/ + +/**************************************************************************** + * Public Functions + ****************************************************************************/ + +/**************************************************************************** + * Name: nxmu_sendwindow + * + * Description: + * Send a message to the server destined for a specific window at + * NX_SVRMSG_PRIO priority + * + * Input Parameters: + * wnd - A pointer to the back-end window structure + * msg - A pointer to the message to send + * msglen - The length of the message in bytes. + * + * Return: + * OK on success; ERROR on failure with errno set appropriately + * + ****************************************************************************/ + +int nxmu_sendwindow(FAR struct nxbe_window_s *wnd, FAR const void *msg, + size_t msglen) +{ + int ret = OK; + + /* Sanity checking */ + +#ifdef CONFIG_DEBUG + if (!wnd || !wnd->conn) + { + set_errno(EINVAL); + return ERROR; + } +#endif + + /* Ignore messages destined to a blocked window (no errors reported) */ + + if (!NXBE_ISBLOCKED(wnd)) + { + /* Send the message to the server */ + + ret = nxmu_sendserver(wnd->conn, msg, msglen); + } + + return ret; +} -- cgit v1.2.3