⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 guigal.h

📁 The combined demo is dedicated for S1C33L05, so DMT33L05 should be used to load and run the demo. F
💻 H
📖 第 1 页 / 共 2 页
字号:
/* $Id: guiGal.h V1.0 2001/10/20 */
/*************************************************************************
 *    This source code has been made available to you by EPSON on an AS-IS
 *    basis.  Anyone receiving this source is licensed under EPSON
 *    copyrights to use it in any way he or she deems fit, including
 *    copying it, modifying it, compiling it, and redistributing it either
 *    with or without modifications.
 *
 *    Any person who transfers this source code or any derivative work
 *    must include the EPSON copyright notice, this paragraph, and the
 *    preceding two paragraphs in the transferred software.
 *
 *    COPYRIGHT   EPSON  CORPORATION 2001
 *    LICENSED MATERIAL  -  PROGRAM PROPERTY OF EPSON
 ***********************************************************************/

/***********************************************************************
 * FILE: guiGal.h
 * MODULE: Graphic abstract layer
 *
 *  PURPOSE:
 * AUTHOR(S): YangCX
 * GROUP: GUI Group
 * DATE CREATED: 2001/10/20
 * REFERENCE DOCUMENT ID:
 * MODIFICATIONS:
 *    Date          userName     Description
 *   2001/10/20     YangCX       Create this file
 **********************************************************************/

#ifndef _GUIGAL_H
#define _GUIGAL_H

