diff Framework/Scene2D/Internals/CompositorHelper.cpp @ 602:03c4b998fcd0

display scene positions in the basic sample
author Sebastien Jodogne <s.jodogne@gmail.com>
date Mon, 29 Apr 2019 14:40:01 +0200
parents 6bf8f881fcb5
children 6e888cf6a48b
line wrap: on
line diff
--- a/Framework/Scene2D/Internals/CompositorHelper.cpp	Sat Apr 27 12:38:25 2019 +0200
+++ b/Framework/Scene2D/Internals/CompositorHelper.cpp	Mon Apr 29 14:40:01 2019 +0200
@@ -32,13 +32,16 @@
     private:
       std::auto_ptr<ILayerRenderer>  renderer_;
       const ISceneLayer&             layer_;
+      uint64_t                       layerIdentifier_;
       uint64_t                       lastRevision_;
 
     public:
       Item(ILayerRenderer* renderer,     // Takes ownership
-           const ISceneLayer& layer) :
+           const ISceneLayer& layer,
+           uint64_t layerIdentifier) :
         renderer_(renderer),
         layer_(layer),
+        layerIdentifier_(layerIdentifier),
         lastRevision_(layer.GetRevision())
       {
         if (renderer == NULL)
@@ -58,6 +61,11 @@
         return layer_;
       }
 
+      uint64_t GetLayerIdentifier() const
+      {
+        return layerIdentifier_;
+      }
+
       uint64_t GetLastRevision() const
       {
         return lastRevision_;
@@ -73,15 +81,19 @@
 
 
     void CompositorHelper::Visit(const ISceneLayer& layer,
+                                 uint64_t layerIdentifier,
                                  int depth)
     {
+      // "Visit()" is only applied to layers existing in the scene
+      assert(scene_.HasLayer(depth)); 
+
       Content::iterator found = content_.find(depth);
 
       assert(found == content_.end() ||
              found->second != NULL);
 
       if (found == content_.end() ||
-          &found->second->GetLayer() != &layer)
+          found->second->GetLayerIdentifier() != layerIdentifier)
       {
         // This is the first time this layer is rendered, or the layer
         // is not the same as before
@@ -96,12 +108,14 @@
         if (renderer.get() != NULL)
         {
           renderer->Render(sceneTransform_);
-          content_[depth] = new Item(renderer.release(), layer);
+          content_[depth] = new Item(renderer.release(), layer, layerIdentifier);
         }
       }
       else
       {
         // This layer has already been rendered
+        assert(found->second->GetLastRevision() <= layer.GetRevision());
+        
         if (found->second->GetLastRevision() < layer.GetRevision())
         {
           found->second->UpdateRenderer();
@@ -112,7 +126,7 @@
 
       // Check invariants
       assert(content_.find(depth) == content_.end() ||
-             (&content_[depth]->GetLayer() == &layer &&
+             (content_[depth]->GetLayerIdentifier() == layerIdentifier &&
               content_[depth]->GetLastRevision() == layer.GetRevision()));
     }