More graphic support routines
git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@1321 42af7a65-404d-4744-a932-0658087f49c3
This commit is contained in:
parent
3ba6819bb9
commit
69adbecf5c
16 changed files with 744 additions and 19 deletions
|
@ -42,17 +42,21 @@ include nxglib/Make.defs
|
|||
DEPPATH += --dep-path nxglib
|
||||
CFLAGS += ${shell $(TOPDIR)/tools/incdir.sh "$(CC)" $(TOPDIR)/graphics/nxglib}
|
||||
|
||||
HAVENX := ${shell if [ -d nx ]; then echo "y"; else echo "n";fi}
|
||||
include nxbe/Make.defs
|
||||
DEPPATH += --dep-path nxbe
|
||||
CFLAGS += ${shell $(TOPDIR)/tools/incdir.sh "$(CC)" $(TOPDIR)/graphics/nxbe}
|
||||
|
||||
HAVENX := ${shell if [ -d nxmu ]; then echo "y"; else echo "n";fi}
|
||||
ifeq ($(HAVENX),y)
|
||||
include nx/Make.defs
|
||||
DEPPATH += --dep-path nx
|
||||
CFLAGS += ${shell $(TOPDIR)/tools/incdir.sh "$(CC)" $(TOPDIR)/graphics/nx}
|
||||
include nxmu/Make.defs
|
||||
DEPPATH += --dep-path nxmu
|
||||
CFLAGS += ${shell $(TOPDIR)/tools/incdir.sh "$(CC)" $(TOPDIR)/graphics/nxmu}
|
||||
endif
|
||||
|
||||
ASRCS = $(NXGLIB_ASRCS) $(NX_ASRCS)
|
||||
ASRCS = $(NXGLIB_ASRCS) $(NXBE_ASRCS) $(NX_ASRCS)
|
||||
AOBJS = $(ASRCS:.S=$(OBJEXT))
|
||||
|
||||
CSRCS = $(NXGLIB_CSRCS) $(NX_CSRCS)
|
||||
CSRCS = $(NXGLIB_CSRCS) $(NXBE_CSRCS) $(NX_CSRCS)
|
||||
COBJS = $(CSRCS:.c=$(OBJEXT))
|
||||
|
||||
SRCS = $(ASRCS) $(CSRCS)
|
||||
|
@ -60,7 +64,7 @@ OBJS = $(AOBJS) $(COBJS)
|
|||
|
||||
BIN = libgraphics$(LIBEXT)
|
||||
|
||||
VPATH = nxglib:nx
|
||||
VPATH = nxglib:nxbe:nxmu
|
||||
|
||||
all: mklibgraphics
|
||||
.PHONY : depend clean distclean mklibgraphics gensources gen1bppsources \
|
||||
|
|
|
@ -44,8 +44,8 @@
|
|||
#include <assert.h>
|
||||
#include <debug.h>
|
||||
|
||||
#include <nuttx/nx.h>
|
||||
#include "nxfe.h"
|
||||
#include <nuttx/nxglib.h>
|
||||
#include "nxbe.h"
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-Processor Definitions
|
||||
|
|
|
@ -41,10 +41,9 @@
|
|||
#include <sys/types.h>
|
||||
|
||||
#include <nuttx/nxglib.h>
|
||||
#include <nuttx/nx.h>
|
||||
|
||||
#include "nxbe.h"
|
||||
#include "nxfe.h"
|
||||
//#include "nxfe.h"
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-Processor Definitions
|
||||
|
|
|
@ -43,7 +43,7 @@
|
|||
#include <nuttx/nxglib.h>
|
||||
|
||||
#include "nxbe.h"
|
||||
#include "nxfe.h"
|
||||
//#include "nxfe.h"
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-Processor Definitions
|
||||
|
|
|
@ -43,8 +43,9 @@
|
|||
#include <errno.h>
|
||||
#include <debug.h>
|
||||
|
||||
#include <nuttx/nxglib.h>
|
||||
#include "nxbe.h"
|
||||
#include "nxfe.h"
|
||||
//#include "nxfe.h"
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-Processor Definitions
|
||||
|
|
|
@ -40,10 +40,10 @@
|
|||
#include <nuttx/config.h>
|
||||
#include <sys/types.h>
|
||||
|
||||
#include <nuttx/nx.h>
|
||||
#include <nuttx/nxglib.h>
|
||||
|
||||
#include "nxbe.h"
|
||||
#include "nxfe.h"
|
||||
//#include "nxfe.h"
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-Processor Definitions
|
||||
|
@ -119,6 +119,6 @@ void nxbe_setposition(FAR struct nxbe_window_s *wnd,
|
|||
/* Report the new size/position */
|
||||
|
||||
#ifdef CONFIG_NX_MULTIUSER
|
||||
nxmu_getposition(wnd);
|
||||
nxmu_reportposition(wnd);
|
||||
#endif
|
||||
}
|
||||
|
|
|
@ -40,8 +40,8 @@
|
|||
#include <nuttx/config.h>
|
||||
#include <sys/types.h>
|
||||
|
||||
#include <nuttx/nx.h>
|
||||
#include "nxfe.h"
|
||||
#include <nuttx/nxglib.h>
|
||||
#include "nxbe.h"
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-Processor Definitions
|
||||
|
@ -108,6 +108,6 @@ void nxbe_setsize(FAR struct nxbe_window_s *wnd,
|
|||
/* Report the new size/position */
|
||||
|
||||
#ifdef CONFIG_NX_MULTIUSER
|
||||
nxmu_getposition(wnd);
|
||||
nxmu_reportposition(wnd);
|
||||
#endif
|
||||
}
|
||||
|
|
|
@ -51,6 +51,9 @@ RMOVE2_CSRCS = nxglib_moverectangle_8bpp.c nxglib_moverectangle_16bpp.c \
|
|||
# nxglib_copyrectangle_4bpp.c
|
||||
RCOPY2_CSRCS = nxglib_copyrectangle_8bpp.c nxglib_copyrectangle_16bpp.c \
|
||||
nxglib_copyrectangle_24bpp.c nxglib_copyrectangle_32bpp.c
|
||||
RECT_CRCS = nxglib_rectcopy.c nxglib_rectoffset.c nxglib_vectoradd.c \
|
||||
nxglib_rectintersect.c nxglib_nonintersecting.c \
|
||||
nxglib_rectoverlap.c nxglib_nullrect.c
|
||||
NXGLIB_CSRCS = nxglib_rgb2yuv.c nxglib_yuv2rgb.c \
|
||||
$(RFILL1_CSRCS) $(RFILL2_CSRCS) $(TFILL1_CSRCS) $(TFILL2_CSRCS) \
|
||||
$(RMOVE1_CSRCS) $(RMOVE2_CSRCS) $(RCOPY1_CSRCS) $(RCOPY2_CSRCS)
|
||||
|
|
116
graphics/nxglib/nxglib_nonintersecting.c
Normal file
116
graphics/nxglib/nxglib_nonintersecting.c
Normal file
|
@ -0,0 +1,116 @@
|
|||
/****************************************************************************
|
||||
* graphics/nxglib/nxsglib_rectnonintersecting.c
|
||||
*
|
||||
* Copyright (C) 2008 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <spudmonkey@racsa.co.cr>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
* 3. Neither the name NuttX nor the names of its contributors may be
|
||||
* used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
||||
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
||||
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Included Files
|
||||
****************************************************************************/
|
||||
|
||||
#include <nuttx/config.h>
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <nuttx/fb.h>
|
||||
#include <nuttx/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()
|
||||
*/
|
||||
|
||||
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;
|
||||
|
||||
result[NX_BOTTOM_NDX].pt1.x = rect1->pt1.x;
|
||||
result[NX_BOTTOM_NDX].pt1.y = intersection.pt2.y;
|
||||
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;
|
||||
result[NX_LEFT_NDX].pt2.y = intersection.pt2.y;
|
||||
|
||||
result[NX_RIGHT_NDX].pt1.x = intersection.pt2.x;
|
||||
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;
|
||||
}
|
||||
|
||||
|
82
graphics/nxglib/nxglib_nullrect.c
Normal file
82
graphics/nxglib/nxglib_nullrect.c
Normal file
|
@ -0,0 +1,82 @@
|
|||
/****************************************************************************
|
||||
* graphics/nxglib/nxsglib_nullrect.c
|
||||
*
|
||||
* Copyright (C) 2008 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <spudmonkey@racsa.co.cr>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
* 3. Neither the name NuttX nor the names of its contributors may be
|
||||
* used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
||||
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
||||
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Included Files
|
||||
****************************************************************************/
|
||||
|
||||
#include <nuttx/config.h>
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <nuttx/fb.h>
|
||||
#include <nuttx/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.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
boolean nxgl_nullrect(FAR const struct nxgl_rect_s *rect)
|
||||
{
|
||||
return (rect->pt1.x >= rect->pt2.x || rect->pt1.y >= rect->pt2.y);
|
||||
}
|
||||
|
86
graphics/nxglib/nxglib_rectcopy.c
Normal file
86
graphics/nxglib/nxglib_rectcopy.c
Normal file
|
@ -0,0 +1,86 @@
|
|||
/****************************************************************************
|
||||
* graphics/nxglib/nxsglib_rectcopy.c
|
||||
*
|
||||
* Copyright (C) 2008 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <spudmonkey@racsa.co.cr>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
* 3. Neither the name NuttX nor the names of its contributors may be
|
||||
* used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
||||
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
||||
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Included Files
|
||||
****************************************************************************/
|
||||
|
||||
#include <nuttx/config.h>
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <nuttx/fb.h>
|
||||
#include <nuttx/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
|
||||
* assignements 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;
|
||||
}
|
86
graphics/nxglib/nxglib_rectintersect.c
Normal file
86
graphics/nxglib/nxglib_rectintersect.c
Normal file
|
@ -0,0 +1,86 @@
|
|||
/****************************************************************************
|
||||
* graphics/nxglib/nxsglib_rectintersect.c
|
||||
*
|
||||
* Copyright (C) 2008 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <spudmonkey@racsa.co.cr>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
* 3. Neither the name NuttX nor the names of its contributors may be
|
||||
* used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
||||
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
||||
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Included Files
|
||||
****************************************************************************/
|
||||
|
||||
#include <nuttx/config.h>
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <nuttx/fb.h>
|
||||
#include <nuttx/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);
|
||||
}
|
89
graphics/nxglib/nxglib_rectoffset.c
Normal file
89
graphics/nxglib/nxglib_rectoffset.c
Normal file
|
@ -0,0 +1,89 @@
|
|||
/****************************************************************************
|
||||
* graphics/nxglib/nxsglib_rectoffset.c
|
||||
*
|
||||
* Copyright (C) 2008 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <spudmonkey@racsa.co.cr>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
* 3. Neither the name NuttX nor the names of its contributors may be
|
||||
* used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
||||
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
||||
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Included Files
|
||||
****************************************************************************/
|
||||
|
||||
#include <nuttx/config.h>
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <nuttx/fb.h>
|
||||
#include <nuttx/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;
|
||||
}
|
||||
|
||||
|
||||
|
90
graphics/nxglib/nxglib_rectoverlap.c
Normal file
90
graphics/nxglib/nxglib_rectoverlap.c
Normal file
|
@ -0,0 +1,90 @@
|
|||
/****************************************************************************
|
||||
* graphics/nxglib/nxsglib_nulloverlap.c
|
||||
*
|
||||
* Copyright (C) 2008 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <spudmonkey@racsa.co.cr>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
* 3. Neither the name NuttX nor the names of its contributors may be
|
||||
* used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
||||
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
||||
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Included Files
|
||||
****************************************************************************/
|
||||
|
||||
#include <nuttx/config.h>
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <nuttx/fb.h>
|
||||
#include <nuttx/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
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
boolean 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 */
|
||||
}
|
||||
|
86
graphics/nxglib/nxglib_vectoradd.c
Normal file
86
graphics/nxglib/nxglib_vectoradd.c
Normal file
|
@ -0,0 +1,86 @@
|
|||
/****************************************************************************
|
||||
* graphics/nxglib/nxsglib_vectoradd.c
|
||||
*
|
||||
* Copyright (C) 2008 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <spudmonkey@racsa.co.cr>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
* 3. Neither the name NuttX nor the names of its contributors may be
|
||||
* used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
||||
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
||||
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Included Files
|
||||
****************************************************************************/
|
||||
|
||||
#include <nuttx/config.h>
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <nuttx/fb.h>
|
||||
#include <nuttx/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;
|
||||
}
|
||||
|
||||
|
|
@ -306,6 +306,89 @@ EXTERN void nxgl_copyrectangle_32bpp(FAR struct fb_planeinfo_s *pinfo,
|
|||
FAR const struct nxgl_point_s *origin,
|
||||
unsigned int srcstride);
|
||||
|
||||
/****************************************************************************
|
||||
* Name: nxgl_rectcopy
|
||||
*
|
||||
* Description:
|
||||
* This is essentially memcpy for rectangles. We don't do structure
|
||||
* assignements because some compilers are not good at that.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
EXTERN void nxgl_rectcopy(FAR struct nxgl_rect_s *dest,
|
||||
FAR const struct nxgl_rect_s *src);
|
||||
|
||||
/****************************************************************************
|
||||
* Name: nxgl_rectoffset
|
||||
*
|
||||
* Description:
|
||||
* Offset the rectangle position by the specified dx, dy values.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
EXTERN void nxgl_rectoffset(FAR struct nxgl_rect_s *dest,
|
||||
FAR const struct nxgl_rect_s *src,
|
||||
nxgl_coord_t dx, nxgl_coord_t dy);
|
||||
|
||||
/****************************************************************************
|
||||
* Name: nxgl_vectoradd
|
||||
*
|
||||
* Description:
|
||||
* Add two 2x1 vectors and save the result to a third.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
EXTERN void nxgl_vectoradd(FAR struct nxgl_point_s *dest,
|
||||
FAR const struct nxgl_point_s *v1,
|
||||
FAR const struct nxgl_point_s *v2);
|
||||
|
||||
/****************************************************************************
|
||||
* Name: nxgl_rectintersect
|
||||
*
|
||||
* Description:
|
||||
* Return the rectangle representing the intersection of the two rectangles.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
EXTERN void nxgl_rectintersect(FAR struct nxgl_rect_s *dest,
|
||||
FAR const struct nxgl_rect_s *src1,
|
||||
FAR const struct nxgl_rect_s *src2);
|
||||
|
||||
/****************************************************************************
|
||||
* 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)
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
EXTERN void nxgl_nonintersecting(FAR struct nxgl_rect_s result[4],
|
||||
FAR const struct nxgl_rect_s *rect1,
|
||||
FAR const struct nxgl_rect_s *rect2);
|
||||
|
||||
/****************************************************************************
|
||||
* Name: nxgl_rectoverlap
|
||||
*
|
||||
* Description:
|
||||
* Return TRUE if the two rectangles overlap
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
EXTERN boolean nxgl_rectoverlap(FAR struct nxgl_rect_s *rect1,
|
||||
FAR struct nxgl_rect_s *rect2);
|
||||
|
||||
/****************************************************************************
|
||||
* Name: nxgl_nullrect
|
||||
*
|
||||
* Description:
|
||||
* Return TRUE if the area of the retangle is <= 0.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
EXTERN boolean nxgl_nullrect(FAR const struct nxgl_rect_s *rect);
|
||||
|
||||
#undef EXTERN
|
||||
#if defined(__cplusplus)
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue