Mercurial > hg > orthanc-stone
annotate OrthancStone/Sources/Scene2D/OpenGLCompositor.cpp @ 1760:e38b9875a969
adaptation to change in API of Orthanc::HttpClient
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Tue, 04 May 2021 11:02:24 +0200 |
parents | 9ac2a65d4172 |
children | 373d7f7e796e |
rev | line source |
---|---|
594 | 1 /** |
2 * Stone of Orthanc | |
3 * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics | |
4 * Department, University Hospital of Liege, Belgium | |
1739
9ac2a65d4172
upgrade to year 2021
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1614
diff
changeset
|
5 * Copyright (C) 2017-2021 Osimis S.A., Belgium |
594 | 6 * |
7 * This program is free software: you can redistribute it and/or | |
1598
8563ea5d8ae4
relicensing some files, cf. osimis bm26 and chu agreement on 2020-05-20
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1576
diff
changeset
|
8 * modify it under the terms of the GNU Lesser General Public License |
594 | 9 * as published by the Free Software Foundation, either version 3 of |
10 * the License, or (at your option) any later version. | |
11 * | |
12 * This program is distributed in the hope that it will be useful, but | |
13 * WITHOUT ANY WARRANTY; without even the implied warranty of | |
1598
8563ea5d8ae4
relicensing some files, cf. osimis bm26 and chu agreement on 2020-05-20
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1576
diff
changeset
|
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
8563ea5d8ae4
relicensing some files, cf. osimis bm26 and chu agreement on 2020-05-20
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1576
diff
changeset
|
15 * Lesser General Public License for more details. |
1327
4f8db2d202c8
OrthancSeriesProgressiveLoader now has two modes that
Benjamin Golinvaux <bgo@osimis.io>
parents:
1300
diff
changeset
|
16 * |
1598
8563ea5d8ae4
relicensing some files, cf. osimis bm26 and chu agreement on 2020-05-20
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1576
diff
changeset
|
17 * You should have received a copy of the GNU Lesser General Public |
8563ea5d8ae4
relicensing some files, cf. osimis bm26 and chu agreement on 2020-05-20
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1576
diff
changeset
|
18 * License along with this program. If not, see |
8563ea5d8ae4
relicensing some files, cf. osimis bm26 and chu agreement on 2020-05-20
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1576
diff
changeset
|
19 * <http://www.gnu.org/licenses/>. |
594 | 20 **/ |
21 | |
22 #include "OpenGLCompositor.h" | |
23 | |
24 #include "Internals/OpenGLAdvancedPolylineRenderer.h" | |
1614
ad9b425f27ae
new class: ArrowSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1611
diff
changeset
|
25 #include "Internals/OpenGLArrowRenderer.h" |
594 | 26 #include "Internals/OpenGLBasicPolylineRenderer.h" |
27 #include "Internals/OpenGLColorTextureRenderer.h" | |
28 #include "Internals/OpenGLFloatTextureRenderer.h" | |
29 #include "Internals/OpenGLInfoPanelRenderer.h" | |
841
266e2b0b9abc
better error reporting in DicomStructureSetLoader + fixed POST request logic
Benjamin Golinvaux <bgo@osimis.io>
parents:
617
diff
changeset
|
30 #include "Internals/OpenGLLookupTableTextureRenderer.h" |
594 | 31 #include "Internals/OpenGLTextRenderer.h" |
1611
787db80a5a1b
new class MacroLayerRenderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1598
diff
changeset
|
32 #include "Internals/MacroLayerRenderer.h" |
594 | 33 |
34 namespace OrthancStone | |
35 { | |
36 class OpenGLCompositor::Font : public boost::noncopyable | |
37 { | |
38 private: | |
1298
8a0a62189f46
replacing std::auto_ptr by std::unique_ptr
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1270
diff
changeset
|
39 std::unique_ptr<GlyphTextureAlphabet> alphabet_; |
8a0a62189f46
replacing std::auto_ptr by std::unique_ptr
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1270
diff
changeset
|
40 std::unique_ptr<OpenGL::OpenGLTexture> texture_; |
594 | 41 |
42 public: | |
947
1091b2adeb5a
Fixed animation frame stopping when returning false + big work on the OpenGL
Benjamin Golinvaux <bgo@osimis.io>
parents:
942
diff
changeset
|
43 Font(OpenGL::IOpenGLContext& context, const GlyphBitmapAlphabet& dict) |
594 | 44 { |
45 alphabet_.reset(new GlyphTextureAlphabet(dict)); | |
947
1091b2adeb5a
Fixed animation frame stopping when returning false + big work on the OpenGL
Benjamin Golinvaux <bgo@osimis.io>
parents:
942
diff
changeset
|
46 texture_.reset(new OpenGL::OpenGLTexture(context)); |
594 | 47 |
1298
8a0a62189f46
replacing std::auto_ptr by std::unique_ptr
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1270
diff
changeset
|
48 std::unique_ptr<Orthanc::ImageAccessor> bitmap(alphabet_->ReleaseTexture()); |
594 | 49 texture_->Load(*bitmap, true /* enable linear interpolation */); |
50 } | |
51 | |
52 OpenGL::OpenGLTexture& GetTexture() const | |
53 { | |
54 assert(texture_.get() != NULL); | |
55 return *texture_; | |
56 } | |
57 | |
58 const GlyphTextureAlphabet& GetAlphabet() const | |
59 { | |
60 assert(alphabet_.get() != NULL); | |
61 return *alphabet_; | |
62 } | |
63 }; | |
64 | |
65 const OpenGLCompositor::Font* OpenGLCompositor::GetFont(size_t fontIndex) const | |
66 { | |
67 Fonts::const_iterator found = fonts_.find(fontIndex); | |
68 | |
69 if (found == fonts_.end()) | |
70 { | |
71 return NULL; // Unknown font, nothing should be drawn | |
72 } | |
73 else | |
74 { | |
75 assert(found->second != NULL); | |
76 return found->second; | |
77 } | |
78 } | |
79 | |
80 Internals::CompositorHelper::ILayerRenderer* OpenGLCompositor::Create(const ISceneLayer& layer) | |
81 { | |
947
1091b2adeb5a
Fixed animation frame stopping when returning false + big work on the OpenGL
Benjamin Golinvaux <bgo@osimis.io>
parents:
942
diff
changeset
|
82 if (!context_.IsContextLost()) |
594 | 83 { |
947
1091b2adeb5a
Fixed animation frame stopping when returning false + big work on the OpenGL
Benjamin Golinvaux <bgo@osimis.io>
parents:
942
diff
changeset
|
84 switch (layer.GetType()) |
1091b2adeb5a
Fixed animation frame stopping when returning false + big work on the OpenGL
Benjamin Golinvaux <bgo@osimis.io>
parents:
942
diff
changeset
|
85 { |
594 | 86 case ISceneLayer::Type_InfoPanel: |
87 return new Internals::OpenGLInfoPanelRenderer | |
947
1091b2adeb5a
Fixed animation frame stopping when returning false + big work on the OpenGL
Benjamin Golinvaux <bgo@osimis.io>
parents:
942
diff
changeset
|
88 (context_, colorTextureProgram_, dynamic_cast<const InfoPanelSceneLayer&>(layer)); |
594 | 89 |
90 case ISceneLayer::Type_ColorTexture: | |
91 return new Internals::OpenGLColorTextureRenderer | |
947
1091b2adeb5a
Fixed animation frame stopping when returning false + big work on the OpenGL
Benjamin Golinvaux <bgo@osimis.io>
parents:
942
diff
changeset
|
92 (context_, colorTextureProgram_, dynamic_cast<const ColorTextureSceneLayer&>(layer)); |
594 | 93 |
94 case ISceneLayer::Type_FloatTexture: | |
95 return new Internals::OpenGLFloatTextureRenderer | |
947
1091b2adeb5a
Fixed animation frame stopping when returning false + big work on the OpenGL
Benjamin Golinvaux <bgo@osimis.io>
parents:
942
diff
changeset
|
96 (context_, floatTextureProgram_, dynamic_cast<const FloatTextureSceneLayer&>(layer)); |
594 | 97 |
841
266e2b0b9abc
better error reporting in DicomStructureSetLoader + fixed POST request logic
Benjamin Golinvaux <bgo@osimis.io>
parents:
617
diff
changeset
|
98 case ISceneLayer::Type_LookupTableTexture: |
266e2b0b9abc
better error reporting in DicomStructureSetLoader + fixed POST request logic
Benjamin Golinvaux <bgo@osimis.io>
parents:
617
diff
changeset
|
99 return new Internals::OpenGLLookupTableTextureRenderer |
266e2b0b9abc
better error reporting in DicomStructureSetLoader + fixed POST request logic
Benjamin Golinvaux <bgo@osimis.io>
parents:
617
diff
changeset
|
100 (context_, colorTextureProgram_, dynamic_cast<const LookupTableTextureSceneLayer&>(layer)); |
266e2b0b9abc
better error reporting in DicomStructureSetLoader + fixed POST request logic
Benjamin Golinvaux <bgo@osimis.io>
parents:
617
diff
changeset
|
101 |
594 | 102 case ISceneLayer::Type_Polyline: |
103 return new Internals::OpenGLAdvancedPolylineRenderer | |
1571 | 104 (context_, linesProgram_, dynamic_cast<const PolylineSceneLayer&>(layer)); |
594 | 105 //return new Internals::OpenGLBasicPolylineRenderer(context_, dynamic_cast<const PolylineSceneLayer&>(layer)); |
106 | |
107 case ISceneLayer::Type_Text: | |
108 { | |
109 const TextSceneLayer& l = dynamic_cast<const TextSceneLayer&>(layer); | |
110 const Font* font = GetFont(l.GetFontIndex()); | |
111 if (font == NULL) | |
112 { | |
949
32eaf4929b08
OrthancMultiframeVolumeLoader and OrthancSeriesVolumeProgressiveLoader now implement IGeometryProvider so that the geometry reference can be switched (CT or DOSE, for instance) + VolumeImageGeometry::SetSize renamed to VolumeImageGeometry::SetSizeInVoxels + prevent text layer update if text or properties do not change + a few stream operator<< for debug (Vector, Matrix,...) + fixed memory access aligment issues in ImageBuffer3D::ExtractSagittalSlice + fix for wrong screen Y offset of mpr slices in DicomVolumeImageMPRSlicer.
Benjamin Golinvaux <bgo@osimis.io>
parents:
947
diff
changeset
|
113 LOG(WARNING) << "There is no font at index " << l.GetFontIndex(); |
594 | 114 return NULL; |
115 } | |
116 else | |
117 { | |
118 return new Internals::OpenGLTextRenderer | |
947
1091b2adeb5a
Fixed animation frame stopping when returning false + big work on the OpenGL
Benjamin Golinvaux <bgo@osimis.io>
parents:
942
diff
changeset
|
119 (context_, textProgram_, font->GetAlphabet(), font->GetTexture(), l); |
594 | 120 } |
121 } | |
122 | |
1611
787db80a5a1b
new class MacroLayerRenderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1598
diff
changeset
|
123 case ISceneLayer::Type_Macro: |
787db80a5a1b
new class MacroLayerRenderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1598
diff
changeset
|
124 return new Internals::MacroLayerRenderer(*this, layer); |
787db80a5a1b
new class MacroLayerRenderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1598
diff
changeset
|
125 |
1614
ad9b425f27ae
new class: ArrowSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1611
diff
changeset
|
126 case ISceneLayer::Type_Arrow: |
ad9b425f27ae
new class: ArrowSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1611
diff
changeset
|
127 return new Internals::OpenGLArrowRenderer |
ad9b425f27ae
new class: ArrowSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1611
diff
changeset
|
128 (context_, linesProgram_, dynamic_cast<const ArrowSceneLayer&>(layer)); |
ad9b425f27ae
new class: ArrowSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1611
diff
changeset
|
129 |
594 | 130 default: |
131 return NULL; | |
947
1091b2adeb5a
Fixed animation frame stopping when returning false + big work on the OpenGL
Benjamin Golinvaux <bgo@osimis.io>
parents:
942
diff
changeset
|
132 } |
1091b2adeb5a
Fixed animation frame stopping when returning false + big work on the OpenGL
Benjamin Golinvaux <bgo@osimis.io>
parents:
942
diff
changeset
|
133 } |
1091b2adeb5a
Fixed animation frame stopping when returning false + big work on the OpenGL
Benjamin Golinvaux <bgo@osimis.io>
parents:
942
diff
changeset
|
134 else |
1091b2adeb5a
Fixed animation frame stopping when returning false + big work on the OpenGL
Benjamin Golinvaux <bgo@osimis.io>
parents:
942
diff
changeset
|
135 { |
1091b2adeb5a
Fixed animation frame stopping when returning false + big work on the OpenGL
Benjamin Golinvaux <bgo@osimis.io>
parents:
942
diff
changeset
|
136 // context is lost. returning null. |
1091b2adeb5a
Fixed animation frame stopping when returning false + big work on the OpenGL
Benjamin Golinvaux <bgo@osimis.io>
parents:
942
diff
changeset
|
137 return NULL; |
594 | 138 } |
139 } | |
140 | |
1211
d10d2acb8a02
compositors do not keep a reference to the scene anymore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
949
diff
changeset
|
141 OpenGLCompositor::OpenGLCompositor(OpenGL::IOpenGLContext& context) : |
594 | 142 context_(context), |
143 colorTextureProgram_(context), | |
144 floatTextureProgram_(context), | |
145 linesProgram_(context), | |
146 textProgram_(context), | |
147 canvasWidth_(0), | |
148 canvasHeight_(0) | |
149 { | |
1211
d10d2acb8a02
compositors do not keep a reference to the scene anymore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
949
diff
changeset
|
150 ResetScene(); |
594 | 151 } |
152 | |
153 OpenGLCompositor::~OpenGLCompositor() | |
154 { | |
947
1091b2adeb5a
Fixed animation frame stopping when returning false + big work on the OpenGL
Benjamin Golinvaux <bgo@osimis.io>
parents:
942
diff
changeset
|
155 if (!context_.IsContextLost()) |
594 | 156 { |
1327
4f8db2d202c8
OrthancSeriesProgressiveLoader now has two modes that
Benjamin Golinvaux <bgo@osimis.io>
parents:
1300
diff
changeset
|
157 try |
947
1091b2adeb5a
Fixed animation frame stopping when returning false + big work on the OpenGL
Benjamin Golinvaux <bgo@osimis.io>
parents:
942
diff
changeset
|
158 { |
1327
4f8db2d202c8
OrthancSeriesProgressiveLoader now has two modes that
Benjamin Golinvaux <bgo@osimis.io>
parents:
1300
diff
changeset
|
159 try |
4f8db2d202c8
OrthancSeriesProgressiveLoader now has two modes that
Benjamin Golinvaux <bgo@osimis.io>
parents:
1300
diff
changeset
|
160 { |
4f8db2d202c8
OrthancSeriesProgressiveLoader now has two modes that
Benjamin Golinvaux <bgo@osimis.io>
parents:
1300
diff
changeset
|
161 context_.MakeCurrent(); // this can throw if context lost! |
4f8db2d202c8
OrthancSeriesProgressiveLoader now has two modes that
Benjamin Golinvaux <bgo@osimis.io>
parents:
1300
diff
changeset
|
162 } |
4f8db2d202c8
OrthancSeriesProgressiveLoader now has two modes that
Benjamin Golinvaux <bgo@osimis.io>
parents:
1300
diff
changeset
|
163 catch (...) |
4f8db2d202c8
OrthancSeriesProgressiveLoader now has two modes that
Benjamin Golinvaux <bgo@osimis.io>
parents:
1300
diff
changeset
|
164 { |
4f8db2d202c8
OrthancSeriesProgressiveLoader now has two modes that
Benjamin Golinvaux <bgo@osimis.io>
parents:
1300
diff
changeset
|
165 LOG(ERROR) << "context_.MakeCurrent() failed in OpenGLCompositor::~OpenGLCompositor()!"; |
4f8db2d202c8
OrthancSeriesProgressiveLoader now has two modes that
Benjamin Golinvaux <bgo@osimis.io>
parents:
1300
diff
changeset
|
166 } |
4f8db2d202c8
OrthancSeriesProgressiveLoader now has two modes that
Benjamin Golinvaux <bgo@osimis.io>
parents:
1300
diff
changeset
|
167 |
4f8db2d202c8
OrthancSeriesProgressiveLoader now has two modes that
Benjamin Golinvaux <bgo@osimis.io>
parents:
1300
diff
changeset
|
168 for (Fonts::iterator it = fonts_.begin(); it != fonts_.end(); ++it) |
4f8db2d202c8
OrthancSeriesProgressiveLoader now has two modes that
Benjamin Golinvaux <bgo@osimis.io>
parents:
1300
diff
changeset
|
169 { |
4f8db2d202c8
OrthancSeriesProgressiveLoader now has two modes that
Benjamin Golinvaux <bgo@osimis.io>
parents:
1300
diff
changeset
|
170 try |
4f8db2d202c8
OrthancSeriesProgressiveLoader now has two modes that
Benjamin Golinvaux <bgo@osimis.io>
parents:
1300
diff
changeset
|
171 { |
4f8db2d202c8
OrthancSeriesProgressiveLoader now has two modes that
Benjamin Golinvaux <bgo@osimis.io>
parents:
1300
diff
changeset
|
172 |
4f8db2d202c8
OrthancSeriesProgressiveLoader now has two modes that
Benjamin Golinvaux <bgo@osimis.io>
parents:
1300
diff
changeset
|
173 assert(it->second != NULL); |
4f8db2d202c8
OrthancSeriesProgressiveLoader now has two modes that
Benjamin Golinvaux <bgo@osimis.io>
parents:
1300
diff
changeset
|
174 delete it->second; |
4f8db2d202c8
OrthancSeriesProgressiveLoader now has two modes that
Benjamin Golinvaux <bgo@osimis.io>
parents:
1300
diff
changeset
|
175 } |
4f8db2d202c8
OrthancSeriesProgressiveLoader now has two modes that
Benjamin Golinvaux <bgo@osimis.io>
parents:
1300
diff
changeset
|
176 catch (...) |
4f8db2d202c8
OrthancSeriesProgressiveLoader now has two modes that
Benjamin Golinvaux <bgo@osimis.io>
parents:
1300
diff
changeset
|
177 { |
4f8db2d202c8
OrthancSeriesProgressiveLoader now has two modes that
Benjamin Golinvaux <bgo@osimis.io>
parents:
1300
diff
changeset
|
178 LOG(ERROR) << "Exception thrown while deleting OpenGL-based font!"; |
4f8db2d202c8
OrthancSeriesProgressiveLoader now has two modes that
Benjamin Golinvaux <bgo@osimis.io>
parents:
1300
diff
changeset
|
179 } |
4f8db2d202c8
OrthancSeriesProgressiveLoader now has two modes that
Benjamin Golinvaux <bgo@osimis.io>
parents:
1300
diff
changeset
|
180 } |
4f8db2d202c8
OrthancSeriesProgressiveLoader now has two modes that
Benjamin Golinvaux <bgo@osimis.io>
parents:
1300
diff
changeset
|
181 } |
4f8db2d202c8
OrthancSeriesProgressiveLoader now has two modes that
Benjamin Golinvaux <bgo@osimis.io>
parents:
1300
diff
changeset
|
182 catch (...) |
4f8db2d202c8
OrthancSeriesProgressiveLoader now has two modes that
Benjamin Golinvaux <bgo@osimis.io>
parents:
1300
diff
changeset
|
183 { |
4f8db2d202c8
OrthancSeriesProgressiveLoader now has two modes that
Benjamin Golinvaux <bgo@osimis.io>
parents:
1300
diff
changeset
|
184 // logging threw an exception! |
947
1091b2adeb5a
Fixed animation frame stopping when returning false + big work on the OpenGL
Benjamin Golinvaux <bgo@osimis.io>
parents:
942
diff
changeset
|
185 } |
594 | 186 } |
187 } | |
188 | |
1211
d10d2acb8a02
compositors do not keep a reference to the scene anymore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
949
diff
changeset
|
189 void OpenGLCompositor::Refresh(const Scene2D& scene) |
594 | 190 { |
947
1091b2adeb5a
Fixed animation frame stopping when returning false + big work on the OpenGL
Benjamin Golinvaux <bgo@osimis.io>
parents:
942
diff
changeset
|
191 if (!context_.IsContextLost()) |
1091b2adeb5a
Fixed animation frame stopping when returning false + big work on the OpenGL
Benjamin Golinvaux <bgo@osimis.io>
parents:
942
diff
changeset
|
192 { |
1091b2adeb5a
Fixed animation frame stopping when returning false + big work on the OpenGL
Benjamin Golinvaux <bgo@osimis.io>
parents:
942
diff
changeset
|
193 context_.MakeCurrent(); // this can throw if context lost! |
594 | 194 |
947
1091b2adeb5a
Fixed animation frame stopping when returning false + big work on the OpenGL
Benjamin Golinvaux <bgo@osimis.io>
parents:
942
diff
changeset
|
195 glViewport(0, 0, canvasWidth_, canvasHeight_); |
1091b2adeb5a
Fixed animation frame stopping when returning false + big work on the OpenGL
Benjamin Golinvaux <bgo@osimis.io>
parents:
942
diff
changeset
|
196 glClearColor(0, 0, 0, 1); |
1091b2adeb5a
Fixed animation frame stopping when returning false + big work on the OpenGL
Benjamin Golinvaux <bgo@osimis.io>
parents:
942
diff
changeset
|
197 glClear(GL_COLOR_BUFFER_BIT); |
594 | 198 |
1211
d10d2acb8a02
compositors do not keep a reference to the scene anymore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
949
diff
changeset
|
199 helper_->Refresh(scene, canvasWidth_, canvasHeight_); |
594 | 200 |
947
1091b2adeb5a
Fixed animation frame stopping when returning false + big work on the OpenGL
Benjamin Golinvaux <bgo@osimis.io>
parents:
942
diff
changeset
|
201 context_.SwapBuffer(); |
1091b2adeb5a
Fixed animation frame stopping when returning false + big work on the OpenGL
Benjamin Golinvaux <bgo@osimis.io>
parents:
942
diff
changeset
|
202 } |
594 | 203 } |
204 | |
205 void OpenGLCompositor::SetFont(size_t index, | |
206 const GlyphBitmapAlphabet& dict) | |
207 { | |
947
1091b2adeb5a
Fixed animation frame stopping when returning false + big work on the OpenGL
Benjamin Golinvaux <bgo@osimis.io>
parents:
942
diff
changeset
|
208 if (!context_.IsContextLost()) |
594 | 209 { |
947
1091b2adeb5a
Fixed animation frame stopping when returning false + big work on the OpenGL
Benjamin Golinvaux <bgo@osimis.io>
parents:
942
diff
changeset
|
210 context_.MakeCurrent(); // this can throw if context lost |
1091b2adeb5a
Fixed animation frame stopping when returning false + big work on the OpenGL
Benjamin Golinvaux <bgo@osimis.io>
parents:
942
diff
changeset
|
211 |
1298
8a0a62189f46
replacing std::auto_ptr by std::unique_ptr
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1270
diff
changeset
|
212 std::unique_ptr<Font> font(new Font(context_, dict)); |
947
1091b2adeb5a
Fixed animation frame stopping when returning false + big work on the OpenGL
Benjamin Golinvaux <bgo@osimis.io>
parents:
942
diff
changeset
|
213 |
1091b2adeb5a
Fixed animation frame stopping when returning false + big work on the OpenGL
Benjamin Golinvaux <bgo@osimis.io>
parents:
942
diff
changeset
|
214 Fonts::iterator found = fonts_.find(index); |
594 | 215 |
947
1091b2adeb5a
Fixed animation frame stopping when returning false + big work on the OpenGL
Benjamin Golinvaux <bgo@osimis.io>
parents:
942
diff
changeset
|
216 if (found == fonts_.end()) |
1091b2adeb5a
Fixed animation frame stopping when returning false + big work on the OpenGL
Benjamin Golinvaux <bgo@osimis.io>
parents:
942
diff
changeset
|
217 { |
1091b2adeb5a
Fixed animation frame stopping when returning false + big work on the OpenGL
Benjamin Golinvaux <bgo@osimis.io>
parents:
942
diff
changeset
|
218 fonts_[index] = font.release(); |
1091b2adeb5a
Fixed animation frame stopping when returning false + big work on the OpenGL
Benjamin Golinvaux <bgo@osimis.io>
parents:
942
diff
changeset
|
219 } |
1091b2adeb5a
Fixed animation frame stopping when returning false + big work on the OpenGL
Benjamin Golinvaux <bgo@osimis.io>
parents:
942
diff
changeset
|
220 else |
1091b2adeb5a
Fixed animation frame stopping when returning false + big work on the OpenGL
Benjamin Golinvaux <bgo@osimis.io>
parents:
942
diff
changeset
|
221 { |
1091b2adeb5a
Fixed animation frame stopping when returning false + big work on the OpenGL
Benjamin Golinvaux <bgo@osimis.io>
parents:
942
diff
changeset
|
222 assert(found->second != NULL); |
1091b2adeb5a
Fixed animation frame stopping when returning false + big work on the OpenGL
Benjamin Golinvaux <bgo@osimis.io>
parents:
942
diff
changeset
|
223 delete found->second; |
1091b2adeb5a
Fixed animation frame stopping when returning false + big work on the OpenGL
Benjamin Golinvaux <bgo@osimis.io>
parents:
942
diff
changeset
|
224 |
1091b2adeb5a
Fixed animation frame stopping when returning false + big work on the OpenGL
Benjamin Golinvaux <bgo@osimis.io>
parents:
942
diff
changeset
|
225 found->second = font.release(); |
1091b2adeb5a
Fixed animation frame stopping when returning false + big work on the OpenGL
Benjamin Golinvaux <bgo@osimis.io>
parents:
942
diff
changeset
|
226 } |
594 | 227 } |
228 } | |
229 | |
230 #if ORTHANC_ENABLE_LOCALE == 1 | |
231 void OpenGLCompositor::SetFont(size_t index, | |
1471
28c64c246312
working on a shared library
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1327
diff
changeset
|
232 const std::string& ttf, |
594 | 233 unsigned int fontSize, |
234 Orthanc::Encoding codepage) | |
235 { | |
947
1091b2adeb5a
Fixed animation frame stopping when returning false + big work on the OpenGL
Benjamin Golinvaux <bgo@osimis.io>
parents:
942
diff
changeset
|
236 if (!context_.IsContextLost()) |
1091b2adeb5a
Fixed animation frame stopping when returning false + big work on the OpenGL
Benjamin Golinvaux <bgo@osimis.io>
parents:
942
diff
changeset
|
237 { |
1091b2adeb5a
Fixed animation frame stopping when returning false + big work on the OpenGL
Benjamin Golinvaux <bgo@osimis.io>
parents:
942
diff
changeset
|
238 FontRenderer renderer; |
1471
28c64c246312
working on a shared library
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1327
diff
changeset
|
239 renderer.LoadFont(ttf, fontSize); |
594 | 240 |
947
1091b2adeb5a
Fixed animation frame stopping when returning false + big work on the OpenGL
Benjamin Golinvaux <bgo@osimis.io>
parents:
942
diff
changeset
|
241 GlyphBitmapAlphabet dict; |
1091b2adeb5a
Fixed animation frame stopping when returning false + big work on the OpenGL
Benjamin Golinvaux <bgo@osimis.io>
parents:
942
diff
changeset
|
242 dict.LoadCodepage(renderer, codepage); |
594 | 243 |
947
1091b2adeb5a
Fixed animation frame stopping when returning false + big work on the OpenGL
Benjamin Golinvaux <bgo@osimis.io>
parents:
942
diff
changeset
|
244 SetFont(index, dict); |
1091b2adeb5a
Fixed animation frame stopping when returning false + big work on the OpenGL
Benjamin Golinvaux <bgo@osimis.io>
parents:
942
diff
changeset
|
245 } |
594 | 246 } |
247 #endif | |
1482
5c96bf3f1d32
IOpenGL::RefreshCanvasSize()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1471
diff
changeset
|
248 |
5c96bf3f1d32
IOpenGL::RefreshCanvasSize()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1471
diff
changeset
|
249 |
1576
92fca2b3ba3d
sanitizing the handling of canvas size
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1571
diff
changeset
|
250 void OpenGLCompositor::SetCanvasSize(unsigned int canvasWidth, |
92fca2b3ba3d
sanitizing the handling of canvas size
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1571
diff
changeset
|
251 unsigned int canvasHeight) |
1482
5c96bf3f1d32
IOpenGL::RefreshCanvasSize()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1471
diff
changeset
|
252 { |
1576
92fca2b3ba3d
sanitizing the handling of canvas size
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1571
diff
changeset
|
253 canvasWidth_ = canvasWidth; |
92fca2b3ba3d
sanitizing the handling of canvas size
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1571
diff
changeset
|
254 canvasHeight_ = canvasHeight; |
1482
5c96bf3f1d32
IOpenGL::RefreshCanvasSize()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1471
diff
changeset
|
255 } |
594 | 256 } |