]> git.vomp.tv Git - vompclient.git/commitdiff
OSDOpenVG: Render on demand: Fix backing out of a view render race
authorChris Tallon <chris@vomp.tv>
Sat, 23 May 2020 15:02:45 +0000 (16:02 +0100)
committerChris Tallon <chris@vomp.tv>
Sat, 23 May 2020 15:02:45 +0000 (16:02 +0100)
boxstack.cc
boxstack.h
osd.h
osdopenvg.cc
osdopenvg.h
osdvector.cc
surfacevector.cc

index dcb1258254ebee5ce108455b7723b028bddbf76b..1bfad7a06b9ca7406d38ae7fe569de3efc86c384 100644 (file)
@@ -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;
index 9f96de683fce3c134c24966a0f24344512756a6f..f9a492e33658d352544e1bdb7b1509e436bc4b6c 100644 (file)
@@ -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 dfe696cc65d5621e1443c1133a470b2b52aa5609..804d571b83f35c59cace16439f4a56ceedadfd25 100644 (file)
--- 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;
index b5a7c03e0f9509b2b0e1d402ba487b1b33a69955..7779fd0c26e60ab99f9dd4f6c8e359c5c6a6e4e7 100644 (file)
@@ -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();
index 43645ca273a78a782a096aafb3a4ec182c147263..4588c9565c81cb4103358b31a188f4f3bf2e2a9a 100644 (file)
@@ -106,7 +106,7 @@ class OsdOpenVG : public OsdVector
   protected:
 
     // OSDOVG-ROD-EXPERIMENT
-    void nudgeRenderThread();
+    void doRender();
 
     /*osd vector implementation*/
     void destroyImageRef(ImageIndex index);
index 88f536bdadf2cd4d71da0038c88e2fc928d83f30..cf938fe111d4ce5b9d5698df8f0caff245ca9878 100644 (file)
@@ -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<std::mutex> 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();
index cf2f9b0ae1f49ff23de45c39597bc3287553b89c..fd18002f1c69fc77158d6e70bde637c47c2319d9 100644 (file)
@@ -32,6 +32,7 @@ SurfaceVector::SurfaceVector(OsdVector* vosd)
 
 SurfaceVector::~SurfaceVector()
 {
+
   osd->removeSurface(this);
 
   for (SVGCommand& command : commands)