From 6dd47822545bf27f69a18a2d0ccc8abf91daa8d5 Mon Sep 17 00:00:00 2001 From: Thomas Geymayer Date: Tue, 25 Sep 2012 23:06:27 +0200 Subject: [PATCH] Canvas: Proper fix for OpenVG init handling. - 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 | 16 ++++++---------- src/Canvas/canvas_fwd.hpp | 2 ++ src/Canvas/elements/path.cxx | 6 +++++- 3 files changed, 13 insertions(+), 11 deletions(-) diff --git a/src/Canvas/canvas.cxx b/src/Canvas/canvas.cxx index d0f4b9567..2efe42638 100644 --- a/src/Canvas/canvas.cxx +++ b/src/Canvas/canvas.cxx @@ -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: diff --git a/src/Canvas/canvas_fwd.hpp b/src/Canvas/canvas_fwd.hpp index 56b40fcb2..004fb253b 100644 --- a/src/Canvas/canvas_fwd.hpp +++ b/src/Canvas/canvas_fwd.hpp @@ -36,6 +36,8 @@ typedef boost::weak_ptr PropertyBasedElementWeakPtr; namespace canvas { + const std::string VG_INIT_SIGNAL = "/sim/signals/vg-initialized-frame"; + class Group; class Image; class MouseEvent; diff --git a/src/Canvas/elements/path.cxx b/src/Canvas/elements/path.cxx index 31cc52d27..65031cfd2 100644 --- a/src/Canvas/elements/path.cxx +++ b/src/Canvas/elements/path.cxx @@ -17,6 +17,7 @@ // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. #include "path.hxx" +#include #include #include
@@ -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; }