annotate Framework/Scene2D/Internals/CompositorHelper.cpp @ 1268:9a0a95c0b578

sync
author Sebastien Jodogne <s.jodogne@gmail.com>
date Fri, 31 Jan 2020 17:25:27 +0100
parents 6e888cf6a48b
children 6009c59d8676 2d8ab34c8c91
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
585
b9ce24c606ae TextSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1 /**
b9ce24c606ae TextSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2 * Stone of Orthanc
b9ce24c606ae TextSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3 * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics
b9ce24c606ae TextSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
4 * Department, University Hospital of Liege, Belgium
b9ce24c606ae TextSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
5 * Copyright (C) 2017-2019 Osimis S.A., Belgium
b9ce24c606ae TextSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
6 *
b9ce24c606ae TextSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
7 * This program is free software: you can redistribute it and/or
b9ce24c606ae TextSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
8 * modify it under the terms of the GNU Affero General Public License
b9ce24c606ae TextSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
9 * as published by the Free Software Foundation, either version 3 of
b9ce24c606ae TextSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
10 * the License, or (at your option) any later version.
b9ce24c606ae TextSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
11 *
b9ce24c606ae TextSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
12 * This program is distributed in the hope that it will be useful, but
b9ce24c606ae TextSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
13 * WITHOUT ANY WARRANTY; without even the implied warranty of
b9ce24c606ae TextSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
b9ce24c606ae TextSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
15 * Affero General Public License for more details.
b9ce24c606ae TextSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
16 *
b9ce24c606ae TextSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
17 * You should have received a copy of the GNU Affero General Public License
b9ce24c606ae TextSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
18 * along with this program. If not, see <http://www.gnu.org/licenses/>.
b9ce24c606ae TextSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
19 **/
b9ce24c606ae TextSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
20
b9ce24c606ae TextSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
21
b9ce24c606ae TextSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
22 #include "CompositorHelper.h"
b9ce24c606ae TextSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
23
b9ce24c606ae TextSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
24 #include <Core/OrthancException.h>
b9ce24c606ae TextSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
25
b9ce24c606ae TextSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
26 namespace OrthancStone
b9ce24c606ae TextSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
27 {
593
6bf8f881fcb5 OpenGLBasicPolylineRenderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 585
diff changeset
28 namespace Internals
585
b9ce24c606ae TextSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
29 {
593
6bf8f881fcb5 OpenGLBasicPolylineRenderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 585
diff changeset
30 class CompositorHelper::Item : public boost::noncopyable
6bf8f881fcb5 OpenGLBasicPolylineRenderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 585
diff changeset
31 {
6bf8f881fcb5 OpenGLBasicPolylineRenderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 585
diff changeset
32 private:
6bf8f881fcb5 OpenGLBasicPolylineRenderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 585
diff changeset
33 std::auto_ptr<ILayerRenderer> renderer_;
6bf8f881fcb5 OpenGLBasicPolylineRenderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 585
diff changeset
34 const ISceneLayer& layer_;
602
03c4b998fcd0 display scene positions in the basic sample
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 593
diff changeset
35 uint64_t layerIdentifier_;
593
6bf8f881fcb5 OpenGLBasicPolylineRenderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 585
diff changeset
36 uint64_t lastRevision_;
6bf8f881fcb5 OpenGLBasicPolylineRenderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 585
diff changeset
37
6bf8f881fcb5 OpenGLBasicPolylineRenderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 585
diff changeset
38 public:
6bf8f881fcb5 OpenGLBasicPolylineRenderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 585
diff changeset
39 Item(ILayerRenderer* renderer, // Takes ownership
602
03c4b998fcd0 display scene positions in the basic sample
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 593
diff changeset
40 const ISceneLayer& layer,
03c4b998fcd0 display scene positions in the basic sample
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 593
diff changeset
41 uint64_t layerIdentifier) :
593
6bf8f881fcb5 OpenGLBasicPolylineRenderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 585
diff changeset
42 renderer_(renderer),
6bf8f881fcb5 OpenGLBasicPolylineRenderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 585
diff changeset
43 layer_(layer),
602
03c4b998fcd0 display scene positions in the basic sample
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 593
diff changeset
44 layerIdentifier_(layerIdentifier),
593
6bf8f881fcb5 OpenGLBasicPolylineRenderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 585
diff changeset
45 lastRevision_(layer.GetRevision())
6bf8f881fcb5 OpenGLBasicPolylineRenderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 585
diff changeset
46 {
6bf8f881fcb5 OpenGLBasicPolylineRenderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 585
diff changeset
47 if (renderer == NULL)
6bf8f881fcb5 OpenGLBasicPolylineRenderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 585
diff changeset
48 {
6bf8f881fcb5 OpenGLBasicPolylineRenderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 585
diff changeset
49 throw Orthanc::OrthancException(Orthanc::ErrorCode_NullPointer);
6bf8f881fcb5 OpenGLBasicPolylineRenderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 585
diff changeset
50 }
6bf8f881fcb5 OpenGLBasicPolylineRenderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 585
diff changeset
51 }
6bf8f881fcb5 OpenGLBasicPolylineRenderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 585
diff changeset
52
6bf8f881fcb5 OpenGLBasicPolylineRenderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 585
diff changeset
53 ILayerRenderer& GetRenderer() const
6bf8f881fcb5 OpenGLBasicPolylineRenderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 585
diff changeset
54 {
6bf8f881fcb5 OpenGLBasicPolylineRenderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 585
diff changeset
55 assert(renderer_.get() != NULL);
6bf8f881fcb5 OpenGLBasicPolylineRenderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 585
diff changeset
56 return *renderer_;
6bf8f881fcb5 OpenGLBasicPolylineRenderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 585
diff changeset
57 }
6bf8f881fcb5 OpenGLBasicPolylineRenderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 585
diff changeset
58
6bf8f881fcb5 OpenGLBasicPolylineRenderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 585
diff changeset
59 const ISceneLayer& GetLayer() const
6bf8f881fcb5 OpenGLBasicPolylineRenderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 585
diff changeset
60 {
6bf8f881fcb5 OpenGLBasicPolylineRenderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 585
diff changeset
61 return layer_;
6bf8f881fcb5 OpenGLBasicPolylineRenderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 585
diff changeset
62 }
6bf8f881fcb5 OpenGLBasicPolylineRenderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 585
diff changeset
63
602
03c4b998fcd0 display scene positions in the basic sample
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 593
diff changeset
64 uint64_t GetLayerIdentifier() const
03c4b998fcd0 display scene positions in the basic sample
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 593
diff changeset
65 {
03c4b998fcd0 display scene positions in the basic sample
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 593
diff changeset
66 return layerIdentifier_;
03c4b998fcd0 display scene positions in the basic sample
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 593
diff changeset
67 }
03c4b998fcd0 display scene positions in the basic sample
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 593
diff changeset
68
593
6bf8f881fcb5 OpenGLBasicPolylineRenderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 585
diff changeset
69 uint64_t GetLastRevision() const
6bf8f881fcb5 OpenGLBasicPolylineRenderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 585
diff changeset
70 {
6bf8f881fcb5 OpenGLBasicPolylineRenderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 585
diff changeset
71 return lastRevision_;
6bf8f881fcb5 OpenGLBasicPolylineRenderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 585
diff changeset
72 }
6bf8f881fcb5 OpenGLBasicPolylineRenderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 585
diff changeset
73
6bf8f881fcb5 OpenGLBasicPolylineRenderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 585
diff changeset
74 void UpdateRenderer()
6bf8f881fcb5 OpenGLBasicPolylineRenderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 585
diff changeset
75 {
6bf8f881fcb5 OpenGLBasicPolylineRenderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 585
diff changeset
76 assert(renderer_.get() != NULL);
6bf8f881fcb5 OpenGLBasicPolylineRenderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 585
diff changeset
77 renderer_->Update(layer_);
6bf8f881fcb5 OpenGLBasicPolylineRenderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 585
diff changeset
78 lastRevision_ = layer_.GetRevision();
6bf8f881fcb5 OpenGLBasicPolylineRenderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 585
diff changeset
79 }
6bf8f881fcb5 OpenGLBasicPolylineRenderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 585
diff changeset
80 };
6bf8f881fcb5 OpenGLBasicPolylineRenderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 585
diff changeset
81
585
b9ce24c606ae TextSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
82
593
6bf8f881fcb5 OpenGLBasicPolylineRenderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 585
diff changeset
83 void CompositorHelper::Visit(const ISceneLayer& layer,
602
03c4b998fcd0 display scene positions in the basic sample
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 593
diff changeset
84 uint64_t layerIdentifier,
593
6bf8f881fcb5 OpenGLBasicPolylineRenderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 585
diff changeset
85 int depth)
585
b9ce24c606ae TextSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
86 {
602
03c4b998fcd0 display scene positions in the basic sample
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 593
diff changeset
87 // "Visit()" is only applied to layers existing in the scene
03c4b998fcd0 display scene positions in the basic sample
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 593
diff changeset
88 assert(scene_.HasLayer(depth));
03c4b998fcd0 display scene positions in the basic sample
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 593
diff changeset
89
593
6bf8f881fcb5 OpenGLBasicPolylineRenderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 585
diff changeset
90 Content::iterator found = content_.find(depth);
6bf8f881fcb5 OpenGLBasicPolylineRenderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 585
diff changeset
91
6bf8f881fcb5 OpenGLBasicPolylineRenderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 585
diff changeset
92 assert(found == content_.end() ||
6bf8f881fcb5 OpenGLBasicPolylineRenderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 585
diff changeset
93 found->second != NULL);
6bf8f881fcb5 OpenGLBasicPolylineRenderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 585
diff changeset
94
6bf8f881fcb5 OpenGLBasicPolylineRenderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 585
diff changeset
95 if (found == content_.end() ||
602
03c4b998fcd0 display scene positions in the basic sample
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 593
diff changeset
96 found->second->GetLayerIdentifier() != layerIdentifier)
585
b9ce24c606ae TextSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
97 {
593
6bf8f881fcb5 OpenGLBasicPolylineRenderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 585
diff changeset
98 // This is the first time this layer is rendered, or the layer
6bf8f881fcb5 OpenGLBasicPolylineRenderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 585
diff changeset
99 // is not the same as before
6bf8f881fcb5 OpenGLBasicPolylineRenderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 585
diff changeset
100 if (found != content_.end())
6bf8f881fcb5 OpenGLBasicPolylineRenderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 585
diff changeset
101 {
6bf8f881fcb5 OpenGLBasicPolylineRenderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 585
diff changeset
102 delete found->second;
6bf8f881fcb5 OpenGLBasicPolylineRenderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 585
diff changeset
103 content_.erase(found);
6bf8f881fcb5 OpenGLBasicPolylineRenderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 585
diff changeset
104 }
6bf8f881fcb5 OpenGLBasicPolylineRenderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 585
diff changeset
105
6bf8f881fcb5 OpenGLBasicPolylineRenderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 585
diff changeset
106 std::auto_ptr<ILayerRenderer> renderer(factory_.Create(layer));
6bf8f881fcb5 OpenGLBasicPolylineRenderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 585
diff changeset
107
6bf8f881fcb5 OpenGLBasicPolylineRenderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 585
diff changeset
108 if (renderer.get() != NULL)
6bf8f881fcb5 OpenGLBasicPolylineRenderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 585
diff changeset
109 {
888
6e888cf6a48b renderers now have access to canvas width/height
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 602
diff changeset
110 renderer->Render(sceneTransform_, canvasWidth_, canvasHeight_);
602
03c4b998fcd0 display scene positions in the basic sample
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 593
diff changeset
111 content_[depth] = new Item(renderer.release(), layer, layerIdentifier);
593
6bf8f881fcb5 OpenGLBasicPolylineRenderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 585
diff changeset
112 }
6bf8f881fcb5 OpenGLBasicPolylineRenderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 585
diff changeset
113 }
6bf8f881fcb5 OpenGLBasicPolylineRenderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 585
diff changeset
114 else
6bf8f881fcb5 OpenGLBasicPolylineRenderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 585
diff changeset
115 {
6bf8f881fcb5 OpenGLBasicPolylineRenderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 585
diff changeset
116 // This layer has already been rendered
602
03c4b998fcd0 display scene positions in the basic sample
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 593
diff changeset
117 assert(found->second->GetLastRevision() <= layer.GetRevision());
03c4b998fcd0 display scene positions in the basic sample
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 593
diff changeset
118
593
6bf8f881fcb5 OpenGLBasicPolylineRenderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 585
diff changeset
119 if (found->second->GetLastRevision() < layer.GetRevision())
6bf8f881fcb5 OpenGLBasicPolylineRenderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 585
diff changeset
120 {
6bf8f881fcb5 OpenGLBasicPolylineRenderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 585
diff changeset
121 found->second->UpdateRenderer();
6bf8f881fcb5 OpenGLBasicPolylineRenderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 585
diff changeset
122 }
6bf8f881fcb5 OpenGLBasicPolylineRenderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 585
diff changeset
123
888
6e888cf6a48b renderers now have access to canvas width/height
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 602
diff changeset
124 found->second->GetRenderer().Render(sceneTransform_, canvasWidth_, canvasHeight_);
593
6bf8f881fcb5 OpenGLBasicPolylineRenderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 585
diff changeset
125 }
6bf8f881fcb5 OpenGLBasicPolylineRenderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 585
diff changeset
126
6bf8f881fcb5 OpenGLBasicPolylineRenderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 585
diff changeset
127 // Check invariants
6bf8f881fcb5 OpenGLBasicPolylineRenderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 585
diff changeset
128 assert(content_.find(depth) == content_.end() ||
602
03c4b998fcd0 display scene positions in the basic sample
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 593
diff changeset
129 (content_[depth]->GetLayerIdentifier() == layerIdentifier &&
593
6bf8f881fcb5 OpenGLBasicPolylineRenderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 585
diff changeset
130 content_[depth]->GetLastRevision() == layer.GetRevision()));
6bf8f881fcb5 OpenGLBasicPolylineRenderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 585
diff changeset
131 }
6bf8f881fcb5 OpenGLBasicPolylineRenderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 585
diff changeset
132
6bf8f881fcb5 OpenGLBasicPolylineRenderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 585
diff changeset
133
6bf8f881fcb5 OpenGLBasicPolylineRenderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 585
diff changeset
134 CompositorHelper::~CompositorHelper()
6bf8f881fcb5 OpenGLBasicPolylineRenderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 585
diff changeset
135 {
6bf8f881fcb5 OpenGLBasicPolylineRenderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 585
diff changeset
136 for (Content::iterator it = content_.begin(); it != content_.end(); ++it)
6bf8f881fcb5 OpenGLBasicPolylineRenderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 585
diff changeset
137 {
6bf8f881fcb5 OpenGLBasicPolylineRenderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 585
diff changeset
138 assert(it->second != NULL);
6bf8f881fcb5 OpenGLBasicPolylineRenderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 585
diff changeset
139 delete it->second;
585
b9ce24c606ae TextSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
140 }
b9ce24c606ae TextSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
141 }
b9ce24c606ae TextSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
142
593
6bf8f881fcb5 OpenGLBasicPolylineRenderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 585
diff changeset
143
6bf8f881fcb5 OpenGLBasicPolylineRenderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 585
diff changeset
144 void CompositorHelper::Refresh(unsigned int canvasWidth,
6bf8f881fcb5 OpenGLBasicPolylineRenderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 585
diff changeset
145 unsigned int canvasHeight)
585
b9ce24c606ae TextSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
146 {
593
6bf8f881fcb5 OpenGLBasicPolylineRenderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 585
diff changeset
147 // Bring coordinate (0,0) to the center of the canvas
6bf8f881fcb5 OpenGLBasicPolylineRenderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 585
diff changeset
148 AffineTransform2D offset = AffineTransform2D::CreateOffset(
6bf8f881fcb5 OpenGLBasicPolylineRenderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 585
diff changeset
149 static_cast<double>(canvasWidth) / 2.0,
6bf8f881fcb5 OpenGLBasicPolylineRenderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 585
diff changeset
150 static_cast<double>(canvasHeight) / 2.0);
585
b9ce24c606ae TextSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
151
593
6bf8f881fcb5 OpenGLBasicPolylineRenderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 585
diff changeset
152 sceneTransform_ = AffineTransform2D::Combine(offset, scene_.GetSceneToCanvasTransform());
888
6e888cf6a48b renderers now have access to canvas width/height
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 602
diff changeset
153 canvasWidth_ = canvasWidth;
6e888cf6a48b renderers now have access to canvas width/height
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 602
diff changeset
154 canvasHeight_ = canvasHeight;
593
6bf8f881fcb5 OpenGLBasicPolylineRenderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 585
diff changeset
155 scene_.Apply(*this);
585
b9ce24c606ae TextSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
156 }
b9ce24c606ae TextSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
157 }
b9ce24c606ae TextSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
158 }