forked from len0rd/rockbox
Added return parameter for space taken by grayscale buffer to gray_init_buffer()
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@4648 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
parent
0e1faea5ac
commit
007e1d1af3
2 changed files with 22 additions and 16 deletions
|
@ -423,31 +423,31 @@ void gray_init(struct plugin_api* newrb)
|
||||||
*
|
*
|
||||||
* The total memory needed can be calculated as follows:
|
* The total memory needed can be calculated as follows:
|
||||||
* total_mem =
|
* total_mem =
|
||||||
* sizeof(tGraymap) (= 48 bytes currently)
|
* sizeof(tGraybuf) (= 48 bytes currently)
|
||||||
* + sizeof(long) (= 4 bytes)
|
* + sizeof(long) (= 4 bytes)
|
||||||
* + (width * bheight + sizeof(long)) * depth
|
* + (width * bheight + sizeof(long)) * depth
|
||||||
* + 0..3 (longword alignment of grayscale display buffer)
|
* + 0..3 (longword alignment of grayscale display buffer)
|
||||||
*/
|
*/
|
||||||
int gray_init_buffer(unsigned char *gbuf, int gbuf_size, int width,
|
int gray_init_buffer(unsigned char *gbuf, int gbuf_size, int width,
|
||||||
int bheight, int depth)
|
int bheight, int depth, int *buf_taken)
|
||||||
{
|
{
|
||||||
int possible_depth, plane_size;
|
int possible_depth, plane_size;
|
||||||
int i, j;
|
int i, j, align;
|
||||||
|
|
||||||
if (rb == NULL || (unsigned) width > LCD_WIDTH
|
if (rb == NULL
|
||||||
|
|| (unsigned) width > LCD_WIDTH
|
||||||
|| (unsigned) bheight > (LCD_HEIGHT/8)
|
|| (unsigned) bheight > (LCD_HEIGHT/8)
|
||||||
|| depth < 1)
|
|| depth < 1)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
while ((unsigned long)gbuf & 3) /* the buffer has to be long aligned */
|
/* the buffer has to be long aligned */
|
||||||
{
|
align = 3 - (((unsigned long)gbuf + 3) & 3);
|
||||||
gbuf++;
|
gbuf += align;
|
||||||
gbuf_size--;
|
gbuf_size -= align;
|
||||||
}
|
|
||||||
|
|
||||||
plane_size = width * bheight;
|
plane_size = width * bheight;
|
||||||
possible_depth = (gbuf_size - sizeof(tGraybuf) - sizeof(unsigned long))
|
possible_depth = (gbuf_size - sizeof(tGraybuf) - sizeof(long))
|
||||||
/ (plane_size + sizeof(unsigned long));
|
/ (plane_size + sizeof(long));
|
||||||
|
|
||||||
if (possible_depth < 1)
|
if (possible_depth < 1)
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -455,8 +455,8 @@ int gray_init_buffer(unsigned char *gbuf, int gbuf_size, int width,
|
||||||
depth = MIN(depth, 32);
|
depth = MIN(depth, 32);
|
||||||
depth = MIN(depth, possible_depth);
|
depth = MIN(depth, possible_depth);
|
||||||
|
|
||||||
graybuf = (tGraybuf *) gbuf; /* global pointer to buffer structure */
|
graybuf = (tGraybuf *) gbuf; /* global pointer to buffer structure */
|
||||||
|
|
||||||
graybuf->x = 0;
|
graybuf->x = 0;
|
||||||
graybuf->by = 0;
|
graybuf->by = 0;
|
||||||
graybuf->width = width;
|
graybuf->width = width;
|
||||||
|
@ -467,9 +467,9 @@ int gray_init_buffer(unsigned char *gbuf, int gbuf_size, int width,
|
||||||
graybuf->cur_plane = 0;
|
graybuf->cur_plane = 0;
|
||||||
graybuf->flags = 0;
|
graybuf->flags = 0;
|
||||||
graybuf->data = gbuf + sizeof(tGraybuf);
|
graybuf->data = gbuf + sizeof(tGraybuf);
|
||||||
graybuf->bitpattern = (unsigned long *) (graybuf->data
|
graybuf->bitpattern = (unsigned long *) (graybuf->data
|
||||||
+ depth * plane_size);
|
+ depth * plane_size);
|
||||||
|
|
||||||
i = depth;
|
i = depth;
|
||||||
j = 8;
|
j = 8;
|
||||||
while (i != 0)
|
while (i != 0)
|
||||||
|
@ -503,6 +503,12 @@ int gray_init_buffer(unsigned char *gbuf, int gbuf_size, int width,
|
||||||
graybuf->bitpattern[i] = pattern;
|
graybuf->bitpattern[i] = pattern;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (buf_taken) /* caller requested info about space taken */
|
||||||
|
{
|
||||||
|
*buf_taken = sizeof(tGraybuf) + sizeof(long)
|
||||||
|
+ (plane_size + sizeof(long)) * depth + align;
|
||||||
|
}
|
||||||
|
|
||||||
return depth;
|
return depth;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -37,7 +37,7 @@ void gray_init(struct plugin_api* newrb);
|
||||||
|
|
||||||
/* general functions */
|
/* general functions */
|
||||||
int gray_init_buffer(unsigned char *gbuf, int gbuf_size, int width,
|
int gray_init_buffer(unsigned char *gbuf, int gbuf_size, int width,
|
||||||
int bheight, int depth);
|
int bheight, int depth, int *buf_taken);
|
||||||
void gray_release_buffer(void);
|
void gray_release_buffer(void);
|
||||||
void gray_position_display(int x, int by);
|
void gray_position_display(int x, int by);
|
||||||
void gray_show_display(bool enable);
|
void gray_show_display(bool enable);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue