]> git.mxchange.org Git - flightgear.git/commitdiff
Canvas: Proper fix for OpenVG init handling.
authorThomas Geymayer <tomgey@gmail.com>
Tue, 25 Sep 2012 21:06:27 +0000 (23:06 +0200)
committerThomas Geymayer <tomgey@gmail.com>
Tue, 25 Sep 2012 21:24:29 +0000 (23:24 +0200)
 - Redraw all canvases in the frame OpenVG is initialized.
   Otherwise if multiple canvases are created in the same frame
   only one of them would get correctly updated.

src/Canvas/canvas.cxx
src/Canvas/canvas_fwd.hpp
src/Canvas/elements/path.cxx

index d0f4b956781694761afba97c319f8c850086dbec..2efe4263812adb92d7e671b6047c662303366b54 100644 (file)
@@ -49,17 +49,13 @@ class Canvas::DrawCallback:
 
     virtual void operator()(osg::RenderInfo& renderInfo) const
     {
-      const std::string VG_SIGNAL = "/sim/signals/vg-initialized";
+      const long frame = renderInfo.getView()->getFrameStamp()
+                                             ->getFrameNumber();
 
-      if( fgGetBool(VG_SIGNAL) )
-      {
-        fgSetBool(VG_SIGNAL, false);
-        // If OpenVG has been initialized we need to redraw the frame, because
-        // initializing has happened instead of rendering
-        _canvas->_render_dirty = true;
-      }
-      else
-        _canvas->_render_dirty = false;
+      // If OpenVG has been initialized we need to redraw the frame, because
+      // initializing has happened instead of rendering.
+      // Otherwise we just reset the _render_dirty flag.
+      _canvas->_render_dirty = (frame == fgGetLong(canvas::VG_INIT_SIGNAL));
     }
 
   protected:
index 56b40fcb25da8bc40bebb4c98f859d10cb2a48b2..004fb253bb8f35c3859b6a884e14baa752a9304a 100644 (file)
@@ -36,6 +36,8 @@ typedef boost::weak_ptr<PropertyBasedElement> PropertyBasedElementWeakPtr;
 
 namespace canvas
 {
+  const std::string VG_INIT_SIGNAL = "/sim/signals/vg-initialized-frame";
+
   class Group;
   class Image;
   class MouseEvent;
index 31cc52d2754c2a2aea30e8d050a04258262279b7..65031cfd264d1f18e1d10b2695bf153b96cf649a 100644 (file)
@@ -17,6 +17,7 @@
 // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
 
 #include "path.hxx"
+#include <Canvas/canvas_fwd.hpp>
 #include <Canvas/property_helper.hxx>
 #include <Main/fg_props.hxx>
 
@@ -170,7 +171,10 @@ namespace canvas
 
           vgCreateContextSH(vp[2], vp[3]);
           _vg_initialized = true;
-          fgSetBool("/sim/signals/vg-initialized", true);
+
+          fgSetInt( canvas::VG_INIT_SIGNAL,
+                    renderInfo.getView()->getFrameStamp()->getFrameNumber() );
+
           return;
         }