Mercurial > hg > orthanc-stone
annotate Applications/Platforms/Sdl/SdlViewport.h @ 1830:fa38043b14b0
todo
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Sat, 29 May 2021 11:14:20 +0200 |
parents | 5a872e69c74f |
children | 3889ae96d2e9 |
rev | line source |
---|---|
891
0aff28f15ea2
new abstraction: IViewport
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1 /** |
0aff28f15ea2
new abstraction: IViewport
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2 * Stone of Orthanc |
0aff28f15ea2
new abstraction: IViewport
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
3 * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics |
0aff28f15ea2
new abstraction: IViewport
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
4 * Department, University Hospital of Liege, Belgium |
1739
9ac2a65d4172
upgrade to year 2021
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1591
diff
changeset
|
5 * Copyright (C) 2017-2021 Osimis S.A., Belgium |
891
0aff28f15ea2
new abstraction: IViewport
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
6 * |
0aff28f15ea2
new abstraction: IViewport
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
7 * This program is free software: you can redistribute it and/or |
0aff28f15ea2
new abstraction: IViewport
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
8 * modify it under the terms of the GNU Affero General Public License |
0aff28f15ea2
new abstraction: IViewport
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
9 * as published by the Free Software Foundation, either version 3 of |
0aff28f15ea2
new abstraction: IViewport
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
10 * the License, or (at your option) any later version. |
0aff28f15ea2
new abstraction: IViewport
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
11 * |
0aff28f15ea2
new abstraction: IViewport
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
12 * This program is distributed in the hope that it will be useful, but |
0aff28f15ea2
new abstraction: IViewport
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
13 * WITHOUT ANY WARRANTY; without even the implied warranty of |
0aff28f15ea2
new abstraction: IViewport
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
0aff28f15ea2
new abstraction: IViewport
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
15 * Affero General Public License for more details. |
0aff28f15ea2
new abstraction: IViewport
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
16 * |
0aff28f15ea2
new abstraction: IViewport
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
17 * You should have received a copy of the GNU Affero General Public License |
0aff28f15ea2
new abstraction: IViewport
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
18 * along with this program. If not, see <http://www.gnu.org/licenses/>. |
0aff28f15ea2
new abstraction: IViewport
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
19 **/ |
0aff28f15ea2
new abstraction: IViewport
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
20 |
0aff28f15ea2
new abstraction: IViewport
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
21 #pragma once |
0aff28f15ea2
new abstraction: IViewport
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
22 |
0aff28f15ea2
new abstraction: IViewport
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
23 #if !defined(ORTHANC_ENABLE_SDL) |
0aff28f15ea2
new abstraction: IViewport
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
24 # error Macro ORTHANC_ENABLE_SDL must be defined |
0aff28f15ea2
new abstraction: IViewport
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
25 #endif |
0aff28f15ea2
new abstraction: IViewport
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
26 |
0aff28f15ea2
new abstraction: IViewport
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
27 #if ORTHANC_ENABLE_SDL != 1 |
0aff28f15ea2
new abstraction: IViewport
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
28 # error SDL must be enabled to use this file |
0aff28f15ea2
new abstraction: IViewport
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
29 #endif |
0aff28f15ea2
new abstraction: IViewport
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
30 |
0aff28f15ea2
new abstraction: IViewport
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
31 #if !defined(ORTHANC_ENABLE_OPENGL) |
0aff28f15ea2
new abstraction: IViewport
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
32 # error The macro ORTHANC_ENABLE_OPENGL must be defined |
0aff28f15ea2
new abstraction: IViewport
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
33 #endif |
0aff28f15ea2
new abstraction: IViewport
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
34 |
1591
5887a4f8594b
moving platform-specific files out of the "OrthancStone" folder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1576
diff
changeset
|
35 #include "SdlOpenGLContext.h" |
5887a4f8594b
moving platform-specific files out of the "OrthancStone" folder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1576
diff
changeset
|
36 #include "../../../OrthancStone/Sources/Scene2D/CairoCompositor.h" |
5887a4f8594b
moving platform-specific files out of the "OrthancStone" folder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1576
diff
changeset
|
37 #include "../../../OrthancStone/Sources/Viewport/IViewport.h" |
891
0aff28f15ea2
new abstraction: IViewport
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
38 |
1804 | 39 #if ORTHANC_ENABLE_OPENGL == 1 |
40 # include "../../../OrthancStone/Sources/Scene2D/OpenGLCompositor.h" | |
41 #endif | |
42 | |
1205 | 43 #include <SDL_events.h> |
891
0aff28f15ea2
new abstraction: IViewport
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
44 |
1307
8a28a9bf8876
ViewportController now gets a ref to its parent viewport for proper lock usage
Benjamin Golinvaux <bgo@osimis.io>
parents:
1279
diff
changeset
|
45 // TODO: required for UndoStack injection |
8a28a9bf8876
ViewportController now gets a ref to its parent viewport for proper lock usage
Benjamin Golinvaux <bgo@osimis.io>
parents:
1279
diff
changeset
|
46 // I don't like it either :) |
8a28a9bf8876
ViewportController now gets a ref to its parent viewport for proper lock usage
Benjamin Golinvaux <bgo@osimis.io>
parents:
1279
diff
changeset
|
47 #include <boost/weak_ptr.hpp> |
8a28a9bf8876
ViewportController now gets a ref to its parent viewport for proper lock usage
Benjamin Golinvaux <bgo@osimis.io>
parents:
1279
diff
changeset
|
48 |
8a28a9bf8876
ViewportController now gets a ref to its parent viewport for proper lock usage
Benjamin Golinvaux <bgo@osimis.io>
parents:
1279
diff
changeset
|
49 #include <boost/thread/recursive_mutex.hpp> |
1560
b4ccd4963d37
fix sdl and wasm samples
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1512
diff
changeset
|
50 #include <boost/enable_shared_from_this.hpp> |
1307
8a28a9bf8876
ViewportController now gets a ref to its parent viewport for proper lock usage
Benjamin Golinvaux <bgo@osimis.io>
parents:
1279
diff
changeset
|
51 |
891
0aff28f15ea2
new abstraction: IViewport
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
52 namespace OrthancStone |
0aff28f15ea2
new abstraction: IViewport
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
53 { |
1307
8a28a9bf8876
ViewportController now gets a ref to its parent viewport for proper lock usage
Benjamin Golinvaux <bgo@osimis.io>
parents:
1279
diff
changeset
|
54 class UndoStack; |
8a28a9bf8876
ViewportController now gets a ref to its parent viewport for proper lock usage
Benjamin Golinvaux <bgo@osimis.io>
parents:
1279
diff
changeset
|
55 |
1331
ab81ee8fce1f
- Viewport is not passed and stored as a shared_ptr instead
Benjamin Golinvaux <bgo@osimis.io>
parents:
1308
diff
changeset
|
56 class SdlViewport : public IViewport, |
ab81ee8fce1f
- Viewport is not passed and stored as a shared_ptr instead
Benjamin Golinvaux <bgo@osimis.io>
parents:
1308
diff
changeset
|
57 public boost::enable_shared_from_this<SdlViewport> |
891
0aff28f15ea2
new abstraction: IViewport
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
58 { |
1205 | 59 private: |
1307
8a28a9bf8876
ViewportController now gets a ref to its parent viewport for proper lock usage
Benjamin Golinvaux <bgo@osimis.io>
parents:
1279
diff
changeset
|
60 boost::recursive_mutex mutex_; |
1216
5147277850cf
better abstraction for IViewport
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1215
diff
changeset
|
61 uint32_t refreshEvent_; |
5147277850cf
better abstraction for IViewport
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1215
diff
changeset
|
62 boost::shared_ptr<ViewportController> controller_; |
1331
ab81ee8fce1f
- Viewport is not passed and stored as a shared_ptr instead
Benjamin Golinvaux <bgo@osimis.io>
parents:
1308
diff
changeset
|
63 std::unique_ptr<ICompositor> compositor_; |
1216
5147277850cf
better abstraction for IViewport
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1215
diff
changeset
|
64 |
5147277850cf
better abstraction for IViewport
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1215
diff
changeset
|
65 void SendRefreshEvent(); |
1203
f3bb9a6dd949
locking abstraction in IViewport
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1055
diff
changeset
|
66 |
1205 | 67 protected: |
1215
9efa66d8d3f8
removed ViewportBase, and removed dependency of ViewportController on IViewport
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1213
diff
changeset
|
68 class SdlLock : public ILock |
1053
32b403a47b19
simplifying IViewport
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1047
diff
changeset
|
69 { |
1203
f3bb9a6dd949
locking abstraction in IViewport
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1055
diff
changeset
|
70 private: |
1307
8a28a9bf8876
ViewportController now gets a ref to its parent viewport for proper lock usage
Benjamin Golinvaux <bgo@osimis.io>
parents:
1279
diff
changeset
|
71 SdlViewport& that_; |
8a28a9bf8876
ViewportController now gets a ref to its parent viewport for proper lock usage
Benjamin Golinvaux <bgo@osimis.io>
parents:
1279
diff
changeset
|
72 boost::recursive_mutex::scoped_lock lock_; |
1216
5147277850cf
better abstraction for IViewport
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1215
diff
changeset
|
73 |
1203
f3bb9a6dd949
locking abstraction in IViewport
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1055
diff
changeset
|
74 public: |
1571 | 75 explicit SdlLock(SdlViewport& that) : |
76 that_(that), | |
77 lock_(that.mutex_) | |
1203
f3bb9a6dd949
locking abstraction in IViewport
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1055
diff
changeset
|
78 { |
f3bb9a6dd949
locking abstraction in IViewport
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1055
diff
changeset
|
79 } |
f3bb9a6dd949
locking abstraction in IViewport
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1055
diff
changeset
|
80 |
f3bb9a6dd949
locking abstraction in IViewport
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1055
diff
changeset
|
81 virtual bool HasCompositor() const ORTHANC_OVERRIDE |
f3bb9a6dd949
locking abstraction in IViewport
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1055
diff
changeset
|
82 { |
f3bb9a6dd949
locking abstraction in IViewport
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1055
diff
changeset
|
83 return true; |
f3bb9a6dd949
locking abstraction in IViewport
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1055
diff
changeset
|
84 } |
f3bb9a6dd949
locking abstraction in IViewport
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1055
diff
changeset
|
85 |
1216
5147277850cf
better abstraction for IViewport
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1215
diff
changeset
|
86 virtual ICompositor& GetCompositor() ORTHANC_OVERRIDE; |
5147277850cf
better abstraction for IViewport
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1215
diff
changeset
|
87 |
5147277850cf
better abstraction for IViewport
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1215
diff
changeset
|
88 virtual ViewportController& GetController() ORTHANC_OVERRIDE |
1203
f3bb9a6dd949
locking abstraction in IViewport
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1055
diff
changeset
|
89 { |
1216
5147277850cf
better abstraction for IViewport
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1215
diff
changeset
|
90 return *that_.controller_; |
5147277850cf
better abstraction for IViewport
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1215
diff
changeset
|
91 } |
5147277850cf
better abstraction for IViewport
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1215
diff
changeset
|
92 |
5147277850cf
better abstraction for IViewport
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1215
diff
changeset
|
93 virtual void Invalidate() ORTHANC_OVERRIDE |
5147277850cf
better abstraction for IViewport
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1215
diff
changeset
|
94 { |
5147277850cf
better abstraction for IViewport
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1215
diff
changeset
|
95 that_.SendRefreshEvent(); |
1203
f3bb9a6dd949
locking abstraction in IViewport
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1055
diff
changeset
|
96 } |
1576
92fca2b3ba3d
sanitizing the handling of canvas size
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1571
diff
changeset
|
97 |
92fca2b3ba3d
sanitizing the handling of canvas size
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1571
diff
changeset
|
98 virtual void RefreshCanvasSize() ORTHANC_OVERRIDE |
92fca2b3ba3d
sanitizing the handling of canvas size
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1571
diff
changeset
|
99 { |
92fca2b3ba3d
sanitizing the handling of canvas size
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1571
diff
changeset
|
100 that_.RefreshCanvasSize(); |
92fca2b3ba3d
sanitizing the handling of canvas size
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1571
diff
changeset
|
101 } |
1203
f3bb9a6dd949
locking abstraction in IViewport
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1055
diff
changeset
|
102 }; |
1216
5147277850cf
better abstraction for IViewport
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1215
diff
changeset
|
103 |
5147277850cf
better abstraction for IViewport
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1215
diff
changeset
|
104 void ClearCompositor() |
5147277850cf
better abstraction for IViewport
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1215
diff
changeset
|
105 { |
5147277850cf
better abstraction for IViewport
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1215
diff
changeset
|
106 compositor_.reset(); |
1053
32b403a47b19
simplifying IViewport
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1047
diff
changeset
|
107 } |
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:
893
diff
changeset
|
108 |
1216
5147277850cf
better abstraction for IViewport
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1215
diff
changeset
|
109 void AcquireCompositor(ICompositor* compositor /* takes ownership */); |
5147277850cf
better abstraction for IViewport
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1215
diff
changeset
|
110 |
1576
92fca2b3ba3d
sanitizing the handling of canvas size
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1571
diff
changeset
|
111 virtual void RefreshCanvasSize() = 0; |
92fca2b3ba3d
sanitizing the handling of canvas size
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1571
diff
changeset
|
112 |
1331
ab81ee8fce1f
- Viewport is not passed and stored as a shared_ptr instead
Benjamin Golinvaux <bgo@osimis.io>
parents:
1308
diff
changeset
|
113 protected: |
1216
5147277850cf
better abstraction for IViewport
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1215
diff
changeset
|
114 SdlViewport(); |
1576
92fca2b3ba3d
sanitizing the handling of canvas size
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1571
diff
changeset
|
115 |
1331
ab81ee8fce1f
- Viewport is not passed and stored as a shared_ptr instead
Benjamin Golinvaux <bgo@osimis.io>
parents:
1308
diff
changeset
|
116 void PostConstructor(); |
ab81ee8fce1f
- Viewport is not passed and stored as a shared_ptr instead
Benjamin Golinvaux <bgo@osimis.io>
parents:
1308
diff
changeset
|
117 |
ab81ee8fce1f
- Viewport is not passed and stored as a shared_ptr instead
Benjamin Golinvaux <bgo@osimis.io>
parents:
1308
diff
changeset
|
118 public: |
1216
5147277850cf
better abstraction for IViewport
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1215
diff
changeset
|
119 bool IsRefreshEvent(const SDL_Event& event) const |
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:
893
diff
changeset
|
120 { |
1216
5147277850cf
better abstraction for IViewport
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1215
diff
changeset
|
121 return (event.type == refreshEvent_); |
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:
893
diff
changeset
|
122 } |
88bf49aebc13
introduced ICompositor and allow SdlViewport to work with a CairoCompositor (to run on machines without OpenGL drivers)
Alain Mazy <alain@mazy.be>
parents:
893
diff
changeset
|
123 |
1203
f3bb9a6dd949
locking abstraction in IViewport
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1055
diff
changeset
|
124 virtual ILock* Lock() ORTHANC_OVERRIDE |
891
0aff28f15ea2
new abstraction: IViewport
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
125 { |
1203
f3bb9a6dd949
locking abstraction in IViewport
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1055
diff
changeset
|
126 return new SdlLock(*this); |
891
0aff28f15ea2
new abstraction: IViewport
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
127 } |
909 | 128 |
1391
32272ecfc6c2
Drilled a hole through the abstractions to be able to match
Benjamin Golinvaux <bgo@osimis.io>
parents:
1332
diff
changeset
|
129 virtual uint32_t GetSdlWindowId() = 0; |
32272ecfc6c2
Drilled a hole through the abstractions to be able to match
Benjamin Golinvaux <bgo@osimis.io>
parents:
1332
diff
changeset
|
130 |
1576
92fca2b3ba3d
sanitizing the handling of canvas size
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1571
diff
changeset
|
131 void UpdateSize(unsigned int width, |
92fca2b3ba3d
sanitizing the handling of canvas size
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1571
diff
changeset
|
132 unsigned int height); |
1216
5147277850cf
better abstraction for IViewport
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1215
diff
changeset
|
133 |
5147277850cf
better abstraction for IViewport
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1215
diff
changeset
|
134 virtual void ToggleMaximize() = 0; |
5147277850cf
better abstraction for IViewport
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1215
diff
changeset
|
135 |
5147277850cf
better abstraction for IViewport
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1215
diff
changeset
|
136 // Must be invoked from the main SDL thread |
5147277850cf
better abstraction for IViewport
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1215
diff
changeset
|
137 virtual void Paint() = 0; |
1053
32b403a47b19
simplifying IViewport
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1047
diff
changeset
|
138 }; |
947
1091b2adeb5a
Fixed animation frame stopping when returning false + big work on the OpenGL
Benjamin Golinvaux <bgo@osimis.io>
parents:
942
diff
changeset
|
139 |
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:
893
diff
changeset
|
140 |
1804 | 141 #if ORTHANC_ENABLE_OPENGL == 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:
893
diff
changeset
|
142 class SdlOpenGLViewport : public SdlViewport |
88bf49aebc13
introduced ICompositor and allow SdlViewport to work with a CairoCompositor (to run on machines without OpenGL drivers)
Alain Mazy <alain@mazy.be>
parents:
893
diff
changeset
|
143 { |
891
0aff28f15ea2
new abstraction: IViewport
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
144 private: |
0aff28f15ea2
new abstraction: IViewport
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
145 SdlOpenGLContext context_; |
0aff28f15ea2
new abstraction: IViewport
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
146 |
1332
be614695747d
std::string in viewport ctor
Benjamin Golinvaux <bgo@osimis.io>
parents:
1331
diff
changeset
|
147 SdlOpenGLViewport(const std::string& title, |
be614695747d
std::string in viewport ctor
Benjamin Golinvaux <bgo@osimis.io>
parents:
1331
diff
changeset
|
148 unsigned int width, |
be614695747d
std::string in viewport ctor
Benjamin Golinvaux <bgo@osimis.io>
parents:
1331
diff
changeset
|
149 unsigned int height, |
be614695747d
std::string in viewport ctor
Benjamin Golinvaux <bgo@osimis.io>
parents:
1331
diff
changeset
|
150 bool allowDpiScaling = true); |
1576
92fca2b3ba3d
sanitizing the handling of canvas size
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1571
diff
changeset
|
151 |
92fca2b3ba3d
sanitizing the handling of canvas size
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1571
diff
changeset
|
152 protected: |
92fca2b3ba3d
sanitizing the handling of canvas size
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1571
diff
changeset
|
153 virtual void RefreshCanvasSize() ORTHANC_OVERRIDE; |
92fca2b3ba3d
sanitizing the handling of canvas size
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1571
diff
changeset
|
154 |
1331
ab81ee8fce1f
- Viewport is not passed and stored as a shared_ptr instead
Benjamin Golinvaux <bgo@osimis.io>
parents:
1308
diff
changeset
|
155 public: |
1804 | 156 static boost::shared_ptr<SdlOpenGLViewport> Create(const std::string& title, |
1331
ab81ee8fce1f
- Viewport is not passed and stored as a shared_ptr instead
Benjamin Golinvaux <bgo@osimis.io>
parents:
1308
diff
changeset
|
157 unsigned int width, |
ab81ee8fce1f
- Viewport is not passed and stored as a shared_ptr instead
Benjamin Golinvaux <bgo@osimis.io>
parents:
1308
diff
changeset
|
158 unsigned int height, |
ab81ee8fce1f
- Viewport is not passed and stored as a shared_ptr instead
Benjamin Golinvaux <bgo@osimis.io>
parents:
1308
diff
changeset
|
159 bool allowDpiScaling = true); |
891
0aff28f15ea2
new abstraction: IViewport
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
160 |
1307
8a28a9bf8876
ViewportController now gets a ref to its parent viewport for proper lock usage
Benjamin Golinvaux <bgo@osimis.io>
parents:
1279
diff
changeset
|
161 |
1216
5147277850cf
better abstraction for IViewport
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1215
diff
changeset
|
162 virtual ~SdlOpenGLViewport(); |
891
0aff28f15ea2
new abstraction: IViewport
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
163 |
1391
32272ecfc6c2
Drilled a hole through the abstractions to be able to match
Benjamin Golinvaux <bgo@osimis.io>
parents:
1332
diff
changeset
|
164 virtual uint32_t GetSdlWindowId() ORTHANC_OVERRIDE; |
32272ecfc6c2
Drilled a hole through the abstractions to be able to match
Benjamin Golinvaux <bgo@osimis.io>
parents:
1332
diff
changeset
|
165 |
1216
5147277850cf
better abstraction for IViewport
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1215
diff
changeset
|
166 virtual void Paint() ORTHANC_OVERRIDE; |
1053
32b403a47b19
simplifying IViewport
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1047
diff
changeset
|
167 |
1216
5147277850cf
better abstraction for IViewport
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1215
diff
changeset
|
168 virtual void ToggleMaximize() ORTHANC_OVERRIDE; |
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:
893
diff
changeset
|
169 }; |
1804 | 170 #endif |
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:
893
diff
changeset
|
171 |
88bf49aebc13
introduced ICompositor and allow SdlViewport to work with a CairoCompositor (to run on machines without OpenGL drivers)
Alain Mazy <alain@mazy.be>
parents:
893
diff
changeset
|
172 |
88bf49aebc13
introduced ICompositor and allow SdlViewport to work with a CairoCompositor (to run on machines without OpenGL drivers)
Alain Mazy <alain@mazy.be>
parents:
893
diff
changeset
|
173 class SdlCairoViewport : public SdlViewport |
88bf49aebc13
introduced ICompositor and allow SdlViewport to work with a CairoCompositor (to run on machines without OpenGL drivers)
Alain Mazy <alain@mazy.be>
parents:
893
diff
changeset
|
174 { |
88bf49aebc13
introduced ICompositor and allow SdlViewport to work with a CairoCompositor (to run on machines without OpenGL drivers)
Alain Mazy <alain@mazy.be>
parents:
893
diff
changeset
|
175 private: |
1216
5147277850cf
better abstraction for IViewport
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1215
diff
changeset
|
176 SdlWindow window_; |
5147277850cf
better abstraction for IViewport
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1215
diff
changeset
|
177 SDL_Surface* sdlSurface_; |
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:
893
diff
changeset
|
178 |
1571 | 179 void CreateSdlSurfaceFromCompositor(const CairoCompositor& compositor); |
1053
32b403a47b19
simplifying IViewport
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1047
diff
changeset
|
180 |
1804 | 181 SdlCairoViewport(const std::string& title, |
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:
893
diff
changeset
|
182 unsigned int width, |
88bf49aebc13
introduced ICompositor and allow SdlViewport to work with a CairoCompositor (to run on machines without OpenGL drivers)
Alain Mazy <alain@mazy.be>
parents:
893
diff
changeset
|
183 unsigned int height, |
1804 | 184 bool allowDpiScaling); |
1576
92fca2b3ba3d
sanitizing the handling of canvas size
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1571
diff
changeset
|
185 |
92fca2b3ba3d
sanitizing the handling of canvas size
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1571
diff
changeset
|
186 protected: |
92fca2b3ba3d
sanitizing the handling of canvas size
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1571
diff
changeset
|
187 virtual void RefreshCanvasSize() ORTHANC_OVERRIDE; |
92fca2b3ba3d
sanitizing the handling of canvas size
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1571
diff
changeset
|
188 |
1331
ab81ee8fce1f
- Viewport is not passed and stored as a shared_ptr instead
Benjamin Golinvaux <bgo@osimis.io>
parents:
1308
diff
changeset
|
189 public: |
1804 | 190 static boost::shared_ptr<SdlCairoViewport> Create(const std::string& title, |
191 unsigned int width, | |
192 unsigned int height, | |
193 bool allowDpiScaling = true); | |
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:
893
diff
changeset
|
194 |
1216
5147277850cf
better abstraction for IViewport
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1215
diff
changeset
|
195 virtual ~SdlCairoViewport(); |
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:
893
diff
changeset
|
196 |
1391
32272ecfc6c2
Drilled a hole through the abstractions to be able to match
Benjamin Golinvaux <bgo@osimis.io>
parents:
1332
diff
changeset
|
197 virtual uint32_t GetSdlWindowId() ORTHANC_OVERRIDE; |
32272ecfc6c2
Drilled a hole through the abstractions to be able to match
Benjamin Golinvaux <bgo@osimis.io>
parents:
1332
diff
changeset
|
198 |
1216
5147277850cf
better abstraction for IViewport
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1215
diff
changeset
|
199 virtual void Paint() ORTHANC_OVERRIDE; |
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:
893
diff
changeset
|
200 |
1216
5147277850cf
better abstraction for IViewport
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1215
diff
changeset
|
201 virtual void ToggleMaximize() ORTHANC_OVERRIDE; |
891
0aff28f15ea2
new abstraction: IViewport
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
202 }; |
0aff28f15ea2
new abstraction: IViewport
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
203 } |