Change pixel_t to gPixel

This commit is contained in:
inmarket 2018-07-08 11:08:55 +10:00
parent 2ab2d77fcb
commit cfb1b2a488
22 changed files with 58 additions and 56 deletions

View File

@ -21,6 +21,7 @@ FEATURE: Added gI64 and gU64 when the compiler supports it. GFX_TYPE_64 macro is
FEATURE: Fixed headers to ensure size_t, NULL are always defined. size_t is not used as it may be 64bit.
CHANGE: Added type gPoint to replace V2.x point and point_t
CHANGE: Added type gCoord to replace V2.x coord_t
CHANGE: Added type gPixel to replace V2.x pixel_t
FIX: Added gfxRealloc() to Qt port
FIX: Fixed UC1610 driver private area initialisation
FIX: Fixed ST7735 driver and added kapacuk changes

View File

@ -33,7 +33,7 @@
#define PIXMAP_HEIGHT 10
static GDisplay* pixmap;
static pixel_t* surface;
static gPixel* surface;
int main(void) {
gCoord width, height;

View File

@ -345,16 +345,16 @@ LLDSPEC gBool gdisp_lld_init(GDisplay *g) {
gCoord lg, x, y;
uint16_t c1, c2;
unsigned tuples;
const pixel_t *buffer;
const gPixel *buffer;
#if GDISP_PACKED_PIXELS
unsigned pnum, pstart;
const uint8_t *p;
#else
const pixel_t *p;
const gPixel *p;
#endif
tuples = (g->p.cx * g->p.cy + 1)>>1;
buffer = (const pixel_t *)g->p.ptr;
buffer = (const gPixel *)g->p.ptr;
/* Set up the data window to transfer */
acquire_bus(g);
@ -428,7 +428,7 @@ LLDSPEC gBool gdisp_lld_init(GDisplay *g) {
srccx = (g->p.x2 + 1) & ~1;
#endif
pstart = g->p.y1 * g->p.x2 + g->p.x1; // The starting pixel number
buffer = (const pixel_t)(((const uint8_t *)buffer) + ((pstart>>1) * 3)); // The buffer start position
buffer = (const gPixel)(((const uint8_t *)buffer) + ((pstart>>1) * 3)); // The buffer start position
lg = ((g->p.x2-g->p.cx)>>1)*3; // The buffer gap between lines
pnum = pstart + g->p.x2*y + x; // Adjustment for controller craziness
p = ((const uint8_t *)buffer) + (((g->p.x2*y + x)>>1)*3); // Adjustment for controller craziness

View File

@ -258,10 +258,10 @@ LLDSPEC gBool gdisp_lld_init(GDisplay *g) {
#endif
LLDSPEC void gdisp_lld_blit_area(GDisplay *g) {
pixel_t *buffer;
gPixel *buffer;
gCoord ycnt;
buffer = (pixel_t *)g->p.ptr + g->p.x1 + g->p.y1 * g->p.x2;
buffer = (gPixel *)g->p.ptr + g->p.x1 + g->p.y1 * g->p.x2;
acquire_bus(g);
set_viewport(g);

View File

@ -294,10 +294,10 @@ LLDSPEC gBool gdisp_lld_init(GDisplay* g) {
#endif
LLDSPEC void gdisp_lld_blit_area(GDisplay* g) {
pixel_t* buffer;
gPixel* buffer;
gCoord ycnt;
buffer = (pixel_t*)g->p.ptr + g->p.x1 + g->p.y1 * g->p.x2;
buffer = (gPixel*)g->p.ptr + g->p.x1 + g->p.y1 * g->p.x2;
acquire_bus(g);
set_viewport(g);

View File

@ -1224,16 +1224,16 @@ LLDSPEC gBool gdisp_lld_init(GDisplay *g) {
#endif
#if GDISP_HARDWARE_BITFILLS && GDISP_NEED_CONTROL
static pixel_t *rotateimg(GDisplay *g, const pixel_t *buffer) {
pixel_t *dstbuf;
pixel_t *dst;
const pixel_t *src;
static gPixel *rotateimg(GDisplay *g, const gPixel *buffer) {
gPixel *dstbuf;
gPixel *dst;
const gPixel *src;
size_t sz;
gCoord i, j;
// Allocate the destination buffer
sz = (size_t)g->p.cx * (size_t)g->p.cy;
if (!(dstbuf = (pixel_t *)malloc(sz * sizeof(pixel_t))))
if (!(dstbuf = (gPixel *)malloc(sz * sizeof(gPixel))))
return 0;
// Copy the bits we need
@ -1272,7 +1272,7 @@ LLDSPEC gBool gdisp_lld_init(GDisplay *g) {
LLDSPEC void gdisp_lld_blit_area(GDisplay *g) {
winPriv * priv;
pixel_t * buffer;
gPixel * buffer;
RECT rect;
BITMAPV4HEADER bmpInfo;
@ -1300,7 +1300,7 @@ LLDSPEC gBool gdisp_lld_init(GDisplay *g) {
switch(g->g.Orientation) {
case GDISP_ROTATE_0:
default:
bmpInfo.bV4SizeImage = (g->p.cy*g->p.x2) * sizeof(pixel_t);
bmpInfo.bV4SizeImage = (g->p.cy*g->p.x2) * sizeof(gPixel);
bmpInfo.bV4Width = g->p.x2;
bmpInfo.bV4Height = -g->p.cy; /* top-down image */
rect.top = g->p.y;
@ -1310,7 +1310,7 @@ LLDSPEC gBool gdisp_lld_init(GDisplay *g) {
break;
case GDISP_ROTATE_90:
if (!(buffer = rotateimg(g, buffer))) return;
bmpInfo.bV4SizeImage = (g->p.cy*g->p.cx) * sizeof(pixel_t);
bmpInfo.bV4SizeImage = (g->p.cy*g->p.cx) * sizeof(gPixel);
bmpInfo.bV4Width = g->p.cy;
bmpInfo.bV4Height = -g->p.cx; /* top-down image */
rect.bottom = g->g.Width - g->p.x;
@ -1320,7 +1320,7 @@ LLDSPEC gBool gdisp_lld_init(GDisplay *g) {
break;
case GDISP_ROTATE_180:
if (!(buffer = rotateimg(g, buffer))) return;
bmpInfo.bV4SizeImage = (g->p.cy*g->p.cx) * sizeof(pixel_t);
bmpInfo.bV4SizeImage = (g->p.cy*g->p.cx) * sizeof(gPixel);
bmpInfo.bV4Width = g->p.cx;
bmpInfo.bV4Height = -g->p.cy; /* top-down image */
rect.bottom = g->g.Height-1 - g->p.y;
@ -1330,7 +1330,7 @@ LLDSPEC gBool gdisp_lld_init(GDisplay *g) {
break;
case GDISP_ROTATE_270:
if (!(buffer = rotateimg(g, buffer))) return;
bmpInfo.bV4SizeImage = (g->p.cy*g->p.cx) * sizeof(pixel_t);
bmpInfo.bV4SizeImage = (g->p.cy*g->p.cx) * sizeof(gPixel);
bmpInfo.bV4Width = g->p.cy;
bmpInfo.bV4Height = -g->p.cx; /* top-down image */
rect.top = g->p.x;
@ -1340,7 +1340,7 @@ LLDSPEC gBool gdisp_lld_init(GDisplay *g) {
break;
}
#else
bmpInfo.bV4SizeImage = (g->p.cy*g->p.x2) * sizeof(pixel_t);
bmpInfo.bV4SizeImage = (g->p.cy*g->p.x2) * sizeof(gPixel);
bmpInfo.bV4Width = g->p.x2;
bmpInfo.bV4Height = -g->p.cy; /* top-down image */
rect.top = g->p.y;
@ -1365,7 +1365,7 @@ LLDSPEC gBool gdisp_lld_init(GDisplay *g) {
#endif
#if GDISP_NEED_CONTROL
if (buffer != (pixel_t *)g->p.ptr)
if (buffer != (gPixel *)g->p.ptr)
free(buffer);
#endif
}

View File

@ -443,7 +443,7 @@ LLDSPEC void gdisp_lld_draw_pixel(GDisplay *g)
// Start of Bitblit code
//XImage bitmap;
//pixel_t *bits;
//gPixel *bits;
// bits = malloc(vis.depth * GDISP_SCREEN_WIDTH * GDISP_SCREEN_HEIGHT);
// bitmap = XCreateImage(dis, vis, vis.depth, ZPixmap,
// 0, bits, GDISP_SCREEN_WIDTH, GDISP_SCREEN_HEIGHT,

View File

@ -538,7 +538,7 @@ LLDSPEC gBool gdisp_lld_init(GDisplay *g) {
#if GDISP_HARDWARE_BITFILLS
LLDSPEC void gdisp_lld_blit_area(GDisplay *g) {
netPriv * priv;
pixel_t * buffer;
gPixel * buffer;
uint16_t buf[5];
gCoord x, y;

View File

@ -421,7 +421,7 @@ LLDSPEC gBool gdisp_lld_init(GDisplay *g) {
#if GDISP_HARDWARE_BITFILLS
LLDSPEC void gdisp_lld_blit_area(GDisplay *g) {
netPriv * priv;
pixel_t * buffer;
gPixel * buffer;
uint16_t buf[5];
gCoord x, y;

View File

@ -1097,7 +1097,7 @@ void gdispGFillArea(GDisplay *g, gCoord x, gCoord y, gCoord cx, gCoord cy, color
MUTEX_EXIT(g);
}
void gdispGBlitArea(GDisplay *g, gCoord x, gCoord y, gCoord cx, gCoord cy, gCoord srcx, gCoord srcy, gCoord srccx, const pixel_t *buffer) {
void gdispGBlitArea(GDisplay *g, gCoord x, gCoord y, gCoord cx, gCoord cy, gCoord srcx, gCoord srcy, gCoord srccx, const gPixel *buffer) {
MUTEX_ENTER(g);
#if NEED_CLIPPING
@ -3732,7 +3732,7 @@ color_t gdispContrastColor(color_t color) {
}
#if (!defined(gdispPackPixels) && !defined(GDISP_PIXELFORMAT_CUSTOM))
void gdispPackPixels(pixel_t *buf, gCoord cx, gCoord x, gCoord y, color_t color) {
void gdispPackPixels(gPixel *buf, gCoord cx, gCoord x, gCoord y, color_t color) {
/* No mutex required as we only read static data */
#if defined(GDISP_PIXELFORMAT_RGB888)
#error "GDISP: Packed pixels not supported yet"

View File

@ -223,7 +223,7 @@ extern GDisplay *GDISP;
/**
* @brief The type of a pixel.
*/
typedef color_t pixel_t;
typedef color_t gPixel;
/* Color Utility Functions */
@ -452,7 +452,7 @@ void gdispGFillArea(GDisplay *g, gCoord x, gCoord y, gCoord cx, gCoord cy, color
*
* @api
*/
void gdispGBlitArea(GDisplay *g, gCoord x, gCoord y, gCoord cx, gCoord cy, gCoord srcx, gCoord srcy, gCoord srccx, const pixel_t *buffer);
void gdispGBlitArea(GDisplay *g, gCoord x, gCoord y, gCoord cx, gCoord cy, gCoord srcx, gCoord srcy, gCoord srccx, const gPixel *buffer);
#define gdispBlitAreaEx(x,y,cx,cy,sx,sy,rx,b) gdispGBlitArea(GDISP,x,y,cx,cy,sx,sy,rx,b)
/**
@ -1230,6 +1230,7 @@ void gdispGDrawBox(GDisplay *g, gCoord x, gCoord y, gCoord cx, gCoord cy, color_
/* V2 compatibility */
#if GFX_COMPAT_V2
typedef gPixel pixel_t;
typedef gCoord coord_t;
typedef gPoint point, point_t;
#endif

View File

@ -308,7 +308,7 @@
*
* @api
*/
void gdispPackPixels(const pixel_t *buf, gCoord cx, gCoord x, gCoord y, color_t color);
void gdispPackPixels(const gPixel *buf, gCoord cx, gCoord x, gCoord y, color_t color);
#endif
//------------------------------------------------------------------------------------------------------------

View File

@ -24,7 +24,7 @@ typedef struct gdispImagePrivate_BMP {
uint8_t bitsperpixel;
#if GDISP_NEED_IMAGE_BMP_1 || GDISP_NEED_IMAGE_BMP_4 || GDISP_NEED_IMAGE_BMP_4_RLE || GDISP_NEED_IMAGE_BMP_8 || GDISP_NEED_IMAGE_BMP_8_RLE
uint16_t palsize;
pixel_t *palette;
gPixel *palette;
#endif
#if GDISP_NEED_IMAGE_BMP_4_RLE || GDISP_NEED_IMAGE_BMP_8_RLE
uint16_t rlerun;
@ -41,8 +41,8 @@ typedef struct gdispImagePrivate_BMP {
uint32_t maskalpha;
#endif
size_t frame0pos;
pixel_t *frame0cache;
pixel_t buf[GDISP_IMAGE_BMP_BLIT_BUFFER_SIZE];
gPixel *frame0cache;
gPixel buf[GDISP_IMAGE_BMP_BLIT_BUFFER_SIZE];
} gdispImagePrivate_BMP;
void gdispImageClose_BMP(gdispImage *img) {
@ -55,7 +55,7 @@ void gdispImageClose_BMP(gdispImage *img) {
gdispImageFree(img, (void *)priv->palette, priv->palsize*sizeof(color_t));
#endif
if (priv->frame0cache)
gdispImageFree(img, (void *)priv->frame0cache, img->width*img->height*sizeof(pixel_t));
gdispImageFree(img, (void *)priv->frame0cache, img->width*img->height*sizeof(gPixel));
gdispImageFree(img, (void *)priv, sizeof(gdispImagePrivate_BMP));
img->priv = 0;
}
@ -704,8 +704,8 @@ gdispImageError gdispImageCache_BMP(gdispImage *img) {
return GDISP_IMAGE_ERR_OK;
/* We need to allocate the cache */
len = img->width * img->height * sizeof(pixel_t);
priv->frame0cache = (pixel_t *)gdispImageAlloc(img, len);
len = img->width * img->height * sizeof(gPixel);
priv->frame0cache = (gPixel *)gdispImageAlloc(img, len);
if (!priv->frame0cache)
return GDISP_IMAGE_ERR_NOMEMORY;

View File

@ -91,14 +91,14 @@ typedef struct gdispImagePrivate_GIF {
uint8_t bgcolor; // Background Color (global)
uint16_t loops; // Remaining frame loops (if animated)
uint16_t palsize; // Global palette size (global)
pixel_t *palette; // Global palette (global)
gPixel *palette; // Global palette (global)
size_t frame0pos; // The position of the first frame
gifimgcache * cache; // The list of cached frames
gifimgcache * curcache; // The cache of the current frame (if created)
gifimgdecode * decode; // The decode data for the decode in progress
gifimgframe frame;
gifimgdispose dispose;
pixel_t buf[GDISP_IMAGE_GIF_BLIT_BUFFER_SIZE]; // Buffer for reading and blitting
gPixel buf[GDISP_IMAGE_GIF_BLIT_BUFFER_SIZE]; // Buffer for reading and blitting
} gdispImagePrivate_GIF;
/**

View File

@ -59,7 +59,7 @@ gdispImageError jd_decomp(JDEC*, unsigned(*)(gdispImage*,void*,JRECT*), uint8_t)
/*---------------------------------------------------------------------------*/
typedef struct gdispImagePrivate_JPG {
pixel_t *frame0cache;
gPixel *frame0cache;
} gdispImagePrivate_JPG;
gdispImageError gdispImageOpen_JPG(gdispImage *img){
@ -123,7 +123,7 @@ void gdispImageClose_JPG(gdispImage *img){
gdispImagePrivate_JPG *priv = (gdispImagePrivate_JPG *)img->priv;
if(priv){
if (priv->frame0cache){
gdispImageFree(img, (void *)priv->frame0cache, img->width * img->height * sizeof(pixel_t));
gdispImageFree(img, (void *)priv->frame0cache, img->width * img->height * sizeof(gPixel));
}
gdispImageFree(img, (void*) priv, sizeof(gdispImagePrivate_JPG));
}
@ -133,7 +133,7 @@ static unsigned gdispImage_JPG_WriteToCache(gdispImage *img, void *bitmap, JRECT
{
gdispImagePrivate_JPG *priv;
uint8_t *in;
pixel_t *out;
gPixel *out;
gCoord x, y;
priv = (gdispImagePrivate_JPG *)img->priv;
@ -158,7 +158,7 @@ gdispImageError gdispImageCache_JPG(gdispImage *img) {
return GDISP_IMAGE_ERR_OK;
/* Otherwise start a new decode */
priv->frame0cache = (pixel_t *)gdispImageAlloc(img, img->width * img->height * sizeof(pixel_t));
priv->frame0cache = (gPixel *)gdispImageAlloc(img, img->width * img->height * sizeof(gPixel));
if (!priv->frame0cache)
return GDISP_IMAGE_ERR_NOMEMORY;

View File

@ -27,8 +27,8 @@ void *gdispImageAlloc(gdispImage *img, size_t sz);
void gdispImageFree(gdispImage *img, void *ptr, size_t sz);
typedef struct gdispImagePrivate_NATIVE {
pixel_t *frame0cache;
pixel_t buf[BLIT_BUFFER_SIZE_NATIVE];
gPixel *frame0cache;
gPixel buf[BLIT_BUFFER_SIZE_NATIVE];
} gdispImagePrivate_NATIVE;
void gdispImageClose_NATIVE(gdispImage *img) {
@ -37,7 +37,7 @@ void gdispImageClose_NATIVE(gdispImage *img) {
priv = (gdispImagePrivate_NATIVE *)img->priv;
if (priv) {
if (priv->frame0cache)
gdispImageFree(img, (void *)priv->frame0cache, img->width * img->height * sizeof(pixel_t));
gdispImageFree(img, (void *)priv->frame0cache, img->width * img->height * sizeof(gPixel));
gdispImageFree(img, (void *)priv, sizeof(gdispImagePrivate_NATIVE));
img->priv = 0;
}
@ -80,8 +80,8 @@ gdispImageError gdispImageCache_NATIVE(gdispImage *img) {
return GDISP_IMAGE_ERR_OK;
/* We need to allocate the cache */
len = img->width * img->height * sizeof(pixel_t);
priv->frame0cache = (pixel_t *)gdispImageAlloc(img, len);
len = img->width * img->height * sizeof(gPixel);
priv->frame0cache = (gPixel *)gdispImageAlloc(img, len);
if (!priv->frame0cache)
return GDISP_IMAGE_ERR_NOMEMORY;
@ -112,7 +112,7 @@ gdispImageError gdispGImageDraw_NATIVE(GDisplay *g, gdispImage *img, gCoord x, g
}
/* For this image decoder we cheat and just seek straight to the region we want to display */
pos = FRAME0POS_NATIVE + (img->width * sy + sx) * sizeof(pixel_t);
pos = FRAME0POS_NATIVE + (img->width * sy + sx) * sizeof(gPixel);
/* Cycle through the lines */
for(;cy;cy--, y++) {
@ -124,8 +124,8 @@ gdispImageError gdispGImageDraw_NATIVE(GDisplay *g, gdispImage *img, gCoord x, g
// Read the data
len = gfileRead(img->f,
priv->buf,
mcx > BLIT_BUFFER_SIZE_NATIVE ? (BLIT_BUFFER_SIZE_NATIVE*sizeof(pixel_t)) : (mcx * sizeof(pixel_t)))
/ sizeof(pixel_t);
mcx > BLIT_BUFFER_SIZE_NATIVE ? (BLIT_BUFFER_SIZE_NATIVE*sizeof(gPixel)) : (mcx * sizeof(gPixel)))
/ sizeof(gPixel);
if (!len)
return GDISP_IMAGE_ERR_BADDATA;
@ -134,7 +134,7 @@ gdispImageError gdispGImageDraw_NATIVE(GDisplay *g, gdispImage *img, gCoord x, g
}
/* Get the position for the start of the next line */
pos += img->width*sizeof(pixel_t);
pos += img->width*sizeof(gPixel);
}
return GDISP_IMAGE_ERR_OK;

View File

@ -70,7 +70,7 @@ typedef struct PNG_output {
gCoord sx, sy;
gCoord ix, iy;
unsigned cnt;
pixel_t buf[GDISP_IMAGE_PNG_BLIT_BUFFER_SIZE];
gPixel buf[GDISP_IMAGE_PNG_BLIT_BUFFER_SIZE];
} PNG_output;
// Handle the PNG scan line filter

View File

@ -92,7 +92,7 @@ void gdispPixmapDelete(GDisplay *g) {
gdriverUnRegister(&g->d);
}
pixel_t *gdispPixmapGetBits(GDisplay *g) {
gPixel *gdispPixmapGetBits(GDisplay *g) {
if (gvmt(g) != GDISPVMT_pixmap)
return 0;
return ((pixmap *)g->priv)->pixels;

View File

@ -59,7 +59,7 @@ void gdispPixmapDelete(GDisplay *g);
* (although different pixmaps will have different pixel pointers). Once a pixmap is deleted, the pixel pointer
* should not be used by the application.
*/
pixel_t *gdispPixmapGetBits(GDisplay *g);
gPixel *gdispPixmapGetBits(GDisplay *g);
#if GDISP_NEED_PIXMAP_IMAGE || defined(__DOXYGEN__)
/**

View File

@ -261,7 +261,7 @@ void gwinFillArea(GHandle gh, gCoord x, gCoord y, gCoord cx, gCoord cy) {
_gwinDrawEnd(gh);
}
void gwinBlitArea(GHandle gh, gCoord x, gCoord y, gCoord cx, gCoord cy, gCoord srcx, gCoord srcy, gCoord srccx, const pixel_t *buffer) {
void gwinBlitArea(GHandle gh, gCoord x, gCoord y, gCoord cx, gCoord cy, gCoord srcx, gCoord srcy, gCoord srccx, const gPixel *buffer) {
if (!_gwinDrawStart(gh)) return;
gdispGBlitArea(gh->display, gh->x+x, gh->y+y, cx, cy, srcx, srcy, srccx, buffer);
_gwinDrawEnd(gh);

View File

@ -680,7 +680,7 @@ void gwinFillArea(GHandle gh, gCoord x, gCoord y, gCoord cx, gCoord cy);
*
* @api
*/
void gwinBlitArea(GHandle gh, gCoord x, gCoord y, gCoord cx, gCoord cy, gCoord srcx, gCoord srcy, gCoord srccx, const pixel_t *buffer);
void gwinBlitArea(GHandle gh, gCoord x, gCoord y, gCoord cx, gCoord cy, gCoord srcx, gCoord srcy, gCoord srccx, const gPixel *buffer);
/*-------------------------------------------------
* Circle, ellipse, arc and arc-sectors functions

View File

@ -86,7 +86,7 @@ static void gl3dRedraw(GWindowObject *gh) {
ZBuffer * zb;
zb = ((GGL3DObject *)gh)->glcxt->zb;
gdispGBlitArea(gh->display, gh->x, gh->y, zb->xsize, zb->ysize, 0, 0, zb->linesize/sizeof(color_t), (const pixel_t *)zb->pbuf);
gdispGBlitArea(gh->display, gh->x, gh->y, zb->xsize, zb->ysize, 0, 0, zb->linesize/sizeof(color_t), (const gPixel *)zb->pbuf);
}
static int gl3dResizeGLViewport(GLContext *c, int *xsize_ptr, int *ysize_ptr) {