#ifdef __cplusplus
extern "C" {
#endif

#define GAL_OK 		0
#define GAL_FAILED  -1

/**********************************************************************************
  Interface to Screen Device Driver
  This structure is also allocated for memory (offscreen) drawing and blitting.
  This structure is used to pass parameters into the low level device
  driver functions.
 *********************************************************************************/

typedef  struct T_GAL_GraphicContext*  T_GAL_pGC;

typedef struct T_GAL_GraphicContext {
	T_WORD	xRes;			/* X screen res (real) */
	T_WORD	yRes;			/* Y screen res (real) */
	T_WORD	xVirtRes;		/* X drawing res (will be flipped in portrait mode) */
	T_WORD	yVirtRes;		/* Y drawing res (will be flipped in portrait mode) */
	T_WORD	planes;			/* # planes */
	T_WORD	bpp;			/* # bits per pixel */
	T_WORD	LineLen;		/* line length in bytes */
	T_WORD	size;			/* size of memory allocated*/
    T_UWORD ForeGround;	   	/* current foreground color */
	T_UWORD BackGround;     /* current background color */
  	T_WORD	DoClip;         /* flag of clipping */
	T_WORD	ClipMinX;		/* minimum x value of cache rectangle */
	T_WORD	ClipMinY;		/* minimum y value of cache rectangle */
	T_WORD	ClipMaxX;		/* maximum x value of cache rectangle */
	T_WORD	ClipMaxY;		/* maximum y value of cache rectangle */
	T_WORD	ncolors;		/* # screen colors */
	T_WORD	flags;			/* device flags */
	T_VOID  *addr;			/* address of memory allocated (memdc or fb) */

	T_GAL_pGC	(*Open)(T_GAL_pGC pGC);
	T_VOID	(*Close)(T_GAL_pGC pGC);

	T_VOID	(*SetPalette)(T_GAL_pGC pGC,T_WORD first, T_WORD count,  T_GUI_COLOR *cmap);
	T_VOID	(*GetPalette)(T_GAL_pGC pGC,T_WORD first, T_WORD count, T_GUI_COLOR *cmap);

	T_GAL_pGC	(*AllocateMemGC)(T_GAL_pGC pGC);

	T_WORD	(*MapMemGC)(
			T_GAL_pGC	MempGC,
			T_WORD	w,
			T_WORD 	h,
			T_WORD 	planes,
			T_WORD 	bpp,
			T_WORD	LineLen,
			T_WORD	size,
			T_VOID 	*addr
			);

	T_VOID	(*FreeMemGC)(T_GAL_pGC MempGC);

	T_WORD	(*ClipPoint)(T_GAL_pGC pGC,T_WORD x,T_WORD y);

	T_VOID	(*FillRect)(
			T_GAL_pGC 	pGC,
			T_WORD 	x,
			T_WORD 	y ,
			T_WORD 	w ,
			T_WORD 	h,
			T_GUI_PIXEL	c
			);

	T_VOID 	 (*DrawPixel)(T_GAL_pGC pGC, T_WORD x, T_WORD y, T_GUI_PIXEL c);
	T_UWORD  (*ReadPixel)(T_GAL_pGC pGC, T_WORD x, T_WORD y);

	T_VOID 	(*DrawHLine)(
			T_GAL_pGC	pgc,
			T_WORD 	x,
			T_WORD 	y,
			T_WORD 	w,
			T_GUI_PIXEL c
			);

	T_VOID	(*PutHLine) (
			T_GAL_pGC 	pGC,
			T_WORD 	x,
			T_WORD 	y,
			T_WORD 	w,
			T_VOID	*buf
			);

	T_VOID	(*GetHLine) (
			T_GAL_pGC 	pGC,
			T_WORD 	x,
			T_WORD 	y,
			T_WORD 	w,
			T_VOID	*buf
			);

	T_VOID 	(*DrawVLine)(
			T_GAL_pGC 	pGC,
			T_WORD 	x,
			T_WORD 	y,
			T_WORD 	h,
			T_GUI_PIXEL c
			);

	T_VOID	(*PutVLine) (
			T_GAL_pGC	pGC,
			T_WORD 	x,
			T_WORD 	y,
			T_WORD 	h,
			T_VOID	* buf
			);

	T_VOID	(*GetVLine) (
			T_GAL_pGC 	pGC,
			T_WORD 	x,
			T_WORD 	y,
			T_WORD 	h,
			T_VOID	*buf
			);

	T_VOID  (*Blit) (
			T_GAL_pGC	DstpGC,
			T_WORD	DstX,
			T_WORD 	DstY,
			T_WORD 	w,
			T_WORD 	h,
			T_GAL_pGC 	Srcpgc,
			T_WORD 	SrcX,
			T_WORD 	SrcY
			);

	T_VOID	(*PutBox)(
			T_GAL_pGC 	pGC,
			T_WORD 	x,
			T_WORD 	y,
			T_WORD 	w,
			T_WORD 	h,
			T_VOID	*buf,
			T_WORD BufLen
			);

	T_VOID	(*GetBox)(
			T_GAL_pGC 	pGC,
			T_WORD 	x,
			T_WORD 	y,
			T_WORD 	w,
			T_WORD 	h,
			T_VOID	*buf,
			T_WORD BufLen
			);

	T_VOID	(*PutBoxMask) (
			T_GAL_pGC 	pGC,
			T_WORD	x,
			T_WORD 	y,
			T_WORD 	w,
			T_WORD 	h,
			T_VOID	*buf,
			T_WORD BufLen,
			T_GUI_PIXEL	cxx
			);

	T_VOID 	(*CopyBox) (
			T_GAL_pGC 	pGC,
			T_WORD 	x1,
			T_WORD 	y1,
			T_WORD	w,
			T_WORD 	h,
			T_WORD 	x2,
			T_WORD 	y2
			);
	
	T_GUI_PIXEL(*MapColor) (
			T_GAL_pGC pGC, 
			T_GUI_COLOR *color
			);	/*added for porting easily 2002.6.12*/

} T_GAL_GraphicContext;

T_EXTERN T_GAL_GraphicContext* tpGAL_PhyGc;
T_EXTERN T_GAL_GraphicContext  tGAL_PhyGc;

/****************************************************************************
* Truecolor color conversion and extraction macros
* Conversion from T_RGB to T_GUI_PIXEL
*****************************************************************************/

/* create 24 bit 8/8/8 format pixel (0x00RRGGBB) from RGB triplet*/
#define GAL_RGB2PIXEL888(r,g,b)	\
	(((r) << 16) | ((g) << 8) | (b))

/* create 16 bit 5/6/5 format pixel from RGB triplet */
#define GAL_RGB2PIXEL565(r,g,b)	\
	((((r) & 0xf8) << 8) | (((g) & 0xfc) << 3) | (((b) & 0xf8) >> 3))

/* create 16 bit 4/4/4/0 format pixel from RGB triplet */
#define GAL_RGB2PIXEL4440(r,g,b)	\
	((((r) & 0xf0) << 8) | (((g) & 0xf0) << 4) | (((b) & 0xf0) << 0))

/* create 15 bit 5/5/5 format pixel from RGB triplet */
#define GAL_RGB2PIXEL555(r,g,b)	\
	((((r) & 0xf8) << 7) | (((g) & 0xf8) << 2) | (((b) & 0xf8) >> 3))

/* create 8 bit 3/3/2 format pixel from RGB triplet*/
#define GAL_RGB2PIXEL332(r,g,b)	\
	(((r) & 0xe0) | (((g) & 0xe0) >> 3) | (((b) & 0xc0) >> 6))

/*****************************************************************************
* Conversion from COLORVAL to T_GUI_PIXEL
******************************************************************************/

/* create 24 bit 8/8/8 format pixel from RGB colorval (0x00BBGGRR)*/
#define GAL_COLOR2PIXEL888(c)	\
	((((c) & 0xff) << 16) | ((c) & 0xff00) | (((c) & 0xff0000) >> 16))

/* create 16 bit 5/6/5 format pixel from RGB colorval (0x00BBGGRR)*/
#define GAL_COLOR2PIXEL565(c)	\
	((((c) & 0xf8) << 8) | (((c) & 0xfc00) >> 5) | (((c) & 0xf80000) >> 19))

/* create 15 bit 5/5/5 format pixel from RGB colorval (0x00BBGGRR)*/
#define GAL_COLOR2PIXEL555(c)	\
	((((c) & 0xf8) << 7) | (((c) & 0xf800) >> 6) | (((c) & 0xf80000) >> 19))

/* create 8 bit 3/3/2 format pixel from RGB colorval (0x00BBGGRR)*/
#define GAL_COLOR2PIXEL332(c)	\
	(((c) & 0xe0) | (((c) & 0xe000) >> 11) | (((c) & 0xc00000) >> 22))

/******************************************************************************
* Conversion from T_GUI_PIXEL to red, green or blue components
*******************************************************************************/

/* return 8/8/8 bit r, g or b component of 24 bit T_GUI_PIXEL */
#define GAL_PIXEL888RED(gal_pixel)		(((gal_pixel) >> 16) & 0xff)
#define GAL_PIXEL888GREEN(gal_pixel)	(((gal_pixel) >> 8) & 0xff)
#define GAL_PIXEL888BLUE(gal_pixel)		((gal_pixel) & 0xff)

/* return 5/6/5 bit r, g or b component of 16 bit T_GUI_PIXEL */
#define GAL_PIXEL565RED(gal_pixel)		(((gal_pixel) >> 11) & 0x1f)
#define GAL_PIXEL565GREEN(gal_pixel)	(((gal_pixel) >> 5) & 0x3f)
#define GAL_PIXEL565BLUE(gal_pixel)		((gal_pixel) & 0x1f)

/* return 4/4/4/0 bit r, g or b component of 16 bit T_GUI_PIXEL */
#define GAL_PIXEL4440RED(gal_pixel)		(((gal_pixel) >> 12) & 0x0f)
#define GAL_PIXEL4440GREEN(gal_pixel)	(((gal_pixel) >> 8) & 0x0f)
#define GAL_PIXEL4440BLUE(gal_pixel)	(((gal_pixel) >> 4) & 0x0f)

/* return 5/5/5 bit r, g or b component of 16 bit T_GUI_PIXEL */
#define GAL_PIXEL555RED(gal_pixel)		(((gal_pixel) >> 10) & 0x1f)
#define GAL_PIXEL555GREEN(gal_pixel)	(((gal_pixel) >> 5) & 0x1f)
#define GAL_PIXEL555BLUE(gal_pixel)		((gal_pixel) & 0x1f)

/* return 3/3/2 bit r, g or b component of 8 bit T_GUI_PIXEL */
#define GAL_PIXEL332RED(gal_pixel)		(((gal_pixel) >> 5) & 0x07)
#define GAL_PIXEL332GREEN(gal_pixel)	(((gal_pixel) >> 2) & 0x07)
#define GAL_PIXEL332BLUE(gal_pixel)		((gal_pixel) & 0x03)

/* PGC flags */
#define	GAL_PSF_SCREEN			0x0001	/* screen device*/
#define GAL_PSF_MEMORY			0x0002	/* memory device*/
#define GAL_PSF_HAVEBLIT		0x0004	/* have bitblit*/
#define GAL_PSF_PORTRAIT		0x0008	/* in portrait mode*/
#define GAL_PSF_HAVEOP_COPY		0x0010	/* pGC->DrawArea can do area copy*/
#define GAL_PSF_ADDRMALLOC		0x0020	/* pGC->addr was malloc'd*/
#define GAL_PSF_ADDRSHAREDMEM	0x0040	/* pGC->addr is shared memory*/

#define GAL_CLIP_VISIBLE 	1
#define GAL_CLIP_INVISIBLE	0
#define GAL_CLIP_PARTIAL	-1


/***********************************************************************

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -