Index: libwps/src/api.h =================================================================== --- libwps/src/api.h (revision 18656) +++ libwps/src/api.h (working copy) @@ -51,43 +51,22 @@ { bool (*load_remote_wps_backdrop)(char* file_name); bool (*load_wps_backdrop)(char* file_name); + + int (*getwidth)(); + int (*getheight)(); - unsigned (*get_foreground)(void); - unsigned (*get_background)(void); - int (*getwidth)(void); - int (*getheight)(void); - - void (*puts_scroll)(int x, int y, const unsigned char *string); - void (*putsxy)(int x, int y, const unsigned char *str); - int (*getfont)(); - int (*getstringsize)(const unsigned char *str, int *w, int *h); void (*stop_scroll)(); - void (*transparent_bitmap_part)(const void *src, int src_x, int src_y, - int stride, int x, int y, int width, int height); - void (*bitmap_part)(const void *src, int src_x, int src_y, - int stride, int x, int y, int width, int height); - void (*hline)(int x1, int x2, int y); - void (*vline)(int x, int y1, int y2); - void (*drawpixel)(int x, int y); - void (*set_drawmode)(int mode); - void (*fillrect)(int x, int y, int width, int height); - - void (*update)(); - void (*set_viewport)(struct viewport* vp); - void (*clear_display)(void); - void (*clear_viewport)(int x,int y,int w,int h, int color); void* (*plugin_get_buffer)(size_t *buffer_size); int (*read_bmp_file)(const char* filename,int *width, int *height); - void (*set_wpsstate)(struct wpsstate state); - void (*set_trackstate)(struct trackstate state); - void (*set_next_trackstate)(struct trackstate state); - void (*set_audio_status)(int status); + void (*lcd_update)(const unsigned char* adr, int x, int y, int width, int height); + + pfdebugf debugf; - int verbose; + int verbose; /************************** @@ -95,8 +74,12 @@ **************************/ const char* (*get_model_name)(); void (*get_current_vp)(struct viewport_api *avp); - - + void (*set_wpsstate)(struct wpsstate state); + void (*set_trackstate)(struct trackstate state); + void (*set_next_trackstate)(struct trackstate state); + void (*set_audio_status)(int status); + + bool (*load_font)(const char *path); }; extern struct proxy_api *xapi; Index: libwps/src/proxy.c =================================================================== --- libwps/src/proxy.c (revision 18656) +++ libwps/src/proxy.c (working copy) @@ -43,7 +43,8 @@ static char pluginbuf[PLUGIN_BUFFER_SIZE]; -const char* get_model_name(){ +const char* get_model_name() +{ #ifdef MODEL_NAME return MODEL_NAME; #else @@ -95,7 +96,8 @@ wps_verbose_level = verbose; fd = open(filename, O_RDONLY); - if (fd < 0) { + if (fd < 0) + { DEBUGF1("Failed to open %s\n",filename); return 2; } @@ -103,7 +105,8 @@ res = wps_data_load(&wps, &screens[0], filename, true); - if (!res) { + if (!res) + { DEBUGF1("WPS parsing failure\n"); return 3; } @@ -112,21 +115,25 @@ return 0; } -int wps_init(const char* filename,struct proxy_api *api, bool isfile){ +int wps_init(const char* filename, struct proxy_api *api, bool isfile) +{ int res; if (!api) return 4; dummies_init(); - test_api(api); set_api(api); + font_load("/home/toor/rockbox/utils/wpseditor/gui/bin/font.fnt"); wps_data_init(&wpsdata); wps_verbose_level = api->verbose; res = wps_data_load(&wpsdata, &screens[0], filename, isfile); if (!res) { DEBUGF1("ERR: WPS parsing failure\n"); - } else + } + else + { DEBUGF1("WPS parsed OK\n"); + } DEBUGF1("\n-------------------------------------------------\n"); wps_state.paused = true; gwps.data = &wpsdata; @@ -138,13 +145,16 @@ return (res?res:3); } -int wps_display(){ +int wps_display() +{ DEBUGF3("wps_display(): begin\n"); int res = gui_wps_display(); DEBUGF3("\nWPS %sdisplayed\n", (res ? "" : "not ")); return res; } -int wps_refresh(){ + +int wps_refresh() +{ DEBUGF3("----------------------------------\n"); int res = gui_wps_refresh(&gwps, 0, WPS_REFRESH_ALL); DEBUGF3("\nWPS %srefreshed\n", (res ? "" : "not ")); Index: libwps/src/include/backlight-target.h =================================================================== --- libwps/src/include/backlight-target.h (revision 0) +++ libwps/src/include/backlight-target.h (revision 0) @@ -0,0 +1,2 @@ +#define SIMULATOR +void sim_backlight(int x) {} Property changes on: libwps/src/include/backlight-target.h ___________________________________________________________________ Name: eol-style + native Index: libwps/src/include/system-target.h =================================================================== --- libwps/src/include/system-target.h (revision 18656) +++ libwps/src/include/system-target.h (working copy) @@ -1 +1,2 @@ - +#define swap16(x) ((typeof(x))(unsigned short)(((unsigned short)(x) >> 8) | \ + ((unsigned short)(x) << 8))) Index: libwps/src/lcd.c =================================================================== --- libwps/src/lcd.c (revision 18656) +++ libwps/src/lcd.c (working copy) @@ -177,3 +177,36 @@ void lcd_scroll_stop(struct viewport* vp){ DEBUGF3("lcd_scroll_stop(struct viewport* vp=%x)\n",vp); } + +static void lcd_putsxyofs(int x, int y, int ofs, const unsigned char *str) +{ + unsigned short ch; + struct font* pf = font_get(current_vp->font); + + while ((ch = *str++) != 0 && x < current_vp->width) + { + int width; + const unsigned char *bits; + + /* get proportional width and glyph bits */ + width = font_get_width(pf,ch); + + if (ofs > width) + { + ofs -= width; + continue; + } + + bits = font_get_bits(pf, ch); + + xapi->mono_bitmap_part(bits, ofs, 0, width, x, y, width - ofs, pf->height); + + x += width - ofs; + ofs = 0; + } +} + +void lcd_putsxy(int x, int y, const unsigned char *str) +{ + lcd_putsxyofs(x, y, 0, str); +} Index: libwps/src/dummies.c =================================================================== --- libwps/src/dummies.c (revision 18656) +++ libwps/src/dummies.c (working copy) @@ -321,19 +321,23 @@ int rtc_read_datetime(unsigned char* buf){return 0;} int rtc_write_datetime(unsigned char* buf){return 0;} -void backlight_on(void){} -void backlight_off(void){} - void remote_backlight_on(void){} void remote_backlight_off(void){} void debugf(const char *fmt, ...) {} -void panicf( const char *fmt, ...) +void panicf(const char *fmt, ...) { } -off_t filesize(int fd){return 0;} +off_t filesize(int fd) +{ + off_t fsize, oldpos; + oldpos = lseek(fd, 0, SEEK_CUR); + fsize = lseek(fd, 0, SEEK_END); + lseek(fd, oldpos, SEEK_SET); + return fsize; +} int playlist_amount(void) { @@ -352,9 +356,6 @@ return 0; } -void lcd_mono_bitmap(const unsigned char *src, int x, int y, int width, - int height){} - void pcm_calculate_rec_peaks(int *left, int *right) { } @@ -388,3 +389,18 @@ { } void pcmbuf_beep(unsigned int frequency, size_t duration, int amplitude){} + +unsigned short *bidi_l2v(const unsigned char *str, int orientation) +{ + /* HACK! */ + return (unsigned short*)str; +} + +void lcd_init_device(void) +{ +} + +struct viewport* get_current_vp(void) +{ + return NULL; +} Index: libwps/src/proxy.h =================================================================== --- libwps/src/proxy.h (revision 18656) +++ libwps/src/proxy.h (working copy) @@ -35,7 +35,7 @@ #define DEBUGF4(...) EXPORT int checkwps(const char *filename, int verbose); -EXPORT int wps_init(const char* filename,struct proxy_api *api,bool isfile); +EXPORT int wps_init(const char* filename, struct proxy_api *api, bool isfile); EXPORT int wps_display(); EXPORT int wps_refresh(); EXPORT const char* get_model_name(); @@ -44,5 +44,4 @@ extern bool debug_wps; extern int wps_verbose_level; - #endif Index: libwps/src/api.c =================================================================== --- libwps/src/api.c (revision 18656) +++ libwps/src/api.c (working copy) @@ -35,24 +35,101 @@ /************************************************************* *************************************************************/ -#ifdef HAVE_LCD_BITMAP -void screen_clear_area(struct screen * display, int xstart, int ystart, - int width, int height) { - display->set_drawmode(DRMODE_SOLID|DRMODE_INVERSEVID); - display->fillrect(xstart, ystart, width, height); - display->set_drawmode(DRMODE_SOLID); + +#define LBLOCKSIZE (sizeof(long)/2) +#define UNALIGNED(X) ((long)X & (sizeof(long) - 1)) +#define TOO_SMALL(LEN) ((LEN) < LBLOCKSIZE) + +void memset16(void *dst, int val, size_t len) +{ +#ifdef __OPTIMIZE_SIZE__ + unsigned short *p = (unsigned short *)dst; + + while (len--) + *p++ = val; +#else + unsigned short *p = (unsigned short *)dst; + unsigned int i; + unsigned long buffer; + unsigned long *aligned_addr; + + if (!TOO_SMALL(len) && !UNALIGNED(dst)) + { + aligned_addr = (unsigned long *)dst; + + val &= 0xffff; + if (LBLOCKSIZE == 2) + { + buffer = (val << 16) | val; + } + else + { + buffer = 0; + for (i = 0; i < LBLOCKSIZE; i++) + buffer = (buffer << 16) | val; + } + + while (len >= LBLOCKSIZE*4) + { + *aligned_addr++ = buffer; + *aligned_addr++ = buffer; + *aligned_addr++ = buffer; + *aligned_addr++ = buffer; + len -= 4*LBLOCKSIZE; + } + + while (len >= LBLOCKSIZE) + { + *aligned_addr++ = buffer; + len -= LBLOCKSIZE; + } + + p = (unsigned short *)aligned_addr; + } + + while (len--) + *p++ = val; +#endif /* not PREFER_SIZE_OVER_SPEED */ } -#endif -bool load_wps_backdrop(char* filename) { +bool load_font(const char* filename) +{ + if (filename != NULL) + { + if(font_load(filename) == NULL) + return false; + else + return true; + } + else + { + font_reset(); + return true; + } +} + +void lcd_update(void) +{ + lcd_update_rect(0, 0, LCD_WIDTH, LCD_HEIGHT); +} + +void lcd_update_rect(int x, int y, int width, int height) +{ + xapi->lcd_update((unsigned char*)&lcd_framebuffer[y][x], x, y, width, height); +} + +bool load_wps_backdrop(char* filename) +{ return xapi->load_wps_backdrop(filename); } -bool load_remote_wps_backdrop(char* filename) { +bool load_remote_wps_backdrop(char* filename) +{ return xapi->load_remote_wps_backdrop(filename); } -int read_bmp_file(const char* filename,struct bitmap *bm, int maxsize,int format) { +int read_bmp_file(const char* filename,struct bitmap *bm, int maxsize,int format) +{ if (!xapi->read_bmp_file) { DEBUGF1("can't read bmp file! NULL api!\n"); return -1; @@ -66,45 +143,20 @@ return 1; } -bool load_wps_backdrop2(char* filename) { +bool load_wps_backdrop2(char* filename) +{ DEBUGF1("load_wps_backdrop(char* filename='%s')",filename); return true; } -bool load_remote_wps_backdrop2(char* filename) { +bool load_remote_wps_backdrop2(char* filename) +{ DEBUGF1("load_remote_wps_backdrop2(char* filename='%s')",filename); return true; } -void stop_scroll() { - DEBUGF3("stop_scroll\n"); - return; -} - -void puts_scroll(int x, int y, const unsigned char *string) { - DEBUGF2("puts_scroll(int x=%d, int y=%d, const unsigned char *string='%s'\n",x,y,string); -} - -void putsxy(int x, int y, const unsigned char *str) { - DEBUGF2("putsxy(int =%d, int y=%d, const unsigned char *str='%s')\n",x,y,str); -} - -void lcd_update() { - DEBUGF3("update\n"); -} - -void clear_viewport(int x, int y, int w, int h, int color) { - DEBUGF3("clear_viewport(int x=%d, int y=%d, int w=%d, int h=%d, int color=%d)\n", x, y, w, h, color); -}; - -int getstringsize(const unsigned char *str, int *w, int *h) { - //DEBUGF1("getstringsize(const unsigned char *str=\"%s\", int *w=%d, int *h=%d \n",str,*w,*h); - *w=strlen((char*)str)*sysfont.maxwidth; - *h=sysfont.height; - return 1; -} - -void set_wpsstate(struct wpsstate state) { +void set_wpsstate(struct wpsstate state) +{ sysfont.height = state.fontheight; sysfont.maxwidth = state.fontwidth; global_settings.volume = state.volume; @@ -112,7 +164,8 @@ _audio_status = state.audio_status; } -void set_trackstate(struct trackstate state) { +void set_trackstate(struct trackstate state) +{ if (!(gui_wps[0].state) || !(gui_wps[0].state->id3)) return; @@ -123,7 +176,8 @@ gui_wps[0].state->id3->length = state.length; } -void set_next_trackstate(struct trackstate state) { +void set_next_trackstate(struct trackstate state) +{ gui_wps[0].state->nid3->title = state.title; gui_wps[0].state->nid3->artist = state.artist; gui_wps[0].state->nid3->album = state.album; @@ -144,7 +198,8 @@ }; -void set_audio_status(int status) { +void set_audio_status(int status) +{ DEBUGF1("%s",playmodeNames[status]); switch (status) { case API_STATUS_PLAY: @@ -170,104 +225,28 @@ } } -void test_api(struct proxy_api *api) { - if (!api->stop_scroll) - api->stop_scroll=stop_scroll; - if (!api->set_viewport) - api->set_viewport=lcd_set_viewport; - if (!api->clear_viewport) - api->clear_viewport=clear_viewport; - if (!api->getstringsize) - api->getstringsize=getstringsize; - if (!api->getwidth) - api->getwidth=lcd_getwidth; - if (!api->getheight) - api->getheight=lcd_getheight; - if (!api->set_drawmode) - api->set_drawmode=lcd_set_drawmode; - if (!api->puts_scroll) - api->puts_scroll=puts_scroll; - if (!api->update) - api->update=lcd_update; - if (!api->clear_display) - api->clear_display=lcd_clear_display; - if (!api->getfont) - api->getfont=lcd_getfont; - if (!api->putsxy) - api->putsxy=putsxy; +int getwidth(void) +{ + return LCD_WIDTH; +} -#if LCD_DEPTH > 1 - if (!api->get_foreground) - api->get_foreground=lcd_get_foreground; - if (!api->get_background) - api->get_background=lcd_get_background; -#endif - if (!api->load_remote_wps_backdrop) - api->load_remote_wps_backdrop = load_remote_wps_backdrop2; - if (!api->load_wps_backdrop) - api->load_wps_backdrop = load_wps_backdrop2; - //dbgf = printf; +int getheight(void) +{ + return LCD_HEIGHT; } /************************************************************** **************************************************************/ -int set_api(struct proxy_api* api) { - if (api->debugf) +int set_api(struct proxy_api* api) +{ + /************************** + * IN * + **************************/ + if(api->debugf) dbgf = api->debugf; - screens[0].screen_type=SCREEN_MAIN; - screens[0].lcdwidth=LCD_WIDTH; - screens[0].lcdheight=LCD_HEIGHT; - screens[0].depth=LCD_DEPTH; -#ifdef HAVE_LCD_COLOR - screens[0].is_color=true; -#else - screens[0].is_color=false; -#endif - if (api->stop_scroll) - screens[0].stop_scroll=api->stop_scroll; - screens[0].scroll_stop = lcd_scroll_stop; - if (api->set_viewport) - screens[0].set_viewport=api->set_viewport; - if (api->clear_viewport) - screens[0].clear_viewport=lcd_clear_viewport; - if (api->getstringsize) - screens[0].getstringsize=api->getstringsize; - if (api->getwidth) - screens[0].getwidth=api->getwidth; - if (api->getheight) - screens[0].getheight=api->getheight; - if (api->set_drawmode) - screens[0].set_drawmode=api->set_drawmode; - if (api->fillrect) - screens[0].fillrect=api->fillrect; - if (api->puts_scroll) - screens[0].puts_scroll=api->puts_scroll; - if (api->transparent_bitmap_part) - screens[0].transparent_bitmap_part=api->transparent_bitmap_part; - if (api->update) - screens[0].update=api->update; - if (api->clear_display) - screens[0].clear_display=api->clear_display; - if (api->getfont) - screens[0].getfont=api->getfont; - if (api->hline) - screens[0].hline=api->hline; - if (api->vline) - screens[0].vline=api->vline; - if (api->drawpixel) - screens[0].drawpixel=api->drawpixel; - if (api->putsxy) - screens[0].putsxy=api->putsxy; -#if LCD_DEPTH > 1 - if (api->get_foreground) - screens[0].get_foreground=api->get_foreground; - if (api->get_background) - screens[0].get_background=api->get_background; -#endif - screens[0].bitmap_part = api->bitmap_part; /************************** * OUT * **************************/ @@ -275,15 +254,12 @@ api->get_current_vp = get_current_vp; api->set_wpsstate = set_wpsstate; api->set_trackstate = set_trackstate; - api->set_next_trackstate= set_next_trackstate; - api->set_audio_status= set_audio_status; + api->set_next_trackstate = set_next_trackstate; + api->set_audio_status = set_audio_status; + api->load_font = load_font; + api->getwidth = getwidth; + api->getheight = getheight; + xapi = api; return 0; } - - - - - - - Index: libwps/Makefile =================================================================== --- libwps/Makefile (revision 18656) +++ libwps/Makefile (working copy) @@ -32,8 +32,8 @@ IRIVER_H10_5GB \ IPOD_COLOR \ IPOD_NANO \ - IPOD_VIDEO \ - IPOD_3G \ + IPOD_VIDEO + # IPOD_3G \ IPOD_4G \ IPOD_MINI \ IPOD_MINI2G \ @@ -52,7 +52,6 @@ SOURCES= \ src/api.c \ src/dummies.c \ - src/lcd.c \ src/proxy.c \ $(ROOT)/apps/gui/scrollbar.c \ $(ROOT)/apps/gui/gwps-common.c \ @@ -70,7 +69,12 @@ $(ROOT)/firmware/id3.c \ $(ROOT)/firmware/lru.c \ $(ROOT)/firmware/mp3data.c \ - $(ROOT)/firmware/replaygain.c + $(ROOT)/firmware/replaygain.c \ + $(ROOT)/firmware/drivers/lcd-16bit.c \ + $(ROOT)/apps/screen_access.c \ + $(ROOT)/firmware/scroll_engine.c \ + $(ROOT)/firmware/backlight.c +# src/lcd.c \ # $(ROOT)/apps/recorder/bmp.c # $(ROOT)/apps/abrepeat.c \ # $(ROOT)/apps/action.c \ @@ -86,7 +90,7 @@ -I $(ROOT)/apps \ -I src -CFLAGS = -g -Wall -Wno-format -D__PCTOOL__ -DWPSEDITOR -DDEBUG -DROCKBOX_DIR_LEN=1 -DBUTTON_REMOTE +CFLAGS = -g -Wall -Wno-format -Wno-pointer-sign -D__PCTOOL__ -DWPSEDITOR -DDEBUG -DROCKBOX_DIR_LEN=1 -DBUTTON_REMOTE RESULTS := $(patsubst %,libwps_%$(EXT),$(TARGETS)) Index: gui/src/qwpsdrawer.cpp =================================================================== --- gui/src/qwpsdrawer.cpp (revision 18656) +++ gui/src/qwpsdrawer.cpp (working copy) @@ -38,13 +38,15 @@ proxy_api QWpsDrawer::api; QWpsDrawer::QWpsDrawer( QWpsState *ws,QTrackState *ms, QWidget *parent ) - : QWidget(parent),wpsState(ws),trackState(ms),showGrid(false),mCurTarget(qApp->applicationDirPath()+"/libwps_IRIVER_H10_5GB") { + : QWidget(parent),wpsState(ws),trackState(ms),showGrid(false),mCurTarget(qApp->applicationDirPath()+"/libwps_IRIVER_H10_5GB") +{ tryResolve(); newTempWps(); } -bool QWpsDrawer::tryResolve() { +bool QWpsDrawer::tryResolve() +{ QLibrary lib(mCurTarget); lib_wps_init = (pfwps_init)lib.resolve("wps_init"); lib_wps_display = (pfwps_display)lib.resolve("wps_display"); @@ -53,18 +55,12 @@ mResolved = lib_wps_init && lib_wps_display && lib_wps_refresh && lib_get_model_name; if (!mResolved) DEBUGF1(tr("ERR: Failed to resolve funcs!")); - else { + else + { int v = api.verbose; memset(&api,0,sizeof(struct proxy_api)); api.verbose = v; - api.putsxy = &QWpsDrawer::putsxy; - api.transparent_bitmap_part = &QWpsDrawer::transparent_bitmap_part; - api.bitmap_part = &QWpsDrawer::bitmap_part; - api.drawpixel = &QWpsDrawer::drawpixel; - api.fillrect = &QWpsDrawer::fillrect; - api.hline = &QWpsDrawer::hline; - api.vline = &QWpsDrawer::vline; - api.clear_viewport = &QWpsDrawer::clear_viewport; + api.lcd_update = &QWpsDrawer::lcd_update; api.load_wps_backdrop = &QWpsDrawer::load_wps_backdrop; api.read_bmp_file = &QWpsDrawer::read_bmp_file; api.debugf = &qlogger; @@ -72,55 +68,69 @@ } return mResolved; } -QWpsDrawer::~QWpsDrawer() { +QWpsDrawer::~QWpsDrawer() +{ qDebug()<<"QWpsDrawer::~QWpsDrawer()"; cleanTemp(); } -void QWpsDrawer::mouseReleaseEvent ( QMouseEvent * event ) { +void QWpsDrawer::mouseReleaseEvent ( QMouseEvent * event ) +{ Q_UNUSED(event); /*int x = event->x() - (this->width()-pix->width())/2, y = event->y() - (this->height()-pix->height())/2; DEBUGF1("x=%d,y=%d",x,y);*/ } -void QWpsDrawer::newTempWps() { +void QWpsDrawer::newTempWps() +{ QTemporaryFile tmpWps; tmpWps.setAutoRemove(false); tmpWps.setFileTemplate(QDir::tempPath()+"/XXXXXXXXXX.wps"); - if (tmpWps.open()) { + if (tmpWps.open()) + { QString tmpDir = tmpWps.fileName().left(tmpWps.fileName().length()-4); - if (QDir::temp().mkpath(tmpDir)) { + if (QDir::temp().mkpath(tmpDir)) + { mTmpWpsString = tmpDir; DEBUGF3(QString("Created :"+mTmpWpsString).toAscii()); } } } -void QWpsDrawer::WpsInit(QString buffer, bool isFile) { +void QWpsDrawer::WpsInit(QString buffer, bool isFile) +{ DEBUGF3("QWpsDrawer::WpsInit"); if (!mResolved) + { if (!tryResolve()) return; - if (isFile) { + } + + if (isFile) + { cleanTemp(); DEBUGF1( tr("Loading %1").arg(buffer)); QFile file(buffer); if (file.open(QIODevice::ReadOnly | QIODevice::Text)) mWpsString = file.readAll(); newTempWps(); - } else + } + else + { mWpsString = buffer; - { QFile tfile(mTmpWpsString+".wps"); if (tfile.open(QIODevice::WriteOnly | QIODevice::Text)) tfile.write(mWpsString.toAscii(),mWpsString.length()); } + backdrop.fill(Qt::black); DEBUGF3("clear backdrop"); + if (isFile) lib_wps_init(buffer.toAscii(), &api, isFile); else lib_wps_init(QString(mTmpWpsString+".wps").toAscii(), &api, true); + pix = new QPixmap(api.getwidth(),api.getheight()); pix->fill(Qt::black); @@ -128,10 +138,14 @@ setMinimumWidth(api.getwidth()); setMinimumHeight(api.getheight()); + + DEBUGF3("Loading font... %x", api.load_font("/home/toor/rockbox/utils/wpseditor/gui/bin/font.fnt")); + update(); } -void QWpsDrawer::paintEvent(QPaintEvent * event) { +void QWpsDrawer::paintEvent(QPaintEvent * event) +{ DEBUGF3("QWpsDrawer::paintEvent()"); if (!mResolved) return; @@ -143,65 +157,63 @@ drawBackdrop(); lib_wps_refresh(); - if (showGrid) { + if (showGrid) + { QPainter g(pix); viewport_api avp; api.get_current_vp(&avp); g.setPen(Qt::green); - for (int i=0;i*avp.fontheight/1.5width())/2,(rect.height()-pix->height())/2,*pix); } -void QWpsDrawer::clear_viewport(int x,int y,int w,int h, int color) { - DEBUGF2("clear_viewport(int x=%d,int y=%d,int w=%d,int h=%d, int color)",x,y,w,h); - QPainter p(pix); - //p.setOpacity(0.1); - //QImage img = backdrop.copy(x,y,w,h); - //p.drawImage(x,y,img); -} - -void QWpsDrawer::slotSetVolume() { +void QWpsDrawer::slotSetVolume() +{ Slider *slider = new Slider(this, tr("Volume"),-74,10); slider->show(); connect(slider, SIGNAL(valueChanged(int)), wpsState, SLOT(setVolume(int))); connect(this, SIGNAL(destroyed()),slider, SLOT(close())); } -void QWpsDrawer::slotSetProgress() { +void QWpsDrawer::slotSetProgress() +{ Slider *slider = new Slider(this,tr("Progress"),0,100); slider->show(); connect(slider, SIGNAL(valueChanged(int)), trackState, SLOT(setElapsed(int))); connect(this, SIGNAL(destroyed()),slider, SLOT(close())); } -void QWpsDrawer::slotWpsStateChanged(wpsstate ws_) { +void QWpsDrawer::slotWpsStateChanged(wpsstate ws_) +{ if (api.set_wpsstate) api.set_wpsstate(ws_); update(); } -void QWpsDrawer::slotTrackStateChanged(trackstate ms_) { +void QWpsDrawer::slotTrackStateChanged(trackstate ms_) +{ if (api.set_wpsstate) api.set_trackstate(ms_); update(); } -void QWpsDrawer::slotShowGrid(bool show) { +void QWpsDrawer::slotShowGrid(bool show) +{ showGrid = show; update(); } -void QWpsDrawer::drawBackdrop() { +void QWpsDrawer::drawBackdrop() +{ DEBUGF3("QWpsDrawer::drawBackdrop()"); if (backdrop.isNull()) return; @@ -232,11 +244,13 @@ event->accept(); } -QString QWpsDrawer::getModelName(QString libraryName) { +QString QWpsDrawer::getModelName(QString libraryName) +{ QLibrary lib(libraryName); if ((pfget_model_name)lib.resolve("get_model_name")) return ((pfget_model_name)lib.resolve("get_model_name"))(); - DEBUGF1("ERR: failed to resolve "); + + DEBUGF1("ERR: failed to resolve :\n" + lib.errorString()); return "unknown"; } Index: gui/src/qwpsdrawer.h =================================================================== --- gui/src/qwpsdrawer.h (revision 18656) +++ gui/src/qwpsdrawer.h (working copy) @@ -35,12 +35,13 @@ class QWpsState; class QTrackState; -typedef int (*pfwps_init)(const char* buff,struct proxy_api *api, bool isfile); +typedef int (*pfwps_init)(const char* buff, struct proxy_api *api, bool isfile); typedef int (*pfwps_display)(); typedef int (*pfwps_refresh)(); typedef const char* (*pfget_model_name)(); -class QWpsDrawer : public QWidget { +class QWpsDrawer : public QWidget +{ Q_OBJECT pfwps_init lib_wps_init; @@ -82,10 +83,12 @@ ~QWpsDrawer(); void WpsInit(QString buffer, bool isFile = true); - QString wpsString() const { + QString wpsString() const + { return mWpsString; }; - QString tempWps() const { + QString tempWps() const + { return mTmpWpsString; }; QList getTargets(); @@ -94,16 +97,7 @@ static proxy_api api; /***********Drawing api******************/ - static void putsxy(int x, int y, const unsigned char *str); - static void transparent_bitmap_part(const void *src, int src_x, int src_y, - int stride, int x, int y, int width, int height); - static void bitmap_part(const void *src, int src_x, int src_y, - int stride, int x, int y, int width, int height); - static void drawpixel(int x, int y); - static void fillrect(int x, int y, int width, int height); - static void hline(int x1, int x2, int y); - static void vline(int x, int y1, int y2); - static void clear_viewport(int x,int y,int w,int h, int color); + static void lcd_update(const unsigned char* adr, int x, int y, int width, int height); static bool load_wps_backdrop(char* filename); static int read_bmp_file(const char* filename,int *width, int *height); /****************************************/ Index: gui/src/qwpsdrawer_static.cpp =================================================================== --- gui/src/qwpsdrawer_static.cpp (revision 18656) +++ gui/src/qwpsdrawer_static.cpp (working copy) @@ -26,55 +26,20 @@ #include "utils.h" #include "api.h" -void QWpsDrawer::putsxy(int x, int y, const unsigned char *str) { - DEBUGF3("putsxy(int x=%d, int y=%d, *str=%s)",x,y,str); +void QWpsDrawer::lcd_update(const unsigned char* adr, int x, int y, int width, int height) +{ + QImage img(adr, width, height, QImage::Format_RGB16); + + DEBUGF2("lcd_update(const void *adr=%x, int x=%d, int y=%d, int width=%d, int height=%d", adr, x, y, width, height); QPainter p(pix); - viewport_api avp; - api.get_current_vp(&avp); - p.setPen(Qt::gray); - QFont font("times",avp.fontheight,QFont::Bold); - p.setFont(font); - p.drawText(x+avp.x,y + avp.fontheight + avp.y,(char*)str); -} -void QWpsDrawer::transparent_bitmap_part(const void *src, int src_x, int src_y, - int stride, int x, int y, int width, int height) { - QImage img; - img.load((char*)src); - DEBUGF2("transparent_bitmap_part(const void *src=%s, int src_x=%d, int src_y=%d,int stride=%d, int x=%d, int y=%d, int width=%d, int height=%d",(char*)src,src_x, src_y,stride, x, y, width, height); - QPainter p(pix); - QPoint target(x,y); - QRectF source(src_x, src_y, width, height); + QPoint target(x, y); + QRectF source(x, y, width, height); - QImage pink = img.createMaskFromColor(qRgb(255,0,255),Qt::MaskOutColor); - img.setAlphaChannel(pink); - p.drawImage(target, img, source); } -void QWpsDrawer::bitmap_part(const void *src, int src_x, int src_y, - int stride, int x, int y, int width, int height) { - transparent_bitmap_part(src,src_x,src_y,stride,x,y,width,height); -} -void QWpsDrawer::drawpixel(int x, int y) { - QPainter p(pix); - p.setPen(Qt::blue); - p.drawPoint(x,y); -} -void QWpsDrawer::fillrect(int x, int y, int width, int height) { - QPainter p(pix); - DEBUGF2("fillrect(int x=%d, int y=%d, int width=%d, int height=%d)\n",x, y, width, height); - p.setPen(Qt::green); -} -void QWpsDrawer::hline(int x1, int x2, int y) { - QPainter p(pix); - p.setPen(Qt::black); - p.drawLine(x1,y,x2,y); -} -void QWpsDrawer::vline(int x, int y1, int y2) { - QPainter p(pix); - p.setPen(Qt::black); - p.drawLine(x,y1,x,y2); -} -bool QWpsDrawer::load_wps_backdrop(char* filename) { + +bool QWpsDrawer::load_wps_backdrop(char* filename) +{ DEBUGF3("load backdrop: %s", filename); QFile file(filename); QFileInfo info(file); @@ -83,7 +48,8 @@ return true; } -int QWpsDrawer::read_bmp_file(const char* filename,int *width, int *height) { +int QWpsDrawer::read_bmp_file(const char* filename,int *width, int *height) +{ QImage img; QFile file(filename);