comparison Framework/Scene2D/Internals/CompositorHelper.cpp @ 1211:d10d2acb8a02 broker

compositors do not keep a reference to the scene anymore
author Sebastien Jodogne <s.jodogne@gmail.com>
date Wed, 04 Dec 2019 16:47:21 +0100
parents 6009c59d8676
children 0ca50d275b9a
comparison
equal deleted inserted replaced
1210:644baa70373d 1211:d10d2acb8a02
78 lastRevision_ = layer_.GetRevision(); 78 lastRevision_ = layer_.GetRevision();
79 } 79 }
80 }; 80 };
81 81
82 82
83 void CompositorHelper::Visit(const ISceneLayer& layer, 83 void CompositorHelper::Visit(const Scene2D& scene,
84 const ISceneLayer& layer,
84 uint64_t layerIdentifier, 85 uint64_t layerIdentifier,
85 int depth) 86 int depth)
86 { 87 {
87 // "Visit()" is only applied to layers existing in the scene 88 // "Visit()" is only applied to layers existing in the scene
88 assert(scene_.HasLayer(depth)); 89 assert(scene.HasLayer(depth));
89 90
90 Content::iterator found = content_.find(depth); 91 Content::iterator found = content_.find(depth);
91 92
92 assert(found == content_.end() || 93 assert(found == content_.end() ||
93 found->second != NULL); 94 found->second != NULL);
139 delete it->second; 140 delete it->second;
140 } 141 }
141 } 142 }
142 143
143 144
144 void CompositorHelper::Refresh(unsigned int canvasWidth, 145 void CompositorHelper::Refresh(const Scene2D& scene,
146 unsigned int canvasWidth,
145 unsigned int canvasHeight) 147 unsigned int canvasHeight)
146 { 148 {
149 /**
150 * Safeguard mechanism to enforce the fact that the same scene
151 * is always used with the compositor. Note that the safeguard
152 * is not 100% bullet-proof, as a new scene might reuse the same
153 * address as a previous scene.
154 **/
155 if (lastScene_ != NULL &&
156 lastScene_ != &scene)
157 {
158 throw Orthanc::OrthancException(Orthanc::ErrorCode_BadSequenceOfCalls,
159 "ICompositor::ResetScene() should have been called");
160 }
161
162 lastScene_ = &scene;
163
147 // Bring coordinate (0,0) to the center of the canvas 164 // Bring coordinate (0,0) to the center of the canvas
148 AffineTransform2D offset = AffineTransform2D::CreateOffset( 165 AffineTransform2D offset = AffineTransform2D::CreateOffset(
149 static_cast<double>(canvasWidth) / 2.0, 166 static_cast<double>(canvasWidth) / 2.0,
150 static_cast<double>(canvasHeight) / 2.0); 167 static_cast<double>(canvasHeight) / 2.0);
151 168
152 sceneTransform_ = AffineTransform2D::Combine(offset, scene_.GetSceneToCanvasTransform()); 169 sceneTransform_ = AffineTransform2D::Combine(offset, scene.GetSceneToCanvasTransform());
153 canvasWidth_ = canvasWidth; 170 canvasWidth_ = canvasWidth;
154 canvasHeight_ = canvasHeight; 171 canvasHeight_ = canvasHeight;
155 scene_.Apply(*this); 172 scene.Apply(*this);
156 } 173 }
157 } 174 }
158 } 175 }