From 2fb8076ad68300a4def603166a6eea76c1ec3762 Mon Sep 17 00:00:00 2001 From: Marten Richter Date: Sat, 4 Apr 2015 14:27:53 +0200 Subject: [PATCH] Improved background color/gradient handling and radio recording menu --- command.cc | 6 ++++++ osdopenvg.cc | 48 +++++++++++++++++++++++++++++++----------------- osdopenvg.h | 2 ++ osdvector.h | 3 ++- recording.cc | 1 - vradiorec.cc | 8 +++++--- vradiorec.h | 1 + vvideolivetv.cc | 18 ++++++++++++++++++ vvideorec.cc | 12 ++++++++++++ 9 files changed, 77 insertions(+), 22 deletions(-) diff --git a/command.cc b/command.cc index 24cd815..121c11f 100644 --- a/command.cc +++ b/command.cc @@ -181,6 +181,12 @@ void Command::doWallpaper() boxstack->add(wallpaper); boxstack->update(wallpaper); + OsdVector* osdv=dynamic_cast(Osd::getInstance()); + if (osdv) + { + osdv->updateBackgroundColor(DrawStyle::WALLPAPER); + } + } diff --git a/osdopenvg.cc b/osdopenvg.cc index 584d337..f034b14 100644 --- a/osdopenvg.cc +++ b/osdopenvg.cc @@ -58,6 +58,8 @@ OsdOpenVG::OsdOpenVG() mode=0; aspect_correction=1.; + bcm_backres=NULL; + freetype_inited=false; wait_id=1; const char *fontname="Droid Sans:style=Regular"; @@ -192,23 +194,11 @@ int OsdOpenVG::init(void* device) uint32_t back_image_ptr; bcm_backres=vc_dispmanx_resource_create(VC_IMAGE_RGBX32,16,16,&back_image_ptr); - unsigned int color[16*16]; - DrawStyle bg=DrawStyle::WALLPAPER; - if (bg.ft!=DrawStyle::GradientLinear) { - bg.grad_col[0]=bg; - } - //memset(color,0xFF,sizeof(unsigned int)*4*8); - for (int j=0;j<16;j++) { - int helpr=(((15-j)*bg.red)+(j*bg.grad_col[0].red))/15; - int helpb=(((15-j)*bg.blue)+(j*bg.grad_col[0].blue))/15; - int helpg=(((15-j)*bg.green)+(j*bg.grad_col[0].green))/15; - //unsigned int cur_col=help | (help<< 8) | (help<< 16) | (0xFF<< 24); - unsigned int cur_col=helpr | (helpg<< (8)) | (helpb<< (16)) | (0xFF<< (24)); - for (int i=0;i<16;i++) { - color[i+16*j]=cur_col; - } - } - vc_dispmanx_resource_write_data(bcm_backres,VC_IMAGE_RGBX32,16*4,color,&src_rect_im); + + + updateBackgroundColor(DrawStyle::WALLPAPER); + + DISPMANX_UPDATE_HANDLE_T bcm_update; bcm_display=vc_dispmanx_display_open(0); @@ -333,6 +323,29 @@ int OsdOpenVG::init(void* device) return 1; } +void OsdOpenVG::updateBackgroundColor(DrawStyle bg) +{ + unsigned int color[16*16]; + if (!bcm_backres) return; + VC_RECT_T src_rect_im={0,0,16,16}; + + if (bg.ft!=DrawStyle::GradientLinear) { + bg.grad_col[0]=bg; + } + //memset(color,0xFF,sizeof(unsigned int)*4*8); + for (int j=0;j<16;j++) { + int helpr=(((15-j)*bg.red)+(j*bg.grad_col[0].red))/15; + int helpb=(((15-j)*bg.blue)+(j*bg.grad_col[0].blue))/15; + int helpg=(((15-j)*bg.green)+(j*bg.grad_col[0].green))/15; + //unsigned int cur_col=help | (help<< 8) | (help<< 16) | (0xFF<< 24); + unsigned int cur_col=helpr | (helpg<< (8)) | (helpb<< (16)) | (0xFF<< (24)); + for (int i=0;i<16;i++) { + color[i+16*j]=cur_col; + } + } + vc_dispmanx_resource_write_data(bcm_backres,VC_IMAGE_RGBX32,16*4,color,&src_rect_im); +} + void OsdOpenVG::getScreenSize(int &width, int &height) { width=BACKBUFFER_WIDTH; @@ -524,6 +537,7 @@ int OsdOpenVG::shutdown() vc_dispmanx_element_remove(bcm_update,bcm_background); vc_dispmanx_update_submit_sync(bcm_update); vc_dispmanx_resource_delete(bcm_backres); + bcm_backres=NULL; vc_dispmanx_display_close(bcm_display); diff --git a/osdopenvg.h b/osdopenvg.h index 2367cbe..77d75cb 100644 --- a/osdopenvg.h +++ b/osdopenvg.h @@ -102,6 +102,8 @@ class OsdOpenVG : public OsdVector, public Thread_TYPE, public EGLPictureCreator bool getEGLPicture(struct OsdVector::PictureInfo & info, EGLDisplay * display); + void updateBackgroundColor(DrawStyle bg); + protected: diff --git a/osdvector.h b/osdvector.h index 5bb45de..41935b2 100644 --- a/osdvector.h +++ b/osdvector.h @@ -220,6 +220,7 @@ class OsdVector : public Osd Surface * createNewSurface(); void Blank(); + virtual void updateBackgroundColor(DrawStyle bg) {}; void updateOrAddSurface(const SurfaceVector *surf,float x,float y,float height,float width, std::vector& commands); @@ -415,4 +416,4 @@ protected: -#endif \ No newline at end of file +#endif diff --git a/recording.cc b/recording.cc index 83e8ee3..374f3ff 100644 --- a/recording.cc +++ b/recording.cc @@ -128,7 +128,6 @@ void Recording::loadRecInfo() seriesInfo = NULL; movieID = 0; seriesID =0; - vdr->getScraperEventType(fileName, movieID, seriesID, episodeID); Log::getInstance()->log("Recording", Log::DEBUG, "Got Scraper EventType %d %d %d", movieID, seriesID, episodeID); diff --git a/vradiorec.cc b/vradiorec.cc index 5575b63..04f2cc3 100644 --- a/vradiorec.cc +++ b/vradiorec.cc @@ -75,6 +75,8 @@ VRadioRec::VRadioRec(Recording* rec) setSize(video->getScreenWidth(), video->getScreenHeight()); createBuffer(); + transparent.set(0, 0, 0, 0); + setBackgroundColour(transparent); setPosition(0, 0); barRegion.x = 0; @@ -88,7 +90,7 @@ VRadioRec::VRadioRec(Recording* rec) clocksRegion.h = getFontHeight(); - barBlue.set(0, 0, 150, 150); + barBlue.set(0, 0, 0, 128); barShowing = false; } @@ -112,7 +114,7 @@ VRadioRec::~VRadioRec() void VRadioRec::draw() { - fillColour(DrawStyle::BLACK); + fillColour(transparent); } void VRadioRec::go() @@ -541,7 +543,7 @@ void VRadioRec::removeBar() if (!barShowing) return; timers->cancelTimer(this, 2); barShowing = false; - rectangle(barRegion, DrawStyle::BLACK); + rectangle(barRegion, transparent); boxstack->update(this, &barRegion); } diff --git a/vradiorec.h b/vradiorec.h index 70bf3ec..543fb08 100644 --- a/vradiorec.h +++ b/vradiorec.h @@ -59,6 +59,7 @@ class VRadioRec : public Boxx, public TimerReceiver BoxStack* boxstack; DrawStyle barBlue; + DrawStyle transparent; bool playing; bool barShowing; diff --git a/vvideolivetv.cc b/vvideolivetv.cc index 552c853..d140d24 100644 --- a/vvideolivetv.cc +++ b/vvideolivetv.cc @@ -305,6 +305,11 @@ VVideoLiveTV::~VVideoLiveTV() delete player; video->setDefaultAspect(); delData(); + OsdVector* osdv=dynamic_cast(Osd::getInstance()); + if (osdv) + { + osdv->updateBackgroundColor(DrawStyle::WALLPAPER); + } } void VVideoLiveTV::delData() @@ -1140,6 +1145,12 @@ void VVideoLiveTV::processMessage(Message* m) } #endif + OsdVector* osdv=dynamic_cast(Osd::getInstance()); + if (osdv) + { + osdv->updateBackgroundColor(DrawStyle::BLACK); + } + sAspectRatio.nextSymbol = WSymbol::VIDEOASPECT43; sAspectRatio.setVisible(true); @@ -1166,6 +1177,13 @@ void VVideoLiveTV::processMessage(Message* m) sAspectRatio.nextSymbol = WSymbol::VIDEOASPECT169; sAspectRatio.setVisible(true); + OsdVector* osdv=dynamic_cast(Osd::getInstance()); + if (osdv) + { + osdv->updateBackgroundColor(DrawStyle::WALLPAPER); + } + + if (osd.getVisible()) // don't wake up the whole osd just for a aspect change { osd.draw(); diff --git a/vvideorec.cc b/vvideorec.cc index 3cc7c9d..8fca589 100644 --- a/vvideorec.cc +++ b/vvideorec.cc @@ -93,6 +93,12 @@ VVideoRec::VVideoRec(Recording* rec, bool ish264) transparent.set(0, 0, 0, 0); setBackgroundColour(transparent); + OsdVector* osdv=dynamic_cast(Osd::getInstance()); + if (osdv) + { + osdv->updateBackgroundColor(DrawStyle::BLACK); + } + barRegion.x = 0; barRegion.y = video->getScreenHeight() - 58; // FIXME, need to be - 1? and below? barRegion.w = video->getScreenWidth(); @@ -167,6 +173,12 @@ VVideoRec::~VVideoRec() myRec->dropRecInfo(); // FIXME - do this properly - save the resume point back to the server manually and update // rec->recInfo->resumePoint - this will fix the ~10s offset problem as well + + OsdVector* osdv=dynamic_cast(Osd::getInstance()); + if (osdv) + { + osdv->updateBackgroundColor(DrawStyle::WALLPAPER); + } } void VVideoRec::go(bool resume) -- 2.39.2