]> git.vomp.tv Git - vompclient.git/commitdiff
Bug fix: Don't inc/dec ref counts for invalid VectorHandles
authorChris Tallon <chris@vomp.tv>
Fri, 15 May 2020 22:33:24 +0000 (23:33 +0100)
committerChris Tallon <chris@vomp.tv>
Fri, 15 May 2020 22:33:24 +0000 (23:33 +0100)
osdopenvg.cc
osdvector.cc
osdvector.h
surfacevector.cc

index 757704b393d64e2eb41c84e596629deb5cf986e0..4fdb27f3950c39d3f3bed479ff1e1fbb06233f15 100644 (file)
@@ -651,6 +651,10 @@ void OsdOpenVG::threadMethod()
 
       if ((time1 - lastrendertime) > 200)  //5 fps for OSD updates are enough, avoids tearing
       {
+        #if DEV
+        dumpStyles();
+        #endif
+
         InternalRendering();
         lastrendertime = getTimeMS();
 
index 237f056d127199e170740539fce7d4470619e0eb..9657d8ad85ea5d8ece98fa98a92b5b16369c638c 100644 (file)
@@ -277,6 +277,11 @@ void OsdVector::updateOrAddSurface(const SurfaceVector* surf, float x, float y,
   std::lock_guard<std::mutex> lg(surfaces_mutex);
   SurfacesIterator si;
 
+  #if DEV
+  Log::getInstance()->log("OsdVector", Log::CRAZY, "updateOrAddSurface, surfaces.length %i", surfaces.size());
+  dumpStyles();
+  #endif
+
   // First determine it is already in our system
   for(si = surfaces.begin(); si != surfaces.end(); si++)
   {
@@ -323,6 +328,11 @@ void OsdVector::updateOrAddSurface(const SurfaceVector* surf, float x, float y,
   incrementAllRefCounts(si->commands);
 
   cleanupOrphanedRefs();
+
+  #if DEV
+  Log::getInstance()->log("OsdVector", Log::CRAZY, "After UOAS:");
+  dumpStyles();
+  #endif
 }
 
 void OsdVector::removeSurface(const SurfaceVector* surf)
@@ -344,7 +354,9 @@ void OsdVector::decrementAllRefCounts(std::vector<SVGCommand>& commands)
 {
   for (SVGCommand& command : commands)
   {
-    decrementDrawStyleHandleRefCount(command.getHandle()); // FIXME BUG BUG BUG
+    VectorHandle handle = command.getHandle();
+    if (handle != 0) // command might not have a handle
+      decrementDrawStyleHandleRefCount(handle);
 
     ImageIndex ii = command.getImageIndex();
     if (ii) removeImageRef(ii);
@@ -358,7 +370,9 @@ void OsdVector::incrementAllRefCounts(std::vector<SVGCommand>& commands)
 {
   for (SVGCommand& command : commands)
   {
-    incrementDrawStyleHandleRefCount(command.getHandle()); // FIXME BUG BUG BUG
+    VectorHandle handle = command.getHandle();
+    if (handle != 0) // command might not have a handle
+      incrementDrawStyleHandleRefCount(handle);
 
     ImageIndex ii = command.getImageIndex();
     if (ii) incImageRef(ii);
@@ -608,6 +622,10 @@ VectorHandle OsdVector::getDrawStyleHandle(const DrawStyle& c)
   surfaces_mutex.lock();
   VectorHandle style_handle = 0;
 
+  #if DEV
+  dumpStyles();
+  #endif
+
   if (!drawstyleHandles_lastit_valid || (drawstyleHandles_lastit->first != c))
   {
     drawstyleHandles_lastit_valid = false;
@@ -649,6 +667,24 @@ VectorHandle OsdVector::getDrawStyleHandle(const DrawStyle& c)
   return style_handle;
 }
 
+#if DEV
+void OsdVector::dumpStyles()
+{
+  std::map<DrawStyle, VectorHandle>::iterator i;
+  for(i = drawstyleHandles.begin(); i != drawstyleHandles.end(); i++)
+  {
+    const DrawStyle* test = &(i->first);
+    Log::getInstance()->log("OsdVector", Log::DEBUG, "DumpStyles: %p %i", test , i->second);
+  }
+
+  std::map<VectorHandle, int>::iterator i2;
+  for (i2 = drawstyleHandlesRefCounts.begin(); i2 != drawstyleHandlesRefCounts.end(); i2++)
+  {
+    Log::getInstance()->log("OsdVector", Log::DEBUG, "DumpStylesRef: %i %i", i2->first, i2->second);
+  }
+}
+#endif
+
 LoadIndex OsdVector::getTVMediaRef(TVMediaInfo& tvmedia, ImageIndex& image)
 {
   ImageIndex image_handle = 0;
index 1797c257046c585a619eb044de4f575a8b8321a5..713879e64f81a5b7b746c2c894d1a416f095aeaf 100644 (file)
@@ -385,6 +385,10 @@ class OsdVector : public Osd
     virtual void executeDrawCommand(SVGCommand& command) = 0;
 
     void drawSurfaces();
+
+    #if DEV
+    void dumpStyles();
+    #endif
 };
 
 #endif
index 1dc153e4d3d17d351860c0189e1165ec50b289c0..cf2f9b0ae1f49ff23de45c39597bc3287553b89c 100644 (file)
@@ -56,6 +56,21 @@ float SurfaceVector::getCharWidth(wchar_t c)
   return osd->getCharWidth(c);
 }
 
+/*
+ * By current design it's not permitted to have a surface without the first drawing being to
+ * fill with a background colour. The fillblt calls removeCommands which deletes all the old
+ * commands before the background colour becomes the new first command, then all the rest are
+ * redrawn on top. If you want to change this in future then do this as the first thing in
+ * Boxx::draw():
+ *   surface->clear();
+ * and have this function in here:
+ *   void SurfaceVector::clear()
+ *   {
+ *     removeCommands(0, 0, swidth, sheight);
+ *   }
+ * Or preferably a simpler one that doesn't do all the comparison work.
+*/
+
 int SurfaceVector::drawText(const char* text, int x, int y, const DrawStyle& c)
 {
   return drawText(text, x, y, 0, c);