From 42f66842fd2e2239706c38d354e7a0bed382ef66 Mon Sep 17 00:00:00 2001 From: Chris Tallon Date: Mon, 11 May 2020 21:59:38 +0100 Subject: [PATCH] Remove some dead code, rename some things Remove all Osd::getFD() functions Rename struct SurfaceCommands to SurfaceInfo Rename OsdVector::scommands to surfaces Rename OsdVector::dereferenceSVGCommand to decrementAllRefCounts Rename OsdVector::referenceSVGCommand to incrementAllRefCounts --- osd.h | 2 -- osddirectfb.cc | 6 ---- osddirectfb.h | 2 -- osdopengl.cc | 6 ---- osdopengl.h | 2 -- osdopenvg.cc | 5 ++-- osdopenvg.h | 2 +- osdvector.cc | 78 +++++++++++++++---------------------------------- osdvector.h | 15 ++++------ osdwinpixel.cc | 6 ---- osdwinpixel.h | 2 -- osdwinvector.cc | 2 +- osdwinvector.h | 2 +- 13 files changed, 33 insertions(+), 97 deletions(-) diff --git a/osd.h b/osd.h index 89db75e..003a33d 100644 --- a/osd.h +++ b/osd.h @@ -39,8 +39,6 @@ class Osd bool isInitted() { return initted; }; - virtual int getFD()=0; - virtual void screenShot(const char* fileName)=0; virtual int getFontNames(const char*** /* names */,const char*** /* names_keys */) { return 0; }; diff --git a/osddirectfb.cc b/osddirectfb.cc index d7980c8..923318c 100644 --- a/osddirectfb.cc +++ b/osddirectfb.cc @@ -39,12 +39,6 @@ OsdDirectFB::~OsdDirectFB() if (initted) shutdown(); } -int OsdDirectFB::getFD() -{ - if (!initted) return 0; - return 0; -} - int OsdDirectFB::init() { diff --git a/osddirectfb.h b/osddirectfb.h index dcdafed..48caf70 100644 --- a/osddirectfb.h +++ b/osddirectfb.h @@ -42,8 +42,6 @@ class OsdDirectFB : public Osd int init(); int shutdown(); - int getFD(); - void screenShot(char* fileName); IDirectFB* getDfb() {return dfb;}; diff --git a/osdopengl.cc b/osdopengl.cc index 2ad47c5..9f0d9a0 100644 --- a/osdopengl.cc +++ b/osdopengl.cc @@ -59,12 +59,6 @@ OsdOpenGL::~OsdOpenGL() glmutex.unlock(); } -int OsdOpenGL::getFD() -{ - if (!initted) return 0; - return fdOsd; -} - Surface * OsdOpenGL::createNewSurface() { return (Surface*)new SurfaceOpenGL(); } diff --git a/osdopengl.h b/osdopengl.h index 82abbae..867956e 100644 --- a/osdopengl.h +++ b/osdopengl.h @@ -61,8 +61,6 @@ class OsdOpenGL : public Osd, public Thread_TYPE int init(); int shutdown(); - int getFD(); - void screenShot(const char* fileName); Surface * createNewSurface(); diff --git a/osdopenvg.cc b/osdopenvg.cc index 321c214..cc1f7b6 100644 --- a/osdopenvg.cc +++ b/osdopenvg.cc @@ -639,12 +639,11 @@ void OsdOpenVG::threadMethod() return; } - int ts = 0; + int ts; while (true) { ts = 1; - //unsigned int waittime=1; if (initted) { @@ -1053,7 +1052,7 @@ int OsdOpenVG::loadFont(bool newfont) } -void OsdOpenVG::drawSetTrans(SurfaceCommands& sc) +void OsdOpenVG::drawSetTrans(SurfaceInfo& sc) { vgSeti(VG_MATRIX_MODE, VG_MATRIX_PATH_USER_TO_SURFACE); vgLoadIdentity(); diff --git a/osdopenvg.h b/osdopenvg.h index f62c628..a06182e 100644 --- a/osdopenvg.h +++ b/osdopenvg.h @@ -121,7 +121,7 @@ class OsdOpenVG : public OsdVector, public Thread_TYPE VectorHandle createStyleRef(const DrawStyle& c); bool getStaticImageData(unsigned int static_id, UCHAR** userdata, ULONG* length); - void drawSetTrans(SurfaceCommands& sc); + void drawSetTrans(SurfaceInfo& sc); void executeDrawCommand(SVGCommand& command); void initPaths(); diff --git a/osdvector.cc b/osdvector.cc index e1eb845..d4b4ab1 100644 --- a/osdvector.cc +++ b/osdvector.cc @@ -123,17 +123,6 @@ OsdVector::OsdVector() } styles_lastit_valid = styles_ref_lastit_valid = false; - -} - -OsdVector::~OsdVector() -{ -} - - -int OsdVector::getFD() -{ - return 0; } void OsdVector::screenShot(const char* fileName) @@ -186,9 +175,9 @@ int OsdVector::restore() surfaces_mutex.lock(); //Now go through all surfaces and draw them - std::list::iterator curdraw = scommands.begin(); + std::list::iterator curdraw = surfaces.begin(); - while (curdraw != scommands.end()) + while (curdraw != surfaces.end()) { (*curdraw).commands.clear(); (*curdraw).commands.reserve(2048); @@ -217,19 +206,19 @@ int OsdVector::restore() void OsdVector::drawSurfaces() { surfaces_mutex.lock(); - std::list todraw; //First figure out if a surfaces is below another surface - std::list::iterator itty1 = scommands.begin(); + std::list todraw; //First figure out if a surfaces is below another surface + std::list::iterator itty1 = surfaces.begin(); - while (itty1 != scommands.end()) + while (itty1 != surfaces.end()) { - std::list::iterator itty2 = itty1; + std::list::iterator itty2 = itty1; itty2++; bool hidden = false; - while (itty2 != scommands.end()) + while (itty2 != surfaces.end()) { - SurfaceCommands& ref1 = *itty1; - SurfaceCommands& ref2 = *itty2; + SurfaceInfo& ref1 = *itty1; + SurfaceInfo& ref2 = *itty2; if (ref1.x >= ref2.x && ref1.y >= ref2.y && (ref1.x + ref1.w) <= (ref2.x + ref2.w) @@ -253,7 +242,7 @@ void OsdVector::drawSurfaces() int swidth, sheight; getScreenSize(swidth, sheight); //Now go through all surfaces and draw them - std::list::iterator curdraw = todraw.begin(); + std::list::iterator curdraw = todraw.begin(); while (curdraw != todraw.end()) { @@ -298,14 +287,14 @@ void OsdVector::updateOrAddSurface(const SurfaceVector* surf, float x, float y, { surfaces_mutex.lock(); //First determine it is already in our system - std::list::iterator itty = scommands.begin(); + std::list::iterator itty = surfaces.begin(); - while (itty != scommands.end()) + while (itty != surfaces.end()) { if ((*itty).surf == surf) { //decrease the references - dereferenceSVGCommand((*itty).commands); + decrementAllRefCounts((*itty).commands); break; } @@ -313,15 +302,15 @@ void OsdVector::updateOrAddSurface(const SurfaceVector* surf, float x, float y, } // if not insert it - if (itty == scommands.end()) + if (itty == surfaces.end()) { - SurfaceCommands new_sc; + SurfaceInfo new_sc; new_sc.surf = surf; new_sc.x = x; new_sc.y = y; new_sc.w = width; new_sc.h = height; - itty = scommands.insert(itty, new_sc); + itty = surfaces.insert(itty, new_sc); } // update any images loaded in the mean time @@ -351,7 +340,7 @@ void OsdVector::updateOrAddSurface(const SurfaceVector* surf, float x, float y, (*itty).commands.clear(); (*itty).commands = commands; //increase the references - referenceSVGCommand((*itty).commands); + incrementAllRefCounts((*itty).commands); cleanupOrphanedRefs(); surfaces_mutex.unlock(); @@ -361,15 +350,15 @@ void OsdVector::removeSurface(const SurfaceVector* surf) { surfaces_mutex.lock(); //First determine it is already in our system - std::list::iterator itty = scommands.begin(); + std::list::iterator itty = surfaces.begin(); - while (itty != scommands.end()) + while (itty != surfaces.end()) { if ((*itty).surf == surf) { - dereferenceSVGCommand((*itty).commands); + decrementAllRefCounts((*itty).commands); (*itty).commands.clear(); - scommands.erase(itty); + surfaces.erase(itty); break; } @@ -380,7 +369,7 @@ void OsdVector::removeSurface(const SurfaceVector* surf) } -void OsdVector::dereferenceSVGCommand(std::vector& commands ) +void OsdVector::decrementAllRefCounts(std::vector& commands ) { std::vector::iterator sitty = commands.begin(); @@ -400,7 +389,7 @@ void OsdVector::dereferenceSVGCommand(std::vector& commands ) } } -void OsdVector::referenceSVGCommand(std::vector& commands ) +void OsdVector::incrementAllRefCounts(std::vector& commands ) { std::vector::iterator sitty = commands.begin(); @@ -712,27 +701,6 @@ VectorHandle OsdVector::getStyleRef(const DrawStyle& c) return style_handle; } - - -int OsdVector::getStyleRef(VectorHandle index) -{ - if (!styles_ref_lastit_valid || (*styles_ref_lastit).first != index) - { - styles_ref_lastit_valid = false; - styles_ref_lastit = styles_ref.find(index); - } - - if (styles_ref_lastit == styles_ref.end()) - { - return -1; - } - else - { - styles_ref_lastit_valid = true; - return (*styles_ref_lastit).second; - } -} - LoadIndex OsdVector::getTVMediaRef(TVMediaInfo& tvmedia, ImageIndex& image) { ImageIndex image_handle = 0; diff --git a/osdvector.h b/osdvector.h index 7d4585b..73962d4 100644 --- a/osdvector.h +++ b/osdvector.h @@ -204,7 +204,7 @@ class SVGCommand class SurfaceVector; class VDR_ResponsePacket; -struct SurfaceCommands +struct SurfaceInfo { const SurfaceVector* surf; std::vector commands; @@ -216,13 +216,9 @@ class OsdVector : public Osd { public: OsdVector(); - virtual ~OsdVector(); - int restore(); - int getFD(); - void screenShot(const char* fileName); virtual bool screenShot(void* buffer, int width, int height, bool osd /*include osd*/) = 0; @@ -390,7 +386,6 @@ class OsdVector : public Osd void incStyleRef(VectorHandle index); - int getStyleRef(VectorHandle index); virtual void destroyStyleRef(VectorHandle index) = 0; @@ -403,17 +398,17 @@ class OsdVector : public Osd virtual VectorHandle createStyleRef(const DrawStyle& c) = 0; - void dereferenceSVGCommand(std::vector& commands ); - void referenceSVGCommand(std::vector& commands ); + void decrementAllRefCounts(std::vector& commands ); + void incrementAllRefCounts(std::vector& commands ); void cleanupOrphanedRefs(); - virtual void drawSetTrans(SurfaceCommands& sc) = 0; + virtual void drawSetTrans(SurfaceInfo& sc) = 0; virtual void executeDrawCommand(SVGCommand& command) = 0; - std::list scommands; + std::list surfaces; std::mutex surfaces_mutex; diff --git a/osdwinpixel.cc b/osdwinpixel.cc index 2b69778..e4cc117 100644 --- a/osdwinpixel.cc +++ b/osdwinpixel.cc @@ -48,12 +48,6 @@ OsdWinPixel::~OsdWinPixel() } } -int OsdWinPixel::getFD() -{ - if (!initted) return 0; - return fdOsd; -} - Surface * OsdWinPixel::createNewSurface(){ return (Surface*)new SurfaceWin(); } diff --git a/osdwinpixel.h b/osdwinpixel.h index 8ad2cc6..caf3321 100644 --- a/osdwinpixel.h +++ b/osdwinpixel.h @@ -41,8 +41,6 @@ class OsdWinPixel : public Osd, public WindowsOsd bool isInitialized() { return initted; } - int getFD(); - void screenShot(const char* fileName); Surface * createNewSurface(); diff --git a/osdwinvector.cc b/osdwinvector.cc index 9839817..64bcd39 100644 --- a/osdwinvector.cc +++ b/osdwinvector.cc @@ -810,7 +810,7 @@ void OsdWinVector::setFont(const char * fontname) { -void OsdWinVector::drawSetTrans(SurfaceCommands & sc) +void OsdWinVector::drawSetTrans(SurfaceInfo & sc) { D2D1::Matrix3x2F trans = D2D1::Matrix3x2F::Identity(); diff --git a/osdwinvector.h b/osdwinvector.h index 923882a..e56622d 100644 --- a/osdwinvector.h +++ b/osdwinvector.h @@ -106,7 +106,7 @@ protected: void executeDrawCommand(SVGCommand & command); - void drawSetTrans(SurfaceCommands & sc); + void drawSetTrans(SurfaceInfo & sc); typedef struct { LPDIRECT3DTEXTURE9 surf9; -- 2.39.5