mirror of
https://github.com/apache/nuttx.git
synced 2026-06-04 23:03:27 +08:00
Adds support for cursors with differing pixel depths on multiple displays
Squashed commit of the following:
Update .gitignore
Fix some compile-related issues.
Add support for cursors of differing pixeldepth.
Various compile-related fixes.
graphics/nxglib: Separate cursor rendering routines in nxglib/ (like all other rendering logic). graphics/nxbe: Flesh out remaining cursor methods.
This commit is contained in:
@@ -10,4 +10,6 @@
|
||||
/pwfb_filltrapezoid_*bpp.c
|
||||
/pwfb_moverectangle_*bpp.c
|
||||
/pwfb_copyrectangle_*bpp.c
|
||||
|
||||
/nxglib_cursor_draw_*bpp.c
|
||||
/nxglib_cursor_erase_*bpp.c
|
||||
/nxglib_cursor_backup_*bpp.c
|
||||
@@ -97,6 +97,19 @@ CSRCS += pwfb_copyrectangle_32bpp.c
|
||||
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_NX_SWCURSOR),y)
|
||||
|
||||
CSRCS += nxglib_cursor_draw_8bpp.c nxglib_cursor_draw_16bpp.c
|
||||
CSRCS += nxglib_cursor_draw_24bpp.c nxglib_cursor_draw_32bpp.c
|
||||
|
||||
CSRCS += nxglib_cursor_erase_8bpp.c nxglib_cursor_erase_16bpp.c
|
||||
CSRCS += nxglib_cursor_erase_24bpp.c nxglib_cursor_erase_32bpp.c
|
||||
|
||||
CSRCS += nxglib_cursor_backup_8bpp.c nxglib_cursor_backup_16bpp.c
|
||||
CSRCS += nxglib_cursor_backup_24bpp.c nxglib_cursor_backup_32bpp.c
|
||||
|
||||
endif
|
||||
|
||||
DEPPATH += --dep-path nxglib
|
||||
CFLAGS += ${shell $(INCDIR) $(INCDIROPT) "$(CC)" $(TOPDIR)/graphics/nxglib}
|
||||
#VPATH += :nxglib
|
||||
|
||||
@@ -0,0 +1,105 @@
|
||||
############################################################################
|
||||
# graphics/nxglib/Makefile.cursor
|
||||
#
|
||||
# Copyright (C) 2019 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.
|
||||
#
|
||||
############################################################################
|
||||
|
||||
-include $(TOPDIR)/Make.defs
|
||||
|
||||
ifeq ($(NXGLIB_BITSPERPIXEL),8)
|
||||
NXGLIB_SUFFIX := _8bpp
|
||||
DRAW_CSRC := nxglib_cursor_draw_8bpp.c
|
||||
ERASE_CSRC := nxglib_cursor_erase_8bpp.c
|
||||
BACKUP_CSRC := nxglib_cursor_backup_8bpp.c
|
||||
endif
|
||||
ifeq ($(NXGLIB_BITSPERPIXEL),16)
|
||||
NXGLIB_SUFFIX := _16bpp
|
||||
DRAW_CSRC := nxglib_cursor_draw_16bpp.c
|
||||
ERASE_CSRC := nxglib_cursor_erase_16bpp.c
|
||||
BACKUP_CSRC := nxglib_cursor_backup_16bpp.c
|
||||
endif
|
||||
ifeq ($(NXGLIB_BITSPERPIXEL),24)
|
||||
NXGLIB_SUFFIX := _24bpp
|
||||
DRAW_CSRC := nxglib_cursor_draw_24bpp.c
|
||||
ERASE_CSRC := nxglib_cursor_erase_24bpp.c
|
||||
BACKUP_CSRC := nxglib_cursor_backup_24bpp.c
|
||||
endif
|
||||
ifeq ($(NXGLIB_BITSPERPIXEL),32)
|
||||
NXGLIB_SUFFIX := _32bpp
|
||||
DRAW_CSRC := nxglib_cursor_draw_32bpp.c
|
||||
ERASE_CSRC := nxglib_cursor_erase_32bpp.c
|
||||
BACKUP_CSRC := nxglib_cursor_backup_32bpp.c
|
||||
endif
|
||||
|
||||
CPPFLAGS += -DNXGLIB_BITSPERPIXEL=$(NXGLIB_BITSPERPIXEL)
|
||||
CPPFLAGS += -DNXGLIB_SUFFIX=$(NXGLIB_SUFFIX)
|
||||
|
||||
DRAW_TMP = $(DRAW_CSRC:.c=.i)
|
||||
ERASE_TMP = $(ERASE_CSRC:.c=.i)
|
||||
BACKUP_TMP = $(BACKUP_CSRC:.c=.i)
|
||||
|
||||
GEN_CSRCS = $(DRAW_CSRC) $(ERASE_CSRC) $(BACKUP_CSRC)
|
||||
|
||||
BLITDIR = cursor
|
||||
|
||||
all: $(GEN_CSRCS)
|
||||
.PHONY : clean distclean
|
||||
|
||||
$(DRAW_CSRC) : $(BLITDIR)/nxglib_cursor_draw.c nxglib_bitblit.h
|
||||
ifneq ($(NXGLIB_BITSPERPIXEL),)
|
||||
$(call PREPROCESS, $(BLITDIR)/nxglib_cursor_draw.c, $(DRAW_TMP))
|
||||
$(Q) cat $(DRAW_TMP) | sed -e "/^#/d" >$@
|
||||
$(Q) rm -f $(DRAW_TMP)
|
||||
endif
|
||||
|
||||
$(ERASE_CSRC) : $(BLITDIR)/nxglib_cursor_erase.c nxglib_bitblit.h
|
||||
ifneq ($(NXGLIB_BITSPERPIXEL),)
|
||||
$(call PREPROCESS, $(BLITDIR)/nxglib_cursor_erase.c, $(ERASE_TMP))
|
||||
$(Q) cat $(ERASE_TMP) | sed -e "/^#/d" >$@
|
||||
$(Q) rm -f $(ERASE_TMP)
|
||||
endif
|
||||
|
||||
$(BACKUP_CSRC) : $(BLITDIR)/nxglib_cursor_backup.c nxglib_bitblit.h
|
||||
ifneq ($(NXGLIB_BITSPERPIXEL),)
|
||||
$(call PREPROCESS, $(BLITDIR)/nxglib_cursor_backup.c, $(BACKUP_TMP))
|
||||
$(Q) cat $(BACKUP_TMP) | sed -e "/^#/d" >$@
|
||||
$(Q) rm -f $(BACKUP_TMP)
|
||||
endif
|
||||
|
||||
clean:
|
||||
$(call DELFILE, *.i)
|
||||
$(call CLEAN)
|
||||
|
||||
distclean: clean
|
||||
$(call DELFILE, nxglib_cursor_draw_*bpp.c)
|
||||
$(call DELFILE, nxglib_cursor_erase_*bpp.c)
|
||||
$(call DELFILE, nxglib_cursor_backup_*bpp.c)
|
||||
@@ -0,0 +1,145 @@
|
||||
/****************************************************************************
|
||||
* graphics/nxglib/nxglib_cursor_backup.c
|
||||
*
|
||||
* Copyright (C) 2019 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 <assert.h>
|
||||
|
||||
#include <nuttx/nx/nxglib.h>
|
||||
|
||||
#include "nxglib_bitblit.h"
|
||||
#include "../nxbe/nxbe.h"
|
||||
#include "nxglib.h"
|
||||
|
||||
#ifdef CONFIG_NX_SWCURSOR
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Name: nxglib_cursor_backup
|
||||
*
|
||||
* Description:
|
||||
* Saved the cursor background data from the device graphics memory into an
|
||||
* internal save area. This saved image will be used to "erase" the cursor
|
||||
* when necessary.
|
||||
*
|
||||
* Input Parameters:
|
||||
* be - The back-end state structure instance
|
||||
* planeno - The color plane being drawn
|
||||
*
|
||||
* Returned Value:
|
||||
* None
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
void NXGL_FUNCNAME(nxglib_cursor_backup, NXGLIB_SUFFIX)
|
||||
(FAR struct nxbe_state_s *be, int planeno)
|
||||
{
|
||||
struct nxgl_rect_s intersection;
|
||||
struct nxgl_point_s origin;
|
||||
FAR struct nxbe_plane_s *plane;
|
||||
FAR uint8_t *fbmem;
|
||||
FAR uint8_t *sline;
|
||||
FAR uint8_t *dline;
|
||||
FAR NXGL_PIXEL_T *src;
|
||||
FAR NXGL_PIXEL_T *dest;
|
||||
nxgl_coord_t width;
|
||||
nxgl_coord_t height;
|
||||
nxgl_coord_t sstride;
|
||||
nxgl_coord_t dstride;
|
||||
int row;
|
||||
int col;
|
||||
|
||||
/* Handle the case some or all of the backup image is off of the display. */
|
||||
|
||||
nxgl_rectintersect(&intersection, &be->cursor.bounds, &be->bkgd.bounds);
|
||||
if (!nxgl_nullrect(&intersection))
|
||||
{
|
||||
/* Get the width and the height of the images in pixels/rows */
|
||||
|
||||
width = be->cursor.bounds.pt2.x = be->cursor.bounds.pt1.x + 1;
|
||||
height = be->cursor.bounds.pt2.y = be->cursor.bounds.pt1.y + 1;
|
||||
|
||||
/* Get the width of the images in bytes. */
|
||||
|
||||
plane = &be->plane[planeno];
|
||||
sstride = plane->pinfo.stride;
|
||||
|
||||
dstride = NXGL_SCALEX(width);
|
||||
|
||||
/* Get the origin position in the background image */
|
||||
|
||||
nxgl_vectsubtract(&origin, &intersection.pt1, &be->cursor.bounds.pt1);
|
||||
|
||||
/* Get the source and destination addresses */
|
||||
|
||||
fbmem = (FAR uint8_t *)plane->pinfo.fbmem;
|
||||
sline = (FAR uint8_t *)fbmem + sstride * be->cursor.bounds.pt1.y +
|
||||
NXGL_SCALEX(be->cursor.bounds.pt1.x);
|
||||
dline = (FAR uint8_t *)be->cursor.bkgd + dstride * origin.y +
|
||||
NXGL_SCALEX(origin.y);
|
||||
|
||||
/* Save the cursor background by copying the device graphics memory */
|
||||
|
||||
/* Loop for each row */
|
||||
|
||||
for (row = 0; row < height; row++)
|
||||
{
|
||||
/* Reset to the beginning of the line */
|
||||
|
||||
src = (FAR NXGL_PIXEL_T *)sline;
|
||||
dest = (FAR NXGL_PIXEL_T *)dline;
|
||||
|
||||
/* Loop for each column */
|
||||
|
||||
for (col = 0; col < width; col++)
|
||||
{
|
||||
*dest++ = *src++;
|
||||
}
|
||||
|
||||
/* Update the row addresses to the next row */
|
||||
|
||||
sline += sstride;
|
||||
dline += dstride;
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif /* CONFIG_NX_SWCURSOR */
|
||||
@@ -0,0 +1,234 @@
|
||||
/****************************************************************************
|
||||
* graphics/nxglib/nxglib_cursor_draw.c
|
||||
*
|
||||
* Copyright (C) 2019 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 <assert.h>
|
||||
|
||||
#include <nuttx/nx/nxglib.h>
|
||||
|
||||
#include "nxglib_bitblit.h"
|
||||
#include "../nxbe/nxbe.h"
|
||||
#include "nxglib.h"
|
||||
|
||||
#ifdef CONFIG_NX_SWCURSOR
|
||||
|
||||
/****************************************************************************
|
||||
* Private Functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Name: nxbe_map_color
|
||||
*
|
||||
* Description:
|
||||
* Map a 2-bit cursor pixel value to a device pixel value
|
||||
*
|
||||
* REVISIT: If we really were to support multiple displays (or planes)
|
||||
* with differing pixel depth, then the cursor.color1,2,3 would be
|
||||
* insufficient: There would have to be multiple color sets for each
|
||||
* plane.
|
||||
*
|
||||
* Input Parameters:
|
||||
* be - The back-end state structure instance
|
||||
* pixel - Pixel to be mapped
|
||||
*
|
||||
* Returned Value:
|
||||
* The mapped pixel.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
static NXGL_PIXEL_T nxbe_map_color(FAR struct nxbe_state_s *be, int plane,
|
||||
uint8_t pixel)
|
||||
{
|
||||
switch (pixel)
|
||||
{
|
||||
case 0:
|
||||
default:
|
||||
return 0; /* Should not happen */
|
||||
|
||||
case 1:
|
||||
return be->cursor.color1[plane];
|
||||
break;
|
||||
|
||||
case 2:
|
||||
return be->cursor.color2[plane];
|
||||
break;
|
||||
|
||||
case 3:
|
||||
return be->cursor.color3[plane];
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Name: nxglib_cursor_draw
|
||||
*
|
||||
* Description:
|
||||
* Update the cursor region by drawing directly in device memory.
|
||||
*
|
||||
* Input Parameters:
|
||||
* be - The back-end state structure instance
|
||||
* planeno - The color plane being drawn
|
||||
*
|
||||
* Returned Value:
|
||||
* None
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
void NXGL_FUNCNAME(nxglib_cursor_draw, NXGLIB_SUFFIX)
|
||||
(FAR struct nxbe_state_s *be, int planeno)
|
||||
{
|
||||
struct nxgl_rect_s intersection;
|
||||
struct nxgl_point_s origin;
|
||||
FAR struct nxbe_plane_s *plane;
|
||||
FAR uint8_t *fbmem;
|
||||
FAR uint8_t *src;
|
||||
FAR uint8_t *sline;
|
||||
FAR uint8_t *dline;
|
||||
FAR NXGL_PIXEL_T *dest;
|
||||
nxgl_coord_t width;
|
||||
nxgl_coord_t height;
|
||||
nxgl_coord_t sstride;
|
||||
nxgl_coord_t dstride;
|
||||
nxgl_coord_t sshift;
|
||||
int shift;
|
||||
int row;
|
||||
int col;
|
||||
|
||||
/* Handle the case some or all of the cursor image is off of the display. */
|
||||
|
||||
nxgl_rectintersect(&intersection, &be->cursor.bounds, &be->bkgd.bounds);
|
||||
if (!nxgl_nullrect(&intersection))
|
||||
{
|
||||
/* Get the width and the height of the images in pixels/rows */
|
||||
|
||||
width = be->cursor.bounds.pt2.x = be->cursor.bounds.pt1.x + 1;
|
||||
height = be->cursor.bounds.pt2.y = be->cursor.bounds.pt1.y + 1;
|
||||
|
||||
/* Get the width of the images in bytes. */
|
||||
|
||||
sstride = (width + 3) >> 2; /* 2 bits per pixel, 4 pixels per byte */
|
||||
|
||||
plane = &be->plane[planeno];
|
||||
dstride = plane->pinfo.stride;
|
||||
|
||||
/* Get the origin position in the cursor image */
|
||||
|
||||
nxgl_vectsubtract(&origin, &intersection.pt1, &be->cursor.bounds.pt1);
|
||||
|
||||
/* Update any cursor graphics on top of the device display to include
|
||||
* the modified cursor.
|
||||
*
|
||||
* REVISIT: This will only work for a single plane and for bits per
|
||||
* pixel greater than or equal to 8.
|
||||
*/
|
||||
|
||||
fbmem = (FAR uint8_t *)plane->pinfo.fbmem;
|
||||
sline = be->cursor.image + sstride * origin.y + (origin.y >> 2);
|
||||
dline = (FAR uint8_t *)fbmem + dstride * be->cursor.bounds.pt1.y +
|
||||
NXGL_SCALEX(be->cursor.bounds.pt1.x);
|
||||
|
||||
sshift = (3 - (origin.y & 3)) << 1; /* MS first {0, 2, 4, 6} */
|
||||
|
||||
/* Loop for each row */
|
||||
|
||||
for (row = 0; row < height; row++)
|
||||
{
|
||||
/* Reset to the beginning of the line */
|
||||
|
||||
src = sline;
|
||||
dest = (FAR NXGL_PIXEL_T *)dline;
|
||||
shift = sshift;
|
||||
|
||||
/* Loop for each column */
|
||||
|
||||
for (col = 0; col < width; col++)
|
||||
{
|
||||
/* Extract the 2-bit pixel. Data is always packed MS first.
|
||||
* Shift for first pixel=6, shift for last pixel=0
|
||||
*/
|
||||
|
||||
uint8_t pixel = (*src >> shift) & 3;
|
||||
|
||||
/* Skip over invisible pixels */
|
||||
|
||||
if (pixel != 0)
|
||||
{
|
||||
*dest = nxbe_map_color(be, 0, pixel);
|
||||
}
|
||||
|
||||
/* Update to the next column */
|
||||
|
||||
col++;
|
||||
dest++;
|
||||
|
||||
/* Was that the last pixel in the byte? */
|
||||
|
||||
if (shift == 0)
|
||||
{
|
||||
/* Update source column addresses and reset the shift
|
||||
* value
|
||||
*/
|
||||
|
||||
src++;
|
||||
shift = 6;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* The shift value is one of {2, 4, 6}. Update the shift
|
||||
* value following this order: 6, 4, 2, 0
|
||||
*/
|
||||
|
||||
shift = (shift - 2) & 6;
|
||||
}
|
||||
}
|
||||
|
||||
/* Update the row addresses to the next row */
|
||||
|
||||
sline += sstride;
|
||||
dline += dstride;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif /* CONFIG_NX_SWCURSOR */
|
||||
@@ -0,0 +1,145 @@
|
||||
/****************************************************************************
|
||||
* graphics/nxglib/nxglib_cursor_erase.c
|
||||
*
|
||||
* Copyright (C) 2019 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 <assert.h>
|
||||
|
||||
#include <nuttx/nx/nxglib.h>
|
||||
|
||||
#include "nxglib_bitblit.h"
|
||||
#include "../nxbe/nxbe.h"
|
||||
#include "nxglib.h"
|
||||
|
||||
#ifdef CONFIG_NX_SWCURSOR
|
||||
|
||||
/****************************************************************************
|
||||
* Private Functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Name: nxglib_cursor_erase
|
||||
*
|
||||
* Description:
|
||||
* Erase the cursor region by writing the saved background to the graphics
|
||||
* device memory.
|
||||
*
|
||||
* Input Parameters:
|
||||
* be - The back-end state structure instance
|
||||
* planeno - The color plane being drawn
|
||||
*
|
||||
* Returned Value:
|
||||
* None
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
void NXGL_FUNCNAME(nxglib_cursor_erase, NXGLIB_SUFFIX)
|
||||
(FAR struct nxbe_state_s *be, int planeno)
|
||||
{
|
||||
struct nxgl_rect_s intersection;
|
||||
struct nxgl_point_s origin;
|
||||
FAR struct nxbe_plane_s *plane;
|
||||
FAR uint8_t *fbmem;
|
||||
FAR uint8_t *sline;
|
||||
FAR uint8_t *dline;
|
||||
FAR NXGL_PIXEL_T *src;
|
||||
FAR NXGL_PIXEL_T *dest;
|
||||
nxgl_coord_t width;
|
||||
nxgl_coord_t height;
|
||||
nxgl_coord_t sstride;
|
||||
nxgl_coord_t dstride;
|
||||
int row;
|
||||
int col;
|
||||
|
||||
/* Handle the case some or all of the cursor image is off of the display. */
|
||||
|
||||
nxgl_rectintersect(&intersection, &be->cursor.bounds, &be->bkgd.bounds);
|
||||
if (!nxgl_nullrect(&intersection))
|
||||
{
|
||||
/* Get the width and the height of the images in pixels/rows */
|
||||
|
||||
width = be->cursor.bounds.pt2.x = be->cursor.bounds.pt1.x + 1;
|
||||
height = be->cursor.bounds.pt2.y = be->cursor.bounds.pt1.y + 1;
|
||||
|
||||
/* Get the width of the images in bytes. */
|
||||
|
||||
sstride = NXGL_SCALEX(width);
|
||||
|
||||
plane = &be->plane[planeno];
|
||||
dstride = plane->pinfo.stride;
|
||||
|
||||
/* Get the origin position in the background image */
|
||||
|
||||
nxgl_vectsubtract(&origin, &intersection.pt1, &be->cursor.bounds.pt1);
|
||||
|
||||
/* Get the source and destination addresses */
|
||||
|
||||
fbmem = (FAR uint8_t *)plane->pinfo.fbmem;
|
||||
sline = (FAR uint8_t *)be->cursor.bkgd + sstride * origin.y +
|
||||
NXGL_SCALEX(origin.y);
|
||||
dline = (FAR uint8_t *)fbmem + dstride * be->cursor.bounds.pt1.y +
|
||||
NXGL_SCALEX(be->cursor.bounds.pt1.x);
|
||||
|
||||
/* Erase the old cursor position by copying the previous content */
|
||||
|
||||
/* Loop for each row */
|
||||
|
||||
for (row = 0; row < height; row++)
|
||||
{
|
||||
/* Reset to the beginning of the line */
|
||||
|
||||
src = (FAR NXGL_PIXEL_T *)sline;
|
||||
dest = (FAR NXGL_PIXEL_T *)dline;
|
||||
|
||||
/* Loop for each column */
|
||||
|
||||
for (col = 0; col < width; col++)
|
||||
{
|
||||
*dest++ = *src++;
|
||||
}
|
||||
|
||||
/* Update the row addresses to the next row */
|
||||
|
||||
sline += sstride;
|
||||
dline += dstride;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif /* CONFIG_NX_SWCURSOR */
|
||||
@@ -453,6 +453,55 @@ void pwfb_copyrectangle_32bpp(FAR struct nxbe_window_s *bwnd,
|
||||
unsigned int srcstride);
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Name: nxgl_cursor_draw_*bpp
|
||||
*
|
||||
* Description:
|
||||
* Draw the cursor image into the specified position in the graphics memory.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
struct nxbe_state_s; /* Forward reference */
|
||||
|
||||
#ifdef CONFIG_NX_SWCURSOR
|
||||
void nxglib_cursor_draw_8bpp(FAR struct nxbe_state_s *be, int planeno);
|
||||
void nxglib_cursor_draw_16bpp(FAR struct nxbe_state_s *be, int planeno);
|
||||
void nxglib_cursor_draw_24bpp(FAR struct nxbe_state_s *be, int planeno);
|
||||
void nxglib_cursor_draw_32bpp(FAR struct nxbe_state_s *be, int planeno);
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Name: nxgl_cursor_erase_*bpp
|
||||
*
|
||||
* Description:
|
||||
* Erase the cursor by copying the saved background image into the graphics
|
||||
* memory.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifdef CONFIG_NX_SWCURSOR
|
||||
void nxglib_cursor_erase_8bpp(FAR struct nxbe_state_s *be, int planeno);
|
||||
void nxglib_cursor_erase_16bpp(FAR struct nxbe_state_s *be, int planeno);
|
||||
void nxglib_cursor_erase_24bpp(FAR struct nxbe_state_s *be, int planeno);
|
||||
void nxglib_cursor_erase_32bpp(FAR struct nxbe_state_s *be, int planeno);
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Name: nxgl_cursor_backup_*bpp
|
||||
*
|
||||
* Description:
|
||||
* Save the backgroud image for subsequent use to erase the cursor from the
|
||||
* device graphics memory.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifdef CONFIG_NX_SWCURSOR
|
||||
void nxglib_cursor_backup_8bpp(FAR struct nxbe_state_s *be, int planeno);
|
||||
void nxglib_cursor_backup_16bpp(FAR struct nxbe_state_s *be, int planeno);
|
||||
void nxglib_cursor_backup_24bpp(FAR struct nxbe_state_s *be, int planeno);
|
||||
void nxglib_cursor_backup_32bpp(FAR struct nxbe_state_s *be, int planeno);
|
||||
#endif
|
||||
|
||||
#undef EXTERN
|
||||
#if defined(__cplusplus)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user