1
0
Fork 0
forked from len0rd/rockbox

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
This commit is contained in:
Jonathan Gordon 2010-07-29 12:37:48 +00:00
parent e436483b66
commit 2d31d77a8b
44 changed files with 2105 additions and 3326 deletions

View file

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