diff --git a/apps/plugins/mpegplayer/mpeg_parser.c b/apps/plugins/mpegplayer/mpeg_parser.c index 167f07da5c..0259bc9865 100644 --- a/apps/plugins/mpegplayer/mpeg_parser.c +++ b/apps/plugins/mpegplayer/mpeg_parser.c @@ -1032,7 +1032,28 @@ intptr_t parser_send_video_msg(long id, intptr_t data) break; } - retval = str_send_msg(&video_str, id, data); + switch (id) + { +#ifdef GRAY_CACHE_MAINT + /* This must be done internally here or refresh may be delayed far + * too long */ + case VIDEO_DISPLAY_SHOW: + case VIDEO_PRINT_FRAME: + case VIDEO_PRINT_THUMBNAIL: + stream_gray_pause(true); + + GRAY_INVALIDATE_ICACHE(); + + retval = str_send_msg(&video_str, id, data); + + GRAY_VIDEO_FLUSH_ICACHE(); + + stream_gray_pause(false); + break; +#endif + default: + retval = str_send_msg(&video_str, id, data); + } } return retval; diff --git a/apps/plugins/mpegplayer/mpeg_settings.c b/apps/plugins/mpegplayer/mpeg_settings.c index e99823ed5c..720101706c 100644 --- a/apps/plugins/mpegplayer/mpeg_settings.c +++ b/apps/plugins/mpegplayer/mpeg_settings.c @@ -178,17 +178,56 @@ static void display_options(void) menu_exit(menu_id); } +#ifndef HAVE_LCD_COLOR +/* Cheapo splash implementation for the grey surface */ +static void grey_splash(int ticks, const unsigned char *fmt, ...) +{ + unsigned char buffer[256]; + int x, y, w, h; + int oldfg, oldmode; + + va_list ap; + va_start(ap, fmt); + + rb->vsnprintf(buffer, sizeof (buffer), fmt, ap); + + va_end(ap); + + grey_getstringsize(buffer, &w, &h); + + oldfg = grey_get_foreground(); + oldmode = grey_get_drawmode(); + + grey_set_drawmode(DRMODE_FG); + grey_set_foreground(GREY_LIGHTGRAY); + + x = (LCD_WIDTH - w) / 2; + y = (LCD_HEIGHT - h) / 2; + + grey_fillrect(x - 1, y - 1, w + 2, h + 2); + + grey_set_foreground(GREY_BLACK); + + grey_putsxy(x, y, buffer); + grey_drawrect(x - 2, y - 2, w + 4, h + 4); + + grey_set_foreground(oldfg); + grey_set_drawmode(oldmode); + + grey_update(); + + if (ticks > 0) + rb->sleep(ticks); +} +#endif /* !HAVE_LCD_COLOR */ + static void show_loading(struct vo_rect *rc) { - int oldmode; -#ifndef HAVE_LCD_COLOR - stream_gray_show(false); -#endif - oldmode = rb->lcd_get_drawmode(); - rb->lcd_set_drawmode(DRMODE_BG | DRMODE_INVERSEVID); - rb->lcd_fillrect(rc->l-1, rc->t-1, rc->r - rc->l + 2, rc->b - rc->t + 2); - rb->lcd_set_drawmode(oldmode); - rb->splash(0, "Loading..."); + int oldmode = lcd_(get_drawmode)(); + lcd_(set_drawmode)(DRMODE_SOLID | DRMODE_INVERSEVID); + lcd_(fillrect)(rc->l-1, rc->t-1, rc->r - rc->l + 2, rc->b - rc->t + 2); + lcd_(set_drawmode)(oldmode); + lcd_(splash)(0, "Loading..."); } void draw_slider(uint32_t range, uint32_t pos, struct vo_rect *rc) @@ -211,36 +250,36 @@ void draw_slider(uint32_t range, uint32_t pos, struct vo_rect *rc) /* Put positition on left */ ts_to_hms(pos, &hms); hms_format(str, sizeof(str), &hms); - rb->lcd_getstringsize(str, NULL, &text_h); + lcd_(getstringsize)(str, NULL, &text_h); text_y = SLIDER_Y - SLIDER_TEXTMARGIN - text_h; if (rc == NULL) { - int oldmode = rb->lcd_get_drawmode(); - rb->lcd_set_drawmode(DRMODE_BG | DRMODE_INVERSEVID); - rb->lcd_fillrect(SLIDER_X, text_y, SLIDER_WIDTH, - LCD_HEIGHT - SLIDER_BMARGIN - text_y - - SLIDER_TMARGIN); - rb->lcd_set_drawmode(oldmode); + int oldmode = lcd_(get_drawmode)(); + lcd_(set_drawmode)(DRMODE_BG | DRMODE_INVERSEVID); + lcd_(fillrect)(SLIDER_X, text_y, SLIDER_WIDTH, + LCD_HEIGHT - SLIDER_BMARGIN - text_y + - SLIDER_TMARGIN); + lcd_(set_drawmode)(oldmode); - rb->lcd_putsxy(SLIDER_X, text_y, str); + lcd_(putsxy)(SLIDER_X, text_y, str); /* Put duration on right */ ts_to_hms(range, &hms); hms_format(str, sizeof(str), &hms); - rb->lcd_getstringsize(str, &text_w, NULL); + lcd_(getstringsize)(str, &text_w, NULL); - rb->lcd_putsxy(SLIDER_X + SLIDER_WIDTH - text_w, text_y, str); + lcd_(putsxy)(SLIDER_X + SLIDER_WIDTH - text_w, text_y, str); /* Draw slider */ - rb->lcd_drawrect(SLIDER_X, SLIDER_Y, SLIDER_WIDTH, SLIDER_HEIGHT); - rb->lcd_fillrect(SLIDER_X, SLIDER_Y, - muldiv_uint32(pos, SLIDER_WIDTH, range), - SLIDER_HEIGHT); + lcd_(drawrect)(SLIDER_X, SLIDER_Y, SLIDER_WIDTH, SLIDER_HEIGHT); + lcd_(fillrect)(SLIDER_X, SLIDER_Y, + muldiv_uint32(pos, SLIDER_WIDTH, range), + SLIDER_HEIGHT); /* Update screen */ - rb->lcd_update_rect(SLIDER_X, text_y - SLIDER_TMARGIN, SLIDER_WIDTH, - LCD_HEIGHT - SLIDER_BMARGIN - text_y + SLIDER_TEXTMARGIN); + lcd_(update_rect)(SLIDER_X, text_y - SLIDER_TMARGIN, SLIDER_WIDTH, + LCD_HEIGHT - SLIDER_BMARGIN - text_y + SLIDER_TEXTMARGIN); } else { @@ -256,33 +295,28 @@ bool display_thumb_image(const struct vo_rect *rc) { if (!stream_display_thumb(rc)) { - rb->splash(0, "Frame not available"); + lcd_(splash)(0, "Frame not available"); return false; } -#ifdef HAVE_LCD_COLOR /* Draw a raised border around the frame */ - int oldcolor = rb->lcd_get_foreground(); - rb->lcd_set_foreground(LCD_LIGHTGRAY); + int oldcolor = lcd_(get_foreground)(); + lcd_(set_foreground)(DRAW_LIGHTGRAY); - rb->lcd_hline(rc->l-1, rc->r-1, rc->t-1); - rb->lcd_vline(rc->l-1, rc->t, rc->b-1); + lcd_(hline)(rc->l-1, rc->r-1, rc->t-1); + lcd_(vline)(rc->l-1, rc->t, rc->b-1); - rb->lcd_set_foreground(LCD_DARKGRAY); + lcd_(set_foreground)(DRAW_DARKGRAY); - rb->lcd_hline(rc->l-1, rc->r, rc->b); - rb->lcd_vline(rc->r, rc->t-1, rc->b); + lcd_(hline)(rc->l-1, rc->r, rc->b); + lcd_(vline)(rc->r, rc->t-1, rc->b); - rb->lcd_set_foreground(oldcolor); + lcd_(set_foreground)(oldcolor); - rb->lcd_update_rect(rc->l-1, rc->t-1, rc->r - rc->l + 2, 1); - rb->lcd_update_rect(rc->l-1, rc->t, 1, rc->b - rc->t); - rb->lcd_update_rect(rc->l-1, rc->b, rc->r - rc->l + 2, 1); - rb->lcd_update_rect(rc->r, rc->t, 1, rc->b - rc->t); -#else - /* Just show the thumbnail */ - stream_gray_show(true); -#endif + lcd_(update_rect)(rc->l-1, rc->t-1, rc->r - rc->l + 2, 1); + lcd_(update_rect)(rc->l-1, rc->t, 1, rc->b - rc->t); + lcd_(update_rect)(rc->l-1, rc->b, rc->r - rc->l + 2, 1); + lcd_(update_rect)(rc->r, rc->t, 1, rc->b - rc->t); return true; } @@ -320,18 +354,12 @@ int get_start_time(uint32_t duration) enum state_enum slider_state = state0; - rb->lcd_clear_display(); - rb->lcd_update(); + lcd_(clear_display)(); + lcd_(update)(); draw_slider(0, 100, &rc_bound); rc_bound.b = rc_bound.t - SLIDER_TMARGIN; -#ifdef HAVE_LCD_COLOR rc_bound.t = SCREEN_MARGIN; -#else - rc_bound.t = 0; - rc_bound.l = 0; - rc_bound.r = LCD_WIDTH; -#endif DEBUGF("rc_bound: %d, %d, %d, %d\n", rc_bound.l, rc_bound.t, rc_bound.r, rc_bound.b); @@ -344,12 +372,6 @@ int get_start_time(uint32_t duration) rc_vid.b = rc_bound.b - rc_bound.t; } -#if !defined (HAVE_LCD_COLOR) -#if LCD_PIXELFORMAT == VERTICAL_PACKING - rc_bound.b &= ~7; /* Align bottom edge */ -#endif -#endif - /* Get aspect ratio of bounding rectangle and video in u16.16 */ aspect_bound = ((rc_bound.r - rc_bound.l) << 16) / (rc_bound.b - rc_bound.t); @@ -398,8 +420,8 @@ int get_start_time(uint32_t duration) rc_vid.r, rc_vid.b); #ifndef HAVE_LCD_COLOR - /* Set gray overlay to the bounding rectangle */ - stream_set_gray_rect(&rc_bound); + /* Restore gray overlay dimensions */ + stream_gray_show(true); #endif while(slider_state < state9) @@ -487,10 +509,9 @@ int get_start_time(uint32_t duration) } #ifndef HAVE_LCD_COLOR - /* Restore gray overlay dimensions */ stream_gray_show(false); - rc_bound.b = LCD_HEIGHT; - stream_set_gray_rect(&rc_bound); + grey_clear_display(); + grey_update(); #endif cancel_cpu_boost(); diff --git a/apps/plugins/mpegplayer/mpegplayer.c b/apps/plugins/mpegplayer/mpegplayer.c index b547d36f6a..a41d3b498a 100644 --- a/apps/plugins/mpegplayer/mpegplayer.c +++ b/apps/plugins/mpegplayer/mpegplayer.c @@ -257,10 +257,8 @@ struct wvs int height; unsigned fgcolor; unsigned bgcolor; -#ifdef HAVE_LCD_COLOR unsigned prog_fillcolor; struct vo_rect update_rect; -#endif struct vo_rect prog_rect; struct vo_rect time_rect; struct vo_rect dur_rect; @@ -310,16 +308,21 @@ static unsigned draw_blendcolor(unsigned c1, unsigned c2, unsigned char amount) /* Drawing functions that operate rotated on LCD_PORTRAIT displays - * most are just wrappers of lcd_* functions with transforms applied. * The origin is the upper-left corner of the WVS area */ -#ifdef HAVE_LCD_COLOR static void draw_update_rect(int x, int y, int width, int height) { - rb->lcd_update_rect(_X, _Y, _W, _H); + lcd_(update_rect)(_X, _Y, _W, _H); } -#endif static void draw_clear_area(int x, int y, int width, int height) { +#ifdef HAVE_LCD_COLOR rb->screen_clear_area(rb->screens[SCREEN_MAIN], _X, _Y, _W, _H); +#else + int oldmode = grey_get_drawmode(); + grey_set_drawmode(DRMODE_SOLID | DRMODE_INVERSEVID); + grey_fillrect(_X, _Y, _W, _H); + grey_set_drawmode(oldmode); +#endif } static void draw_clear_area_rect(const struct vo_rect *rc) @@ -328,50 +331,71 @@ static void draw_clear_area_rect(const struct vo_rect *rc) int y = rc->t; int width = rc->r - rc->l; int height = rc->b - rc->t; +#ifdef HAVE_LCD_COLOR rb->screen_clear_area(rb->screens[SCREEN_MAIN], _X, _Y, _W, _H); -} - -static void draw_scrollbar_draw(int x, int y, int width, int height, - int items, int min_shown, int max_shown) -{ -#ifdef HAVE_LCD_COLOR - int oldbg = rb->lcd_get_background(); - rb->lcd_set_background(wvs.prog_fillcolor); -#endif - - rb->gui_scrollbar_draw(rb->screens[SCREEN_MAIN], _X, _Y, - _W, _H, items, min_shown, max_shown, - 0 -#ifdef LCD_LANDSCAPE - | HORIZONTAL -#endif -#ifdef HAVE_LCD_COLOR - | INNER_BGFILL | FOREGROUND -#endif - ); - -#ifdef HAVE_LCD_COLOR - rb->lcd_set_background(oldbg); +#else + int oldmode = grey_get_drawmode(); + grey_set_drawmode(DRMODE_SOLID | DRMODE_INVERSEVID); + grey_fillrect(_X, _Y, _W, _H); + grey_set_drawmode(oldmode); #endif } -static void draw_scrollbar_draw_rect(const struct vo_rect *rc, int items, - int min_shown, int max_shown) +static void draw_fillrect(int x, int y, int width, int height) { - draw_scrollbar_draw(rc->l, rc->t, rc->r - rc->l, rc->b - rc->t, - items, min_shown, max_shown); + lcd_(fillrect)(_X, _Y, _W, _H); } static void draw_hline(int x1, int x2, int y) { #ifdef LCD_LANDSCAPE - rb->lcd_hline(x1 + wvs.x, x2 + wvs.x, y + wvs.y); + lcd_(hline)(x1 + wvs.x, x2 + wvs.x, y + wvs.y); #else y = LCD_WIDTH - (y + wvs.y) - 1; - rb->lcd_vline(y, x1 + wvs.x, x2 + wvs.x); + lcd_(vline)(y, x1 + wvs.x, x2 + wvs.x); #endif } +static void draw_vline(int x, int y1, int y2) +{ +#ifdef LCD_LANDSCAPE + lcd_(vline)(x + wvs.x, y1 + wvs.y, y2 + wvs.y); +#else + y1 = LCD_WIDTH - (y1 + wvs.y) - 1; + y2 = LCD_WIDTH - (y2 + wvs.y) - 1; + lcd_(hline)(y1, y2, x + wvs.x); +#endif +} + +static void draw_scrollbar_draw(int x, int y, int width, int height, + uint32_t min, uint32_t max, uint32_t val) +{ + unsigned oldfg = lcd_(get_foreground)(); + + draw_hline(x + 1, x + width - 2, y); + draw_hline(x + 1, x + width - 2, y + height - 1); + draw_vline(x, y + 1, y + height - 2); + draw_vline(x + width - 1, y + 1, y + height - 2); + + val = muldiv_uint32(width - 2, val, max - min); + val = MIN(val, (uint32_t)(width - 2)); + + draw_fillrect(x + 1, y + 1, val, height - 2); + + lcd_(set_foreground)(wvs.prog_fillcolor); + + draw_fillrect(x + 1 + val, y + 1, width - 2 - val, height - 2); + + lcd_(set_foreground)(oldfg); +} + +static void draw_scrollbar_draw_rect(const struct vo_rect *rc, int min, + int max, int val) +{ + draw_scrollbar_draw(rc->l, rc->t, rc->r - rc->l, rc->b - rc->t, + min, max, val); +} + #ifdef LCD_PORTRAIT /* Portrait displays need rotated text rendering */ @@ -480,18 +504,18 @@ static void draw_oriented_mono_bitmap_part(const unsigned char *src, int stride, int x, int y, int width, int height) { - int mode = rb->lcd_get_drawmode(); - rb->lcd_set_drawmode(DRMODE_FG); - rb->lcd_mono_bitmap_part(src, src_x, src_y, stride, x, y, width, height); - rb->lcd_set_drawmode(mode); + int mode = lcd_(get_drawmode)(); + lcd_(set_drawmode)(DRMODE_FG); + lcd_(mono_bitmap_part)(src, src_x, src_y, stride, x, y, width, height); + lcd_(set_drawmode)(mode); } static void draw_putsxy_oriented(int x, int y, const char *str) { - int mode = rb->lcd_get_drawmode(); - rb->lcd_set_drawmode(DRMODE_FG); - rb->lcd_putsxy(x + wvs.x, y + wvs.y, str); - rb->lcd_set_drawmode(mode); + int mode = lcd_(get_drawmode)(); + lcd_(set_drawmode)(DRMODE_FG); + lcd_(putsxy)(x + wvs.x, y + wvs.y, str); + lcd_(set_drawmode)(mode); } #endif /* LCD_PORTRAIT */ @@ -503,7 +527,7 @@ static void wvs_text_init(void) int phys; int spc_width; - rb->lcd_setfont(FONT_UI); + lcd_(setfont)(FONT_UI); wvs.x = 0; wvs.width = SCREEN_WIDTH; @@ -515,8 +539,7 @@ static void wvs_text_init(void) ts_to_hms(stream_get_duration(), &hms); hms_format(buf, sizeof (buf), &hms); - rb->lcd_getstringsize(buf, &wvs.time_rect.r, - &wvs.time_rect.b); + lcd_(getstringsize)(buf, &wvs.time_rect.r, &wvs.time_rect.b); /* Choose well-sized bitmap images relative to font height */ if (wvs.time_rect.b < 12) { @@ -546,8 +569,8 @@ static void wvs_text_init(void) rb->snprintf(buf, sizeof(buf), "%d%s", phys, rb->sound_unit(SOUND_VOLUME)); - rb->lcd_getstringsize(" ", &spc_width, NULL); - rb->lcd_getstringsize(buf, &wvs.vol_rect.r, &wvs.vol_rect.b); + lcd_(getstringsize)(" ", &spc_width, NULL); + lcd_(getstringsize)(buf, &wvs.vol_rect.r, &wvs.vol_rect.b); wvs.prog_rect.r = SCREEN_WIDTH - WVS_BDR_L - spc_width - wvs.vol_rect.r - WVS_BDR_R; @@ -568,14 +591,12 @@ static void wvs_text_init(void) wvs.height = WVS_BDR_T + MAX(wvs.prog_rect.b, wvs.vol_rect.b) - MIN(wvs.time_rect.t, wvs.stat_rect.t) + WVS_BDR_B; -#if LCD_PIXELFORMAT == VERTICAL_PACKING - wvs.height = ALIGN_UP(wvs.height, 8); -#else +#ifdef HAVE_LCD_COLOR wvs.height = ALIGN_UP(wvs.height, 2); #endif wvs.y = SCREEN_HEIGHT - wvs.height; - rb->lcd_setfont(FONT_SYSFIXED); + lcd_(setfont)(FONT_SYSFIXED); } static void wvs_init(void) @@ -589,8 +610,9 @@ static void wvs_init(void) wvs.fgcolor = LCD_WHITE; wvs.prog_fillcolor = LCD_BLACK; #else - wvs.bgcolor = LCD_LIGHTGRAY; - wvs.fgcolor = LCD_BLACK; + wvs.bgcolor = GREY_LIGHTGRAY; + wvs.fgcolor = GREY_BLACK; + wvs.prog_fillcolor = GREY_WHITE; #endif wvs.curr_time = 0; wvs.status = WVS_STATUS_STOPPED; @@ -623,37 +645,39 @@ static void wvs_refresh_background(void) char buf[32]; struct hms hms; - int bg = rb->lcd_get_background(); - rb->lcd_set_drawmode(DRMODE_SOLID | DRMODE_INVERSEVID); + unsigned bg = lcd_(get_background)(); + lcd_(set_drawmode)(DRMODE_SOLID | DRMODE_INVERSEVID); #ifdef HAVE_LCD_COLOR /* Draw a "raised" area for our graphics */ - rb->lcd_set_background(draw_blendcolor(bg, LCD_WHITE, 192)); + lcd_(set_background)(draw_blendcolor(bg, DRAW_WHITE, 192)); draw_hline(0, wvs.width, 0); - rb->lcd_set_background(draw_blendcolor(bg, LCD_WHITE, 80)); + lcd_(set_background)(draw_blendcolor(bg, DRAW_WHITE, 80)); draw_hline(0, wvs.width, 1); - rb->lcd_set_background(draw_blendcolor(bg, LCD_BLACK, 48)); + lcd_(set_background)(draw_blendcolor(bg, DRAW_BLACK, 48)); draw_hline(0, wvs.width, wvs.height-2); - rb->lcd_set_background(draw_blendcolor(bg, LCD_BLACK, 128)); + lcd_(set_background)(draw_blendcolor(bg, DRAW_BLACK, 128)); draw_hline(0, wvs.width, wvs.height-1); - rb->lcd_set_background(bg); + lcd_(set_background)(bg); draw_clear_area(0, 2, wvs.width, wvs.height - 4); - - vo_rect_set_ext(&wvs.update_rect, 0, 0, wvs.width, wvs.height); #else /* Give contrast with the main background */ - rb->lcd_set_background(LCD_DARKGRAY); + lcd_(set_background)(GREY_WHITE); draw_hline(0, wvs.width, 0); - rb->lcd_set_background(bg); - draw_clear_area(0, 1, wvs.width, wvs.height - 1); + lcd_(set_background)(GREY_DARKGRAY); + draw_hline(0, wvs.width, wvs.height-1); + + lcd_(set_background)(bg); + draw_clear_area(0, 1, wvs.width, wvs.height - 2); #endif - rb->lcd_set_drawmode(DRMODE_SOLID); + vo_rect_set_ext(&wvs.update_rect, 0, 0, wvs.width, wvs.height); + lcd_(set_drawmode)(DRMODE_SOLID); if (stream_get_duration() != INVALID_TIMESTAMP) { /* Draw the movie duration */ @@ -672,7 +696,7 @@ static void wvs_refresh_time(void) uint32_t duration = stream_get_duration(); - draw_scrollbar_draw_rect(&wvs.prog_rect, duration, 0, + draw_scrollbar_draw_rect(&wvs.prog_rect, 0, duration, wvs.curr_time); ts_to_hms(wvs.curr_time, &hms); @@ -681,12 +705,10 @@ static void wvs_refresh_time(void) draw_clear_area_rect(&wvs.time_rect); draw_putsxy_oriented(wvs.time_rect.l, wvs.time_rect.t, buf); -#ifdef HAVE_LCD_COLOR vo_rect_union(&wvs.update_rect, &wvs.update_rect, &wvs.prog_rect); vo_rect_union(&wvs.update_rect, &wvs.update_rect, &wvs.time_rect); -#endif } /* Refresh the volume display area */ @@ -699,15 +721,13 @@ static void wvs_refresh_volume(void) rb->snprintf(buf, sizeof (buf), "%d%s", rb->sound_val2phys(SOUND_VOLUME, volume), rb->sound_unit(SOUND_VOLUME)); - rb->lcd_getstringsize(buf, &width, NULL); + lcd_(getstringsize)(buf, &width, NULL); /* Right-justified */ draw_clear_area_rect(&wvs.vol_rect); draw_putsxy_oriented(wvs.vol_rect.r - width, wvs.vol_rect.t, buf); -#ifdef HAVE_LCD_COLOR vo_rect_union(&wvs.update_rect, &wvs.update_rect, &wvs.vol_rect); -#endif } /* Refresh the status icon */ @@ -719,11 +739,11 @@ static void wvs_refresh_status(void) #ifdef HAVE_LCD_COLOR /* Draw status icon with a drop shadow */ - unsigned oldfg = rb->lcd_get_foreground(); + unsigned oldfg = lcd_(get_foreground)(); int i = 1; - rb->lcd_set_foreground(draw_blendcolor(rb->lcd_get_background(), - LCD_BLACK, 96)); + lcd_(set_foreground)(draw_blendcolor(lcd_(get_background)(), + DRAW_BLACK, 96)); while (1) { @@ -738,7 +758,7 @@ static void wvs_refresh_status(void) if (--i < 0) break; - rb->lcd_set_foreground(oldfg); + lcd_(set_foreground)(oldfg); } vo_rect_union(&wvs.update_rect, &wvs.update_rect, &wvs.stat_rect); @@ -750,6 +770,7 @@ static void wvs_refresh_status(void) wvs.stat_rect.l + wvs.x, wvs.stat_rect.t + wvs.y, icon_size, icon_size); + vo_rect_union(&wvs.update_rect, &wvs.update_rect, &wvs.stat_rect); #endif } @@ -859,16 +880,14 @@ static void wvs_refresh(int hint) /* Set basic drawing params that are used. Elements that perform variations * will restore them. */ - oldfg = rb->lcd_get_foreground(); - oldbg = rb->lcd_get_background(); + oldfg = lcd_(get_foreground)(); + oldbg = lcd_(get_background)(); - rb->lcd_setfont(FONT_UI); - rb->lcd_set_foreground(wvs.fgcolor); - rb->lcd_set_background(wvs.bgcolor); + lcd_(setfont)(FONT_UI); + lcd_(set_foreground)(wvs.fgcolor); + lcd_(set_background)(wvs.bgcolor); -#ifdef HAVE_LCD_COLOR vo_rect_clear(&wvs.update_rect); -#endif if (hint & WVS_REFRESH_BACKGROUND) { wvs_refresh_background(); @@ -888,11 +907,10 @@ static void wvs_refresh(int hint) } /* Go back to defaults */ - rb->lcd_setfont(FONT_SYSFIXED); - rb->lcd_set_foreground(oldfg); - rb->lcd_set_background(oldbg); + lcd_(setfont)(FONT_SYSFIXED); + lcd_(set_foreground)(oldfg); + lcd_(set_background)(oldbg); -#ifdef HAVE_LCD_COLOR /* Update the dirty rectangle */ vo_lock(); @@ -902,10 +920,6 @@ static void wvs_refresh(int hint) wvs.update_rect.b - wvs.update_rect.t); vo_unlock(); -#else - /* Defer update to greylib */ - grey_deferred_lcd_update(); -#endif } /* Show/Hide the WVS */ @@ -930,7 +944,9 @@ static void wvs_show(unsigned show) stream_vo_set_clip(NULL); +#ifdef HAVE_LCD_COLOR draw_clear_area(0, 0, wvs.width, wvs.height); +#endif if (!(show & WVS_NODRAW)) { #ifdef HAVE_LCD_COLOR @@ -1393,7 +1409,6 @@ enum plugin_status plugin_start(struct plugin_api* api, void* parameter) DEBUGF("Could not initialize streams\n"); } else { rb->splash(0, "Loading..."); - init_settings((char*)parameter); err = stream_open((char *)parameter); diff --git a/apps/plugins/mpegplayer/mpegplayer.h b/apps/plugins/mpegplayer/mpegplayer.h index 4ebf321fce..01ab9bdad6 100644 --- a/apps/plugins/mpegplayer/mpegplayer.h +++ b/apps/plugins/mpegplayer/mpegplayer.h @@ -80,11 +80,8 @@ enum mpeg_malloc_reason_t #define lcd_(fn) rb->lcd_##fn #define lcd_splash splash -#define GRAY_FLUSH_ICACHE() -#define GRAY_INVALIDATE_ICACHE() -#define GRAY_VIDEO_FLUSH_ICACHE() -#define GRAY_VIDEO_INVALIDATE_ICACHE() #else + #include "grey.h" #define DRAW_BLACK GREY_BLACK #define DRAW_DARKGRAY GREY_DARKGRAY @@ -92,6 +89,7 @@ enum mpeg_malloc_reason_t #define DRAW_WHITE GREY_WHITE #define lcd_(fn) grey_##fn +#if defined(CPU_PP) && NUM_CORES > 1 #define GRAY_FLUSH_ICACHE() \ IF_COP(flush_icache()) #define GRAY_INVALIDATE_ICACHE() \ @@ -100,11 +98,18 @@ enum mpeg_malloc_reason_t IF_COP(parser_send_video_msg(VIDEO_GRAY_CACHEOP, 0)) #define GRAY_VIDEO_INVALIDATE_ICACHE() \ IF_COP(parser_send_video_msg(VIDEO_GRAY_CACHEOP, 1)) -#if NUM_CORES > 1 + #define GRAY_CACHE_MAINT #endif #endif +#ifndef GRAY_CACHE_MAINT +#define GRAY_FLUSH_ICACHE() +#define GRAY_INVALIDATE_ICACHE() +#define GRAY_VIDEO_FLUSH_ICACHE() +#define GRAY_VIDEO_INVALIDATE_ICACHE() +#endif + #include "mpeg2.h" #include "video_out.h" #include "mpeg_stream.h" diff --git a/apps/plugins/mpegplayer/stream_mgr.c b/apps/plugins/mpegplayer/stream_mgr.c index dbc8ce9427..096ac4b0f9 100644 --- a/apps/plugins/mpegplayer/stream_mgr.c +++ b/apps/plugins/mpegplayer/stream_mgr.c @@ -710,75 +710,13 @@ void stream_vo_set_clip(const struct vo_rect *rc) stream_mgr.parms.rc = *rc; rc = &stream_mgr.parms.rc; } -#ifndef HAVE_LCD_COLOR - else - { - vo_rect_set_ext(&stream_mgr.parms.rc, 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT); - rc = &stream_mgr.parms.rc; - } -#endif parser_send_video_msg(VIDEO_SET_CLIP_RECT, (intptr_t)rc); -#ifndef HAVE_LCD_COLOR - stream_set_gray_rect(rc); -#endif - stream_mgr_unlock(); } #ifndef HAVE_LCD_COLOR -/* Set the rectangle for the gray video overlay - clipped to screen */ -bool stream_set_gray_rect(const struct vo_rect *rc) -{ - bool retval = false; - struct vo_rect rc_gray; - - stream_mgr_lock(); - - vo_rect_set_ext(&rc_gray, 0, 0, LCD_WIDTH, LCD_HEIGHT); - - if (vo_rect_intersect(&rc_gray, &rc_gray, rc)) - { - bool vis = parser_send_video_msg(VIDEO_DISPLAY_SHOW, false); - - /* The impudence! Keeps the image from disappearing anyway. */ -#ifdef SIMULATOR - rb->sim_lcd_ex_init(0, NULL); -#else - rb->timer_unregister(); -#endif - GRAY_VIDEO_INVALIDATE_ICACHE(); - GRAY_INVALIDATE_ICACHE(); - - vo_lock(); - - grey_init(rb, stream_mgr.graymem, stream_mgr.graysize, false, - rc_gray.r - rc_gray.l, rc_gray.b - rc_gray.t, NULL); - - grey_set_position(rc_gray.l, rc_gray.t); - - vo_unlock(); - - GRAY_INVALIDATE_ICACHE(); - - if (stream_mgr.status != STREAM_PLAYING) - parser_send_video_msg(VIDEO_PRINT_FRAME, true); - - GRAY_VIDEO_FLUSH_ICACHE(); - - if (vis) - { - grey_show(true); - parser_send_video_msg(VIDEO_DISPLAY_SHOW, true); - } - } - - stream_mgr_unlock(); - - return retval; -} - /* Show/hide the gray video overlay (independently of vo visibility). */ void stream_gray_show(bool show) { @@ -793,6 +731,29 @@ void stream_gray_show(bool show) stream_mgr_unlock(); } + +#ifdef GRAY_CACHE_MAINT +void stream_gray_pause(bool pause) +{ + static bool gray_paused = false; + + if (pause && !gray_paused) + { + if (_grey_info.flags & _GREY_RUNNING) + { + rb->timer_unregister(); + _grey_info.flags &= ~_GREY_RUNNING; + gray_paused = true; + } + } + else if (!pause && gray_paused) + { + gray_paused = false; + grey_show(true); + } +} +#endif + #endif /* Display a thumbnail at the last seek point */ @@ -805,14 +766,10 @@ bool stream_display_thumb(const struct vo_rect *rc) stream_mgr_lock(); - GRAY_INVALIDATE_ICACHE(); - stream_mgr.parms.rc = *rc; retval = parser_send_video_msg(VIDEO_PRINT_THUMBNAIL, (intptr_t)&stream_mgr.parms.rc); - GRAY_VIDEO_FLUSH_ICACHE(); - stream_mgr_unlock(); return retval; @@ -823,12 +780,8 @@ bool stream_draw_frame(bool no_prepare) bool retval; stream_mgr_lock(); - GRAY_INVALIDATE_ICACHE(); - retval = parser_send_video_msg(VIDEO_PRINT_FRAME, no_prepare); - GRAY_VIDEO_FLUSH_ICACHE(); - stream_mgr_unlock(); return retval; @@ -1055,26 +1008,27 @@ int stream_init(void) /* Initialize non-allocator blocks first */ #ifndef HAVE_LCD_COLOR bool success; + long graysize; /* This can run on another processor - align data */ memsize = CACHEALIGN_BUFFER(&mem, memsize); - stream_mgr.graymem = mem; - success = grey_init(rb, mem, memsize, false, LCD_WIDTH, - LCD_HEIGHT, &stream_mgr.graysize); + success = grey_init(rb, mem, memsize, true, LCD_WIDTH, + LCD_HEIGHT, &graysize); /* This can run on another processor - align size */ - stream_mgr.graysize = CACHEALIGN_UP(stream_mgr.graysize); + graysize = CACHEALIGN_UP(graysize); - mem += stream_mgr.graysize; - memsize -= stream_mgr.graysize; + mem += graysize; + memsize -= graysize; if (!success || (ssize_t)memsize <= 0) { rb->splash(HZ, "greylib init failed!"); - stream_mgr.graymem = NULL; return STREAM_ERROR; } + + grey_clear_display(); #endif /* !HAVE_LCD_COLOR */ stream_mgr.thread = rb->create_thread(stream_mgr_thread, @@ -1144,7 +1098,6 @@ void stream_exit(void) } #ifndef HAVE_LCD_COLOR - if (stream_mgr.graymem != NULL) - grey_release(); + grey_release(); #endif } diff --git a/apps/plugins/mpegplayer/stream_mgr.h b/apps/plugins/mpegplayer/stream_mgr.h index dd5d8cabec..b2aa90967e 100644 --- a/apps/plugins/mpegplayer/stream_mgr.h +++ b/apps/plugins/mpegplayer/stream_mgr.h @@ -37,10 +37,6 @@ struct stream_mgr struct list_item actl; /* List of active streams */ struct mutex str_mtx; /* Main stream manager mutex */ struct mutex actl_mtx; /* Lock for current-streams list */ -#ifndef HAVE_LCD_COLOR - void *graymem; - size_t graysize; -#endif union /* A place for reusable non-cacheable parameters */ { struct vo_rect rc; @@ -109,9 +105,10 @@ bool stream_show_vo(bool show); void stream_vo_set_clip(const struct vo_rect *rc); #ifndef HAVE_LCD_COLOR -/* Set the gray overlay rectangle */ -bool stream_set_gray_rect(const struct vo_rect *rc); void stream_gray_show(bool show); +#ifdef GRAY_CACHE_MAINT +void stream_gray_pause(bool pause); +#endif #endif /* Display thumbnail of the current seekpoint */ diff --git a/apps/plugins/mpegplayer/video_out.h b/apps/plugins/mpegplayer/video_out.h index ed8c4c5907..0b521b40b3 100644 --- a/apps/plugins/mpegplayer/video_out.h +++ b/apps/plugins/mpegplayer/video_out.h @@ -57,7 +57,7 @@ void vo_set_clip_rect(const struct vo_rect *rc); void vo_dimensions(struct vo_ext *sz); void vo_cleanup (void); -#if NUM_CORES > 1 || !defined (HAVE_LCD_COLOR) +#if NUM_CORES > 1 void vo_lock(void); void vo_unlock(void); #else diff --git a/apps/plugins/mpegplayer/video_out_rockbox.c b/apps/plugins/mpegplayer/video_out_rockbox.c index 12431bef4a..5a479858f1 100644 --- a/apps/plugins/mpegplayer/video_out_rockbox.c +++ b/apps/plugins/mpegplayer/video_out_rockbox.c @@ -503,21 +503,14 @@ void vo_set_clip_rect(const struct vo_rect *rc) vo.output_height = rc_out.b - rc_out.t; } -#if NUM_CORES > 1 || !defined (HAVE_LCD_COLOR) +#if NUM_CORES > 1 void vo_lock(void) { -/* TODO: evaluate synchronization with graylib in the sim */ -#if !defined(HAVE_LCD_COLOR) && !defined(SIMULATOR) - set_irq_level(HIGHEST_IRQ_LEVEL); -#endif video_lock(); } void vo_unlock(void) { video_unlock(); -#if !defined(HAVE_LCD_COLOR) && !defined(SIMULATOR) - set_irq_level(0); -#endif } #endif diff --git a/apps/plugins/mpegplayer/video_thread.c b/apps/plugins/mpegplayer/video_thread.c index 6a54706942..4fc428d522 100644 --- a/apps/plugins/mpegplayer/video_thread.c +++ b/apps/plugins/mpegplayer/video_thread.c @@ -72,10 +72,10 @@ static void draw_fps(struct video_thread_data *td) rb->snprintf(str, sizeof(str), "%d.%02d %d %d ", fps / 100, fps % 100, td->num_skipped, td->info->display_picture->temporal_reference); - rb->lcd_putsxy(0, 0, str); + lcd_(putsxy)(0, 0, str); vo_lock(); - rb->lcd_update_rect(0, 0, LCD_WIDTH, 8); + lcd_(update_rect)(0, 0, LCD_WIDTH, 8); vo_unlock(); td->last_showfps = *rb->current_tick; @@ -489,7 +489,7 @@ static void video_thread_msg(struct video_thread_data *td) case STREAM_STOP: if (td->state == TSTATE_DATA) - stream_clear_notify(&audio_str, DISK_BUF_DATA_NOTIFY); + stream_clear_notify(&video_str, DISK_BUF_DATA_NOTIFY); td->status = STREAM_STOPPED; td->state = TSTATE_EOS; @@ -522,14 +522,12 @@ static void video_thread_msg(struct video_thread_data *td) rb->lcd_update(); vo_unlock(); } -#else - GRAY_FLUSH_ICACHE(); #endif break; case STREAM_RESET: if (td->state == TSTATE_DATA) - stream_clear_notify(&audio_str, DISK_BUF_DATA_NOTIFY); + stream_clear_notify(&video_str, DISK_BUF_DATA_NOTIFY); td->state = TSTATE_INIT; td->status = STREAM_STOPPED;