From 2d31d77a8ba231cb03ec35863c4c4ce2024f6509 Mon Sep 17 00:00:00 2001 From: Jonathan Gordon Date: Thu, 29 Jul 2010 12:37:48 +0000 Subject: 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 --- lib/skin_parser/skin_buffer.c | 38 +++++++++++++++++++++++++------------- 1 file changed, 25 insertions(+), 13 deletions(-) (limited to 'lib/skin_parser/skin_buffer.c') 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 #include +#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 -- cgit v1.2.3