forked from len0rd/rockbox
skin: don't calculate id3->elapsed+state->ff_rewind_count each time. remove trailing spaces.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@25045 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
parent
f79b45d8bb
commit
1fbdd91333
9 changed files with 77 additions and 95 deletions
|
@ -93,7 +93,7 @@ char* skin_backdrop_load(char* backdrop, char *bmpdir, enum screen_type screen)
|
||||||
{
|
{
|
||||||
return backdrops[i].buffer;
|
return backdrops[i].buffer;
|
||||||
}
|
}
|
||||||
else if (backdrops[i].buffer == NULL)
|
else if (!bdrop && backdrops[i].buffer == NULL)
|
||||||
{
|
{
|
||||||
bdrop = &backdrops[i];
|
bdrop = &backdrops[i];
|
||||||
}
|
}
|
||||||
|
@ -107,7 +107,6 @@ char* skin_backdrop_load(char* backdrop, char *bmpdir, enum screen_type screen)
|
||||||
loaded = screens[screen].backdrop_load(filename, bdrop->buffer);
|
loaded = screens[screen].backdrop_load(filename, bdrop->buffer);
|
||||||
bdrop->screen = screen;
|
bdrop->screen = screen;
|
||||||
strlcpy(bdrop->name, backdrop, MAX_FILENAME+1);
|
strlcpy(bdrop->name, backdrop, MAX_FILENAME+1);
|
||||||
bdrop->name[MAX_FILENAME] = '\0';
|
|
||||||
|
|
||||||
return loaded ? bdrop->buffer : NULL;
|
return loaded ? bdrop->buffer : NULL;
|
||||||
}
|
}
|
||||||
|
@ -117,4 +116,3 @@ void skin_backdrop_init(void)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
@ -116,13 +116,13 @@ void skin_statusbar_changed(struct gui_wps *skin)
|
||||||
|
|
||||||
static void draw_progressbar(struct gui_wps *gwps,
|
static void draw_progressbar(struct gui_wps *gwps,
|
||||||
struct skin_viewport *wps_vp)
|
struct skin_viewport *wps_vp)
|
||||||
{
|
{
|
||||||
struct screen *display = gwps->display;
|
struct screen *display = gwps->display;
|
||||||
struct wps_state *state = gwps->state;
|
struct wps_state *state = gwps->state;
|
||||||
struct progressbar *pb = wps_vp->pb;
|
struct progressbar *pb = wps_vp->pb;
|
||||||
struct mp3entry *id3 = state->id3;
|
struct mp3entry *id3 = state->id3;
|
||||||
int y = pb->y;
|
int y = pb->y, height = pb->height;
|
||||||
int height = pb->height;
|
unsigned long length, elapsed;
|
||||||
|
|
||||||
if (pb->height < 0 && !pb->have_bitmap_pb)
|
if (pb->height < 0 && !pb->have_bitmap_pb)
|
||||||
height = font_get(wps_vp->vp.font)->height;
|
height = font_get(wps_vp->vp.font)->height;
|
||||||
|
@ -136,39 +136,39 @@ static void draw_progressbar(struct gui_wps *gwps,
|
||||||
y = (-y -1)*line_height + (0 > center ? 0 : center);
|
y = (-y -1)*line_height + (0 > center ? 0 : center);
|
||||||
}
|
}
|
||||||
|
|
||||||
int elapsed, length;
|
if (id3 && id3->length)
|
||||||
if (id3)
|
|
||||||
{
|
{
|
||||||
elapsed = id3->elapsed;
|
|
||||||
length = id3->length;
|
length = id3->length;
|
||||||
|
elapsed = id3->elapsed + state->ff_rewind_count;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
length = 1;
|
||||||
elapsed = 0;
|
elapsed = 0;
|
||||||
length = 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pb->have_bitmap_pb)
|
if (pb->have_bitmap_pb)
|
||||||
gui_bitmap_scrollbar_draw(display, pb->bm,
|
gui_bitmap_scrollbar_draw(display, pb->bm,
|
||||||
pb->x, y, pb->width, pb->bm.height,
|
pb->x, y, pb->width, pb->bm.height,
|
||||||
length ? length : 1, 0,
|
length, 0, elapsed, HORIZONTAL);
|
||||||
length ? elapsed + state->ff_rewind_count : 0,
|
|
||||||
HORIZONTAL);
|
|
||||||
else
|
else
|
||||||
gui_scrollbar_draw(display, pb->x, y, pb->width, height,
|
gui_scrollbar_draw(display, pb->x, y, pb->width, height,
|
||||||
length ? length : 1, 0,
|
length, 0, elapsed, HORIZONTAL);
|
||||||
length ? elapsed + state->ff_rewind_count : 0,
|
|
||||||
HORIZONTAL);
|
if (id3 && id3->length)
|
||||||
|
{
|
||||||
#ifdef AB_REPEAT_ENABLE
|
#ifdef AB_REPEAT_ENABLE
|
||||||
if ( ab_repeat_mode_enabled() && length != 0 )
|
if (ab_repeat_mode_enabled())
|
||||||
ab_draw_markers(display, length,
|
ab_draw_markers(display, id3->length,
|
||||||
pb->x, pb->x + pb->width, y, height);
|
pb->x, pb->x + pb->width, y, height);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (id3 && id3->cuesheet)
|
if (id3->cuesheet)
|
||||||
cue_draw_markers(display, state->id3->cuesheet, length,
|
cue_draw_markers(display, id3->cuesheet, id3->length,
|
||||||
pb->x, pb->x + pb->width, y+1, height-2);
|
pb->x, pb->x + pb->width, y+1, height-2);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool audio_peek_track(struct mp3entry* id3, int offset);
|
bool audio_peek_track(struct mp3entry* id3, int offset);
|
||||||
static void draw_playlist_viewer_list(struct gui_wps *gwps,
|
static void draw_playlist_viewer_list(struct gui_wps *gwps,
|
||||||
struct playlistviewer *viewer)
|
struct playlistviewer *viewer)
|
||||||
|
@ -189,7 +189,6 @@ static void draw_playlist_viewer_list(struct gui_wps *gwps,
|
||||||
char buf[MAX_PATH*2], tempbuf[MAX_PATH];
|
char buf[MAX_PATH*2], tempbuf[MAX_PATH];
|
||||||
unsigned int buf_used = 0;
|
unsigned int buf_used = 0;
|
||||||
|
|
||||||
|
|
||||||
gwps->display->set_viewport(viewer->vp);
|
gwps->display->set_viewport(viewer->vp);
|
||||||
for(i=start_item; (i-start_item)<lines && i<playlist_amount(); i++)
|
for(i=start_item; (i-start_item)<lines && i<playlist_amount(); i++)
|
||||||
{
|
{
|
||||||
|
|
|
@ -133,8 +133,3 @@ void skin_font_unload(int font_id)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -41,5 +41,4 @@ int skin_font_load(char* font_name);
|
||||||
/* unload a skin font. If a font has been loaded more than once it wont actually
|
/* unload a skin font. If a font has been loaded more than once it wont actually
|
||||||
* be unloaded untill all references have been unloaded */
|
* be unloaded untill all references have been unloaded */
|
||||||
void skin_font_unload(int font_id);
|
void skin_font_unload(int font_id);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -910,7 +910,6 @@ static int parse_viewport(const char *wps_bufptr,
|
||||||
if (!skin_start_new_line(skin_vp, wps_data->num_tokens))
|
if (!skin_start_new_line(skin_vp, wps_data->num_tokens))
|
||||||
return WPS_ERROR_INVALID_PARAM;
|
return WPS_ERROR_INVALID_PARAM;
|
||||||
|
|
||||||
|
|
||||||
if (*ptr == 'i')
|
if (*ptr == 'i')
|
||||||
{
|
{
|
||||||
skin_vp->label = VP_INFO_LABEL;
|
skin_vp->label = VP_INFO_LABEL;
|
||||||
|
@ -978,7 +977,6 @@ static int parse_image_special(const char *wps_bufptr,
|
||||||
|
|
||||||
error = (pos > newline);
|
error = (pos > newline);
|
||||||
|
|
||||||
|
|
||||||
#if LCD_DEPTH > 1
|
#if LCD_DEPTH > 1
|
||||||
if (token->type == WPS_TOKEN_IMAGE_BACKDROP)
|
if (token->type == WPS_TOKEN_IMAGE_BACKDROP)
|
||||||
{
|
{
|
||||||
|
|
|
@ -158,6 +158,8 @@ const char *get_id3_token(struct wps_token *token, struct mp3entry *id3,
|
||||||
struct wps_state *state = &wps_state;
|
struct wps_state *state = &wps_state;
|
||||||
if (id3)
|
if (id3)
|
||||||
{
|
{
|
||||||
|
unsigned long length = id3->length;
|
||||||
|
unsigned long elapsed = id3->elapsed + state->ff_rewind_count;
|
||||||
switch (token->type)
|
switch (token->type)
|
||||||
{
|
{
|
||||||
case WPS_TOKEN_METADATA_ARTIST:
|
case WPS_TOKEN_METADATA_ARTIST:
|
||||||
|
@ -226,31 +228,26 @@ const char *get_id3_token(struct wps_token *token, struct mp3entry *id3,
|
||||||
return "?";
|
return "?";
|
||||||
return buf;
|
return buf;
|
||||||
case WPS_TOKEN_TRACK_TIME_ELAPSED:
|
case WPS_TOKEN_TRACK_TIME_ELAPSED:
|
||||||
format_time(buf, buf_size,
|
format_time(buf, buf_size, elapsed);
|
||||||
id3->elapsed + state->ff_rewind_count);
|
|
||||||
return buf;
|
return buf;
|
||||||
|
|
||||||
case WPS_TOKEN_TRACK_TIME_REMAINING:
|
case WPS_TOKEN_TRACK_TIME_REMAINING:
|
||||||
format_time(buf, buf_size,
|
format_time(buf, buf_size, length - elapsed);
|
||||||
id3->length - id3->elapsed -
|
|
||||||
state->ff_rewind_count);
|
|
||||||
return buf;
|
return buf;
|
||||||
|
|
||||||
case WPS_TOKEN_TRACK_LENGTH:
|
case WPS_TOKEN_TRACK_LENGTH:
|
||||||
format_time(buf, buf_size, id3->length);
|
format_time(buf, buf_size, length);
|
||||||
return buf;
|
return buf;
|
||||||
|
|
||||||
case WPS_TOKEN_TRACK_ELAPSED_PERCENT:
|
case WPS_TOKEN_TRACK_ELAPSED_PERCENT:
|
||||||
if (id3->length <= 0)
|
if (length <= 0)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
if (intval)
|
if (intval)
|
||||||
{
|
{
|
||||||
*intval = limit * (id3->elapsed + state->ff_rewind_count)
|
*intval = limit * elapsed / length + 1;
|
||||||
/ id3->length + 1;
|
|
||||||
}
|
}
|
||||||
snprintf(buf, buf_size, "%d",
|
snprintf(buf, buf_size, "%d", 100 * elapsed / length);
|
||||||
100*(id3->elapsed + state->ff_rewind_count) / id3->length);
|
|
||||||
return buf;
|
return buf;
|
||||||
|
|
||||||
|
|
||||||
|
@ -443,7 +440,8 @@ const char *get_token_value(struct gui_wps *gwps,
|
||||||
snprintf(buf, buf_size, "%d", global_settings.volume);
|
snprintf(buf, buf_size, "%d", global_settings.volume);
|
||||||
if (intval)
|
if (intval)
|
||||||
{
|
{
|
||||||
if (global_settings.volume == sound_min(SOUND_VOLUME))
|
int minvol = sound_min(SOUND_VOLUME);
|
||||||
|
if (global_settings.volume == minvol)
|
||||||
{
|
{
|
||||||
*intval = 1;
|
*intval = 1;
|
||||||
}
|
}
|
||||||
|
@ -457,9 +455,8 @@ const char *get_token_value(struct gui_wps *gwps,
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
*intval = (limit - 3) * (global_settings.volume
|
*intval = (limit-3) * (global_settings.volume - minvol - 1)
|
||||||
- sound_min(SOUND_VOLUME) - 1)
|
/ (-1 - minvol) + 2;
|
||||||
/ (-1 - sound_min(SOUND_VOLUME)) + 2;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return buf;
|
return buf;
|
||||||
|
@ -1201,7 +1198,6 @@ const char *get_token_value(struct gui_wps *gwps,
|
||||||
}
|
}
|
||||||
if (intval)
|
if (intval)
|
||||||
{
|
{
|
||||||
|
|
||||||
*intval = curr_screen;
|
*intval = curr_screen;
|
||||||
}
|
}
|
||||||
snprintf(buf, buf_size, "%d", curr_screen);
|
snprintf(buf, buf_size, "%d", curr_screen);
|
||||||
|
|
|
@ -244,4 +244,3 @@ struct skin_token_list {
|
||||||
char* get_dir(char* buf, int buf_size, const char* path, int level);
|
char* get_dir(char* buf, int buf_size, const char* path, int level);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
@ -649,5 +649,4 @@ void debug_skin_usage(void)
|
||||||
(unsigned long)(skin_buffer_usage() + skin_buffer_freespace()));
|
(unsigned long)(skin_buffer_usage() + skin_buffer_freespace()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#endif /* DEBUG || SIMULATOR */
|
#endif /* DEBUG || SIMULATOR */
|
||||||
|
|
|
@ -247,7 +247,6 @@ struct playlistviewer {
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#ifdef HAVE_ALBUMART
|
#ifdef HAVE_ALBUMART
|
||||||
struct skin_albumart {
|
struct skin_albumart {
|
||||||
/* Album art support */
|
/* Album art support */
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue