plugins/lib/feature_wrappers.h to provide easy access to some feature that may be in either API or pluginlib depending on target

pictureflow modified to use feature wrappers, and built on all targets that have tagcache and are swcodec


git-svn-id: svn://svn.rockbox.org/rockbox/trunk@19837 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
Andrew Mahone 2009-01-24 09:29:22 +00:00
parent 3f7d137725
commit 6fc558b2db
5 changed files with 80 additions and 10 deletions

View file

@ -52,6 +52,10 @@ text_editor.c
wavview.c
robotfindskitten.c
#if defined(HAVE_TAGCACHE) && (CONFIG_CODEC == SWCODEC)
pictureflow.c
#endif
#ifdef HAVE_LCD_COLOR
ppmviewer.c
#endif
@ -129,9 +133,6 @@ splitedit.c
#if LCD_DEPTH > 1 /* non-mono bitmap targets */
matrix.c
#if defined(HAVE_ALBUMART) && defined(HAVE_TAGCACHE)
pictureflow.c
#endif
#endif
/* Platform-specific plugins */

View file

@ -669,7 +669,7 @@ matrix_normal.bmp
#endif
/* pictureflow */
#if defined(HAVE_ALBUMART) && defined(HAVE_TAGCACHE)
#if defined(HAVE_LCD_BITMAP) && defined(HAVE_TAGCACHE)
#if (LCD_WIDTH < 200)
pictureflow_logo.100x18x16.bmp
#else

View file

@ -0,0 +1,49 @@
/***************************************************************************
* __________ __ ___.
* Open \______ \ ____ ____ | | _\_ |__ _______ ___
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
* \/ \/ \/ \/ \/
* $Id$
*
* Copyright (C) 2009 by Andrew Mahone
*
* This defines wrappers for some features which are used differently depending
* on how the target was built, primarily because of core features being accesed
* via pluginlib on targets where they are missing from core.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
* KIND, either express or implied.
*
****************************************************************************/
#ifndef _LIB_FEATURE_WRAPPERS_H_
#define _LIB_FEATURE_WRAPPERS_H_
/* search_albumart_files is only available in core with HAVE_ALBUMART defined,
* but can easily be implement in pluginlib as long as the database is
* available.
*/
#ifdef HAVE_ALBUMART
#define search_albumart_files rb->search_albumart_files
#endif
/* This should only be used when loading scaled bitmaps, or using custom output
* plugins. The pluginlib loader does not support loading bitmaps unscaled in
* native format, so rb->read_bmp_file should always be used directly to load
* such images.
*/
#if LCD_DEPTH > 1
#define scaled_read_bmp_file rb->read_bmp_file
#else
#define scaled_read_bmp_file read_bmp_file
#endif
#endif

View file

@ -24,12 +24,14 @@
****************************************************************************/
#include "plugin.h"
#include <albumart.h>
#include "lib/pluginlib_actions.h"
#include "lib/helper.h"
#include "lib/configfile.h"
#include "lib/picture.h"
#include "pluginbitmaps/pictureflow_logo.h"
#include "lib/grey.h"
#include "lib/feature_wrappers.h"
PLUGIN_HEADER
@ -41,15 +43,19 @@ const struct button_mapping *plugin_contexts[]
#define NB_ACTION_CONTEXTS sizeof(plugin_contexts)/sizeof(plugin_contexts[0])
#if LCD_DEPTH < 8
#if LCD_DEPTH > 1
#define N_BRIGHT(y) LCD_BRIGHTNESS(y)
#else
#define N_BRIGHT(y) ((y > 127) ? 0 : 1)
#endif
#define USEGSLIB
GREY_INFO_STRUCT
#define LCD_BUF _grey_info.buffer
#define MYLCD(fn) grey_ ## fn
#define G_PIX(r,g,b) \
(77 * (unsigned)(r) + 150 * (unsigned)(g) + 29 * (unsigned)(b)) / 256
#define N_PIX(r,g,b) LCD_BRIGHTNESS(G_PIX(r,g,b))
#define N_PIX(r,g,b) N_BRIGHT(G_PIX(r,g,b))
#define G_BRIGHT(y) (y)
#define N_BRIGHT(y) LCD_BRIGHTNESS(y)
#define BUFFER_WIDTH _grey_info.width
#define BUFFER_HEIGHT _grey_info.height
typedef unsigned char pix_t;
@ -602,7 +608,7 @@ bool get_albumart_for_index_from_db(const int slide_index, char *buf,
fd = rb->open(tcs.result, O_RDONLY);
rb->get_metadata(&id3, fd, tcs.result);
rb->close(fd);
if ( rb->search_albumart_files(&id3, "", buf, buflen) )
if ( search_albumart_files(&id3, "", buf, buflen) )
result = true;
else
result = false;
@ -622,8 +628,10 @@ void draw_splashscreen(void)
{
struct screen* display = rb->screens[0];
#if LCD_DEPTH > 1
rb->lcd_set_background(N_BRIGHT(0));
rb->lcd_set_foreground(N_BRIGHT(255));
#endif
rb->lcd_clear_display();
const struct picture* logo = &(logos[display->screen_type]);
@ -650,12 +658,18 @@ void draw_progressbar(int step)
rb->lcd_putsxy((LCD_WIDTH - txt_w)/2, y, "Preparing album artwork");
y += (txt_h + 5);
#if LCD_DEPTH > 1
rb->lcd_set_foreground(N_BRIGHT(100));
#endif
rb->lcd_drawrect(x, y, w+2, bar_height);
#if LCD_DEPTH > 1
rb->lcd_set_foreground(N_PIX(165, 231, 82));
#endif
rb->lcd_fillrect(x+1, y+1, step * w / album_count, bar_height-2);
#if LCD_DEPTH > 1
rb->lcd_set_foreground(N_BRIGHT(255));
#endif
rb->lcd_update();
rb->yield();
}
@ -691,7 +705,7 @@ bool create_albumart_cache(void)
input_bmp.data = plugin_buf;
input_bmp.width = DISPLAY_WIDTH;
input_bmp.height = DISPLAY_HEIGHT;
ret = rb->read_bmp_file(albumart_file, &input_bmp,
ret = scaled_read_bmp_file(albumart_file, &input_bmp,
plugin_buf_size, format, &format_transposed);
if (ret <= 0) {
rb->splash(HZ, "Could not read bmp");
@ -948,7 +962,9 @@ int read_pfraw(char* filename)
bm->width = bmph.width;
bm->height = bmph.height;
#if LCD_DEPTH > 1
bm->format = FORMAT_NATIVE;
#endif
bm->data = ((unsigned char *)bm + sizeof(struct bitmap));
int y;
@ -1527,9 +1543,11 @@ int create_empty_slide(bool force)
int ret;
input_bmp.width = DISPLAY_WIDTH;
input_bmp.height = DISPLAY_HEIGHT;
#if LCD_DEPTH > 1
input_bmp.format = FORMAT_NATIVE;
#endif
input_bmp.data = (char*)plugin_buf;
ret = rb->read_bmp_file(EMPTY_SLIDE_BMP, &input_bmp,
ret = scaled_read_bmp_file(EMPTY_SLIDE_BMP, &input_bmp,
plugin_buf_size,
FORMAT_NATIVE|FORMAT_RESIZE|FORMAT_KEEP_ASPECT,
&format_transposed);
@ -1641,7 +1659,9 @@ int main_menu(void)
int selection = 0;
int result;
#if LCD_DEPTH > 1
rb->lcd_set_foreground(N_BRIGHT(255));
#endif
MENUITEM_STRINGLIST(main_menu,"PictureFlow Main Menu",NULL,
"Settings", "Return", "Quit");

View file

@ -22,7 +22,7 @@
#ifndef _ALBUMART_H_
#define _ALBUMART_H_
#ifdef HAVE_ALBUMART
#if defined(HAVE_ALBUMART) || defined(PLUGIN)
#include <stdbool.h>
#include "metadata.h"