Add more rasterizers

git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@1316 42af7a65-404d-4744-a932-0658087f49c3
This commit is contained in:
patacongo
2008-11-26 22:20:00 +00:00
parent 9a4ef7992f
commit 076808fec7
6 changed files with 469 additions and 28 deletions
+120 -2
View File
@@ -42,6 +42,18 @@
#include <nuttx/config.h>
#include <sys/types.h>
#include <fixedmath.h>
/****************************************************************************
* Pre-processor definitions
****************************************************************************/
#define ngl_min(a,b) ((a) < (b) ? (a) : (b))
#define ngl_max(a,b) ((a) > (b) ? (a) : (b))
#define ngl_swap(a,b,t) do { t = a; a = b; b = t; } while (0);
#define ngl_clipl(a,mn) ((a) < (mn) ? (mn) : (a))
#define ngl_clipr(a,mx) ((a) > (mx) ? (mx) : (a))
#define ngl_clip(a,mx,mn) ((a) < (mn) ? (mn) : (a) > (mx) ? (mx) : (a))
/****************************************************************************
* Public Types
@@ -60,8 +72,8 @@ typedef sint16 nxgl_coord_t;
struct nxgl_point_s
{
nxgl_coord_t x; /* Range: 0 to screen width - 1 */
nxgl_coord_t y; /* Rnage: 0 to screen height - 1*/
nxgl_coord_t x; /* X position, range: 0 to screen width - 1 */
nxgl_coord_t y; /* Y position, range: 0 to screen height - 1 */
};
/* Describes a rectangle on the display */
@@ -72,6 +84,28 @@ struct nxgl_rect_s
struct nxgl_point_s pt2; /* Lower, right-hand corner */
};
/* Describes a run, i.e., a horizontal line. Note that the start/end positions
* have fractional precision. This is necessary for good joining of trapezoids
* when a more complex shape is decomposed into trapezoids
*/
struct nxgl_run_s
{
b16_t x1; /* Left X position, range: 0 to x2 */
b16_t x2; /* Right X position, range: x1 to screen width - 1 */
nxgl_coord_t y; /* Top Y position, range: 0 to screen height - 1 */
};
/* Describes a horizontal trapezoid on the display in terms the run at the
* top of the trapezoid and the run at the bottom
*/
struct nxgl_trapezoid_s
{
struct nxgl_run_s top; /* Top run */
struct nxgl_run_s bot; /* bottom run */
};
/****************************************************************************
* Public Data
****************************************************************************/
@@ -142,6 +176,45 @@ EXTERN void nxgl_fillrectangle_32bpp(FAR struct fb_planeinfo_s *pinfo,
FAR const struct nxgl_rect_s *rect,
uint32 color);
/****************************************************************************
* Name: nxglib_filltrapezoid_*bpp
*
* Descripton:
* Fill a trapezoidal region in the framebuffer memory with a fixed color.
* This is useful for drawing complex shape -- (most) complex shapes can be
* broken into a set of trapezoids.
*
****************************************************************************/
EXTERN void nxglib_filltrapezoid_1bpp(FAR struct fb_videoinfo_s *vinfo,
FAR struct fb_planeinfo_s *pinfo,
FAR const struct nxgl_trapezoid_s *trap,
ubyte color);
EXTERN void nxglib_filltrapezoid_2bpp(FAR struct fb_videoinfo_s *vinfo,
FAR struct fb_planeinfo_s *pinfo,
FAR const struct nxgl_trapezoid_s *trap,
ubyte color);
EXTERN void nxglib_filltrapezoid_4bpp(FAR struct fb_videoinfo_s *vinfo,
FAR struct fb_planeinfo_s *pinfo,
FAR const struct nxgl_trapezoid_s *trap,
ubyte color);
EXTERN void nxglib_filltrapezoid_8bpp(FAR struct fb_videoinfo_s *vinfo,
FAR struct fb_planeinfo_s *pinfo,
FAR const struct nxgl_trapezoid_s *trap,
ubyte color);
EXTERN void nxglib_filltrapezoid_16bpp(FAR struct fb_videoinfo_s *vinfo,
FAR struct fb_planeinfo_s *pinfo,
FAR const struct nxgl_trapezoid_s *trap,
uint16 color);
EXTERN void nxglib_filltrapezoid_24bpp(FAR struct fb_videoinfo_s *vinfo,
FAR struct fb_planeinfo_s *pinfo,
FAR const struct nxgl_trapezoid_s *trap,
uint32 color);
EXTERN void nxglib_filltrapezoid_32bpp(FAR struct fb_videoinfo_s *vinfo,
FAR struct fb_planeinfo_s *pinfo,
FAR const struct nxgl_trapezoid_s *trap,
uint32 color);
/****************************************************************************
* Name: nxgl_moverectangle_*bpp
*
@@ -173,6 +246,51 @@ EXTERN void nxgl_moverectangle_32bpp(FAR struct fb_planeinfo_s *pinfo,
FAR const struct nxgl_rect_s *rect,
FAR struct nxgl_point_s *offset);
/****************************************************************************
* Name: nxs_copyrectangle_*bpp
*
* Descripton:
* Copy a rectangular bitmap image into the specific position in the
* framebuffer memory.
*
****************************************************************************/
EXTERN void nxs_copyrectangle_1bpp(FAR struct fb_planeinfo_s *pinfo,
FAR const struct nxgl_rect_s *dest,
FAR const ubyte *src,
FAR const struct nxgl_point_s *origin,
unsigned int srcstride);
EXTERN void nxs_copyrectangle_2bpp(FAR struct fb_planeinfo_s *pinfo,
FAR const struct nxgl_rect_s *dest,
FAR const ubyte *src,
FAR const struct nxgl_point_s *origin,
unsigned int srcstride);
EXTERN void nxs_copyrectangle_4bpp(FAR struct fb_planeinfo_s *pinfo,
FAR const struct nxgl_rect_s *dest,
FAR const ubyte *src,
FAR const struct nxgl_point_s *origin,
unsigned int srcstride);
EXTERN void nxs_copyrectangle_8bpp(FAR struct fb_planeinfo_s *pinfo,
FAR const struct nxgl_rect_s *dest,
FAR const ubyte *src,
FAR const struct nxgl_point_s *origin,
unsigned int srcstride);
EXTERN void nxs_copyrectangle_16bpp(FAR struct fb_planeinfo_s *pinfo,
FAR const struct nxgl_rect_s *dest,
FAR const uint16 *src,
FAR const struct nxgl_point_s *origin,
unsigned int srcstride);
EXTERN void nxs_copyrectangle_24bpp(FAR struct fb_planeinfo_s *pinfo,
FAR const struct nxgl_rect_s *dest,
FAR const uint32 *src,
FAR const struct nxgl_point_s *origin,
unsigned int srcstride);
EXTERN void nxs_copyrectangle_32bpp(FAR struct fb_planeinfo_s *pinfo,
FAR const struct nxgl_rect_s *dest,
FAR const uint32 *src,
FAR const struct nxgl_point_s *origin,
unsigned int srcstride);
#undef EXTERN
#if defined(__cplusplus)
}