diff options
author | Jonathan Gordon <rockbox@jdgordon.info> | 2010-07-29 12:37:48 +0000 |
---|---|---|
committer | Jonathan Gordon <rockbox@jdgordon.info> | 2010-07-29 12:37:48 +0000 |
commit | 2d31d77a8ba231cb03ec35863c4c4ce2024f6509 (patch) | |
tree | b85ca1bede3e83695619064ee9a323f0a8da1865 /lib/skin_parser/skin_buffer.c | |
parent | e436483b66a931fef6436e9cd3e69eb2b3ff1f7b (diff) | |
download | rockbox-2d31d77a8ba231cb03ec35863c4c4ce2024f6509.tar.gz rockbox-2d31d77a8ba231cb03ec35863c4c4ce2024f6509.zip |
FS#11470 - new skin code, finally svn uses the new parser from the theme editor. This means that a skin that passes the editor WILL pass svn and checkwps (unless the target runs out of skin buffer or something.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@27613 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'lib/skin_parser/skin_buffer.c')
-rw-r--r-- | lib/skin_parser/skin_buffer.c | 38 |
1 files changed, 25 insertions, 13 deletions
diff --git a/lib/skin_parser/skin_buffer.c b/lib/skin_parser/skin_buffer.c index 05cdc0ce03..69d9d273bd 100644 --- a/lib/skin_parser/skin_buffer.c +++ b/lib/skin_parser/skin_buffer.c @@ -24,21 +24,19 @@ #include <string.h> #include <stdlib.h> +#include "skin_buffer.h" + #ifdef ROCKBOX -#define SKIN_BUFFER_SIZE (400*1024) /* Excessivly large for now */ -static unsigned char buffer[SKIN_BUFFER_SIZE]; -static unsigned char *buffer_front = NULL; /* start of the free space, - increases with allocation*/ +static size_t buf_size; +static unsigned char *buffer_start = NULL; +static unsigned char *buffer_front = NULL; #endif -void skin_buffer_init(void) +void skin_buffer_init(char* buffer, size_t size) { #if defined(ROCKBOX) - { - /* reset the buffer.... */ - buffer_front = buffer; - //TODO: buf_size = size; - } + buffer_start = buffer_front = buffer; + buf_size = size; #endif } @@ -46,7 +44,9 @@ void skin_buffer_init(void) void* skin_buffer_alloc(size_t size) { void *retval = NULL; -#ifdef ROCKBOX +#ifdef ROCKBOX + if (size > skin_buffer_freespace()) + return NULL; retval = buffer_front; buffer_front += size; /* 32-bit aligned */ @@ -62,10 +62,22 @@ void* skin_buffer_alloc(size_t size) /* get the number of bytes currently being used */ size_t skin_buffer_usage(void) { - return buffer_front - buffer; + return buffer_front - buffer_start; } size_t skin_buffer_freespace(void) { - return SKIN_BUFFER_SIZE - skin_buffer_usage(); + return buf_size - skin_buffer_usage(); +} + +static unsigned char *saved_buffer_pos = NULL; +void skin_buffer_save_position(void) +{ + saved_buffer_pos = buffer_front; +} + +void skin_buffer_restore_position(void) +{ + if (saved_buffer_pos) + buffer_front = saved_buffer_pos; } #endif |