Mercurial > hg > orthanc-stone
comparison 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 |
comparison
equal
deleted
inserted
replaced
600:6129b1e5ba42 | 602:03c4b998fcd0 |
---|---|
30 class CompositorHelper::Item : public boost::noncopyable | 30 class CompositorHelper::Item : public boost::noncopyable |
31 { | 31 { |
32 private: | 32 private: |
33 std::auto_ptr<ILayerRenderer> renderer_; | 33 std::auto_ptr<ILayerRenderer> renderer_; |
34 const ISceneLayer& layer_; | 34 const ISceneLayer& layer_; |
35 uint64_t layerIdentifier_; | |
35 uint64_t lastRevision_; | 36 uint64_t lastRevision_; |
36 | 37 |
37 public: | 38 public: |
38 Item(ILayerRenderer* renderer, // Takes ownership | 39 Item(ILayerRenderer* renderer, // Takes ownership |
39 const ISceneLayer& layer) : | 40 const ISceneLayer& layer, |
41 uint64_t layerIdentifier) : | |
40 renderer_(renderer), | 42 renderer_(renderer), |
41 layer_(layer), | 43 layer_(layer), |
44 layerIdentifier_(layerIdentifier), | |
42 lastRevision_(layer.GetRevision()) | 45 lastRevision_(layer.GetRevision()) |
43 { | 46 { |
44 if (renderer == NULL) | 47 if (renderer == NULL) |
45 { | 48 { |
46 throw Orthanc::OrthancException(Orthanc::ErrorCode_NullPointer); | 49 throw Orthanc::OrthancException(Orthanc::ErrorCode_NullPointer); |
56 const ISceneLayer& GetLayer() const | 59 const ISceneLayer& GetLayer() const |
57 { | 60 { |
58 return layer_; | 61 return layer_; |
59 } | 62 } |
60 | 63 |
64 uint64_t GetLayerIdentifier() const | |
65 { | |
66 return layerIdentifier_; | |
67 } | |
68 | |
61 uint64_t GetLastRevision() const | 69 uint64_t GetLastRevision() const |
62 { | 70 { |
63 return lastRevision_; | 71 return lastRevision_; |
64 } | 72 } |
65 | 73 |
71 } | 79 } |
72 }; | 80 }; |
73 | 81 |
74 | 82 |
75 void CompositorHelper::Visit(const ISceneLayer& layer, | 83 void CompositorHelper::Visit(const ISceneLayer& layer, |
84 uint64_t layerIdentifier, | |
76 int depth) | 85 int depth) |
77 { | 86 { |
87 // "Visit()" is only applied to layers existing in the scene | |
88 assert(scene_.HasLayer(depth)); | |
89 | |
78 Content::iterator found = content_.find(depth); | 90 Content::iterator found = content_.find(depth); |
79 | 91 |
80 assert(found == content_.end() || | 92 assert(found == content_.end() || |
81 found->second != NULL); | 93 found->second != NULL); |
82 | 94 |
83 if (found == content_.end() || | 95 if (found == content_.end() || |
84 &found->second->GetLayer() != &layer) | 96 found->second->GetLayerIdentifier() != layerIdentifier) |
85 { | 97 { |
86 // This is the first time this layer is rendered, or the layer | 98 // This is the first time this layer is rendered, or the layer |
87 // is not the same as before | 99 // is not the same as before |
88 if (found != content_.end()) | 100 if (found != content_.end()) |
89 { | 101 { |
94 std::auto_ptr<ILayerRenderer> renderer(factory_.Create(layer)); | 106 std::auto_ptr<ILayerRenderer> renderer(factory_.Create(layer)); |
95 | 107 |
96 if (renderer.get() != NULL) | 108 if (renderer.get() != NULL) |
97 { | 109 { |
98 renderer->Render(sceneTransform_); | 110 renderer->Render(sceneTransform_); |
99 content_[depth] = new Item(renderer.release(), layer); | 111 content_[depth] = new Item(renderer.release(), layer, layerIdentifier); |
100 } | 112 } |
101 } | 113 } |
102 else | 114 else |
103 { | 115 { |
104 // This layer has already been rendered | 116 // This layer has already been rendered |
117 assert(found->second->GetLastRevision() <= layer.GetRevision()); | |
118 | |
105 if (found->second->GetLastRevision() < layer.GetRevision()) | 119 if (found->second->GetLastRevision() < layer.GetRevision()) |
106 { | 120 { |
107 found->second->UpdateRenderer(); | 121 found->second->UpdateRenderer(); |
108 } | 122 } |
109 | 123 |
110 found->second->GetRenderer().Render(sceneTransform_); | 124 found->second->GetRenderer().Render(sceneTransform_); |
111 } | 125 } |
112 | 126 |
113 // Check invariants | 127 // Check invariants |
114 assert(content_.find(depth) == content_.end() || | 128 assert(content_.find(depth) == content_.end() || |
115 (&content_[depth]->GetLayer() == &layer && | 129 (content_[depth]->GetLayerIdentifier() == layerIdentifier && |
116 content_[depth]->GetLastRevision() == layer.GetRevision())); | 130 content_[depth]->GetLastRevision() == layer.GetRevision())); |
117 } | 131 } |
118 | 132 |
119 | 133 |
120 CompositorHelper::~CompositorHelper() | 134 CompositorHelper::~CompositorHelper() |