Mercurial > hg > orthanc-stone
annotate OrthancStone/Sources/Scene2D/CairoCompositor.h @ 1925:a7a77488ddb1
fix
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Wed, 23 Mar 2022 14:21:22 +0100 |
parents | 7053b8a0aaec |
children | 07964689cb0b |
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 | |
1871
7053b8a0aaec
upgrade to year 2022
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1870
diff
changeset
|
5 * Copyright (C) 2017-2022 Osimis S.A., Belgium |
7053b8a0aaec
upgrade to year 2022
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1870
diff
changeset
|
6 * Copyright (C) 2021-2022 Sebastien Jodogne, ICTEAM UCLouvain, Belgium |
597 | 7 * |
8 * 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
|
9 * modify it under the terms of the GNU Lesser General Public License |
597 | 10 * as published by the Free Software Foundation, either version 3 of |
11 * the License, or (at your option) any later version. | |
12 * | |
13 * This program is distributed in the hope that it will be useful, but | |
14 * 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
|
15 * 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
|
16 * 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
|
17 * |
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
|
18 * 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
|
19 * 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
|
20 * <http://www.gnu.org/licenses/>. |
597 | 21 **/ |
22 | |
23 | |
24 #pragma once | |
25 | |
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
|
26 #include "ICompositor.h" |
597 | 27 #include "../Fonts/GlyphBitmapAlphabet.h" |
807
c237e0625065
deprecating CairoFont
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
600
diff
changeset
|
28 #include "../Wrappers/CairoContext.h" |
597 | 29 #include "Internals/CompositorHelper.h" |
30 #include "Internals/ICairoContextProvider.h" | |
31 | |
32 namespace OrthancStone | |
33 { | |
34 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
|
35 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
|
36 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
|
37 private Internals::ICairoContextProvider |
597 | 38 { |
39 private: | |
40 typedef std::map<size_t, GlyphBitmapAlphabet*> Fonts; | |
41 | |
1299
c38c89684d83
replacing std::auto_ptr by std::unique_ptr
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1279
diff
changeset
|
42 std::unique_ptr<Internals::CompositorHelper> helper_; |
597 | 43 CairoSurface canvas_; |
44 Fonts fonts_; | |
45 | |
46 // 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
|
47 std::unique_ptr<CairoContext> context_; |
597 | 48 |
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
|
49 virtual cairo_t* GetCairoContext() ORTHANC_OVERRIDE; |
597 | 50 |
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
|
51 virtual Internals::CompositorHelper::ILayerRenderer* Create(const ISceneLayer& layer) ORTHANC_OVERRIDE; |
597 | 52 |
53 public: | |
1211
d10d2acb8a02
compositors do not keep a reference to the scene anymore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
942
diff
changeset
|
54 CairoCompositor(unsigned int canvasWidth, |
597 | 55 unsigned int canvasHeight); |
56 | |
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
|
57 virtual ~CairoCompositor(); |
597 | 58 |
59 const CairoSurface& GetCanvas() const | |
60 { | |
61 return canvas_; | |
62 } | |
888
6e888cf6a48b
renderers now have access to canvas width/height
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
807
diff
changeset
|
63 |
1576
92fca2b3ba3d
sanitizing the handling of canvas size
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1512
diff
changeset
|
64 virtual void SetCanvasSize(unsigned int canvasWidth, |
92fca2b3ba3d
sanitizing the handling of canvas size
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1512
diff
changeset
|
65 unsigned int canvasHeight) ORTHANC_OVERRIDE; |
1482
5c96bf3f1d32
IOpenGL::RefreshCanvasSize()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1471
diff
changeset
|
66 |
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
|
67 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
|
68 { |
6e888cf6a48b
renderers now have access to canvas width/height
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
807
diff
changeset
|
69 return canvas_.GetWidth(); |
6e888cf6a48b
renderers now have access to canvas width/height
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
807
diff
changeset
|
70 } |
6e888cf6a48b
renderers now have access to canvas width/height
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
807
diff
changeset
|
71 |
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
|
72 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
|
73 { |
6e888cf6a48b
renderers now have access to canvas width/height
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
807
diff
changeset
|
74 return canvas_.GetHeight(); |
6e888cf6a48b
renderers now have access to canvas width/height
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
807
diff
changeset
|
75 } |
597 | 76 |
77 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
|
78 GlyphBitmapAlphabet* dict); // Takes ownership |
597 | 79 |
80 #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
|
81 virtual void SetFont(size_t index, |
1471
28c64c246312
working on a shared library
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1300
diff
changeset
|
82 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
|
83 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
|
84 Orthanc::Encoding codepage) ORTHANC_OVERRIDE; |
597 | 85 #endif |
86 | |
1211
d10d2acb8a02
compositors do not keep a reference to the scene anymore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
942
diff
changeset
|
87 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
|
88 |
d10d2acb8a02
compositors do not keep a reference to the scene anymore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
942
diff
changeset
|
89 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
|
90 { |
d10d2acb8a02
compositors do not keep a reference to the scene anymore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
942
diff
changeset
|
91 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
|
92 } |
597 | 93 |
94 Orthanc::ImageAccessor* RenderText(size_t fontIndex, | |
95 const std::string& utf8) const; | |
1792
373d7f7e796e
ICompositor::ComputeTextBoundingBox()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1739
diff
changeset
|
96 |
373d7f7e796e
ICompositor::ComputeTextBoundingBox()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1739
diff
changeset
|
97 #if ORTHANC_ENABLE_LOCALE == 1 |
373d7f7e796e
ICompositor::ComputeTextBoundingBox()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1739
diff
changeset
|
98 virtual TextBoundingBox* ComputeTextBoundingBox(size_t fontIndex, |
373d7f7e796e
ICompositor::ComputeTextBoundingBox()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1739
diff
changeset
|
99 const std::string& utf8) ORTHANC_OVERRIDE; |
373d7f7e796e
ICompositor::ComputeTextBoundingBox()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1739
diff
changeset
|
100 #endif |
597 | 101 }; |
102 } |