From 2b75db44a096ddce161452c66c97ee20e724787e Mon Sep 17 00:00:00 2001 From: Joel Bodenmann Date: Tue, 10 Jan 2017 10:18:52 +0100 Subject: [PATCH] Adding GDISP_IMAGE_BMP_BLIT_BUFFER_SIZE configuration option --- changelog.txt | 1 + gfxconf.example.h | 1 + src/gdisp/gdisp_image_bmp.c | 24 ++++++++++++------------ src/gdisp/gdisp_options.h | 9 +++++++++ 4 files changed, 23 insertions(+), 12 deletions(-) diff --git a/changelog.txt b/changelog.txt index 675daf58..074da055 100644 --- a/changelog.txt +++ b/changelog.txt @@ -9,6 +9,7 @@ FIX: Multithreading issue with slow window redraws and large images FIX: Ensure valid thread stack sizes on platforms where it matters FEATURE: Add support for a GFILE user provided file system FEATURE: Add gwinListItemSetText() to replace text in a GWIN list item +FEATURE: Added GDISP_IMAGE_BMP_BLIT_BUFFER_SIZE configuration option *** Release 2.7 *** diff --git a/gfxconf.example.h b/gfxconf.example.h index 764d9199..90401af6 100644 --- a/gfxconf.example.h +++ b/gfxconf.example.h @@ -118,6 +118,7 @@ // #define GDISP_NEED_IMAGE_BMP_16 TRUE // #define GDISP_NEED_IMAGE_BMP_24 TRUE // #define GDISP_NEED_IMAGE_BMP_32 TRUE +// #define GDISP_IMAGE_BMP_BLIT_BUFFER_SIZE 32 // #define GDISP_NEED_IMAGE_JPG FALSE // #define GDISP_NEED_IMAGE_PNG FALSE // #define GDISP_NEED_IMAGE_PNG_INTERLACED FALSE diff --git a/src/gdisp/gdisp_image_bmp.c b/src/gdisp/gdisp_image_bmp.c index 2ea4e95f..33087e5d 100644 --- a/src/gdisp/gdisp_image_bmp.c +++ b/src/gdisp/gdisp_image_bmp.c @@ -16,7 +16,7 @@ * Bigger is faster but uses more RAM. * This must be greater than 40 bytes and 32 pixels as we read our headers into this space as well */ -#define BLIT_BUFFER_SIZE_BMP 32 +#define GDISP_IMAGE_BMP_BLIT_BUFFER_SIZE 32 typedef struct gdispImagePrivate_BMP { uint8_t bmpflags; @@ -49,7 +49,7 @@ typedef struct gdispImagePrivate_BMP { #endif size_t frame0pos; pixel_t *frame0cache; - pixel_t buf[BLIT_BUFFER_SIZE_BMP]; + pixel_t buf[GDISP_IMAGE_BMP_BLIT_BUFFER_SIZE]; } gdispImagePrivate_BMP; void gdispImageClose_BMP(gdispImage *img) { @@ -379,7 +379,7 @@ static coord_t getPixels(gdispImage *img, coord_t x) { pc = priv->buf; len = 0; - while(x < img->width && len <= BLIT_BUFFER_SIZE_BMP-32) { + while(x < img->width && len <= GDISP_IMAGE_BMP_BLIT_BUFFER_SIZE-32) { if (gfileRead(img->f, &b, 4) != 4) return 0; @@ -409,7 +409,7 @@ static coord_t getPixels(gdispImage *img, coord_t x) { while(x < img->width) { if (priv->bmpflags & BMP_RLE_ENC) { - while (priv->rlerun && len <= BLIT_BUFFER_SIZE_BMP-2 && x < img->width) { + while (priv->rlerun && len <= GDISP_IMAGE_BMP_BLIT_BUFFER_SIZE-2 && x < img->width) { *pc++ = priv->palette[priv->rlecode >> 4]; priv->rlerun--; len++; @@ -424,7 +424,7 @@ static coord_t getPixels(gdispImage *img, coord_t x) { if (priv->rlerun) // Return if we have more run to do return len; } else if (priv->bmpflags & BMP_RLE_ABS) { - while (priv->rlerun && len <= BLIT_BUFFER_SIZE_BMP-2 && x < img->width) { + while (priv->rlerun && len <= GDISP_IMAGE_BMP_BLIT_BUFFER_SIZE-2 && x < img->width) { if (gfileRead(img->f, &b, 1) != 1) return 0; *pc++ = priv->palette[b[0] >> 4]; @@ -484,7 +484,7 @@ static coord_t getPixels(gdispImage *img, coord_t x) { { uint8_t b[4]; - while(x < img->width && len <= BLIT_BUFFER_SIZE_BMP-8) { + while(x < img->width && len <= GDISP_IMAGE_BMP_BLIT_BUFFER_SIZE-8) { if (gfileRead(img->f, &b, 4) != 4) return 0; @@ -515,7 +515,7 @@ static coord_t getPixels(gdispImage *img, coord_t x) { while(x < img->width) { if (priv->bmpflags & BMP_RLE_ENC) { - while (priv->rlerun && len < BLIT_BUFFER_SIZE_BMP && x < img->width) { + while (priv->rlerun && len < GDISP_IMAGE_BMP_BLIT_BUFFER_SIZE && x < img->width) { *pc++ = priv->palette[priv->rlecode]; priv->rlerun--; len++; @@ -524,7 +524,7 @@ static coord_t getPixels(gdispImage *img, coord_t x) { if (priv->rlerun) // Return if we have more run to do return len; } else if (priv->bmpflags & BMP_RLE_ABS) { - while (priv->rlerun && len < BLIT_BUFFER_SIZE_BMP && x < img->width) { + while (priv->rlerun && len < GDISP_IMAGE_BMP_BLIT_BUFFER_SIZE && x < img->width) { if (gfileRead(img->f, &b, 1) != 1) return 0; *pc++ = priv->palette[b[0]]; @@ -578,7 +578,7 @@ static coord_t getPixels(gdispImage *img, coord_t x) { { uint8_t b[4]; - while(x < img->width && len <= BLIT_BUFFER_SIZE_BMP-4) { + while(x < img->width && len <= GDISP_IMAGE_BMP_BLIT_BUFFER_SIZE-4) { if (gfileRead(img->f, &b, 4) != 4) return 0; @@ -600,7 +600,7 @@ static coord_t getPixels(gdispImage *img, coord_t x) { uint16_t w[2]; color_t r, g, b; - while(x < img->width && len <= BLIT_BUFFER_SIZE_BMP-2) { + while(x < img->width && len <= GDISP_IMAGE_BMP_BLIT_BUFFER_SIZE-2) { if (gfileRead(img->f, &w, 4) != 4) return 0; gdispImageMakeLE16(w[0]); @@ -645,7 +645,7 @@ static coord_t getPixels(gdispImage *img, coord_t x) { { uint8_t b[3]; - while(x < img->width && len < BLIT_BUFFER_SIZE_BMP) { + while(x < img->width && len < GDISP_IMAGE_BMP_BLIT_BUFFER_SIZE) { if (gfileRead(img->f, &b, 3) != 3) return 0; *pc++ = RGB2COLOR(b[2], b[1], b[0]); @@ -668,7 +668,7 @@ static coord_t getPixels(gdispImage *img, coord_t x) { uint32_t dw; color_t r, g, b; - while(x < img->width && len < BLIT_BUFFER_SIZE_BMP) { + while(x < img->width && len < GDISP_IMAGE_BMP_BLIT_BUFFER_SIZE) { if (gfileRead(img->f, &dw, 4) != 4) return 0; gdispImageMakeLE32(dw); diff --git a/src/gdisp/gdisp_options.h b/src/gdisp/gdisp_options.h index 09502618..4ae267ea 100644 --- a/src/gdisp/gdisp_options.h +++ b/src/gdisp/gdisp_options.h @@ -388,6 +388,15 @@ #ifndef GDISP_NEED_IMAGE_BMP_32 #define GDISP_NEED_IMAGE_BMP_32 TRUE #endif + /** + * @brief The blit buffer size. + * @details Defaults to TRUE + * @note Bigger is faster but requires more RAM. + * @note This must be greater than 40 bytes and 32 pixels as we read our headers into this space as well. + */ + #ifndef GDISP_IMAGE_BMP_BLIT_BUFFER_SIZE + #define GDISP_IMAGE_BMP_BLIT_BUFFER_SIZE 32 + #endif /** * @} *