Mercurial > hg > orthanc-stone
annotate OrthancStone/Sources/Scene2D/CairoCompositor.h @ 1750:5f74ebe2516b
fixed includes
author | Benjamin Golinvaux <bgo@osimis.io> |
---|---|
date | Mon, 22 Feb 2021 14:56:06 +0100 |
parents | 9ac2a65d4172 |
children | 373d7f7e796e |
rev | line source |
---|---|
597 | 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:
1598
diff
changeset
|
5 * Copyright (C) 2017-2021 Osimis S.A., Belgium |
597 | 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 |
597 | 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. |
905
88bf49aebc13
introduced ICompositor and allow SdlViewport to work with a CairoCompositor (to run on machines without OpenGL drivers)
Alain Mazy <alain@mazy.be>
parents:
888
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/>. |
597 | 20 **/ |
21 | |
22 | |
23 #pragma once | |
24 | |
905
88bf49aebc13
introduced ICompositor and allow SdlViewport to work with a CairoCompositor (to run on machines without OpenGL drivers)
Alain Mazy <alain@mazy.be>
parents:
888
diff
changeset
|
25 #include "ICompositor.h" |
597 | 26 #include "../Fonts/GlyphBitmapAlphabet.h" |
807
c237e0625065
deprecating CairoFont
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
600
diff
changeset
|
27 #include "../Wrappers/CairoContext.h" |
597 | 28 #include "Internals/CompositorHelper.h" |
29 #include "Internals/ICairoContextProvider.h" | |
30 | |
31 namespace OrthancStone | |
32 { | |
33 class CairoCompositor : | |
905
88bf49aebc13
introduced ICompositor and allow SdlViewport to work with a CairoCompositor (to run on machines without OpenGL drivers)
Alain Mazy <alain@mazy.be>
parents:
888
diff
changeset
|
34 public ICompositor, |
88bf49aebc13
introduced ICompositor and allow SdlViewport to work with a CairoCompositor (to run on machines without OpenGL drivers)
Alain Mazy <alain@mazy.be>
parents:
888
diff
changeset
|
35 private Internals::CompositorHelper::IRendererFactory, |
88bf49aebc13
introduced ICompositor and allow SdlViewport to work with a CairoCompositor (to run on machines without OpenGL drivers)
Alain Mazy <alain@mazy.be>
parents:
888
diff
changeset
|
36 private Internals::ICairoContextProvider |
597 | 37 { |
38 private: | |
39 typedef std::map<size_t, GlyphBitmapAlphabet*> Fonts; | |
40 | |
1299
c38c89684d83
replacing std::auto_ptr by std::unique_ptr
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1279
diff
changeset
|
41 std::unique_ptr<Internals::CompositorHelper> helper_; |
597 | 42 CairoSurface canvas_; |
43 Fonts fonts_; | |
44 | |
45 // Only valid during a call to "Refresh()" | |
1298
8a0a62189f46
replacing std::auto_ptr by std::unique_ptr
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1270
diff
changeset
|
46 std::unique_ptr<CairoContext> context_; |
597 | 47 |
942
685c9a2d115f
Added missing ORTHANC_OVERRIDE + preparation for lost GL context handling + stubs for GL context event handlers
Benjamin Golinvaux <bgo@osimis.io>
parents:
911
diff
changeset
|
48 virtual cairo_t* GetCairoContext() ORTHANC_OVERRIDE; |
597 | 49 |
942
685c9a2d115f
Added missing ORTHANC_OVERRIDE + preparation for lost GL context handling + stubs for GL context event handlers
Benjamin Golinvaux <bgo@osimis.io>
parents:
911
diff
changeset
|
50 virtual Internals::CompositorHelper::ILayerRenderer* Create(const ISceneLayer& layer) ORTHANC_OVERRIDE; |
597 | 51 |
52 public: | |
1211
d10d2acb8a02
compositors do not keep a reference to the scene anymore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
942
diff
changeset
|
53 CairoCompositor(unsigned int canvasWidth, |
597 | 54 unsigned int canvasHeight); |
55 | |
905
88bf49aebc13
introduced ICompositor and allow SdlViewport to work with a CairoCompositor (to run on machines without OpenGL drivers)
Alain Mazy <alain@mazy.be>
parents:
888
diff
changeset
|
56 virtual ~CairoCompositor(); |
597 | 57 |
58 const CairoSurface& GetCanvas() const | |
59 { | |
60 return canvas_; | |
61 } | |
888
6e888cf6a48b
renderers now have access to canvas width/height
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
807
diff
changeset
|
62 |
1576
92fca2b3ba3d
sanitizing the handling of canvas size
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1512
diff
changeset
|
63 virtual void SetCanvasSize(unsigned int canvasWidth, |
92fca2b3ba3d
sanitizing the handling of canvas size
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1512
diff
changeset
|
64 unsigned int canvasHeight) ORTHANC_OVERRIDE; |
1482
5c96bf3f1d32
IOpenGL::RefreshCanvasSize()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1471
diff
changeset
|
65 |
942
685c9a2d115f
Added missing ORTHANC_OVERRIDE + preparation for lost GL context handling + stubs for GL context event handlers
Benjamin Golinvaux <bgo@osimis.io>
parents:
911
diff
changeset
|
66 virtual unsigned int GetCanvasWidth() const ORTHANC_OVERRIDE |
888
6e888cf6a48b
renderers now have access to canvas width/height
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
807
diff
changeset
|
67 { |
6e888cf6a48b
renderers now have access to canvas width/height
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
807
diff
changeset
|
68 return canvas_.GetWidth(); |
6e888cf6a48b
renderers now have access to canvas width/height
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
807
diff
changeset
|
69 } |
6e888cf6a48b
renderers now have access to canvas width/height
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
807
diff
changeset
|
70 |
942
685c9a2d115f
Added missing ORTHANC_OVERRIDE + preparation for lost GL context handling + stubs for GL context event handlers
Benjamin Golinvaux <bgo@osimis.io>
parents:
911
diff
changeset
|
71 virtual unsigned int GetCanvasHeight() const ORTHANC_OVERRIDE |
888
6e888cf6a48b
renderers now have access to canvas width/height
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
807
diff
changeset
|
72 { |
6e888cf6a48b
renderers now have access to canvas width/height
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
807
diff
changeset
|
73 return canvas_.GetHeight(); |
6e888cf6a48b
renderers now have access to canvas width/height
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
807
diff
changeset
|
74 } |
597 | 75 |
76 void SetFont(size_t index, | |
942
685c9a2d115f
Added missing ORTHANC_OVERRIDE + preparation for lost GL context handling + stubs for GL context event handlers
Benjamin Golinvaux <bgo@osimis.io>
parents:
911
diff
changeset
|
77 GlyphBitmapAlphabet* dict); // Takes ownership |
597 | 78 |
79 #if ORTHANC_ENABLE_LOCALE == 1 | |
905
88bf49aebc13
introduced ICompositor and allow SdlViewport to work with a CairoCompositor (to run on machines without OpenGL drivers)
Alain Mazy <alain@mazy.be>
parents:
888
diff
changeset
|
80 virtual void SetFont(size_t index, |
1471
28c64c246312
working on a shared library
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1300
diff
changeset
|
81 const std::string& ttf, |
905
88bf49aebc13
introduced ICompositor and allow SdlViewport to work with a CairoCompositor (to run on machines without OpenGL drivers)
Alain Mazy <alain@mazy.be>
parents:
888
diff
changeset
|
82 unsigned int fontSize, |
942
685c9a2d115f
Added missing ORTHANC_OVERRIDE + preparation for lost GL context handling + stubs for GL context event handlers
Benjamin Golinvaux <bgo@osimis.io>
parents:
911
diff
changeset
|
83 Orthanc::Encoding codepage) ORTHANC_OVERRIDE; |
597 | 84 #endif |
85 | |
1211
d10d2acb8a02
compositors do not keep a reference to the scene anymore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
942
diff
changeset
|
86 virtual void Refresh(const Scene2D& scene) ORTHANC_OVERRIDE; |
d10d2acb8a02
compositors do not keep a reference to the scene anymore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
942
diff
changeset
|
87 |
d10d2acb8a02
compositors do not keep a reference to the scene anymore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
942
diff
changeset
|
88 virtual void ResetScene() ORTHANC_OVERRIDE |
d10d2acb8a02
compositors do not keep a reference to the scene anymore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
942
diff
changeset
|
89 { |
d10d2acb8a02
compositors do not keep a reference to the scene anymore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
942
diff
changeset
|
90 helper_.reset(new Internals::CompositorHelper(*this)); |
d10d2acb8a02
compositors do not keep a reference to the scene anymore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
942
diff
changeset
|
91 } |
597 | 92 |
93 Orthanc::ImageAccessor* RenderText(size_t fontIndex, | |
94 const std::string& utf8) const; | |
95 }; | |
96 } |