mirror of
https://github.com/apache/nuttx.git
synced 2025-01-13 10:58:49 +08:00
Rectangular fills compile for LCD
git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@2605 42af7a65-404d-4744-a932-0658087f49c3
This commit is contained in:
parent
23763aacc0
commit
816cb81e95
8 changed files with 244 additions and 20 deletions
|
@ -94,6 +94,7 @@ int nxbe_configure(FAR struct fb_vtable_s *fb, FAR struct nxbe_state_s *be)
|
|||
|
||||
/* Check the number of color planes */
|
||||
|
||||
#ifdef CONFIG_DEBUG
|
||||
if (be->vinfo.nplanes > CONFIG_NX_NPLANES)
|
||||
{
|
||||
gdbg("NX configured for only %d planes, controller wants %d\n",
|
||||
|
@ -105,6 +106,7 @@ int nxbe_configure(FAR struct fb_vtable_s *fb, FAR struct nxbe_state_s *be)
|
|||
gdbg("NX configured for %d planes, controller only needs %d\n",
|
||||
CONFIG_NX_NPLANES, be->vinfo.nplanes);
|
||||
}
|
||||
#endif
|
||||
|
||||
/* Then get information about each color plane */
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
############################################################################
|
||||
# graphics/nxglib/Make.defs
|
||||
#
|
||||
# Copyright (C) 2008 Gregory Nutt. All rights reserved.
|
||||
# Copyright (C) 2008, 2010 Gregory Nutt. All rights reserved.
|
||||
# Author: Gregory Nutt <spudmonkey@racsa.co.cr>
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
|
@ -37,29 +37,42 @@ NXGLIB_ASRCS =
|
|||
|
||||
RFILL1_CSRCS = nxglib_fillrectangle_1bpp.c nxglib_fillrectangle_2bpp.c \
|
||||
nxglib_fillrectangle_4bpp.c
|
||||
|
||||
RFILL2_CSRCS = nxglib_fillrectangle_8bpp.c nxglib_fillrectangle_16bpp.c \
|
||||
nxglib_fillrectangle_24bpp.c nxglib_fillrectangle_32bpp.c
|
||||
|
||||
TFILL1_CSRCS = nxglib_filltrapezoid_1bpp.c nxglib_filltrapezoid_2bpp.c \
|
||||
nxglib_filltrapezoid_4bpp.c
|
||||
|
||||
TFILL2_CSRCS = nxglib_filltrapezoid_8bpp.c nxglib_filltrapezoid_16bpp.c \
|
||||
nxglib_filltrapezoid_24bpp.c nxglib_filltrapezoid_32bpp.c
|
||||
|
||||
RMOVE1_CSRCS = nxglib_moverectangle_1bpp.c nxglib_moverectangle_2bpp.c \
|
||||
nxglib_moverectangle_4bpp.c
|
||||
|
||||
RMOVE2_CSRCS = nxglib_moverectangle_8bpp.c nxglib_moverectangle_16bpp.c \
|
||||
nxglib_moverectangle_24bpp.c nxglib_moverectangle_32bpp.c
|
||||
|
||||
RCOPY1_CSRCS = nxglib_copyrectangle_1bpp.c nxglib_copyrectangle_2bpp.c \
|
||||
nxglib_copyrectangle_4bpp.c
|
||||
|
||||
RCOPY2_CSRCS = nxglib_copyrectangle_8bpp.c nxglib_copyrectangle_16bpp.c \
|
||||
nxglib_copyrectangle_24bpp.c nxglib_copyrectangle_32bpp.c
|
||||
|
||||
RECT_CSRCS = nxglib_rectcopy.c nxglib_rectoffset.c nxglib_vectoradd.c \
|
||||
nxglib_vectsubtract.c nxglib_rectintersect.c \
|
||||
nxglib_nonintersecting.c nxglib_rectunion.c nxglib_rectinside.c \
|
||||
nxglib_rectoverlap.c nxglib_rectsize.c nxglib_nullrect.c
|
||||
|
||||
TRAP_CSRCS = nxglib_runoffset.c nxglib_runcopy.c \
|
||||
nxglib_trapoffset.c nxglib_trapcopy.c
|
||||
|
||||
COLOR_CSRCS = nxglib_colorcopy.c
|
||||
|
||||
LCD_CSRCS =
|
||||
|
||||
NXGLIB_CSRCS = nxglib_rgb2yuv.c nxglib_yuv2rgb.c \
|
||||
$(RFILL1_CSRCS) $(RFILL2_CSRCS) $(TFILL1_CSRCS) $(TFILL2_CSRCS) \
|
||||
$(RMOVE1_CSRCS) $(RMOVE2_CSRCS) $(RCOPY1_CSRCS) $(RCOPY2_CSRCS) \
|
||||
$(RECT_CSRCS) $(TRAP_CSRCS) $(COLOR_CSRCS)
|
||||
$(RECT_CSRCS) $(TRAP_CSRCS) $(COLOR_CSRCS) $(LCD_CSRCS)
|
||||
|
||||
|
|
|
@ -46,6 +46,7 @@
|
|||
#include <nuttx/nxglib.h>
|
||||
|
||||
#include "nxglib_bitblit.h"
|
||||
#include "nxglib_fillrun.h"
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-Processor Definitions
|
||||
|
@ -89,7 +90,6 @@ void NXGL_FUNCNAME(nxgl_fillrectangle,NXGLIB_SUFFIX)
|
|||
unsigned int ncols;
|
||||
unsigned int nrows;
|
||||
unsigned int row;
|
||||
unsigned int col;
|
||||
|
||||
/* Get the dimensions of the rectange to fill in pixels */
|
||||
|
||||
|
@ -98,13 +98,7 @@ void NXGL_FUNCNAME(nxgl_fillrectangle,NXGLIB_SUFFIX)
|
|||
|
||||
/* Fill the run buffer with the selected color */
|
||||
|
||||
for (col = 0; col < ncols; col++)
|
||||
{
|
||||
#if NXGLIB_BITSPERPIXEL < 8
|
||||
#else
|
||||
g_runbuffer
|
||||
#endif
|
||||
}
|
||||
NXGL_FUNCNAME(nxgl_fillrun,NXGLIB_SUFFIX)((NXGLIB_RUNTYPE*)pinfo->buffer, color, ncols);
|
||||
|
||||
/* Then fill the rectangle line-by-line */
|
||||
|
||||
|
@ -112,6 +106,6 @@ void NXGL_FUNCNAME(nxgl_fillrectangle,NXGLIB_SUFFIX)
|
|||
{
|
||||
/* Draw the raster line at this row */
|
||||
|
||||
(void)pinfo->putrun(row, rect->pt2.x, g_runbuffer, ncols);
|
||||
(void)pinfo->putrun(row, rect->pt2.x, pinfo->buffer, ncols);
|
||||
}
|
||||
}
|
||||
|
|
184
graphics/nxglib/nxglib_fillrun.h
Normal file
184
graphics/nxglib/nxglib_fillrun.h
Normal file
|
@ -0,0 +1,184 @@
|
|||
/****************************************************************************
|
||||
* graphics/nxglib/nxsglib_fullrun.h
|
||||
*
|
||||
* Copyright (C) 2010 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.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef __GRAPHICS_NXGLIB_NXGLIB_FILLRUN_H
|
||||
#define __GRAPHICS_NXGLIB_NXGLIB_FILLRUN_H
|
||||
|
||||
/****************************************************************************
|
||||
* Included Files
|
||||
****************************************************************************/
|
||||
|
||||
#include <nuttx/config.h>
|
||||
#include <stdint.h>
|
||||
#include <string.h>
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-Processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
#if NXGLIB_BITSPERPIXEL < 16
|
||||
# define NXGLIB_RUNTYPE uint8_t
|
||||
#elif NXGLIB_BITSPERPIXEL == 16
|
||||
# define NXGLIB_RUNTYPE uint16_t
|
||||
#else
|
||||
# define NXGLIB_RUNTYPE uint32_t
|
||||
#endif
|
||||
/****************************************************************************
|
||||
* Private Types
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Private Data
|
||||
****************************************************************************/
|
||||
|
||||
#if NXGLIB_BITSPERPIXEL == 2
|
||||
static uint8_t g_wide_2bpp[4] = { 0x00, 0x55, 0xaa, 0xff };
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Public Data
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Private Functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Name: nxgl_fillrun_*bpp
|
||||
*
|
||||
* Description:
|
||||
* fill a run with the specified color.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#if NXGLIB_BITSPERPIXEL == 1
|
||||
static inline void nxgl_fillrun_1bpp(uint8_t *run, nxgl_mxpixel_t color, size_t npixels)
|
||||
{
|
||||
/* Get the number of bytes to fill */
|
||||
|
||||
unsigned int nbytes = (npixels + 7) >> 3;
|
||||
|
||||
/* Get the value of the byte to fill */
|
||||
|
||||
uint8_t wide = (color & 1) != 0 ? 0xff : 0x00;
|
||||
|
||||
/* Fill the run with the color (it is okay to run a fractional byte overy the end */
|
||||
|
||||
memset(run, wide, nbytes);
|
||||
}
|
||||
|
||||
#elif NXGLIB_BITSPERPIXEL == 2
|
||||
static inline void nxgl_fillrun_2bpp(uint8_t *run, nxgl_mxpixel_t color, size_t npixels)
|
||||
{
|
||||
/* Get the number of bytes to fill */
|
||||
|
||||
unsigned int nbytes = (npixels + 3) >> 2;
|
||||
|
||||
/* Get the value of the byte to fill */
|
||||
|
||||
uint8_t wide = g_wide_2bpp[color & 3];
|
||||
|
||||
/* Fill the run with the color (it is okay to run a fractional byte overy the end */
|
||||
|
||||
memset(run, wide, nbytes);
|
||||
}
|
||||
|
||||
#elif NXGLIB_BITSPERPIXEL == 4
|
||||
static inline void nxgl_fillrun_4bpp(uint8_t *run, nxgl_mxpixel_t color, size_t npixels)
|
||||
{
|
||||
/* Get the number of bytes to fill */
|
||||
|
||||
unsigned int nbytes = (npixels + 1) >> 1;
|
||||
|
||||
/* Get the value of the byte to fill */
|
||||
|
||||
uint8_t narrow = (uint8_t)color & 0x0f;
|
||||
uint8_t wide = narrow | (narrow << 4);
|
||||
|
||||
/* Fill the run with the color (it is okay to run a fractional byte overy the end */
|
||||
|
||||
memset(run, wide, nbytes);
|
||||
}
|
||||
|
||||
#elif NXGLIB_BITSPERPIXEL == 8
|
||||
static inline void nxgl_fillrun_8bpp(uint8_t *run, nxgl_mxpixel_t color, size_t npixels)
|
||||
{
|
||||
/* Fill the run with the color (it is okay to run a fractional byte overy the end */
|
||||
|
||||
memset(run, color, npixels);
|
||||
}
|
||||
|
||||
#elif NXGLIB_BITSPERPIXEL == 16
|
||||
static inline void nxgl_fillrun_16bpp(uint16_t *run, nxgl_mxpixel_t color, size_t npixels)
|
||||
{
|
||||
/* Fill the run with the color (it is okay to run a fractional byte overy the end */
|
||||
|
||||
while (npixels-- > 0)
|
||||
{
|
||||
*run++ = (uint16_t)color;
|
||||
}
|
||||
}
|
||||
|
||||
#elif NXGLIB_BITSPERPIXEL == 24
|
||||
static inline void nxgl_fillrun_24bpp(uint32_t *run, nxgl_mxpixel_t color, size_t npixels)
|
||||
{
|
||||
/* Fill the run with the color (it is okay to run a fractional byte overy the end */
|
||||
#warning "Assuming 24-bit color is not packed"
|
||||
while (npixels-- > 0)
|
||||
{
|
||||
*run++ = (uint32_t)color;
|
||||
}
|
||||
}
|
||||
|
||||
#elif NXGLIB_BITSPERPIXEL == 32
|
||||
static inline void nxgl_fillrun_32bpp(uint32_t *run, nxgl_mxpixel_t color, size_t npixels)
|
||||
{
|
||||
/* Fill the run with the color (it is okay to run a fractional byte overy the end */
|
||||
|
||||
while (npixels-- > 0)
|
||||
{
|
||||
*run++ = (uint32_t)color;
|
||||
}
|
||||
}
|
||||
#else
|
||||
# error "Unsupported value of NXGLIB_BITSPERPIXEL"
|
||||
#endif
|
||||
#endif /* __GRAPHICS_NXGLIB_NXGLIB_FILLRUN_H */
|
||||
|
||||
|
|
@ -486,7 +486,7 @@ EXTERN void nxmu_semtake(sem_t *sem);
|
|||
*
|
||||
* Input Parameters:
|
||||
* be - The back-end status structure
|
||||
* wnd - The pre-allocated window structure to be ininitilized [IN/OUT]
|
||||
* wnd - The pre-allocated window structure to be initialized [IN/OUT]
|
||||
*
|
||||
* Return:
|
||||
* None
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/****************************************************************************
|
||||
* graphics/nxmu/nxmu_openwindow.c
|
||||
*
|
||||
* Copyright (C) 2008-2009 Gregory Nutt. All rights reserved.
|
||||
* Copyright (C) 2008-2010 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <spudmonkey@racsa.co.cr>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
|
@ -74,7 +74,7 @@
|
|||
*
|
||||
* Input Parameters:
|
||||
* be - The back-end status structure
|
||||
* wnd - The pre-allocated window structure to be ininitilized [IN/OUT]
|
||||
* wnd - The pre-allocated window structure to be initialized [IN/OUT]
|
||||
*
|
||||
* Return:
|
||||
* None
|
||||
|
|
|
@ -183,10 +183,10 @@ typedef uint16_t fb_coord_t;
|
|||
|
||||
struct fb_videoinfo_s
|
||||
{
|
||||
uint8_t fmt; /* see FB_FMT_* */
|
||||
uint8_t fmt; /* see FB_FMT_* */
|
||||
fb_coord_t xres; /* Resolution in pixels */
|
||||
fb_coord_t yres;
|
||||
uint8_t nplanes; /* Number of color planes supported */
|
||||
uint8_t nplanes; /* Number of color planes supported */
|
||||
};
|
||||
|
||||
/* This structure describes one color plane. Some YUV formats may support
|
||||
|
@ -232,8 +232,8 @@ struct fb_cmap_s
|
|||
#ifdef CONFIG_FB_HWCURSORIMAGE
|
||||
struct fb_cursorimage_s
|
||||
{
|
||||
fb_coord_t width; /* Width of the cursor image in pixels */
|
||||
fb_coord_t height /* Height of the curor image in pixels */
|
||||
fb_coord_t width; /* Width of the cursor image in pixels */
|
||||
fb_coord_t height /* Height of the curor image in pixels */
|
||||
const uint8_t *image; /* Pointer to image data */
|
||||
};
|
||||
#endif
|
||||
|
|
|
@ -62,16 +62,47 @@
|
|||
struct lcd_planeinfo_s
|
||||
{
|
||||
/* LCD Data Transfer ******************************************************/
|
||||
/* This method can be used to write a partial raster line to the LCD:
|
||||
*
|
||||
* row - Starting row to write to (range: 0 <= row < yres)
|
||||
* col - Starting column to write to (range: 0 <= col <= xres-npixels)
|
||||
* buffer - The buffer containing the run to be written to the LCD
|
||||
* npixels - The number of pixels to write to the LCD
|
||||
* (range: 0 < npixels <= xres-col)
|
||||
*/
|
||||
|
||||
int (*putrun)(fb_coord_t row, fb_coord_t col, FAR const uint8_t *buffer,
|
||||
size_t npixels);
|
||||
|
||||
int (*getrun)(fb_coord_t row, fb_coord_t col,FAR uint8_t *buffer,
|
||||
/* This method can be used to read a partial raster line from the LCD:
|
||||
*
|
||||
* row - Starting row to read from (range: 0 <= row < yres)
|
||||
* col - Starting column to read read (range: 0 <= col <= xres-npixels)
|
||||
* buffer - The buffer in which to return the run read from the LCD
|
||||
* npixels - The number of pixels to read from the LCD
|
||||
* (range: 0 < npixels <= xres-col)
|
||||
*/
|
||||
|
||||
int (*getrun)(fb_coord_t row, fb_coord_t col, FAR uint8_t *buffer,
|
||||
size_t npixels);
|
||||
|
||||
/* Plane color characteristics ********************************************/
|
||||
|
||||
uint8_t bpp; /* Bits per pixel */
|
||||
/* This is working memory allocated by the LCD driver for each LCD device
|
||||
* and for each color plane. This memory will hold one raster line of data.
|
||||
* The size of the allocated run buffer must therefor be at least
|
||||
* (bpp * xres / 8). Actual alignment of the buffer must conform to the
|
||||
* bitwidth of the underlying pixel type.
|
||||
*/
|
||||
|
||||
uint8_t *buffer;
|
||||
|
||||
/* This is the number of bits in one pixel. This may be one of {1, 2, 4,
|
||||
* 8, 16, 24, or 32} unless support for one or more of those resolutions
|
||||
* has been disabled.
|
||||
*/
|
||||
|
||||
uint8_t bpp;
|
||||
};
|
||||
|
||||
/* This structure defines an LCD interface */
|
||||
|
|
Loading…
Reference in a new issue