Mercurial > hg > orthanc-stone
annotate Applications/Platforms/Sdl/SdlViewport.h @ 1603:595c0952ef7e
focusing on osirix annotations in Stone Web viewer
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Wed, 28 Oct 2020 18:49:01 +0100 |
parents | 5887a4f8594b |
children | 9ac2a65d4172 |
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 |
1270
2d8ab34c8c91
upgrade to year 2020
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1055
diff
changeset
|
5 * Copyright (C) 2017-2020 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 |
0aff28f15ea2
new abstraction: IViewport
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
35 #if ORTHANC_ENABLE_OPENGL != 1 |
0aff28f15ea2
new abstraction: IViewport
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
36 # error Support for OpenGL is disabled |
0aff28f15ea2
new abstraction: IViewport
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
37 #endif |
0aff28f15ea2
new abstraction: IViewport
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
38 |
1591
5887a4f8594b
moving platform-specific files out of the "OrthancStone" folder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1576
diff
changeset
|
39 #include "SdlOpenGLContext.h" |
5887a4f8594b
moving platform-specific files out of the "OrthancStone" folder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1576
diff
changeset
|
40 #include "../../../OrthancStone/Sources/Scene2D/OpenGLCompositor.h" |
5887a4f8594b
moving platform-specific files out of the "OrthancStone" folder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1576
diff
changeset
|
41 #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
|
42 #include "../../../OrthancStone/Sources/Viewport/IViewport.h" |
891
0aff28f15ea2
new abstraction: IViewport
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
43 |
1205 | 44 #include <SDL_events.h> |
891
0aff28f15ea2
new abstraction: IViewport
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
45 |
1307
8a28a9bf8876
ViewportController now gets a ref to its parent viewport for proper lock usage
Benjamin Golinvaux <bgo@osimis.io>
parents:
1279
diff
changeset
|
46 // 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
|
47 // 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
|
48 #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
|
49 |
8a28a9bf8876
ViewportController now gets a ref to its parent viewport for proper lock usage
Benjamin Golinvaux <bgo@osimis.io>
parents:
1279
diff
changeset
|
50 #include <boost/thread/recursive_mutex.hpp> |
1560
b4ccd4963d37
fix sdl and wasm samples
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1512
diff
changeset
|
51 #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
|
52 |
891
0aff28f15ea2
new abstraction: IViewport
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
53 namespace OrthancStone |
0aff28f15ea2
new abstraction: IViewport
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
54 { |
1307
8a28a9bf8876
ViewportController now gets a ref to its parent viewport for proper lock usage
Benjamin Golinvaux <bgo@osimis.io>
parents:
1279
diff
changeset
|
55 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
|
56 |
1331
ab81ee8fce1f
- Viewport is not passed and stored as a shared_ptr instead
Benjamin Golinvaux <bgo@osimis.io>
parents:
1308
diff
changeset
|
57 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
|
58 public boost::enable_shared_from_this<SdlViewport> |
891
0aff28f15ea2
new abstraction: IViewport
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
59 { |
1205 | 60 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
|
61 boost::recursive_mutex mutex_; |
1216
5147277850cf
better abstraction for IViewport
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1215
diff
changeset
|
62 uint32_t refreshEvent_; |
5147277850cf
better abstraction for IViewport
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1215
diff
changeset
|
63 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
|
64 std::unique_ptr<ICompositor> compositor_; |
1216
5147277850cf
better abstraction for IViewport
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1215
diff
changeset
|
65 |
5147277850cf
better abstraction for IViewport
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1215
diff
changeset
|
66 void SendRefreshEvent(); |
1203
f3bb9a6dd949
locking abstraction in IViewport
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1055
diff
changeset
|
67 |
1205 | 68 protected: |
1215
9efa66d8d3f8
removed ViewportBase, and removed dependency of ViewportController on IViewport
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1213
diff
changeset
|
69 class SdlLock : public ILock |
1053
32b403a47b19
simplifying IViewport
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1047
diff
changeset
|
70 { |
1203
f3bb9a6dd949
locking abstraction in IViewport
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1055
diff
changeset
|
71 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
|
72 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
|
73 boost::recursive_mutex::scoped_lock lock_; |
1216
5147277850cf
better abstraction for IViewport
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1215
diff
changeset
|
74 |
1203
f3bb9a6dd949
locking abstraction in IViewport
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1055
diff
changeset
|
75 public: |
1571 | 76 explicit SdlLock(SdlViewport& that) : |
77 that_(that), | |
78 lock_(that.mutex_) | |
1203
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 |
f3bb9a6dd949
locking abstraction in IViewport
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1055
diff
changeset
|
82 virtual bool HasCompositor() const ORTHANC_OVERRIDE |
f3bb9a6dd949
locking abstraction in IViewport
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1055
diff
changeset
|
83 { |
f3bb9a6dd949
locking abstraction in IViewport
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1055
diff
changeset
|
84 return true; |
f3bb9a6dd949
locking abstraction in IViewport
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1055
diff
changeset
|
85 } |
f3bb9a6dd949
locking abstraction in IViewport
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1055
diff
changeset
|
86 |
1216
5147277850cf
better abstraction for IViewport
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1215
diff
changeset
|
87 virtual ICompositor& GetCompositor() ORTHANC_OVERRIDE; |
5147277850cf
better abstraction for IViewport
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1215
diff
changeset
|
88 |
5147277850cf
better abstraction for IViewport
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1215
diff
changeset
|
89 virtual ViewportController& GetController() ORTHANC_OVERRIDE |
1203
f3bb9a6dd949
locking abstraction in IViewport
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1055
diff
changeset
|
90 { |
1216
5147277850cf
better abstraction for IViewport
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1215
diff
changeset
|
91 return *that_.controller_; |
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 |
5147277850cf
better abstraction for IViewport
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1215
diff
changeset
|
94 virtual void Invalidate() ORTHANC_OVERRIDE |
5147277850cf
better abstraction for IViewport
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1215
diff
changeset
|
95 { |
5147277850cf
better abstraction for IViewport
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1215
diff
changeset
|
96 that_.SendRefreshEvent(); |
1203
f3bb9a6dd949
locking abstraction in IViewport
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1055
diff
changeset
|
97 } |
1576
92fca2b3ba3d
sanitizing the handling of canvas size
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1571
diff
changeset
|
98 |
92fca2b3ba3d
sanitizing the handling of canvas size
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1571
diff
changeset
|
99 virtual void RefreshCanvasSize() ORTHANC_OVERRIDE |
92fca2b3ba3d
sanitizing the handling of canvas size
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1571
diff
changeset
|
100 { |
92fca2b3ba3d
sanitizing the handling of canvas size
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1571
diff
changeset
|
101 that_.RefreshCanvasSize(); |
92fca2b3ba3d
sanitizing the handling of canvas size
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1571
diff
changeset
|
102 } |
1203
f3bb9a6dd949
locking abstraction in IViewport
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1055
diff
changeset
|
103 }; |
1216
5147277850cf
better abstraction for IViewport
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1215
diff
changeset
|
104 |
5147277850cf
better abstraction for IViewport
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1215
diff
changeset
|
105 void ClearCompositor() |
5147277850cf
better abstraction for IViewport
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1215
diff
changeset
|
106 { |
5147277850cf
better abstraction for IViewport
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1215
diff
changeset
|
107 compositor_.reset(); |
1053
32b403a47b19
simplifying IViewport
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1047
diff
changeset
|
108 } |
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
|
109 |
1216
5147277850cf
better abstraction for IViewport
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1215
diff
changeset
|
110 void AcquireCompositor(ICompositor* compositor /* takes ownership */); |
5147277850cf
better abstraction for IViewport
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1215
diff
changeset
|
111 |
1576
92fca2b3ba3d
sanitizing the handling of canvas size
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1571
diff
changeset
|
112 virtual void RefreshCanvasSize() = 0; |
92fca2b3ba3d
sanitizing the handling of canvas size
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1571
diff
changeset
|
113 |
1331
ab81ee8fce1f
- Viewport is not passed and stored as a shared_ptr instead
Benjamin Golinvaux <bgo@osimis.io>
parents:
1308
diff
changeset
|
114 protected: |
1216
5147277850cf
better abstraction for IViewport
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1215
diff
changeset
|
115 SdlViewport(); |
1576
92fca2b3ba3d
sanitizing the handling of canvas size
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1571
diff
changeset
|
116 |
1331
ab81ee8fce1f
- Viewport is not passed and stored as a shared_ptr instead
Benjamin Golinvaux <bgo@osimis.io>
parents:
1308
diff
changeset
|
117 void PostConstructor(); |
ab81ee8fce1f
- Viewport is not passed and stored as a shared_ptr instead
Benjamin Golinvaux <bgo@osimis.io>
parents:
1308
diff
changeset
|
118 |
ab81ee8fce1f
- Viewport is not passed and stored as a shared_ptr instead
Benjamin Golinvaux <bgo@osimis.io>
parents:
1308
diff
changeset
|
119 public: |
1216
5147277850cf
better abstraction for IViewport
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1215
diff
changeset
|
120 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
|
121 { |
1216
5147277850cf
better abstraction for IViewport
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1215
diff
changeset
|
122 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
|
123 } |
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
|
124 |
1203
f3bb9a6dd949
locking abstraction in IViewport
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1055
diff
changeset
|
125 virtual ILock* Lock() ORTHANC_OVERRIDE |
891
0aff28f15ea2
new abstraction: IViewport
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
126 { |
1203
f3bb9a6dd949
locking abstraction in IViewport
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1055
diff
changeset
|
127 return new SdlLock(*this); |
891
0aff28f15ea2
new abstraction: IViewport
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
128 } |
909 | 129 |
1391
32272ecfc6c2
Drilled a hole through the abstractions to be able to match
Benjamin Golinvaux <bgo@osimis.io>
parents:
1332
diff
changeset
|
130 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
|
131 |
1576
92fca2b3ba3d
sanitizing the handling of canvas size
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1571
diff
changeset
|
132 void UpdateSize(unsigned int width, |
92fca2b3ba3d
sanitizing the handling of canvas size
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1571
diff
changeset
|
133 unsigned int height); |
1216
5147277850cf
better abstraction for IViewport
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1215
diff
changeset
|
134 |
5147277850cf
better abstraction for IViewport
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1215
diff
changeset
|
135 virtual void ToggleMaximize() = 0; |
5147277850cf
better abstraction for IViewport
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1215
diff
changeset
|
136 |
5147277850cf
better abstraction for IViewport
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1215
diff
changeset
|
137 // Must be invoked from the main SDL thread |
5147277850cf
better abstraction for IViewport
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1215
diff
changeset
|
138 virtual void Paint() = 0; |
1053
32b403a47b19
simplifying IViewport
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1047
diff
changeset
|
139 }; |
947
1091b2adeb5a
Fixed animation frame stopping when returning false + big work on the OpenGL
Benjamin Golinvaux <bgo@osimis.io>
parents:
942
diff
changeset
|
140 |
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
|
141 |
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: |
1332
be614695747d
std::string in viewport ctor
Benjamin Golinvaux <bgo@osimis.io>
parents:
1331
diff
changeset
|
156 static boost::shared_ptr<SdlOpenGLViewport> Create(const std::string&, |
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 }; |
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
|
170 |
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 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
|
173 { |
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 private: |
1216
5147277850cf
better abstraction for IViewport
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1215
diff
changeset
|
175 SdlWindow window_; |
5147277850cf
better abstraction for IViewport
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1215
diff
changeset
|
176 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
|
177 |
1571 | 178 void CreateSdlSurfaceFromCompositor(const CairoCompositor& compositor); |
1053
32b403a47b19
simplifying IViewport
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1047
diff
changeset
|
179 |
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
|
180 SdlCairoViewport(const char* title, |
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
|
181 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
|
182 unsigned int height, |
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 bool allowDpiScaling = true); |
1576
92fca2b3ba3d
sanitizing the handling of canvas size
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1571
diff
changeset
|
184 |
92fca2b3ba3d
sanitizing the handling of canvas size
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1571
diff
changeset
|
185 protected: |
92fca2b3ba3d
sanitizing the handling of canvas size
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1571
diff
changeset
|
186 virtual void RefreshCanvasSize() ORTHANC_OVERRIDE; |
92fca2b3ba3d
sanitizing the handling of canvas size
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1571
diff
changeset
|
187 |
1331
ab81ee8fce1f
- Viewport is not passed and stored as a shared_ptr instead
Benjamin Golinvaux <bgo@osimis.io>
parents:
1308
diff
changeset
|
188 public: |
ab81ee8fce1f
- Viewport is not passed and stored as a shared_ptr instead
Benjamin Golinvaux <bgo@osimis.io>
parents:
1308
diff
changeset
|
189 static boost::shared_ptr<SdlCairoViewport> Create(const char* title, |
ab81ee8fce1f
- Viewport is not passed and stored as a shared_ptr instead
Benjamin Golinvaux <bgo@osimis.io>
parents:
1308
diff
changeset
|
190 unsigned int width, |
ab81ee8fce1f
- Viewport is not passed and stored as a shared_ptr instead
Benjamin Golinvaux <bgo@osimis.io>
parents:
1308
diff
changeset
|
191 unsigned int height, |
ab81ee8fce1f
- Viewport is not passed and stored as a shared_ptr instead
Benjamin Golinvaux <bgo@osimis.io>
parents:
1308
diff
changeset
|
192 bool allowDpiScaling = true); |
ab81ee8fce1f
- Viewport is not passed and stored as a shared_ptr instead
Benjamin Golinvaux <bgo@osimis.io>
parents:
1308
diff
changeset
|
193 |
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 } |