Adding GDISP_IMAGE_BMP_BLIT_BUFFER_SIZE configuration option

This commit is contained in:
Joel Bodenmann 2017-01-10 10:18:52 +01:00
parent bfe41b4cfd
commit 2b75db44a0
4 changed files with 23 additions and 12 deletions

View File

@ -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 ***

View File

@ -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

View File

@ -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);

View File

@ -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
/**
* @}
*