mirror of
https://github.com/apache/nuttx.git
synced 2026-06-06 16:50:55 +08:00
Move the NX components out of libc and into its own library, libnx
This commit is contained in:
@@ -65,9 +65,6 @@ include mqueue/Make.defs
|
||||
include math/Make.defs
|
||||
include fixedmath/Make.defs
|
||||
include net/Make.defs
|
||||
include nxglib/Make.defs
|
||||
include nx/Make.defs
|
||||
include nxmu/Make.defs
|
||||
include time/Make.defs
|
||||
include libgen/Make.defs
|
||||
include dirent/Make.defs
|
||||
|
||||
+4
-4
@@ -33,8 +33,8 @@
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef __LIB_LIB_INTERNAL_H
|
||||
#define __LIB_LIB_INTERNAL_H
|
||||
#ifndef __LIBC_LIB_INTERNAL_H
|
||||
#define __LIBC_LIB_INTERNAL_H
|
||||
|
||||
/****************************************************************************
|
||||
* Included Files
|
||||
@@ -73,7 +73,7 @@
|
||||
# define lib_give_semaphore(s)
|
||||
#endif
|
||||
|
||||
/* The NuttX C library an be build in two modes: (1) as a standard, C-libary
|
||||
/* The NuttX C library an be build in two modes: (1) as a standard, C-library
|
||||
* that can be used by normal, user-space applications, or (2) as a special,
|
||||
* kernel-mode C-library only used within the OS. If NuttX is not being
|
||||
* built as separated kernel- and user-space modules, then only the first
|
||||
@@ -237,4 +237,4 @@ float lib_sqrtapprox(float x);
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* __LIB_LIB_INTERNAL_H */
|
||||
#endif /* __LIBC_LIB_INTERNAL_H */
|
||||
|
||||
@@ -1,47 +0,0 @@
|
||||
############################################################################
|
||||
# libc/nx/Make.defs
|
||||
#
|
||||
# Copyright (C) 2013 Gregory Nutt. All rights reserved.
|
||||
# Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
# modification, are permitted provided that the following conditions
|
||||
# are met:
|
||||
#
|
||||
# 1. Redistributions of source code must retain the above copyright
|
||||
# notice, this list of conditions and the following disclaimer.
|
||||
# 2. Redistributions in binary form must reproduce the above copyright
|
||||
# notice, this list of conditions and the following disclaimer in
|
||||
# the documentation and/or other materials provided with the
|
||||
# distribution.
|
||||
# 3. Neither the name NuttX nor the names of its contributors may be
|
||||
# used to endorse or promote products derived from this software
|
||||
# without specific prior written permission.
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
||||
# OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
||||
# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
# POSSIBILITY OF SUCH DAMAGE.
|
||||
#
|
||||
############################################################################
|
||||
|
||||
# Expose NXGL interfaces to applications
|
||||
|
||||
ifeq ($(CONFIG_NX),y)
|
||||
|
||||
CSRCS += lib_nx_drawcircle.c lib_nx_drawline.c lib_nx_fillcircle.c
|
||||
|
||||
# Add the nx/ directory to the build
|
||||
|
||||
DEPPATH += --dep-path nx
|
||||
VPATH += :nx
|
||||
|
||||
endif
|
||||
@@ -1,145 +0,0 @@
|
||||
/****************************************************************************
|
||||
* libc/nx/lib_nx_drawcircle.c
|
||||
*
|
||||
* Copyright (C) 2011, 2013 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
* 3. Neither the name NuttX nor the names of its contributors may be
|
||||
* used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
||||
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
||||
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Included Files
|
||||
****************************************************************************/
|
||||
|
||||
#include <nuttx/config.h>
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <debug.h>
|
||||
#include <errno.h>
|
||||
|
||||
#include <nuttx/nx/nxglib.h>
|
||||
#include <nuttx/nx/nx.h>
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-Processor Definitions
|
||||
****************************************************************************/
|
||||
/* Named indices into the 16 circle points generated by nxgl_circlepts */
|
||||
|
||||
#define POINT_0p0 0
|
||||
#define POINT_22p5 1
|
||||
#define POINT_45p0 2
|
||||
#define POINT_67p5 3
|
||||
#define POINT_90p0 4
|
||||
#define POINT_112p5 5
|
||||
#define POINT_135p0 6
|
||||
#define POINT_157p5 7
|
||||
#define POINT_180p0 8
|
||||
#define POINT_202p5 9
|
||||
#define POINT_225p0 10
|
||||
#define POINT_247p5 11
|
||||
#define POINT_270p0 12
|
||||
#define POINT_292p5 13
|
||||
#define POINT_315p0 14
|
||||
#define POINT_337p5 15
|
||||
#define NCIRCLE_POINTS 16
|
||||
|
||||
/****************************************************************************
|
||||
* Private Types
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Private Data
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Public Data
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Private Functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Name: nx_drawcircle
|
||||
*
|
||||
* Description:
|
||||
* Draw a circular outline using the specified line thickness and color.
|
||||
*
|
||||
* Input Parameters:
|
||||
* hwnd - The window handle
|
||||
* center - A pointer to the point that is the center of the circle
|
||||
* radius - The radius of the circle in pixels.
|
||||
* width - The width of the line
|
||||
* color - The color to use to fill the line
|
||||
*
|
||||
* Return:
|
||||
* OK on success; ERROR on failure with errno set appropriately
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
int nx_drawcircle(NXWINDOW hwnd, FAR const struct nxgl_point_s *center,
|
||||
nxgl_coord_t radius, nxgl_coord_t width,
|
||||
nxgl_mxpixel_t color[CONFIG_NX_NPLANES])
|
||||
{
|
||||
struct nxgl_point_s pts[NCIRCLE_POINTS];
|
||||
FAR struct nxgl_vector_s vector;
|
||||
int i;
|
||||
int ret;
|
||||
|
||||
/* Convert the circle to a set of 16 points */
|
||||
|
||||
nxgl_circlepts(center, radius, pts);
|
||||
|
||||
/* Draw each pair of points as a vector */
|
||||
|
||||
for (i = POINT_0p0; i < POINT_337p5; i++)
|
||||
{
|
||||
vector.pt1.x = pts[i].x;
|
||||
vector.pt1.y = pts[i].y;
|
||||
vector.pt2.x = pts[i+1].x;
|
||||
vector.pt2.y = pts[i+1].y;
|
||||
ret = nx_drawline(hwnd, &vector, width, color);
|
||||
if (ret != OK)
|
||||
{
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
|
||||
/* The final, closing vector is a special case */
|
||||
|
||||
vector.pt1.x = pts[POINT_337p5].x;
|
||||
vector.pt1.y = pts[POINT_337p5].y;
|
||||
vector.pt2.x = pts[POINT_0p0].x;
|
||||
vector.pt2.y = pts[POINT_0p0].y;
|
||||
return nx_drawline(hwnd, &vector, width, color);
|
||||
}
|
||||
@@ -1,136 +0,0 @@
|
||||
/****************************************************************************
|
||||
* libc/nx/nx_drawline.c
|
||||
*
|
||||
* Copyright (C) 2011 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
* 3. Neither the name NuttX nor the names of its contributors may be
|
||||
* used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
||||
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
||||
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Included Files
|
||||
****************************************************************************/
|
||||
|
||||
#include <nuttx/config.h>
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <debug.h>
|
||||
#include <errno.h>
|
||||
|
||||
#include <nuttx/nx/nxglib.h>
|
||||
#include <nuttx/nx/nx.h>
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-Processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Private Types
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Private Data
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Public Data
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Private Functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Name: nx_drawline
|
||||
*
|
||||
* Description:
|
||||
* Fill the specified line in the window with the specified color. This
|
||||
* is simply a wrapper that uses nxgl_splitline() to break the line into
|
||||
* trapezoids and then calls nx_filltrapezoid() to render the line.
|
||||
*
|
||||
* Input Parameters:
|
||||
* hwnd - The window handle
|
||||
* vector - Describes the line to be drawn
|
||||
* width - The width of the line
|
||||
* color - The color to use to fill the line
|
||||
*
|
||||
* Return:
|
||||
* OK on success; ERROR on failure with errno set appropriately
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
int nx_drawline(NXWINDOW hwnd, FAR struct nxgl_vector_s *vector,
|
||||
nxgl_coord_t width, nxgl_mxpixel_t color[CONFIG_NX_NPLANES])
|
||||
{
|
||||
struct nxgl_trapezoid_s trap[3];
|
||||
struct nxgl_rect_s rect;
|
||||
int ret;
|
||||
|
||||
#ifdef CONFIG_DEBUG
|
||||
if (!hwnd || !vector || width < 1 || !color)
|
||||
{
|
||||
set_errno(EINVAL);
|
||||
return ERROR;
|
||||
}
|
||||
#endif
|
||||
|
||||
ret = nxgl_splitline(vector, trap, &rect, width);
|
||||
switch (ret)
|
||||
{
|
||||
case 0:
|
||||
ret = nx_filltrapezoid(hwnd, NULL, &trap[0], color);
|
||||
if (ret == OK)
|
||||
{
|
||||
ret = nx_filltrapezoid(hwnd, NULL, &trap[1], color);
|
||||
if (ret == OK)
|
||||
{
|
||||
ret = nx_filltrapezoid(hwnd, NULL, &trap[2], color);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case 1:
|
||||
ret = nx_filltrapezoid(hwnd, NULL, &trap[1], color);
|
||||
break;
|
||||
|
||||
case 2:
|
||||
ret = nx_fill(hwnd, &rect, color);
|
||||
break;
|
||||
|
||||
default:
|
||||
set_errno(-ret);
|
||||
return ERROR;
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
@@ -1,114 +0,0 @@
|
||||
/****************************************************************************
|
||||
* libc/nx/lib_nx_fillcircle.c
|
||||
*
|
||||
* Copyright (C) 2011, 2013 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
* 3. Neither the name NuttX nor the names of its contributors may be
|
||||
* used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
||||
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
||||
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Included Files
|
||||
****************************************************************************/
|
||||
|
||||
#include <nuttx/config.h>
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <debug.h>
|
||||
#include <errno.h>
|
||||
|
||||
#include <nuttx/nx/nxglib.h>
|
||||
#include <nuttx/nx/nx.h>
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-Processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
#define NCIRCLE_TRAPS 8
|
||||
|
||||
/****************************************************************************
|
||||
* Private Types
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Private Data
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Public Data
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Private Functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Name: nx_fillcircle
|
||||
*
|
||||
* Description:
|
||||
* Fill a circular region using the specified color.
|
||||
*
|
||||
* Input Parameters:
|
||||
* hwnd - The window handle
|
||||
* center - A pointer to the point that is the center of the circle
|
||||
* radius - The radius of the circle in pixels.
|
||||
* color - The color to use to fill the circle.
|
||||
*
|
||||
* Return:
|
||||
* OK on success; ERROR on failure with errno set appropriately
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
int nx_fillcircle(NXWINDOW hwnd, FAR const struct nxgl_point_s *center,
|
||||
nxgl_coord_t radius, nxgl_mxpixel_t color[CONFIG_NX_NPLANES])
|
||||
{
|
||||
FAR struct nxgl_trapezoid_s traps[NCIRCLE_TRAPS];
|
||||
int i;
|
||||
int ret;
|
||||
|
||||
/* Describe the circular region as a sequence of 8 trapezoids */
|
||||
|
||||
nxgl_circletraps(center, radius, traps);
|
||||
|
||||
/* Then rend those trapezoids */
|
||||
|
||||
for (i = 0; i < NCIRCLE_TRAPS; i++)
|
||||
{
|
||||
ret = nx_filltrapezoid(hwnd, NULL, &traps[i], color);
|
||||
if (ret != OK)
|
||||
{
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
return OK;
|
||||
}
|
||||
@@ -1,56 +0,0 @@
|
||||
############################################################################
|
||||
# libc/nxglib/Make.defs
|
||||
#
|
||||
# Copyright (C) 2013 Gregory Nutt. All rights reserved.
|
||||
# Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
# modification, are permitted provided that the following conditions
|
||||
# are met:
|
||||
#
|
||||
# 1. Redistributions of source code must retain the above copyright
|
||||
# notice, this list of conditions and the following disclaimer.
|
||||
# 2. Redistributions in binary form must reproduce the above copyright
|
||||
# notice, this list of conditions and the following disclaimer in
|
||||
# the documentation and/or other materials provided with the
|
||||
# distribution.
|
||||
# 3. Neither the name NuttX nor the names of its contributors may be
|
||||
# used to endorse or promote products derived from this software
|
||||
# without specific prior written permission.
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
||||
# OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
||||
# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
# POSSIBILITY OF SUCH DAMAGE.
|
||||
#
|
||||
############################################################################
|
||||
|
||||
# Expose NXGL interfaces to applications
|
||||
|
||||
ifeq ($(CONFIG_NX),y)
|
||||
|
||||
CSRCS += lib_nxglib_circlepts.c lib_nxglib_circletraps.c
|
||||
CSRCS += lib_nxglib_colorcopy.c lib_nxglib_intersecting.c
|
||||
CSRCS += lib_nxglib_nonintersecting.c lib_nxglib_nullrect.c
|
||||
CSRCS += lib_nxglib_rectadd.c lib_nxglib_rectcopy.c lib_nxglib_rectinside.c
|
||||
CSRCS += lib_nxglib_rectintersect.c lib_nxglib_rectoffset.c
|
||||
CSRCS += lib_nxglib_rectoverlap.c lib_nxglib_rectsize.c
|
||||
CSRCS += lib_nxglib_rectunion.c lib_nxglib_rgb2yuv.c lib_nxglib_runcopy.c
|
||||
CSRCS += lib_nxglib_runoffset.c lib_nxglib_splitline.c lib_nxglib_trapcopy.c
|
||||
CSRCS += lib_nxglib_trapoffset.c lib_nxglib_vectoradd.c
|
||||
CSRCS += lib_nxglib_vectsubtract.c lib_nxglib_yuv2rgb.c
|
||||
|
||||
# Add the nxglib/ directory to the build
|
||||
|
||||
DEPPATH += --dep-path nxglib
|
||||
VPATH += :nxglib
|
||||
|
||||
endif
|
||||
@@ -1,171 +0,0 @@
|
||||
/****************************************************************************
|
||||
* graphics/nxglib/nxglib_circlepts.c
|
||||
*
|
||||
* Copyright (C) 2011 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
* 3. Neither the name NuttX nor the names of its contributors may be
|
||||
* used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
||||
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
||||
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Included Files
|
||||
****************************************************************************/
|
||||
|
||||
#include <nuttx/config.h>
|
||||
|
||||
#include <string.h>
|
||||
#include <errno.h>
|
||||
#include <fixedmath.h>
|
||||
|
||||
#include <nuttx/nx/nxglib.h>
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-Processor Definitions
|
||||
****************************************************************************/
|
||||
/* Trigonometry */
|
||||
|
||||
#define SIN_0p0 0 /* sin(0) = 0 */
|
||||
#define COS_0p0 1 /* cos(0) = 1 */
|
||||
#define SIN_22p5 25080 /* sin(22.5) = 25080 / 65536 */
|
||||
#define COS_22p5 60547 /* cos(22.5) = 60547 / 65536 */
|
||||
#define SIN_45p0 46341 /* sin(45) = 46341 / 65536 */
|
||||
#define COS_45p0 SIN_45p0 /* cos(45) = sin(45) */
|
||||
|
||||
/* Named indices into the 16 circle points generated by nxgl_circlepts */
|
||||
|
||||
#define POINT_0p0 0
|
||||
#define POINT_22p5 1
|
||||
#define POINT_45p0 2
|
||||
#define POINT_67p5 3
|
||||
#define POINT_90p0 4
|
||||
#define POINT_112p5 5
|
||||
#define POINT_135p0 6
|
||||
#define POINT_157p5 7
|
||||
#define POINT_180p0 8
|
||||
#define POINT_202p5 9
|
||||
#define POINT_225p0 10
|
||||
#define POINT_247p5 11
|
||||
#define POINT_270p0 12
|
||||
#define POINT_292p5 13
|
||||
#define POINT_315p0 14
|
||||
#define POINT_337p5 15
|
||||
#define NCIRCLE_POINTS 16
|
||||
|
||||
/****************************************************************************
|
||||
* Private Types
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Private Data
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Public Data
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Private Functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Name: nxgl_circlepts
|
||||
*
|
||||
* Description:
|
||||
* Given a description of a circle, return a set of 16 points on the
|
||||
* circumference of the circle. These points may then be used by
|
||||
* nx_drawcircle() or related APIs to draw a circle outline.
|
||||
*
|
||||
* Input parameters:
|
||||
* center - A pointer to the point that is the center of the circle
|
||||
* radius - The radius of the circle in pixels.
|
||||
* circle - A pointer the first entry in an array of 16 points where the
|
||||
* circle points will be returned.
|
||||
*
|
||||
* Returned value:
|
||||
* None
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
void nxgl_circlepts(FAR const struct nxgl_point_s *center, nxgl_coord_t radius,
|
||||
FAR struct nxgl_point_s *circle)
|
||||
{
|
||||
nxgl_coord_t xoffs;
|
||||
nxgl_coord_t yoffs;
|
||||
|
||||
/* 0, 90, 180, and 270 degrees are the easiest */
|
||||
|
||||
circle[POINT_0p0].x = center->x + radius;
|
||||
circle[POINT_0p0].y = center->y;
|
||||
circle[POINT_90p0].x = center->x;
|
||||
circle[POINT_90p0].y = center->y + radius;
|
||||
circle[POINT_180p0].x = center->x - radius;
|
||||
circle[POINT_180p0].y = center->y;
|
||||
circle[POINT_270p0].x = center->x;
|
||||
circle[POINT_270p0].y = center->y - radius;
|
||||
|
||||
/* Now 22.5, 67.5, 112.5, 157.5, 202.5, 247.5, 292.5, and 337.5 */
|
||||
|
||||
xoffs = b16toi(b16muli(COS_22p5, radius) + b16HALF);
|
||||
yoffs = b16toi(b16muli(SIN_22p5, radius) + b16HALF);
|
||||
|
||||
circle[POINT_22p5].x = center->x + xoffs;
|
||||
circle[POINT_22p5].y = center->y + yoffs;
|
||||
circle[POINT_157p5].x = center->x - xoffs;
|
||||
circle[POINT_157p5].y = center->y + yoffs;
|
||||
circle[POINT_202p5].x = center->x - xoffs;
|
||||
circle[POINT_202p5].y = center->y - yoffs;
|
||||
circle[POINT_337p5].x = center->x + xoffs;
|
||||
circle[POINT_337p5].y = center->y - yoffs;
|
||||
|
||||
circle[POINT_67p5].x = center->x + yoffs;
|
||||
circle[POINT_67p5].y = center->y + xoffs;
|
||||
circle[POINT_112p5].x = center->x - yoffs;
|
||||
circle[POINT_112p5].y = center->y + xoffs;
|
||||
circle[POINT_247p5].x = center->x - yoffs;
|
||||
circle[POINT_247p5].y = center->y - xoffs;
|
||||
circle[POINT_292p5].x = center->x + yoffs;
|
||||
circle[POINT_292p5].y = center->y - xoffs;
|
||||
|
||||
/* Finally, 45.0, 135.0, 225.0, 315.0 */
|
||||
|
||||
xoffs = b16toi(b16muli(COS_45p0, radius) + b16HALF);
|
||||
|
||||
circle[POINT_45p0].x = center->x + xoffs;
|
||||
circle[POINT_45p0].y = center->y + xoffs;
|
||||
circle[POINT_135p0].x = center->x - xoffs;
|
||||
circle[POINT_135p0].y = center->y + xoffs;
|
||||
circle[POINT_225p0].x = center->x - xoffs;
|
||||
circle[POINT_225p0].y = center->y - xoffs;
|
||||
circle[POINT_315p0].x = center->x + xoffs;
|
||||
circle[POINT_315p0].y = center->y - xoffs;
|
||||
}
|
||||
@@ -1,176 +0,0 @@
|
||||
/****************************************************************************
|
||||
* graphics/nxglib/nxglib_circletraps.c
|
||||
*
|
||||
* Copyright (C) 2011 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
* 3. Neither the name NuttX nor the names of its contributors may be
|
||||
* used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
||||
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
||||
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Included Files
|
||||
****************************************************************************/
|
||||
|
||||
#include <nuttx/config.h>
|
||||
|
||||
#include <string.h>
|
||||
#include <errno.h>
|
||||
#include <fixedmath.h>
|
||||
|
||||
#include <nuttx/nx/nxglib.h>
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-Processor Definitions
|
||||
****************************************************************************/
|
||||
/* Trigonometry */
|
||||
|
||||
#define SIN_0p0 0 /* sin(0) = 0 */
|
||||
#define COS_0p0 1 /* cos(0) = 1 */
|
||||
#define SIN_22p5 25080 /* sin(22.5) = 25080 / 65536 */
|
||||
#define COS_22p5 60547 /* cos(22.5) = 60547 / 65536 */
|
||||
#define SIN_45p0 46341 /* sin(45) = 46341 / 65536 */
|
||||
#define COS_45p0 SIN_45p0 /* cos(45) = sin(45) */
|
||||
|
||||
/****************************************************************************
|
||||
* Private Types
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Private Data
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Public Data
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Private Functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Name: nxgl_circletraps
|
||||
*
|
||||
* Description:
|
||||
* Given a description of a a circle, return 8 trapezoids that can be
|
||||
* used to fill the circle by nx_fillcircle() and other interfaces.
|
||||
*
|
||||
* Input parameters:
|
||||
* center - A pointer to the point that is the center of the circle
|
||||
* radius - The radius of the circle in pixels.
|
||||
* circle - A pointer the first entry in an array of 8 trapezoids where
|
||||
* the circle description will be returned.
|
||||
*
|
||||
* Returned value:
|
||||
* None
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
void nxgl_circletraps(FAR const struct nxgl_point_s *center, nxgl_coord_t radius,
|
||||
FAR struct nxgl_trapezoid_s *circle)
|
||||
{
|
||||
nxgl_coord_t xoffs;
|
||||
nxgl_coord_t yoffs;
|
||||
|
||||
circle[0].top.x1 = itob16(center->x);
|
||||
circle[0].top.x2 = circle[0].top.x1;
|
||||
circle[0].top.y = center->y - radius;
|
||||
|
||||
circle[7].bot.x1 = circle[0].top.x1;
|
||||
circle[7].bot.x2 = circle[0].top.x1;
|
||||
circle[7].bot.y = center->y + radius;
|
||||
|
||||
circle[3].bot.x1 = itob16(center->x - radius);
|
||||
circle[3].bot.x2 = itob16(center->x + radius);
|
||||
circle[3].bot.y = center->y;
|
||||
|
||||
circle[4].top.x1 = circle[3].bot.x1;
|
||||
circle[4].top.x2 = circle[3].bot.x2;
|
||||
circle[4].top.y = circle[3].bot.y;
|
||||
|
||||
/* Now 22.5, 67.5, 112.5, 157.5, 202.5, 247.5, 292.5, and 337.5 */
|
||||
|
||||
xoffs = b16toi(b16muli(COS_22p5, radius) + b16HALF);
|
||||
yoffs = b16toi(b16muli(SIN_22p5, radius) + b16HALF);
|
||||
|
||||
circle[2].bot.x1 = itob16(center->x - xoffs);
|
||||
circle[2].bot.x2 = itob16(center->x + xoffs);
|
||||
circle[2].bot.y = center->y - yoffs;
|
||||
|
||||
circle[3].top.x1 = circle[2].bot.x1;
|
||||
circle[3].top.x2 = circle[2].bot.x2;
|
||||
circle[3].top.y = circle[2].bot.y;
|
||||
|
||||
circle[4].bot.x1 = circle[2].bot.x1;
|
||||
circle[4].bot.x2 = circle[2].bot.x2;
|
||||
circle[4].bot.y = center->y + yoffs;
|
||||
|
||||
circle[5].top.x1 = circle[4].bot.x1;
|
||||
circle[5].top.x2 = circle[4].bot.x2;
|
||||
circle[5].top.y = circle[4].bot.y;
|
||||
|
||||
circle[0].bot.x1 = itob16(center->x - yoffs);
|
||||
circle[0].bot.x2 = itob16(center->x + yoffs);
|
||||
circle[0].bot.y = center->y - xoffs;
|
||||
|
||||
circle[1].top.x1 = circle[0].bot.x1;
|
||||
circle[1].top.x2 = circle[0].bot.x2;
|
||||
circle[1].top.y = circle[0].bot.y;
|
||||
|
||||
circle[6].bot.x1 = circle[1].top.x1;
|
||||
circle[6].bot.x2 = circle[1].top.x2;
|
||||
circle[6].bot.y = center->y + xoffs;
|
||||
|
||||
circle[7].top.x1 = circle[6].bot.x1;
|
||||
circle[7].top.x2 = circle[6].bot.x2;
|
||||
circle[7].top.y = circle[6].bot.y;
|
||||
|
||||
/* Finally, 45.0, 135.0, 225.0, 315.0 */
|
||||
|
||||
xoffs = b16toi(b16muli(COS_45p0, radius) + b16HALF);
|
||||
|
||||
circle[1].bot.x1 = itob16(center->x - xoffs);
|
||||
circle[1].bot.x2 = itob16(center->x + xoffs);
|
||||
circle[1].bot.y = center->y - xoffs;
|
||||
|
||||
circle[2].top.x1 = circle[1].bot.x1;
|
||||
circle[2].top.x2 = circle[1].bot.x2;
|
||||
circle[2].top.y = circle[1].bot.y;
|
||||
|
||||
circle[5].bot.x1 = circle[1].bot.x1;
|
||||
circle[5].bot.x2 = circle[1].bot.x2;
|
||||
circle[5].bot.y = center->y + xoffs;
|
||||
|
||||
circle[6].top.x1 = circle[5].bot.x1;
|
||||
circle[6].top.x2 = circle[5].bot.x2;
|
||||
circle[6].top.y = circle[5].bot.y;
|
||||
}
|
||||
@@ -1,87 +0,0 @@
|
||||
/****************************************************************************
|
||||
* libc/nxglib/lib_nxglib_colorcopy.c
|
||||
*
|
||||
* Copyright (C) 2008-2011, 2013 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
* 3. Neither the name NuttX nor the names of its contributors may be
|
||||
* used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
||||
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
||||
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Included Files
|
||||
****************************************************************************/
|
||||
|
||||
#include <nuttx/config.h>
|
||||
|
||||
#include <nuttx/nx/nxglib.h>
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-Processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Private Types
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Private Data
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Public Data
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Private Functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Name: nxgl_colorcopy
|
||||
*
|
||||
* Description:
|
||||
* This is essentially memcpy for colors. This does very little for us
|
||||
* other than hide all of the conditional compilation for planar colors
|
||||
* in one place.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
void nxgl_colorcopy(nxgl_mxpixel_t dest[CONFIG_NX_NPLANES],
|
||||
const nxgl_mxpixel_t src[CONFIG_NX_NPLANES])
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i = 0; i < CONFIG_NX_NPLANES; i++)
|
||||
{
|
||||
dest[i] = src[i];
|
||||
}
|
||||
}
|
||||
@@ -1,83 +0,0 @@
|
||||
/****************************************************************************
|
||||
* libc/nxglib/lib_nxglib_intersecting.c
|
||||
*
|
||||
* Copyright (C) 2011, 2013 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
* 3. Neither the name NuttX nor the names of its contributors may be
|
||||
* used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
||||
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
||||
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Included Files
|
||||
****************************************************************************/
|
||||
|
||||
#include <nuttx/config.h>
|
||||
|
||||
#include <stdbool.h>
|
||||
|
||||
#include <nuttx/nx/nxglib.h>
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-Processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Private Types
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Private Data
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Public Data
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Private Functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Name: nxgl_intersecting
|
||||
*
|
||||
* Description:
|
||||
* Return true if the rectangles intersect.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
bool nxgl_intersecting(FAR const struct nxgl_rect_s *rect1,
|
||||
FAR const struct nxgl_rect_s *rect2)
|
||||
{
|
||||
return ((rect1->pt2.x > rect2->pt1.x) && (rect1->pt2.y > rect2->pt1.y) &&
|
||||
(rect1->pt1.x < rect2->pt2.x) && (rect1->pt1.y < rect2->pt1.y));
|
||||
}
|
||||
@@ -1,149 +0,0 @@
|
||||
/****************************************************************************
|
||||
* libc/nxglib/lib_nxglib_rectnonintersecting.c
|
||||
*
|
||||
* Copyright (C) 2008-2011, 2013 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
* 3. Neither the name NuttX nor the names of its contributors may be
|
||||
* used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
||||
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
||||
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Included Files
|
||||
****************************************************************************/
|
||||
|
||||
#include <nuttx/config.h>
|
||||
|
||||
#include <nuttx/nx/nxglib.h>
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-Processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Private Types
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Private Data
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Public Data
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Private Functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Name: nxgl_nonintersecting
|
||||
*
|
||||
* Description:
|
||||
* Return the regions of rectangle rect 1 that do not intersect with
|
||||
* rect2. This may be up to founr rectangles some of which may be
|
||||
* degenerate (and can be picked off with nxgl_nullrect)
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
void nxgl_nonintersecting(FAR struct nxgl_rect_s result[4],
|
||||
FAR const struct nxgl_rect_s *rect1,
|
||||
FAR const struct nxgl_rect_s *rect2)
|
||||
{
|
||||
struct nxgl_rect_s intersection;
|
||||
|
||||
/* Get the intersection of the two rectangles */
|
||||
|
||||
nxgl_rectintersect(&intersection, rect1, rect2);
|
||||
|
||||
/* Then return the four rectangles representing the regions NON included
|
||||
* in the intersection. Some of these rectangles may be invalid (zero
|
||||
* area), but those can be picked off using nxgl_nullrect()
|
||||
*
|
||||
* rect1.pt1
|
||||
* +-------------------------+
|
||||
* | rect2.pt1 |
|
||||
* | int.pt1 |
|
||||
* | +-------------------------+
|
||||
* | | | |
|
||||
* | | | |
|
||||
* +-------------------------+ |
|
||||
* | rect1.pt2 |
|
||||
* | int.pt2 |
|
||||
* +-------------------------+
|
||||
* rect2.pt2
|
||||
* rect1.pt1
|
||||
* +-------------------------+
|
||||
* rect2.pt1 |int.pt1 |
|
||||
* +---------+---------------+ |
|
||||
* | | | |
|
||||
* | | | |
|
||||
* | | |int.pt2 |
|
||||
* | +---------------+---------+
|
||||
* | | rect1.pt2
|
||||
* +-------------------------+
|
||||
* rect2.pt2
|
||||
* rect2.pt1
|
||||
* +-------------------------+
|
||||
* | rect1.pt1 |
|
||||
* | int.pt1 |
|
||||
* | +-------------------------+
|
||||
* | | | |
|
||||
* | | | |
|
||||
* | | | |
|
||||
* +---------+---------------+ |
|
||||
* | rect2.pt2 |
|
||||
* | int.pt2 |
|
||||
* +-------------------------+
|
||||
* rect1.pt2
|
||||
*/
|
||||
|
||||
result[NX_TOP_NDX].pt1.x = rect1->pt1.x;
|
||||
result[NX_TOP_NDX].pt1.y = rect1->pt1.y;
|
||||
result[NX_TOP_NDX].pt2.x = rect1->pt2.x;
|
||||
result[NX_TOP_NDX].pt2.y = intersection.pt1.y - 1;
|
||||
|
||||
result[NX_BOTTOM_NDX].pt1.x = rect1->pt1.x;
|
||||
result[NX_BOTTOM_NDX].pt1.y = intersection.pt2.y + 1;
|
||||
result[NX_BOTTOM_NDX].pt2.x = rect1->pt2.x;
|
||||
result[NX_BOTTOM_NDX].pt2.y = rect1->pt2.y;
|
||||
|
||||
result[NX_LEFT_NDX].pt1.x = rect1->pt1.x;
|
||||
result[NX_LEFT_NDX].pt1.y = intersection.pt1.y;
|
||||
result[NX_LEFT_NDX].pt2.x = intersection.pt1.x - 1;
|
||||
result[NX_LEFT_NDX].pt2.y = intersection.pt2.y;
|
||||
|
||||
result[NX_RIGHT_NDX].pt1.x = intersection.pt2.x + 1;
|
||||
result[NX_RIGHT_NDX].pt1.y = intersection.pt1.y;
|
||||
result[NX_RIGHT_NDX].pt2.x = rect1->pt2.x;
|
||||
result[NX_RIGHT_NDX].pt2.y = intersection.pt2.y;
|
||||
}
|
||||
@@ -1,81 +0,0 @@
|
||||
/****************************************************************************
|
||||
* libc/nxglib/lib_nxglib_nullrect.c
|
||||
*
|
||||
* Copyright (C) 2008-2013 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
* 3. Neither the name NuttX nor the names of its contributors may be
|
||||
* used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
||||
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
||||
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Included Files
|
||||
****************************************************************************/
|
||||
|
||||
#include <nuttx/config.h>
|
||||
|
||||
#include <stdbool.h>
|
||||
|
||||
#include <nuttx/nx/nxglib.h>
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-Processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Private Types
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Private Data
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Public Data
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Private Functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Name: nxgl_nullrect
|
||||
*
|
||||
* Description:
|
||||
* Return true if the area of the retangle is <= 0.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
bool nxgl_nullrect(FAR const struct nxgl_rect_s *rect)
|
||||
{
|
||||
return (rect->pt1.x > rect->pt2.x || rect->pt1.y > rect->pt2.y);
|
||||
}
|
||||
@@ -1,84 +0,0 @@
|
||||
/****************************************************************************
|
||||
* libc/nxglib/lib_nxsglib_rectadd.c
|
||||
*
|
||||
* Copyright (C) 2011, 2013 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
* 3. Neither the name NuttX nor the names of its contributors may be
|
||||
* used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
||||
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
||||
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Included Files
|
||||
****************************************************************************/
|
||||
|
||||
#include <nuttx/config.h>
|
||||
|
||||
#include <nuttx/nx/nxglib.h>
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-Processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Private Types
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Private Data
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Public Data
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Private Functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Name: nxgl_rectadd
|
||||
*
|
||||
* Description:
|
||||
* Return the rectangle that contains exactly two other rectanges.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
void nxgl_rectadd(FAR struct nxgl_rect_s *dest,
|
||||
FAR const struct nxgl_rect_s *src1,
|
||||
FAR const struct nxgl_rect_s *src2)
|
||||
{
|
||||
dest->pt1.x = ngl_min(src1->pt1.x, src2->pt1.x);
|
||||
dest->pt1.y = ngl_min(src1->pt1.y, src2->pt1.y);
|
||||
dest->pt2.x = ngl_max(src1->pt2.x, src2->pt2.x);
|
||||
dest->pt2.y = ngl_max(src1->pt2.y, src2->pt2.y);
|
||||
}
|
||||
@@ -1,84 +0,0 @@
|
||||
/****************************************************************************
|
||||
* libc/nxglib/lib_nxglib_rectcopy.c
|
||||
*
|
||||
* Copyright (C) 2008-2011, 2013 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
* 3. Neither the name NuttX nor the names of its contributors may be
|
||||
* used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
||||
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
||||
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Included Files
|
||||
****************************************************************************/
|
||||
|
||||
#include <nuttx/config.h>
|
||||
|
||||
#include <nuttx/nx/nxglib.h>
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-Processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Private Types
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Private Data
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Public Data
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Private Functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Name: nxgl_rectcopy
|
||||
*
|
||||
* Description:
|
||||
* This is essentially memcpy for rectangles. We don't do structure
|
||||
* assignments because some compilers are not good at that.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
void nxgl_rectcopy(FAR struct nxgl_rect_s *dest,
|
||||
FAR const struct nxgl_rect_s *src)
|
||||
{
|
||||
dest->pt1.x = src->pt1.x;
|
||||
dest->pt1.y = src->pt1.y;
|
||||
dest->pt2.x = src->pt2.x;
|
||||
dest->pt2.y = src->pt2.y;
|
||||
}
|
||||
@@ -1,83 +0,0 @@
|
||||
/****************************************************************************
|
||||
* libc/nxglib/nxglib_rectinside.c
|
||||
*
|
||||
* Copyright (C) 2008-2011, 2013 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
* 3. Neither the name NuttX nor the names of its contributors may be
|
||||
* used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
||||
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
||||
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Included Files
|
||||
****************************************************************************/
|
||||
|
||||
#include <nuttx/config.h>
|
||||
|
||||
#include <stdbool.h>
|
||||
|
||||
#include <nuttx/nx/nxglib.h>
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-Processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Private Types
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Private Data
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Public Data
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Private Functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Name: nxgl_rectinside
|
||||
*
|
||||
* Description:
|
||||
* Return true if the point pt lies within rect.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
bool nxgl_rectinside(FAR const struct nxgl_rect_s *rect,
|
||||
FAR const struct nxgl_point_s *pt)
|
||||
{
|
||||
return (pt->x >= rect->pt1.x && pt->x <= rect->pt2.x &&
|
||||
pt->y >= rect->pt1.y && pt->y <= rect->pt2.y);
|
||||
}
|
||||
@@ -1,84 +0,0 @@
|
||||
/****************************************************************************
|
||||
* libc/nxglib/lib_nxglib_rectintersect.c
|
||||
*
|
||||
* Copyright (C) 2008-2011, 2013 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
* 3. Neither the name NuttX nor the names of its contributors may be
|
||||
* used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
||||
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
||||
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Included Files
|
||||
****************************************************************************/
|
||||
|
||||
#include <nuttx/config.h>
|
||||
|
||||
#include <nuttx/nx/nxglib.h>
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-Processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Private Types
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Private Data
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Public Data
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Private Functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Name: nxgl_rectintersect
|
||||
*
|
||||
* Description:
|
||||
* Return the rectangle representing the intersection of the two rectangles.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
void nxgl_rectintersect(FAR struct nxgl_rect_s *dest,
|
||||
FAR const struct nxgl_rect_s *src1,
|
||||
FAR const struct nxgl_rect_s *src2)
|
||||
{
|
||||
dest->pt1.x = ngl_max(src1->pt1.x, src2->pt1.x);
|
||||
dest->pt1.y = ngl_max(src1->pt1.y, src2->pt1.y);
|
||||
dest->pt2.x = ngl_min(src1->pt2.x, src2->pt2.x);
|
||||
dest->pt2.y = ngl_min(src1->pt2.y, src2->pt2.y);
|
||||
}
|
||||
@@ -1,84 +0,0 @@
|
||||
/****************************************************************************
|
||||
* lbic/nxglib/lib_nxsglib_rectoffset.c
|
||||
*
|
||||
* Copyright (C) 2008-2011, 2013 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
* 3. Neither the name NuttX nor the names of its contributors may be
|
||||
* used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
||||
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
||||
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Included Files
|
||||
****************************************************************************/
|
||||
|
||||
#include <nuttx/config.h>
|
||||
|
||||
#include <nuttx/nx/nxglib.h>
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-Processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Private Types
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Private Data
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Public Data
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Private Functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Name: nxgl_rectoffset
|
||||
*
|
||||
* Description:
|
||||
* Offset the rectangle position by the specified dx, dy values.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
void nxgl_rectoffset(FAR struct nxgl_rect_s *dest,
|
||||
FAR const struct nxgl_rect_s *src,
|
||||
nxgl_coord_t dx, nxgl_coord_t dy)
|
||||
{
|
||||
dest->pt1.x = src->pt1.x + dx;
|
||||
dest->pt1.y = src->pt1.y + dy;
|
||||
dest->pt2.x = src->pt2.x + dx;
|
||||
dest->pt2.y = src->pt2.y + dy;
|
||||
}
|
||||
@@ -1,89 +0,0 @@
|
||||
/****************************************************************************
|
||||
* libc/nxglib/lib_nxglib_nulloverlap.c
|
||||
*
|
||||
* Copyright (C) 2008-2011, 2013 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
* 3. Neither the name NuttX nor the names of its contributors may be
|
||||
* used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
||||
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
||||
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Included Files
|
||||
****************************************************************************/
|
||||
|
||||
#include <nuttx/config.h>
|
||||
|
||||
#include <stdbool.h>
|
||||
|
||||
#include <nuttx/nx/nxglib.h>
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-Processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Private Types
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Private Data
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Public Data
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Private Functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Name: nxgl_rectoverlap
|
||||
*
|
||||
* Description:
|
||||
* Return true if the two rectangles overlap
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
bool nxgl_rectoverlap(FAR struct nxgl_rect_s *rect1,
|
||||
FAR struct nxgl_rect_s *rect2)
|
||||
{
|
||||
/* The neither is wholly above, below, right, or left of the other, then
|
||||
* the two rectangles overlap in some fashion.
|
||||
*/
|
||||
|
||||
return (rect1->pt1.x <= rect2->pt2.x) && /* false: rect1 is wholly to the right */
|
||||
(rect2->pt1.x <= rect1->pt2.x) && /* false: rect2 is wholly to the right */
|
||||
(rect1->pt1.y <= rect2->pt2.y) && /* false: rect1 is wholly below rect2 */
|
||||
(rect2->pt1.y <= rect1->pt2.y); /* false: rect2 is wholly below rect1 */
|
||||
}
|
||||
@@ -1,81 +0,0 @@
|
||||
/****************************************************************************
|
||||
* libc/nxglib/lib_nxglib_rectsize.c
|
||||
*
|
||||
* Copyright (C) 2008-2011, 2013 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
* 3. Neither the name NuttX nor the names of its contributors may be
|
||||
* used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
||||
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
||||
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Included Files
|
||||
****************************************************************************/
|
||||
|
||||
#include <nuttx/config.h>
|
||||
|
||||
#include <nuttx/nx/nxglib.h>
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-Processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Private Types
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Private Data
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Public Data
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Private Functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Name: nxgl_rectsize
|
||||
*
|
||||
* Description:
|
||||
* Return the size of the specified rectangle.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
void nxgl_rectsize(FAR struct nxgl_size_s *size,
|
||||
FAR const struct nxgl_rect_s *rect)
|
||||
{
|
||||
size->w = rect->pt2.x - rect->pt1.x + 1;
|
||||
size->h = rect->pt2.y - rect->pt1.y + 1;
|
||||
}
|
||||
@@ -1,85 +0,0 @@
|
||||
/****************************************************************************
|
||||
* libc/nxglib/lib_nxsglib_rectunion.c
|
||||
*
|
||||
* Copyright (C) 2008-2011, 2013 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
* 3. Neither the name NuttX nor the names of its contributors may be
|
||||
* used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
||||
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
||||
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Included Files
|
||||
****************************************************************************/
|
||||
|
||||
#include <nuttx/config.h>
|
||||
|
||||
#include <nuttx/nx/nxglib.h>
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-Processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Private Types
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Private Data
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Public Data
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Private Functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Name: nxgl_rectunion
|
||||
*
|
||||
* Description:
|
||||
* Given two rectanges, src1 and src2, return the larger rectangle that
|
||||
* contains both, dest.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
void nxgl_rectunion(FAR struct nxgl_rect_s *dest,
|
||||
FAR const struct nxgl_rect_s *src1,
|
||||
FAR const struct nxgl_rect_s *src2)
|
||||
{
|
||||
dest->pt1.x = ngl_min(src1->pt1.x, src2->pt1.x);
|
||||
dest->pt1.y = ngl_min(src1->pt1.y, src2->pt1.y);
|
||||
dest->pt2.x = ngl_max(src1->pt2.x, src2->pt2.x);
|
||||
dest->pt2.y = ngl_max(src1->pt2.y, src2->pt2.y);
|
||||
}
|
||||
@@ -1,103 +0,0 @@
|
||||
/****************************************************************************
|
||||
* libc/nxglib/lib_nxglib_rgb2yuv.c
|
||||
*
|
||||
* Copyright (C) 2008, 2011, 2013 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
* 3. Neither the name NuttX nor the names of its contributors may be
|
||||
* used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
||||
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
||||
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Included Files
|
||||
****************************************************************************/
|
||||
|
||||
#include <nuttx/config.h>
|
||||
|
||||
#include <stdint.h>
|
||||
#include <debug.h>
|
||||
#include <fixedmath.h>
|
||||
|
||||
#include <nuttx/nx/nxglib.h>
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-Processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
#define b16_P0813 0x000014d0 /* 0.0813 */
|
||||
#define b16_P1140 0x00001d2f /* 0.1140 */
|
||||
#define b16_P1687 0x00002b30 /* 0.1687 */
|
||||
#define b16_P2990 0x00004c8b /* 0.2990 */
|
||||
#define b16_P3313 0x000054d0 /* 0.3313 */
|
||||
#define b16_P4187 0x00006b30 /* 0.4187 */
|
||||
#define b16_P5000 0x00008000 /* 0.5000 */
|
||||
#define b16_P5870 0x00009646 /* 0.5870 */
|
||||
#define b16_128P0 0x00800000 /* 128.0 */
|
||||
|
||||
/****************************************************************************
|
||||
* Private Types
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Private Function Prototypes
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Private Data
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Private Functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Name: nxgl_rgb2yuv
|
||||
*
|
||||
* Description:
|
||||
* Convert 8-bit RGB triplet to 8-bit YUV triplet
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
void nxgl_rgb2yuv(uint8_t r, uint8_t g, uint8_t b,
|
||||
uint8_t *y, uint8_t *u, uint8_t *v)
|
||||
{
|
||||
/* Per the JFIF specification:
|
||||
*
|
||||
* Y = (0.2990 * R) + (0.5870 * G) + (0.1140 * B)
|
||||
* U = 128 - (0.1687 * R) - (0.3313 * G) + (0.5000 * B)
|
||||
* V = 128 + (0.5000 * R) - (0.4187 * G) - (0.0813 * B);
|
||||
*/
|
||||
|
||||
*y = (uint8_t)b16toi(b16muli(b16_P2990, r) + b16muli(b16_P5870, g) + b16muli(b16_P1140, b));
|
||||
*u = (uint8_t)b16toi(b16_128P0 - b16muli(b16_P1687, r) - b16muli(b16_P3313, g) + b16muli(b16_P5000, b));
|
||||
*v = (uint8_t)b16toi(b16_128P0 + b16muli(b16_P5000, r) - b16muli(b16_P4187, g) - b16muli(b16_P0813, b));
|
||||
}
|
||||
@@ -1,82 +0,0 @@
|
||||
/****************************************************************************
|
||||
* libc/nxglib/lib_nxglib_runcopy.c
|
||||
*
|
||||
* Copyright (C) 2008-2011, 2013 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
* 3. Neither the name NuttX nor the names of its contributors may be
|
||||
* used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
||||
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
||||
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Included Files
|
||||
****************************************************************************/
|
||||
|
||||
#include <nuttx/config.h>
|
||||
|
||||
#include <nuttx/nx/nxglib.h>
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-Processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Private Types
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Private Data
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Public Data
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Private Functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Name: nxgl_runcopy
|
||||
*
|
||||
* Description:
|
||||
* This is essentially memcpy for runs. We don't do structure assignments
|
||||
* because some compilers are not good at that.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
void nxgl_runcopy(FAR struct nxgl_run_s *dest, FAR const struct nxgl_run_s *src)
|
||||
{
|
||||
dest->x1 = src->x1;
|
||||
dest->x2 = src->x2;
|
||||
dest->y = src->y;
|
||||
}
|
||||
@@ -1,85 +0,0 @@
|
||||
/****************************************************************************
|
||||
* libc/nxglib/lib_nxglib_runoffset.c
|
||||
*
|
||||
* Copyright (C) 2008-2009, 2011, 2013 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
* 3. Neither the name NuttX nor the names of its contributors may be
|
||||
* used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
||||
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
||||
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Included Files
|
||||
****************************************************************************/
|
||||
|
||||
#include <nuttx/config.h>
|
||||
|
||||
#include <fixedmath.h>
|
||||
#include <nuttx/nx/nxglib.h>
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-Processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Private Types
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Private Data
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Public Data
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Private Functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Name: nxgl_runoffset
|
||||
*
|
||||
* Description:
|
||||
* Offset the run position by the specified (integer) dx, dy values.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
void nxgl_runoffset(FAR struct nxgl_run_s *dest,
|
||||
FAR const struct nxgl_run_s *src,
|
||||
nxgl_coord_t dx, nxgl_coord_t dy)
|
||||
{
|
||||
b16_t b16dx = itob16(dx);
|
||||
dest->x1 = src->x1 + b16dx;
|
||||
dest->x2 = src->x2 + b16dx;
|
||||
dest->y = src->y + dy;
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,82 +0,0 @@
|
||||
/****************************************************************************
|
||||
* libc/nxglib/lib_nxglib_trapcopy.c
|
||||
*
|
||||
* Copyright (C) 2008-2011, 2013 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
* 3. Neither the name NuttX nor the names of its contributors may be
|
||||
* used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
||||
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
||||
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Included Files
|
||||
****************************************************************************/
|
||||
|
||||
#include <nuttx/config.h>
|
||||
|
||||
#include <nuttx/nx/nxglib.h>
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-Processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Private Types
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Private Data
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Public Data
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Private Functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Name: nxgl_trapcopy
|
||||
*
|
||||
* Description:
|
||||
* This is essentially memcpy for trapezoids. We don't do structure
|
||||
* assignments because some compilers are not good at that.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
void nxgl_trapcopy(FAR struct nxgl_trapezoid_s *dest,
|
||||
FAR const struct nxgl_trapezoid_s *src)
|
||||
{
|
||||
nxgl_runcopy(&dest->top, &src->top);
|
||||
nxgl_runcopy(&dest->bot, &src->bot);
|
||||
}
|
||||
@@ -1,82 +0,0 @@
|
||||
/****************************************************************************
|
||||
* libc/nxglib/lib_nxglib_trapoffset.c
|
||||
*
|
||||
* Copyright (C) 2008-2009, 2011, 2013 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
* 3. Neither the name NuttX nor the names of its contributors may be
|
||||
* used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
||||
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
||||
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Included Files
|
||||
****************************************************************************/
|
||||
|
||||
#include <nuttx/config.h>
|
||||
|
||||
#include <nuttx/nx/nxglib.h>
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-Processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Private Types
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Private Data
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Public Data
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Private Functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Name: nxgl_trapoffset
|
||||
*
|
||||
* Description:
|
||||
* Offset the trapezoid position by the specified dx, dy values.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
void nxgl_trapoffset(FAR struct nxgl_trapezoid_s *dest,
|
||||
FAR const struct nxgl_trapezoid_s *src,
|
||||
nxgl_coord_t dx, nxgl_coord_t dy)
|
||||
{
|
||||
nxgl_runoffset(&dest->top, &src->top, dx, dy);
|
||||
nxgl_runoffset(&dest->bot, &src->bot, dx, dy);
|
||||
}
|
||||
@@ -1,82 +0,0 @@
|
||||
/****************************************************************************
|
||||
* libc/nxglib/lib_nxsglib_vectoradd.c
|
||||
*
|
||||
* Copyright (C) 2008-2011, 2013 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
* 3. Neither the name NuttX nor the names of its contributors may be
|
||||
* used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
||||
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
||||
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Included Files
|
||||
****************************************************************************/
|
||||
|
||||
#include <nuttx/config.h>
|
||||
|
||||
#include <nuttx/nx/nxglib.h>
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-Processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Private Types
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Private Data
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Public Data
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Private Functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Name: nxgl_vectoradd
|
||||
*
|
||||
* Description:
|
||||
* Add two 2x1 vectors and save the result to a third.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
void nxgl_vectoradd(FAR struct nxgl_point_s *dest,
|
||||
FAR const struct nxgl_point_s *v1,
|
||||
FAR const struct nxgl_point_s *v2)
|
||||
{
|
||||
dest->x = v1->x + v2->x;
|
||||
dest->y = v1->y + v2->y;
|
||||
}
|
||||
@@ -1,82 +0,0 @@
|
||||
/****************************************************************************
|
||||
* libc/nxglib/lib_nxglib_vectorsubtract.c
|
||||
*
|
||||
* Copyright (C) 2008-2011, 2013 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
* 3. Neither the name NuttX nor the names of its contributors may be
|
||||
* used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
||||
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
||||
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Included Files
|
||||
****************************************************************************/
|
||||
|
||||
#include <nuttx/config.h>
|
||||
|
||||
#include <nuttx/nx/nxglib.h>
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-Processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Private Types
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Private Data
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Public Data
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Private Functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Name: nxgl_vectsubtract
|
||||
*
|
||||
* Description:
|
||||
* Add subtract vector v2 from vector v1 and return the result in vector dest
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
void nxgl_vectsubtract(FAR struct nxgl_point_s *dest,
|
||||
FAR const struct nxgl_point_s *v1,
|
||||
FAR const struct nxgl_point_s *v2)
|
||||
{
|
||||
dest->x = v1->x - v2->x;
|
||||
dest->y = v1->y - v2->y;
|
||||
}
|
||||
@@ -1,102 +0,0 @@
|
||||
/****************************************************************************
|
||||
* libc/nxglib/lib_nxglib_yuv2rgb.c
|
||||
*
|
||||
* Copyright (C) 2008-2009, 2011, 2013 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
* 3. Neither the name NuttX nor the names of its contributors may be
|
||||
* used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
||||
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
||||
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Included Files
|
||||
****************************************************************************/
|
||||
|
||||
#include <nuttx/config.h>
|
||||
|
||||
#include <stdint.h>
|
||||
#include <debug.h>
|
||||
#include <fixedmath.h>
|
||||
|
||||
#include <nuttx/nx/nxglib.h>
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-Processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
#define b16_P3441 0x0000581a /* 0.344147 */
|
||||
#define b16_P7141 0x0000b6d2 /* 0.714142 */
|
||||
#define b16_1P402 0x000166ea /* 1.402008 */
|
||||
#define b16_1P772 0x0001c5a2 /* 1.722003 */
|
||||
#define b16_128P0 0x00800000 /* 128.000000 */
|
||||
|
||||
/****************************************************************************
|
||||
* Private Types
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Private Function Prototypes
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Private Data
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Private Functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Name: nxgl_yuv2rgb
|
||||
*
|
||||
* Description:
|
||||
* Convert 8-bit RGB triplet to 8-bit YUV triplet
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
void nxgl_yuv2rgb(uint8_t y, uint8_t u, uint8_t v,
|
||||
uint8_t *r, uint8_t *g, uint8_t *b)
|
||||
{
|
||||
b16_t vm128 = itob16(v) - b16_128P0;
|
||||
b16_t um128 = itob16(u) - b16_128P0;
|
||||
|
||||
/* Per the JFIF specification:
|
||||
*
|
||||
* R = Y + 1.40200 * (V - 128.0)
|
||||
* G = Y - 0.34414 * (U - 128.0) - 0.71414 * (V - 128.0)
|
||||
* B = Y + 1.77200 * (U - 128.0)
|
||||
*/
|
||||
|
||||
*r = (uint8_t)b16toi(itob16(y) + b16muli(b16_1P402, vm128));
|
||||
*g = (uint8_t)b16toi(itob16(y) - b16muli(b16_P3441, um128) - b16muli(b16_P7141, vm128));
|
||||
*b = (uint8_t)b16toi(itob16(y) + b16muli(b16_1P772, um128));
|
||||
}
|
||||
@@ -1,60 +0,0 @@
|
||||
############################################################################
|
||||
# libc/nxmu/Make.defs
|
||||
#
|
||||
# Copyright (C) 2013 Gregory Nutt. All rights reserved.
|
||||
# Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
# modification, are permitted provided that the following conditions
|
||||
# are met:
|
||||
#
|
||||
# 1. Redistributions of source code must retain the above copyright
|
||||
# notice, this list of conditions and the following disclaimer.
|
||||
# 2. Redistributions in binary form must reproduce the above copyright
|
||||
# notice, this list of conditions and the following disclaimer in
|
||||
# the documentation and/or other materials provided with the
|
||||
# distribution.
|
||||
# 3. Neither the name NuttX nor the names of its contributors may be
|
||||
# used to endorse or promote products derived from this software
|
||||
# without specific prior written permission.
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
||||
# OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
||||
# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
# POSSIBILITY OF SUCH DAMAGE.
|
||||
#
|
||||
############################################################################
|
||||
|
||||
# All of user-space hooks must be built in for the multi-user NX
|
||||
# implementation so that they are available to the application in the kernel
|
||||
# build (single use mode cannot be used with the kernel build)
|
||||
|
||||
ifeq ($(CONFIG_NX),y)
|
||||
ifeq ($(CONFIG_NX_MULTIUSER),y)
|
||||
|
||||
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_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
|
||||
|
||||
# Add the nxmu/ directory to the build
|
||||
|
||||
DEPPATH += --dep-path nxmu
|
||||
VPATH += :nxmu
|
||||
|
||||
endif
|
||||
endif
|
||||
|
||||
@@ -1,156 +0,0 @@
|
||||
/****************************************************************************
|
||||
* libc/nxmu/lib_nx_bitmap.c
|
||||
*
|
||||
* Copyright (C) 2008-2009, 2011-2013 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
* 3. Neither the name NuttX nor the names of its contributors may be
|
||||
* used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
||||
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
||||
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Included Files
|
||||
****************************************************************************/
|
||||
|
||||
#include <nuttx/config.h>
|
||||
|
||||
#include <errno.h>
|
||||
#include <debug.h>
|
||||
|
||||
#include <nuttx/nx/nx.h>
|
||||
#include <nuttx/nx/nxbe.h>
|
||||
#include <nuttx/nx/nxmu.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)
|
||||
{
|
||||
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;
|
||||
}
|
||||
@@ -1,146 +0,0 @@
|
||||
/****************************************************************************
|
||||
* libc/lib/lib_nx_block.c
|
||||
*
|
||||
* Copyright (C) 2012-2013 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
* 3. Neither the name NuttX nor the names of its contributors may be
|
||||
* used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
||||
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
||||
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Included Files
|
||||
****************************************************************************/
|
||||
|
||||
#include <nuttx/config.h>
|
||||
|
||||
#include <errno.h>
|
||||
#include <debug.h>
|
||||
|
||||
#include <nuttx/nx/nx.h>
|
||||
#include <nuttx/nx/nxbe.h>
|
||||
#include <nuttx/nx/nxmu.h>
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-Processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Private Types
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Private Data
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Public Data
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Private Functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Name: nx_block
|
||||
*
|
||||
* Description:
|
||||
* This is callback will do to things: (1) any queue a 'blocked' callback
|
||||
* to the window and then (2) block any further window messaging.
|
||||
*
|
||||
* The 'blocked' callback is the response from nx_block (or nxtk_block).
|
||||
* Those blocking interfaces are used to assure that no further messages are
|
||||
* are directed to the window. Receipt of the blocked callback signifies
|
||||
* that (1) there are no further pending callbacks and (2) that the
|
||||
* window is now 'defunct' and will receive no further callbacks.
|
||||
*
|
||||
* This callback supports coordinated destruction of a window in multi-
|
||||
* user mode. In multi-use mode, the client window logic must stay
|
||||
* intact until all of the queued callbacks are processed. Then the
|
||||
* window may be safely closed. Closing the window prior with pending
|
||||
* callbacks can lead to bad behavior when the callback is executed.
|
||||
*
|
||||
* Multiple user mode only!
|
||||
*
|
||||
* Input Parameters:
|
||||
* wnd - The window to be blocked
|
||||
* arg - An argument that will accompany the block messages (This is arg2
|
||||
* in the blocked callback).
|
||||
*
|
||||
* Return:
|
||||
* OK on success; ERROR on failure with errno set appropriately
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
int nx_block(NXWINDOW hwnd, FAR void *arg)
|
||||
{
|
||||
FAR struct nxbe_window_s *wnd = (FAR struct nxbe_window_s *)hwnd;
|
||||
struct nxsvrmsg_blocked_s outmsg;
|
||||
int ret = OK;
|
||||
|
||||
#ifdef CONFIG_DEBUG
|
||||
if (!hwnd)
|
||||
{
|
||||
set_errno(EINVAL);
|
||||
return ERROR;
|
||||
}
|
||||
#endif
|
||||
|
||||
/* Ignore additional attempts to block messages (no errors reported) */
|
||||
|
||||
if (!NXBE_ISBLOCKED(wnd))
|
||||
{
|
||||
/* Mark the window as blocked. This will stop all messages to the window
|
||||
* (EXCEPT the NX_SVRMSG_BLOCKED). Blocking the messages before sending the
|
||||
* blocked message is awkward but assures that no other messages sneak into
|
||||
* the message queue before we can set the blocked state.
|
||||
*/
|
||||
|
||||
NXBE_SETBLOCKED(wnd);
|
||||
|
||||
/* Send the message inicating that the window is blocked (and because of
|
||||
* queue also that there are no additional queue messages for the window)
|
||||
*/
|
||||
|
||||
outmsg.msgid = NX_SVRMSG_BLOCKED;
|
||||
outmsg.wnd = wnd;
|
||||
outmsg.arg = arg;
|
||||
|
||||
/* Send the window message via nxmu_sendserver (vs. nxmu_sendwindow) so
|
||||
* that it will not be blocked.
|
||||
*/
|
||||
|
||||
ret = nxmu_sendserver(wnd->conn, &outmsg, sizeof(struct nxsvrmsg_blocked_s));
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
@@ -1,99 +0,0 @@
|
||||
/****************************************************************************
|
||||
* libc/lib/lib_nx_closewindow.c
|
||||
*
|
||||
* Copyright (C) 2008-2009, 2011-2013 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
* 3. Neither the name NuttX nor the names of its contributors may be
|
||||
* used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
||||
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
||||
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Included Files
|
||||
****************************************************************************/
|
||||
|
||||
#include <nuttx/config.h>
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <errno.h>
|
||||
#include <debug.h>
|
||||
|
||||
#include <nuttx/nx/nx.h>
|
||||
#include <nuttx/nx/nxbe.h>
|
||||
#include <nuttx/nx/nxmu.h>
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-Processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Private Types
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Private Data
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Public Data
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Private Functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Name: nx_closewindow
|
||||
*
|
||||
* Description:
|
||||
* Destroy a window created by nx_openwindow.
|
||||
*
|
||||
* Input Parameters:
|
||||
* wnd - The window to be destroyed
|
||||
*
|
||||
* Return:
|
||||
* OK on success; ERROR on failure with errno set appropriately
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
int nx_closewindow(NXWINDOW hwnd)
|
||||
{
|
||||
FAR struct nxbe_window_s *wnd = (FAR struct nxbe_window_s *)hwnd;
|
||||
struct nxsvrmsg_closewindow_s outmsg;
|
||||
|
||||
/* Request destruction of the window by the server */
|
||||
|
||||
outmsg.msgid = NX_SVRMSG_CLOSEWINDOW;
|
||||
outmsg.wnd = wnd;
|
||||
|
||||
return nxmu_sendserver(wnd->conn, &outmsg, sizeof(struct nxsvrmsg_closewindow_s));
|
||||
}
|
||||
@@ -1,221 +0,0 @@
|
||||
/****************************************************************************
|
||||
* libc/lib/lib_nx_connect.c
|
||||
*
|
||||
* Copyright (C) 2008-2009, 2011-2013 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
* 3. Neither the name NuttX nor the names of its contributors may be
|
||||
* used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
||||
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
||||
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Included Files
|
||||
****************************************************************************/
|
||||
|
||||
#include <nuttx/config.h>
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <fcntl.h>
|
||||
#include <mqueue.h>
|
||||
#include <errno.h>
|
||||
#include <debug.h>
|
||||
|
||||
#include <nuttx/nx/nx.h>
|
||||
#include <nuttx/nx/nxmu.h>
|
||||
|
||||
#include "lib_internal.h"
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-Processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Private Types
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Private Data
|
||||
****************************************************************************/
|
||||
|
||||
/* Each client is assigned a unique ID using the g_nxcid counter. That
|
||||
* counter increments as each new counter is created and is* protected for
|
||||
* thread safefy with g_nxlibsem. Note that these are the only global values
|
||||
* in the NX implementation. This is because the client ID must be unique
|
||||
* even across all server instances.
|
||||
*
|
||||
* NOTE: that client ID 0 is reserved for the server(s) themselves
|
||||
*/
|
||||
|
||||
static sem_t g_nxlibsem = { 1 };
|
||||
static uint32_t g_nxcid = 1;
|
||||
|
||||
/****************************************************************************
|
||||
* Public Data
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Private Functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Name: nx_connectinstance
|
||||
*
|
||||
* Description:
|
||||
* Open a connection from a client to the NX server. One one client
|
||||
* connection is normally needed per thread as each connection can host
|
||||
* multiple windows.
|
||||
*
|
||||
* NOTES:
|
||||
* - This function returns before the connection is fully instantiated.
|
||||
* it is necessary to wait for the connection event before using the
|
||||
* returned handle.
|
||||
* - Multiple instances of the NX server may run at the same time,
|
||||
* each with different message queue names.
|
||||
*
|
||||
* Input Parameters:
|
||||
* svrmqname - The name for the server incoming message queue
|
||||
*
|
||||
* Return:
|
||||
* Success: A non-NULL handle used with subsequent NX accesses
|
||||
* Failure: NULL is returned and errno is set appropriately
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
NXHANDLE nx_connectinstance(FAR const char *svrmqname)
|
||||
{
|
||||
FAR struct nxfe_conn_s *conn;
|
||||
struct nxsvrmsg_s outmsg;
|
||||
char climqname[NX_CLIENT_MXNAMELEN];
|
||||
struct mq_attr attr;
|
||||
int ret;
|
||||
|
||||
/* Sanity checking */
|
||||
|
||||
#ifdef CONFIG_DEBUG
|
||||
if (!svrmqname)
|
||||
{
|
||||
set_errno(EINVAL);
|
||||
return NULL;
|
||||
}
|
||||
#endif
|
||||
|
||||
/* Allocate the NX client structure */
|
||||
|
||||
conn = (FAR struct nxfe_conn_s *)lib_zalloc(sizeof(struct nxfe_conn_s));
|
||||
if (!conn)
|
||||
{
|
||||
set_errno(ENOMEM);
|
||||
goto errout;
|
||||
}
|
||||
|
||||
/* Create the client MQ name */
|
||||
|
||||
nxmu_semtake(&g_nxlibsem);
|
||||
conn->cid = g_nxcid++;
|
||||
nxmu_semgive(&g_nxlibsem);
|
||||
|
||||
sprintf(climqname, NX_CLIENT_MQNAMEFMT, conn->cid);
|
||||
|
||||
/* Open the client MQ for reading */
|
||||
|
||||
attr.mq_maxmsg = CONFIG_NX_MXCLIENTMSGS;
|
||||
attr.mq_msgsize = NX_MXCLIMSGLEN;
|
||||
attr.mq_flags = 0;
|
||||
|
||||
#ifdef CONFIG_NX_BLOCKING
|
||||
conn->crdmq = mq_open(climqname, O_RDONLY|O_CREAT, 0666, &attr);
|
||||
#else
|
||||
conn->crdmq = mq_open(climqname, O_RDONLY|O_CREAT|O_NONBLOCK, 0666, &attr);
|
||||
#endif
|
||||
if (conn->crdmq == (mqd_t)-1)
|
||||
{
|
||||
gdbg("mq_open(%s) failed: %d\n", climqname, errno);
|
||||
goto errout_with_conn;
|
||||
}
|
||||
|
||||
/* Open the server MQ for writing */
|
||||
|
||||
attr.mq_maxmsg = CONFIG_NX_MXSERVERMSGS;
|
||||
attr.mq_msgsize = NX_MXSVRMSGLEN;
|
||||
attr.mq_flags = 0;
|
||||
|
||||
conn->cwrmq = mq_open(svrmqname, O_WRONLY|O_CREAT, 0666, &attr);
|
||||
if (conn->cwrmq == (mqd_t)-1)
|
||||
{
|
||||
gdbg("mq_open(%s) failed: %d\n", svrmqname, errno);
|
||||
goto errout_with_rmq;
|
||||
}
|
||||
|
||||
/* Inform the server that this client exists */
|
||||
|
||||
outmsg.msgid = NX_SVRMSG_CONNECT;
|
||||
outmsg.conn = conn;
|
||||
|
||||
ret = nxmu_sendserver(conn, &outmsg, sizeof(struct nxsvrmsg_s));
|
||||
if (ret < 0)
|
||||
{
|
||||
gdbg("nxmu_sendserver failed: %d\n", errno);
|
||||
goto errout_with_wmq;
|
||||
}
|
||||
|
||||
#if 0
|
||||
/* Now read until we get a response to this message. The server will
|
||||
* respond with either (1) NX_CLIMSG_CONNECTED, in which case the state
|
||||
* will change to NX_CLISTATE_CONNECTED, or (2) NX_CLIMSG_DISCONNECTED
|
||||
* in which case, nx_message will fail with errno = EHOSTDOWN.
|
||||
*/
|
||||
|
||||
do
|
||||
{
|
||||
ret = nx_eventhandler((NXHANDLE)conn);
|
||||
if (ret < 0)
|
||||
{
|
||||
gdbg("nx_message failed: %d\n", errno);
|
||||
goto errout_with_wmq;
|
||||
}
|
||||
usleep(300000);
|
||||
}
|
||||
while (conn->state != NX_CLISTATE_CONNECTED);
|
||||
#endif
|
||||
return (NXHANDLE)conn;
|
||||
|
||||
errout_with_wmq:
|
||||
mq_close(conn->cwrmq);
|
||||
errout_with_rmq:
|
||||
mq_close(conn->crdmq);
|
||||
errout_with_conn:
|
||||
lib_free(conn);
|
||||
errout:
|
||||
return NULL;
|
||||
}
|
||||
@@ -1,107 +0,0 @@
|
||||
/****************************************************************************
|
||||
* libc/lib/lib_nx_disconnect.c
|
||||
*
|
||||
* Copyright (C) 2008-2009, 2011-2013 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
* 3. Neither the name NuttX nor the names of its contributors may be
|
||||
* used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
||||
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
||||
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Included Files
|
||||
****************************************************************************/
|
||||
|
||||
#include <nuttx/config.h>
|
||||
|
||||
#include <mqueue.h>
|
||||
#include <errno.h>
|
||||
#include <debug.h>
|
||||
|
||||
#include <nuttx/nx/nx.h>
|
||||
#include <nuttx/nx/nxmu.h>
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-Processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Private Types
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Private Data
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Public Data
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Private Functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Name: nx_disconnect
|
||||
*
|
||||
* Description:
|
||||
* Disconnect a client from the NX server and/or free resources reserved
|
||||
* by nx_connect/nx_connectinstance.
|
||||
*
|
||||
* Input Parameters:
|
||||
* handle - the handle returned by nx_connect
|
||||
*
|
||||
* Return:
|
||||
* OK on success; ERROR on failure with the errno set appropriately.
|
||||
* NOTE that handle will no long be valid upon return.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
void nx_disconnect(NXHANDLE handle)
|
||||
{
|
||||
FAR struct nxfe_conn_s *conn = (FAR struct nxfe_conn_s *)handle;
|
||||
struct nxsvrmsg_s outmsg;
|
||||
int ret;
|
||||
|
||||
/* Inform the server that this client no longer exists */
|
||||
|
||||
outmsg.msgid = NX_SVRMSG_DISCONNECT;
|
||||
outmsg.conn = conn;
|
||||
|
||||
/* We will finish the teardown upon receipt of the DISCONNECTED message */
|
||||
|
||||
ret = nxmu_sendserver(conn, &outmsg, sizeof(struct nxsvrmsg_s));
|
||||
if (ret < 0)
|
||||
{
|
||||
gdbg("ERROR: nxmu_sendserver() returned %d\n", ret);
|
||||
}
|
||||
}
|
||||
@@ -1,116 +0,0 @@
|
||||
/****************************************************************************
|
||||
* libc/nxmu/lib_nx_fill.c
|
||||
*
|
||||
* Copyright (C) 2008-2009, 2011-2013 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
* 3. Neither the name NuttX nor the names of its contributors may be
|
||||
* used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
||||
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
||||
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Included Files
|
||||
****************************************************************************/
|
||||
|
||||
#include <nuttx/config.h>
|
||||
|
||||
#include <mqueue.h>
|
||||
#include <errno.h>
|
||||
#include <debug.h>
|
||||
|
||||
#include <nuttx/nx/nxglib.h>
|
||||
#include <nuttx/nx/nx.h>
|
||||
#include <nuttx/nx/nxbe.h>
|
||||
#include <nuttx/nx/nxmu.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)
|
||||
{
|
||||
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));
|
||||
}
|
||||
@@ -1,142 +0,0 @@
|
||||
/****************************************************************************
|
||||
* libc/nxmu/lib_nx_filltrapezoid.c
|
||||
*
|
||||
* Copyright (C) 2008-2009, 2011-2013 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
* 3. Neither the name NuttX nor the names of its contributors may be
|
||||
* used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
||||
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
||||
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Included Files
|
||||
****************************************************************************/
|
||||
|
||||
#include <nuttx/config.h>
|
||||
|
||||
#include <string.h>
|
||||
#include <mqueue.h>
|
||||
#include <errno.h>
|
||||
#include <debug.h>
|
||||
|
||||
#include <nuttx/nx/nx.h>
|
||||
#include <nuttx/nx/nxbe.h>
|
||||
#include <nuttx/nx/nxmu.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)
|
||||
{
|
||||
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));
|
||||
}
|
||||
@@ -1,115 +0,0 @@
|
||||
/****************************************************************************
|
||||
* libc/nxmu/lib_nx_getposition.c
|
||||
*
|
||||
* Copyright (C) 2008-2009, 2011-2013 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
* 3. Neither the name NuttX nor the names of its contributors may be
|
||||
* used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
||||
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
||||
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Included Files
|
||||
****************************************************************************/
|
||||
|
||||
#include <nuttx/config.h>
|
||||
|
||||
#include <errno.h>
|
||||
#include <debug.h>
|
||||
|
||||
#include <nuttx/nx/nx.h>
|
||||
#include <nuttx/nx/nxbe.h>
|
||||
#include <nuttx/nx/nxmu.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)
|
||||
{
|
||||
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));
|
||||
}
|
||||
@@ -1,150 +0,0 @@
|
||||
/****************************************************************************
|
||||
* libc/nxmu/lib_nx_getrectangle.c
|
||||
*
|
||||
* Copyright (C) 2011-2013 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
* 3. Neither the name NuttX nor the names of its contributors may be
|
||||
* used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
||||
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
||||
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Included Files
|
||||
****************************************************************************/
|
||||
|
||||
#include <nuttx/config.h>
|
||||
|
||||
#include <mqueue.h>
|
||||
#include <errno.h>
|
||||
#include <debug.h>
|
||||
|
||||
#include <nuttx/nx/nx.h>
|
||||
#include <nuttx/nx/nxbe.h>
|
||||
#include <nuttx/nx/nxmu.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;
|
||||
}
|
||||
@@ -1,99 +0,0 @@
|
||||
/****************************************************************************
|
||||
* libc/lib/lib_nx_kbdchin.c
|
||||
*
|
||||
* Copyright (C) 2008-2009, 2011-2013 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
* 3. Neither the name NuttX nor the names of its contributors may be
|
||||
* used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
||||
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
||||
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Included Files
|
||||
****************************************************************************/
|
||||
|
||||
#include <nuttx/config.h>
|
||||
|
||||
#include <stdint.h>
|
||||
#include <errno.h>
|
||||
#include <debug.h>
|
||||
|
||||
#include <nuttx/nx/nx.h>
|
||||
#include <nuttx/nx/nxmu.h>
|
||||
|
||||
#ifdef CONFIG_NX_KBD
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-Processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Private Types
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Private Data
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Public Data
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Private Functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Name: nx_kbdchin
|
||||
*
|
||||
* Description:
|
||||
* Used by a thread or interrupt handler that manages some kind of keypad
|
||||
* hardware to report text information to the NX server. That text
|
||||
* data will be routed by the NX server to the appropriate window client.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
int nx_kbdchin(NXHANDLE handle, uint8_t ch)
|
||||
{
|
||||
FAR struct nxfe_conn_s *conn = (FAR struct nxfe_conn_s *)handle;
|
||||
struct nxsvrmsg_kbdin_s outmsg;
|
||||
|
||||
/* Inform the server of the new keypad data */
|
||||
|
||||
outmsg.msgid = NX_SVRMSG_KBDIN;
|
||||
outmsg.nch = 1;
|
||||
outmsg.ch[0] = ch;
|
||||
|
||||
return nxmu_sendserver(conn, &outmsg, sizeof(struct nxsvrmsg_kbdin_s));
|
||||
}
|
||||
|
||||
#endif /* CONFIG_NX_KBD */
|
||||
@@ -1,122 +0,0 @@
|
||||
/****************************************************************************
|
||||
* libc/lib/lib_nx_kbdin.c
|
||||
*
|
||||
* Copyright (C) 2008-2009, 2011-2013 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
* 3. Neither the name NuttX nor the names of its contributors may be
|
||||
* used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
||||
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
||||
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Included Files
|
||||
****************************************************************************/
|
||||
|
||||
#include <nuttx/config.h>
|
||||
|
||||
#include <stdint.h>
|
||||
#include <errno.h>
|
||||
|
||||
#include <nuttx/nx/nx.h>
|
||||
#include <nuttx/nx/nxmu.h>
|
||||
|
||||
#include "lib_internal.h"
|
||||
|
||||
#ifdef CONFIG_NX_KBD
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-Processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Private Types
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Private Data
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Public Data
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Private Functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Name: nx_kbdin
|
||||
*
|
||||
* Description:
|
||||
* Used by a thread or interrupt handler that manages some kind of keypad
|
||||
* hardware to report text information to the NX server. That text
|
||||
* data will be routed by the NX server to the appropriate window client.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
int nx_kbdin(NXHANDLE handle, uint8_t nch, FAR const uint8_t *ch)
|
||||
{
|
||||
FAR struct nxfe_conn_s *conn = (FAR struct nxfe_conn_s *)handle;
|
||||
FAR struct nxsvrmsg_kbdin_s *outmsg;
|
||||
int size;
|
||||
int ret;
|
||||
int i;
|
||||
|
||||
/* Allocate a bigger message to account for the variable amount of character
|
||||
* data.
|
||||
*/
|
||||
|
||||
size = sizeof(struct nxsvrmsg_kbdin_s) + nch - 1;
|
||||
outmsg = (FAR struct nxsvrmsg_kbdin_s *)lib_malloc(size);
|
||||
if (!outmsg)
|
||||
{
|
||||
set_errno(ENOMEM);
|
||||
return ERROR;
|
||||
}
|
||||
|
||||
/* Inform the server of the new keypad data */
|
||||
|
||||
outmsg->msgid = NX_SVRMSG_KBDIN;
|
||||
outmsg->nch = nch;
|
||||
|
||||
for (i = 0; i < nch; i++)
|
||||
{
|
||||
outmsg->ch[i] = ch[i];
|
||||
}
|
||||
|
||||
ret = nxmu_sendserver(conn, outmsg, size);
|
||||
|
||||
lib_free(outmsg);
|
||||
return ret;
|
||||
}
|
||||
|
||||
#endif /* CONFIG_NX_KBD */
|
||||
@@ -1,99 +0,0 @@
|
||||
/****************************************************************************
|
||||
* libc/nxmu/lib_nx_lower.c
|
||||
*
|
||||
* Copyright (C) 2008-2009, 2011-2013 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
* 3. Neither the name NuttX nor the names of its contributors may be
|
||||
* used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
||||
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
||||
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Included Files
|
||||
****************************************************************************/
|
||||
|
||||
#include <nuttx/config.h>
|
||||
|
||||
#include <errno.h>
|
||||
#include <debug.h>
|
||||
|
||||
#include <nuttx/nx/nx.h>
|
||||
#include <nuttx/nx/nxbe.h>
|
||||
#include <nuttx/nx/nxmu.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));
|
||||
}
|
||||
|
||||
@@ -1,100 +0,0 @@
|
||||
/****************************************************************************
|
||||
* libc/lib/lib_nx_mousein.c
|
||||
*
|
||||
* Copyright (C) 2008-2009, 2011-2013 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
* 3. Neither the name NuttX nor the names of its contributors may be
|
||||
* used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
||||
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
||||
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Included Files
|
||||
****************************************************************************/
|
||||
|
||||
#include <nuttx/config.h>
|
||||
|
||||
#include <stdint.h>
|
||||
#include <errno.h>
|
||||
#include <debug.h>
|
||||
|
||||
#include <nuttx/nx/nx.h>
|
||||
#include <nuttx/nx/nxmu.h>
|
||||
|
||||
#ifdef CONFIG_NX_MOUSE
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-Processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Private Types
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Private Data
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Public Data
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Private Functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Name: nx_mousein
|
||||
*
|
||||
* Description:
|
||||
* Used by a thread or interrupt handler that manages some kind of pointing
|
||||
* hardware to report new positional data to the NX server. That positional
|
||||
* data will be routed by the NX server to the appropriate window client.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
int nx_mousein(NXHANDLE handle, nxgl_coord_t x, nxgl_coord_t y, uint8_t buttons)
|
||||
{
|
||||
FAR struct nxfe_conn_s *conn = (FAR struct nxfe_conn_s *)handle;
|
||||
struct nxsvrmsg_mousein_s outmsg;
|
||||
|
||||
/* Inform the server that this client no longer exists */
|
||||
|
||||
outmsg.msgid = NX_SVRMSG_MOUSEIN;
|
||||
outmsg.pt.x = x;
|
||||
outmsg.pt.y = y;
|
||||
outmsg.buttons = buttons;
|
||||
|
||||
return nxmu_sendserver(conn, &outmsg, sizeof(struct nxsvrmsg_mousein_s));
|
||||
}
|
||||
|
||||
#endif /* CONFIG_NX_MOUSE */
|
||||
@@ -1,115 +0,0 @@
|
||||
/****************************************************************************
|
||||
* libc/nxmu/lib_nx_move.c
|
||||
*
|
||||
* Copyright (C) 2008-2009, 2012-2013 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
* 3. Neither the name NuttX nor the names of its contributors may be
|
||||
* used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
||||
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
||||
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Included Files
|
||||
****************************************************************************/
|
||||
|
||||
#include <nuttx/config.h>
|
||||
|
||||
#include <errno.h>
|
||||
#include <debug.h>
|
||||
|
||||
#include <nuttx/nx/nx.h>
|
||||
#include <nuttx/nx/nxbe.h>
|
||||
#include <nuttx/nx/nxmu.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)
|
||||
{
|
||||
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));
|
||||
}
|
||||
@@ -1,132 +0,0 @@
|
||||
/****************************************************************************
|
||||
* libc/nxmu/lib_nx_openwindow.c
|
||||
*
|
||||
* Copyright (C) 2008-2009, 2011-2013 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
* 3. Neither the name NuttX nor the names of its contributors may be
|
||||
* used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
||||
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
||||
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Included Files
|
||||
****************************************************************************/
|
||||
|
||||
#include <nuttx/config.h>
|
||||
|
||||
#include <errno.h>
|
||||
#include <debug.h>
|
||||
|
||||
#include <nuttx/nx/nx.h>
|
||||
#include <nuttx/nx/nxbe.h>
|
||||
#include <nuttx/nx/nxmu.h>
|
||||
|
||||
#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;
|
||||
}
|
||||
|
||||
@@ -1,99 +0,0 @@
|
||||
/****************************************************************************
|
||||
* libc/nxmu/lib_nx_raise.c
|
||||
*
|
||||
* Copyright (C) 2008-2009, 2011-2013 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
* 3. Neither the name NuttX nor the names of its contributors may be
|
||||
* used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
||||
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
||||
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Included Files
|
||||
****************************************************************************/
|
||||
|
||||
#include <nuttx/config.h>
|
||||
|
||||
#include <errno.h>
|
||||
#include <debug.h>
|
||||
|
||||
#include <nuttx/nx/nx.h>
|
||||
#include <nuttx/nx/nxbe.h>
|
||||
#include <nuttx/nx/nxmu.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));
|
||||
}
|
||||
|
||||
@@ -1,105 +0,0 @@
|
||||
/****************************************************************************
|
||||
* libc/lib/lib_nx_releasebkgd.c
|
||||
*
|
||||
* Copyright (C) 2008-2009, 2011-2013 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
* 3. Neither the name NuttX nor the names of its contributors may be
|
||||
* used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
||||
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
||||
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Included Files
|
||||
****************************************************************************/
|
||||
|
||||
#include <nuttx/config.h>
|
||||
|
||||
#include <errno.h>
|
||||
#include <debug.h>
|
||||
|
||||
#include <nuttx/nx/nx.h>
|
||||
#include <nuttx/nx/nxbe.h>
|
||||
#include <nuttx/nx/nxmu.h>
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-Processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Private Types
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Private Data
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Public Data
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Private Functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Name: nx_releasebkgd
|
||||
*
|
||||
* Description:
|
||||
* Release the background window previously acquired using nx_openbgwindow
|
||||
* and return control of the background to NX.
|
||||
*
|
||||
* Input Parameters:
|
||||
* hwnd - The handle returned (indirectly) by nx_requestbkgd
|
||||
*
|
||||
* Return:
|
||||
* OK on success; ERROR on failure with errno set appropriately
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
int nx_releasebkgd(NXWINDOW hwnd)
|
||||
{
|
||||
FAR struct nxbe_window_s *wnd = (FAR struct nxbe_window_s *)hwnd;
|
||||
struct nxsvrmsg_releasebkgd_s outmsg;
|
||||
|
||||
#ifdef CONFIG_DEBUG
|
||||
if (!wnd)
|
||||
{
|
||||
set_errno(EINVAL);
|
||||
return ERROR;
|
||||
}
|
||||
#endif
|
||||
|
||||
/* Request access to the background window from the server */
|
||||
|
||||
outmsg.msgid = NX_SVRMSG_RELEASEBKGD;
|
||||
return nxmu_sendserver(wnd->conn, &outmsg, sizeof(struct nxsvrmsg_releasebkgd_s));
|
||||
}
|
||||
@@ -1,135 +0,0 @@
|
||||
/****************************************************************************
|
||||
* libc/lib/lib_nx_requestbkgd.c
|
||||
*
|
||||
* Copyright (C) 2008-2009, 2011-2013 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
* 3. Neither the name NuttX nor the names of its contributors may be
|
||||
* used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
||||
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
||||
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Included Files
|
||||
****************************************************************************/
|
||||
|
||||
#include <nuttx/config.h>
|
||||
|
||||
#include <errno.h>
|
||||
#include <debug.h>
|
||||
|
||||
#include <nuttx/nx/nx.h>
|
||||
#include <nuttx/nx/nxmu.h>
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-Processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Private Types
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Private Data
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Public Data
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Private Functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Name: nx_requestbkgd
|
||||
*
|
||||
* Description:
|
||||
* NX normally controls a separate window called the background window.
|
||||
* It repaints the window as necessary using only a solid color fill. The
|
||||
* background window always represents the entire screen and is always
|
||||
* below other windows. It is useful for an application to control the
|
||||
* background window in the following conditions:
|
||||
*
|
||||
* - If you want to implement a windowless solution. The single screen
|
||||
* can be used to creat a truly simple graphic environment. In this
|
||||
* case, you should probably also de-select CONFIG_NX_MULTIUSER as well.
|
||||
* - When you want more on the background than a solid color. For
|
||||
* example, if you want an image in the background, or animations in the
|
||||
* background, or live video, etc.
|
||||
*
|
||||
* This API only requests the handle of the background window. That
|
||||
* handle will be returned asynchronously in a subsequent position and
|
||||
* redraw callbacks.
|
||||
*
|
||||
*
|
||||
* Cautions:
|
||||
* - The following should never be called using the background window.
|
||||
* They are guaranteed to cause severe crashes:
|
||||
*
|
||||
* nx_setposition, nx_setsize, nx_raise, nx_lower.
|
||||
*
|
||||
* - Neither nx_opengbwindow or nx_closebgwindow should be called more than
|
||||
* once. Multiple instances of the background window are not supported.
|
||||
*
|
||||
* Input Parameters:
|
||||
* handle - The handle returned by nx_connect
|
||||
* cb - Callbacks to use for processing background window events
|
||||
* arg - User provided argument (see nx_openwindow, nx_constructwindow)
|
||||
*
|
||||
* Return:
|
||||
* OK: Success; ERROR of failure with errno set appropriately.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
int nx_requestbkgd(NXHANDLE handle, FAR const struct nx_callback_s *cb,
|
||||
FAR void *arg)
|
||||
{
|
||||
FAR struct nxfe_conn_s *conn = (FAR struct nxfe_conn_s *)handle;
|
||||
struct nxsvrmsg_requestbkgd_s outmsg;
|
||||
|
||||
#ifdef CONFIG_DEBUG
|
||||
if (!conn || !cb)
|
||||
{
|
||||
set_errno(EINVAL);
|
||||
return ERROR;
|
||||
}
|
||||
#endif
|
||||
|
||||
/* Request access to the background window from the server */
|
||||
|
||||
outmsg.msgid = NX_SVRMSG_REQUESTBKGD;
|
||||
outmsg.conn = conn;
|
||||
outmsg.cb = cb;
|
||||
outmsg.arg = arg;
|
||||
|
||||
return nxmu_sendserver(conn, &outmsg, sizeof(struct nxsvrmsg_requestbkgd_s));
|
||||
}
|
||||
@@ -1,109 +0,0 @@
|
||||
/****************************************************************************
|
||||
* libc/lib/lib_nx_setbgcolor.c
|
||||
*
|
||||
* Copyright (C) 2008-2009, 2011-2013 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
* 3. Neither the name NuttX nor the names of its contributors may be
|
||||
* used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
||||
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
||||
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Included Files
|
||||
****************************************************************************/
|
||||
|
||||
#include <nuttx/config.h>
|
||||
|
||||
#include <errno.h>
|
||||
#include <debug.h>
|
||||
|
||||
#include <nuttx/nx/nx.h>
|
||||
#include <nuttx/nx/nxmu.h>
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-Processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Private Types
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Private Data
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Public Data
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Private Functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Name: nx_setbgcolor
|
||||
*
|
||||
* Description:
|
||||
* Set the color of the background
|
||||
*
|
||||
* Input Parameters:
|
||||
* handle - The connection handle
|
||||
* color - The color to use in the background
|
||||
*
|
||||
* Return:
|
||||
* OK on success; ERROR on failure with errno set appropriately
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
int nx_setbgcolor(NXHANDLE handle,
|
||||
nxgl_mxpixel_t color[CONFIG_NX_NPLANES])
|
||||
{
|
||||
FAR struct nxfe_conn_s *conn = (FAR struct nxfe_conn_s *)handle;
|
||||
struct nxsvrmsg_setbgcolor_s outmsg;
|
||||
|
||||
#ifdef CONFIG_DEBUG
|
||||
if (!conn)
|
||||
{
|
||||
set_errno(EINVAL);
|
||||
return ERROR;
|
||||
}
|
||||
#endif
|
||||
|
||||
/* Format the fill command */
|
||||
|
||||
outmsg.msgid = NX_SVRMSG_SETBGCOLOR;
|
||||
nxgl_colorcopy(outmsg.color, color);
|
||||
|
||||
/* Forward the fill command to the server */
|
||||
|
||||
return nxmu_sendserver(conn, &outmsg, sizeof(struct nxsvrmsg_setbgcolor_s));
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user