mirror of
https://github.com/Rockbox/rockbox.git
synced 2025-11-09 21:22:39 -05:00
pictreflow: tweak alpha value for the case number of slides < 3 so that fading looks a bit more smooth.
do not save settings when it is not so needed. make sliding animation better when you press right then left quickly. git-svn-id: svn://svn.rockbox.org/rockbox/trunk@28529 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
parent
24b0b38315
commit
8371d78519
1 changed files with 45 additions and 31 deletions
|
|
@ -1174,11 +1174,12 @@ bool save_pfraw(char* filename, struct bitmap *bm)
|
||||||
int fh = rb->creat( filename , 0666);
|
int fh = rb->creat( filename , 0666);
|
||||||
if( fh < 0 ) return false;
|
if( fh < 0 ) return false;
|
||||||
rb->write( fh, &bmph, sizeof( struct pfraw_header ) );
|
rb->write( fh, &bmph, sizeof( struct pfraw_header ) );
|
||||||
|
pix_t *data = (pix_t*)( bm->data );
|
||||||
int y;
|
int y;
|
||||||
for( y = 0; y < bm->height; y++ )
|
for( y = 0; y < bm->height; y++ )
|
||||||
{
|
{
|
||||||
pix_t *d = (pix_t*)( bm->data ) + (y*bm->width);
|
rb->write( fh, data , sizeof( pix_t ) * bm->width );
|
||||||
rb->write( fh, d, sizeof( pix_t ) * bm->width );
|
data += bm->width;
|
||||||
}
|
}
|
||||||
rb->close( fh );
|
rb->close( fh );
|
||||||
return true;
|
return true;
|
||||||
|
|
@ -1199,8 +1200,6 @@ bool create_albumart_cache(void)
|
||||||
char albumart_file[MAX_PATH];
|
char albumart_file[MAX_PATH];
|
||||||
unsigned int format = FORMAT_NATIVE;
|
unsigned int format = FORMAT_NATIVE;
|
||||||
bool update = (cache_version == CACHE_UPDATE);
|
bool update = (cache_version == CACHE_UPDATE);
|
||||||
cache_version = CACHE_REBUILD;
|
|
||||||
configfile_save(CONFIG_FILE, config, CONFIG_NUM_ITEMS, CONFIG_VERSION);
|
|
||||||
if (resize)
|
if (resize)
|
||||||
format |= FORMAT_RESIZE|FORMAT_KEEP_ASPECT;
|
format |= FORMAT_RESIZE|FORMAT_KEEP_ASPECT;
|
||||||
for (i=0; i < album_count; i++)
|
for (i=0; i < album_count; i++)
|
||||||
|
|
@ -1211,8 +1210,10 @@ bool create_albumart_cache(void)
|
||||||
mfnv(get_album_name(i)));
|
mfnv(get_album_name(i)));
|
||||||
/* delete existing cache, so it's a true rebuild */
|
/* delete existing cache, so it's a true rebuild */
|
||||||
if(rb->file_exists(pfraw_file)) {
|
if(rb->file_exists(pfraw_file)) {
|
||||||
if(update)
|
if(update) {
|
||||||
|
slides++;
|
||||||
continue;
|
continue;
|
||||||
|
}
|
||||||
rb->remove(pfraw_file);
|
rb->remove(pfraw_file);
|
||||||
}
|
}
|
||||||
if (!get_albumart_for_index_from_db(i, albumart_file, MAX_PATH))
|
if (!get_albumart_for_index_from_db(i, albumart_file, MAX_PATH))
|
||||||
|
|
@ -1234,10 +1235,12 @@ bool create_albumart_cache(void)
|
||||||
if (!save_pfraw(pfraw_file, &input_bmp))
|
if (!save_pfraw(pfraw_file, &input_bmp))
|
||||||
{
|
{
|
||||||
rb->splash(HZ, "Could not write bmp");
|
rb->splash(HZ, "Could not write bmp");
|
||||||
|
continue;
|
||||||
}
|
}
|
||||||
slides++;
|
slides++;
|
||||||
if ( rb->button_get(false) == PF_MENU ) return false;
|
if ( rb->button_get(false) == PF_MENU ) return false;
|
||||||
}
|
}
|
||||||
|
draw_progressbar(i);
|
||||||
if ( slides == 0 ) {
|
if ( slides == 0 ) {
|
||||||
/* Warn the user that we couldn't find any albumart */
|
/* Warn the user that we couldn't find any albumart */
|
||||||
rb->splash(2*HZ, "No album art found");
|
rb->splash(2*HZ, "No album art found");
|
||||||
|
|
@ -1516,8 +1519,8 @@ int read_pfraw(char* filename, int prio)
|
||||||
else
|
else
|
||||||
rb->read(fh, &bmph, sizeof(struct pfraw_header));
|
rb->read(fh, &bmph, sizeof(struct pfraw_header));
|
||||||
|
|
||||||
int size = sizeof(struct bitmap) + sizeof( pix_t ) *
|
int size = sizeof(struct dim) +
|
||||||
bmph.width * bmph.height;
|
sizeof( pix_t ) * bmph.width * bmph.height;
|
||||||
|
|
||||||
int hid;
|
int hid;
|
||||||
while (!(hid = buflib_alloc(&buf_ctx, size)) && free_slide_prio(prio));
|
while (!(hid = buflib_alloc(&buf_ctx, size)) && free_slide_prio(prio));
|
||||||
|
|
@ -1928,6 +1931,7 @@ void render_slide(struct slide_data *slide, const int alpha)
|
||||||
}
|
}
|
||||||
rb->yield(); /* allow audio to play when fast scrolling */
|
rb->yield(); /* allow audio to play when fast scrolling */
|
||||||
bmp = surface(slide->slide_index); /* resync surface due to yield */
|
bmp = surface(slide->slide_index); /* resync surface due to yield */
|
||||||
|
src = (pix_t*)(sizeof(struct dim) + (char *)bmp);
|
||||||
ptr = &src[column * bmp->height];
|
ptr = &src[column * bmp->height];
|
||||||
p = (bmp->height-DISPLAY_OFFS) * PFREAL_ONE;
|
p = (bmp->height-DISPLAY_OFFS) * PFREAL_ONE;
|
||||||
plim = MIN(sh * PFREAL_ONE, p + (LCD_HEIGHT/2) * dy);
|
plim = MIN(sh * PFREAL_ONE, p + (LCD_HEIGHT/2) * dy);
|
||||||
|
|
@ -2006,7 +2010,7 @@ void show_previous_slide(void)
|
||||||
}
|
}
|
||||||
} else if ( step > 0 ) {
|
} else if ( step > 0 ) {
|
||||||
target = center_index;
|
target = center_index;
|
||||||
start_animation();
|
step = (target <= center_slide.slide_index) ? -1 : 1;
|
||||||
} else {
|
} else {
|
||||||
target = fmax(0, center_index - 2);
|
target = fmax(0, center_index - 2);
|
||||||
}
|
}
|
||||||
|
|
@ -2025,7 +2029,7 @@ void show_next_slide(void)
|
||||||
}
|
}
|
||||||
} else if ( step < 0 ) {
|
} else if ( step < 0 ) {
|
||||||
target = center_index;
|
target = center_index;
|
||||||
start_animation();
|
step = (target < center_slide.slide_index) ? -1 : 1;
|
||||||
} else {
|
} else {
|
||||||
target = fmin(center_index + 2, number_of_slides - 1);
|
target = fmin(center_index + 2, number_of_slides - 1);
|
||||||
}
|
}
|
||||||
|
|
@ -2044,45 +2048,46 @@ void render_all_slides(void)
|
||||||
int nleft = num_slides;
|
int nleft = num_slides;
|
||||||
int nright = num_slides;
|
int nright = num_slides;
|
||||||
|
|
||||||
|
int alpha;
|
||||||
int index;
|
int index;
|
||||||
if (step == 0) {
|
if (step == 0) {
|
||||||
/* no animation, boring plain rendering */
|
/* no animation, boring plain rendering */
|
||||||
for (index = nleft - 2; index >= 0; index--) {
|
for (index = nleft - 2; index >= 0; index--) {
|
||||||
int alpha = (index < nleft - 2) ? 256 : 128;
|
alpha = (index < nleft - 2) ? 256 : 128;
|
||||||
alpha -= extra_fade;
|
alpha -= extra_fade;
|
||||||
if (alpha > 0 )
|
if (alpha > 0 )
|
||||||
render_slide(&left_slides[index], alpha);
|
render_slide(&left_slides[index], alpha);
|
||||||
}
|
}
|
||||||
for (index = nright - 2; index >= 0; index--) {
|
for (index = nright - 2; index >= 0; index--) {
|
||||||
int alpha = (index < nright - 2) ? 256 : 128;
|
alpha = (index < nright - 2) ? 256 : 128;
|
||||||
alpha -= extra_fade;
|
alpha -= extra_fade;
|
||||||
if (alpha > 0 )
|
if (alpha > 0 )
|
||||||
render_slide(&right_slides[index], alpha);
|
render_slide(&right_slides[index], alpha);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
/* the first and last slide must fade in/fade out */
|
/* the first and last slide must fade in/fade out */
|
||||||
|
|
||||||
|
/* if step<0 and nleft==1, left_slides[0] is fading in */
|
||||||
|
alpha = ((step > 0) ? 0 : ((nleft == 1) ? 256 : 128)) - fade / 2;
|
||||||
for (index = nleft - 1; index >= 0; index--) {
|
for (index = nleft - 1; index >= 0; index--) {
|
||||||
int alpha = 256;
|
if (alpha > 0)
|
||||||
if (index == nleft - 1)
|
render_slide(&left_slides[index], alpha);
|
||||||
alpha = (step > 0) ? 0 : 128 - fade / 2;
|
alpha += 128;
|
||||||
if (index == nleft - 2)
|
if (alpha > 256) alpha = 256;
|
||||||
alpha = (step > 0) ? 128 - fade / 2 : 256 - fade / 2;
|
|
||||||
if (index == nleft - 3)
|
|
||||||
alpha = (step > 0) ? 256 - fade / 2 : 256;
|
|
||||||
render_slide(&left_slides[index], alpha);
|
|
||||||
}
|
}
|
||||||
|
/* if step>0 and nright==1, right_slides[0] is fading in */
|
||||||
|
alpha = ((step > 0) ? ((nright == 1) ? 128 : 0) : -128) + fade / 2;
|
||||||
for (index = nright - 1; index >= 0; index--) {
|
for (index = nright - 1; index >= 0; index--) {
|
||||||
int alpha = (index < nright - 2) ? 256 : 128;
|
if (alpha > 0)
|
||||||
if (index == nright - 1)
|
render_slide(&right_slides[index], alpha);
|
||||||
alpha = (step > 0) ? fade / 2 : 0;
|
alpha += 128;
|
||||||
if (index == nright - 2)
|
if (alpha > 256) alpha = 256;
|
||||||
alpha = (step > 0) ? 128 + fade / 2 : fade / 2;
|
|
||||||
if (index == nright - 3)
|
|
||||||
alpha = (step > 0) ? 256 : 128 + fade / 2;
|
|
||||||
render_slide(&right_slides[index], alpha);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
render_slide(¢er_slide, 256);
|
alpha = 256;
|
||||||
|
if (step != 0 && num_slides <= 2) /* fading out center slide */
|
||||||
|
alpha = (step > 0) ? 256 - fade / 2 : 128 + fade / 2;
|
||||||
|
render_slide(¢er_slide, alpha);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -2142,6 +2147,7 @@ void update_scroll_animation(void)
|
||||||
if (center_index == target) {
|
if (center_index == target) {
|
||||||
reset_slides();
|
reset_slides();
|
||||||
pf_state = pf_idle;
|
pf_state = pf_idle;
|
||||||
|
slide_frame = center_index << 16;
|
||||||
step = 0;
|
step = 0;
|
||||||
fade = 256;
|
fade = 256;
|
||||||
return;
|
return;
|
||||||
|
|
@ -2285,6 +2291,8 @@ int settings_menu(void)
|
||||||
case 7:
|
case 7:
|
||||||
cache_version = CACHE_REBUILD;
|
cache_version = CACHE_REBUILD;
|
||||||
rb->remove(EMPTY_SLIDE);
|
rb->remove(EMPTY_SLIDE);
|
||||||
|
configfile_save(CONFIG_FILE, config,
|
||||||
|
CONFIG_NUM_ITEMS, CONFIG_VERSION);
|
||||||
rb->splash(HZ, "Cache will be rebuilt on next restart");
|
rb->splash(HZ, "Cache will be rebuilt on next restart");
|
||||||
break;
|
break;
|
||||||
case 8:
|
case 8:
|
||||||
|
|
@ -2298,7 +2306,6 @@ int settings_menu(void)
|
||||||
return PLUGIN_USB_CONNECTED;
|
return PLUGIN_USB_CONNECTED;
|
||||||
}
|
}
|
||||||
} while ( selection >= 0 );
|
} while ( selection >= 0 );
|
||||||
configfile_save(CONFIG_FILE, config, CONFIG_NUM_ITEMS, CONFIG_VERSION);
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -2678,16 +2685,23 @@ int main(void)
|
||||||
ALIGN_BUFFER(buf, buf_size, 4);
|
ALIGN_BUFFER(buf, buf_size, 4);
|
||||||
number_of_slides = album_count;
|
number_of_slides = album_count;
|
||||||
if ((cache_version != CACHE_VERSION) && !create_albumart_cache()) {
|
if ((cache_version != CACHE_VERSION) && !create_albumart_cache()) {
|
||||||
|
cache_version = CACHE_REBUILD;
|
||||||
|
configfile_save(CONFIG_FILE, config, CONFIG_NUM_ITEMS, CONFIG_VERSION);
|
||||||
error_wait("Could not create album art cache");
|
error_wait("Could not create album art cache");
|
||||||
return PLUGIN_ERROR;
|
return PLUGIN_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!create_empty_slide(cache_version != CACHE_VERSION)) {
|
if (!create_empty_slide(cache_version != CACHE_VERSION)) {
|
||||||
|
cache_version = CACHE_REBUILD;
|
||||||
|
configfile_save(CONFIG_FILE, config, CONFIG_NUM_ITEMS, CONFIG_VERSION);
|
||||||
error_wait("Could not load the empty slide");
|
error_wait("Could not load the empty slide");
|
||||||
return PLUGIN_ERROR;
|
return PLUGIN_ERROR;
|
||||||
}
|
}
|
||||||
cache_version = CACHE_VERSION;
|
if (cache_version != CACHE_VERSION)
|
||||||
configfile_save(CONFIG_FILE, config, CONFIG_NUM_ITEMS, CONFIG_VERSION);
|
{
|
||||||
|
cache_version = CACHE_VERSION;
|
||||||
|
configfile_save(CONFIG_FILE, config, CONFIG_NUM_ITEMS, CONFIG_VERSION);
|
||||||
|
}
|
||||||
|
|
||||||
buflib_init(&buf_ctx, (void *)buf, buf_size);
|
buflib_init(&buf_ctx, (void *)buf, buf_size);
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue