From afbdced3d82b0dfba32544b855b22171f1c248ba Mon Sep 17 00:00:00 2001 From: Chris Tallon Date: Sat, 23 May 2020 16:02:45 +0100 Subject: [PATCH] OSDOpenVG: Render on demand: Fix backing out of a view render race --- boxstack.cc | 46 +++++++++++++++------------------------------- boxstack.h | 7 ++++--- osd.h | 4 ++-- osdopenvg.cc | 7 ++++--- osdopenvg.h | 2 +- osdvector.cc | 6 +++++- surfacevector.cc | 1 + 7 files changed, 32 insertions(+), 41 deletions(-) diff --git a/boxstack.cc b/boxstack.cc index dcb1258..1bfad7a 100644 --- a/boxstack.cc +++ b/boxstack.cc @@ -29,8 +29,7 @@ BoxStack::BoxStack() { if (instance) return; instance = this; - initted = 0; - numBoxes = 0; + osd = Osd::getInstance(); } BoxStack::~BoxStack() @@ -153,9 +152,15 @@ int BoxStack::remove(Boxx* toDelete) boxLock.lock(); -// Log::getInstance()->log("BoxStack", Log::DEBUG, "Starting deleteBox"); - deleteBox(i); -// Log::getInstance()->log("BoxStack", Log::DEBUG, "Done deleteBox"); + //Log::getInstance()->log("BoxStack", Log::DEBUG, "Starting repaintRevealed loop"); + RegionList rl; + boxSplit(boxes[i]->area, i + 1, numBoxes, 1, rl); + while(!rl.empty()) + { + repaintRevealed(i, rl.front()); + rl.pop_front(); + } + //Log::getInstance()->log("BoxStack", Log::DEBUG, "Done repaintRevealed loop"); // Shift the boxes on top down one --numBoxes; @@ -182,6 +187,9 @@ int BoxStack::remove(Boxx* toDelete) // as this box is not in the stack any more, there is no chance for a second delete Log::getInstance()->log("BoxStack", Log::DEBUG, "remove: going to delete boxx %p, num %d", toDelete, numBoxes); delete toDelete; + + osd->doRender(); + if (display) { Log::getInstance()->log("BoxStack", Log::DEBUG, "setVideoDisplay %d %d %d %d %d %d", display->mode, display->fallbackMode, display->x, display->y, display->width, display->height); @@ -191,32 +199,15 @@ int BoxStack::remove(Boxx* toDelete) return 1; } -///////////////////////////////////////////////////////////////////////////// -// NEW STUFF -///////////////////////////////////////////////////////////////////////////// - -void BoxStack::deleteBox(int z) -{ -// Log::getInstance()->log("BoxStack", Log::DEBUG, "Delete box %i of %i", z, numBoxes); - RegionList rl; - boxSplit(boxes[z]->area, z + 1, numBoxes, 1, rl); - while(!rl.empty()) - { - repaintRevealed(z, rl.front()); - rl.pop_front(); - } -} - void BoxStack::redrawAllBoxes() { boxLock.lock(); for (int z = 0; z < numBoxes; z++) { - boxes[z]->draw(); + boxes[z]->draw(); } - boxLock.unlock(); update(NULL,NULL); // should blt all } @@ -442,13 +433,6 @@ void BoxStack::boxSplit(Region r, int start, int end, int direction, RegionList& } } -///////////////////////////////////////////////////////////////////////////// -// END NEW STUFF -///////////////////////////////////////////////////////////////////////////// - -// ---------------------------------------------------- END OF REMOVE CODE - - void BoxStack::removeAllExceptWallpaper() { // 1.. Don't delete wallpaper. No point. @@ -497,7 +481,7 @@ void BoxStack::removeAllExceptWallpaper() boxLock.unlock(); //AVO: do the delete outside the lock to allow for recursive deletes - Log::getInstance()->log("BoxStack", Log::DEBUG, "going to delete boxx %p, num=%d", toDel, numBoxes); + Log::getInstance()->log("BoxStack", Log::DEBUG, "removeall: going to delete boxx %p, num=%d", toDel, numBoxes); if (display) Video::getInstance()->setVideoDisplay(*display); if (toDel) delete toDel; diff --git a/boxstack.h b/boxstack.h index 9f96de6..f9a492e 100644 --- a/boxstack.h +++ b/boxstack.h @@ -60,16 +60,17 @@ class BoxStack private: static BoxStack* instance; - int initted; + int initted{}; + + Osd* osd{}; Boxx* boxes[20]; - int numBoxes; + int numBoxes{}; VideoDisplayStack videoStack; std::mutex boxLock; - void deleteBox(int z); void repaintRevealed(int x, Region r); void boxSplit(Region r, int start, int end, int direction, RegionList& rl); int addVideoDisplay(Boxx*,VideoDisplay); diff --git a/osd.h b/osd.h index dfe696c..804d571 100644 --- a/osd.h +++ b/osd.h @@ -46,8 +46,8 @@ class Osd virtual float getPixelAspect() { return 1.f; }; - // OSDOVG-ROD-EXPERIMENT - hack to allow OsdVector to call OsdOpenVG::nudge/signal render thread. work out a better way. - virtual void nudgeRenderThread() { }; + // OSDOVG-ROD-EXPERIMENT + virtual void doRender() { }; protected: static Osd* instance; diff --git a/osdopenvg.cc b/osdopenvg.cc index b5a7c03..7779fd0 100644 --- a/osdopenvg.cc +++ b/osdopenvg.cc @@ -413,7 +413,7 @@ int OsdOpenVG::shutdown() } // OSDOVG-ROD-EXPERIMENT - temp hack to allow OsdVector to signal the thread in OsdOpenVG -void OsdOpenVG::nudgeRenderThread() +void OsdOpenVG::doRender() { Log::getInstance()->log("OSD", Log::DEBUG, "Nudge render thread"); @@ -439,8 +439,8 @@ void OsdOpenVG::nudgeRenderThread() * Will tearing show up in on-demand mode? * Moves away from conventional FPS type render loop. VOMP doesn't use 3D GFX / animations * currently, so this doesn't matter at the moment? - * Code needs updating to call nudgeRenderThread, - * e.g. FIXME backing out of the options screen doesn't redraw VWelcome + * Code needs updating to call doRender, + * e.g. backing out of the options screen doesn't redraw VWelcome, fixed now * * Maybe have a hybrid system. One that normally works on-demand but can * also switch to looping on the fly if necessary. @@ -479,6 +479,7 @@ void OsdOpenVG::renderLoop() #if DEV dumpStyles(); #endif + Log::getInstance()->log("OSDOpenVG", Log::CRAZY, "EXPERIMENT - render"); InternalRendering(); lastrendertime = getTimeMS(); diff --git a/osdopenvg.h b/osdopenvg.h index 43645ca..4588c95 100644 --- a/osdopenvg.h +++ b/osdopenvg.h @@ -106,7 +106,7 @@ class OsdOpenVG : public OsdVector protected: // OSDOVG-ROD-EXPERIMENT - void nudgeRenderThread(); + void doRender(); /*osd vector implementation*/ void destroyImageRef(ImageIndex index); diff --git a/osdvector.cc b/osdvector.cc index 88f536b..cf938fe 100644 --- a/osdvector.cc +++ b/osdvector.cc @@ -337,12 +337,14 @@ void OsdVector::updateOrAddSurface(const SurfaceVector* surf, float x, float y, #endif // OSDOVG-ROD-EXPERIMENT - nudgeRenderThread(); + Log::getInstance()->log("OsdVector", Log::CRAZY, "EXPERIMENT - call doRender"); + doRender(); } void OsdVector::removeSurface(const SurfaceVector* surf) { std::lock_guard lg(surfaces_mutex); // FIXME - Can block here on shutdown if a timer is fired just as the wrong time + Log::getInstance()->log("OSDVector-347", Log::CRAZY, "EXPERIMENT - removeSurface"); for (auto i = surfaces.begin(); i != surfaces.end(); i++) { if (i->surface == surf) @@ -870,6 +872,8 @@ ImageIndex OsdVector::getImagePalette(int width, int height, const unsigned char return image_handle; } +/// PictureReader Class + OsdVector::PictureReader::~PictureReader() { decoders_lock.lock(); diff --git a/surfacevector.cc b/surfacevector.cc index cf2f9b0..fd18002 100644 --- a/surfacevector.cc +++ b/surfacevector.cc @@ -32,6 +32,7 @@ SurfaceVector::SurfaceVector(OsdVector* vosd) SurfaceVector::~SurfaceVector() { + osd->removeSurface(this); for (SVGCommand& command : commands) -- 2.39.2