annotate Framework/Viewport/SdlViewport.h @ 1213:86a8266b8888 broker

moving the scene from IViewport to ViewportController
author Sebastien Jodogne <s.jodogne@gmail.com>
date Wed, 04 Dec 2019 17:54:10 +0100
parents 6009c59d8676
children 9efa66d8d3f8
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
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
0aff28f15ea2 new abstraction: IViewport
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
5 * Copyright (C) 2017-2019 Osimis S.A., Belgium
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
1047
efc5b62b9539 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1045
diff changeset
39 #include "../OpenGL/SdlOpenGLContext.h"
891
0aff28f15ea2 new abstraction: IViewport
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
40 #include "../Scene2D/OpenGLCompositor.h"
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
41 #include "../Scene2D/CairoCompositor.h"
891
0aff28f15ea2 new abstraction: IViewport
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
42 #include "ViewportBase.h"
0aff28f15ea2 new abstraction: IViewport
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
43
1205
6009c59d8676 fix to sdl
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1203
diff changeset
44 #include <SDL_events.h>
6009c59d8676 fix to sdl
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1203
diff changeset
45
891
0aff28f15ea2 new abstraction: IViewport
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
46 namespace OrthancStone
0aff28f15ea2 new abstraction: IViewport
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
47 {
0aff28f15ea2 new abstraction: IViewport
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
48 class SdlViewport : public ViewportBase
0aff28f15ea2 new abstraction: IViewport
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
49 {
1205
6009c59d8676 fix to sdl
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1203
diff changeset
50 private:
6009c59d8676 fix to sdl
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1203
diff changeset
51 uint32_t refreshEvent_;
1203
f3bb9a6dd949 locking abstraction in IViewport
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1055
diff changeset
52
1205
6009c59d8676 fix to sdl
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1203
diff changeset
53 protected:
6009c59d8676 fix to sdl
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1203
diff changeset
54 void SendRefreshEvent();
6009c59d8676 fix to sdl
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1203
diff changeset
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: 893
diff changeset
56 public:
1205
6009c59d8676 fix to sdl
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1203
diff changeset
57 SdlViewport();
6009c59d8676 fix to sdl
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1203
diff changeset
58
6009c59d8676 fix to sdl
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1203
diff changeset
59 bool IsRefreshEvent(const SDL_Event& event) const
1053
32b403a47b19 simplifying IViewport
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1047
diff changeset
60 {
1205
6009c59d8676 fix to sdl
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1203
diff changeset
61 return (event.type == refreshEvent_);
1053
32b403a47b19 simplifying IViewport
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1047
diff changeset
62 }
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
63
909
7a7e4e1f558f SdlCairo resizable
Alain Mazy <alain@mazy.be>
parents: 907
diff changeset
64 virtual void UpdateSize(unsigned int width,
7a7e4e1f558f SdlCairo resizable
Alain Mazy <alain@mazy.be>
parents: 907
diff changeset
65 unsigned int height) = 0;
1205
6009c59d8676 fix to sdl
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1203
diff changeset
66
6009c59d8676 fix to sdl
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1203
diff changeset
67 virtual void ToggleMaximize() = 0;
1053
32b403a47b19 simplifying IViewport
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1047
diff changeset
68 };
947
1091b2adeb5a Fixed animation frame stopping when returning false + big work on the OpenGL
Benjamin Golinvaux <bgo@osimis.io>
parents: 942
diff changeset
69
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
70
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
71 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
72 {
891
0aff28f15ea2 new abstraction: IViewport
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
73 private:
1205
6009c59d8676 fix to sdl
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1203
diff changeset
74 boost::mutex mutex_;
6009c59d8676 fix to sdl
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1203
diff changeset
75 SdlOpenGLContext context_;
1203
f3bb9a6dd949 locking abstraction in IViewport
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1055
diff changeset
76 std::auto_ptr<OpenGLCompositor> compositor_;
891
0aff28f15ea2 new abstraction: IViewport
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
77
1203
f3bb9a6dd949 locking abstraction in IViewport
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1055
diff changeset
78 class SdlLock : public LockBase
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 private:
f3bb9a6dd949 locking abstraction in IViewport
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1055
diff changeset
81 SdlOpenGLViewport& that_;
f3bb9a6dd949 locking abstraction in IViewport
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1055
diff changeset
82 boost::mutex::scoped_lock lock_;
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 public:
f3bb9a6dd949 locking abstraction in IViewport
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1055
diff changeset
85 SdlLock(SdlOpenGLViewport& viewport) :
f3bb9a6dd949 locking abstraction in IViewport
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1055
diff changeset
86 LockBase(viewport),
f3bb9a6dd949 locking abstraction in IViewport
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1055
diff changeset
87 that_(viewport),
f3bb9a6dd949 locking abstraction in IViewport
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1055
diff changeset
88 lock_(viewport.mutex_)
f3bb9a6dd949 locking abstraction in IViewport
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1055
diff changeset
89 {
f3bb9a6dd949 locking abstraction in IViewport
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1055
diff changeset
90 }
f3bb9a6dd949 locking abstraction in IViewport
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1055
diff changeset
91
f3bb9a6dd949 locking abstraction in IViewport
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1055
diff changeset
92 virtual bool HasCompositor() const ORTHANC_OVERRIDE
f3bb9a6dd949 locking abstraction in IViewport
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1055
diff changeset
93 {
f3bb9a6dd949 locking abstraction in IViewport
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1055
diff changeset
94 return true;
f3bb9a6dd949 locking abstraction in IViewport
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1055
diff changeset
95 }
f3bb9a6dd949 locking abstraction in IViewport
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1055
diff changeset
96
f3bb9a6dd949 locking abstraction in IViewport
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1055
diff changeset
97 virtual ICompositor& GetCompositor() ORTHANC_OVERRIDE
f3bb9a6dd949 locking abstraction in IViewport
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1055
diff changeset
98 {
f3bb9a6dd949 locking abstraction in IViewport
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1055
diff changeset
99 return *that_.compositor_;
f3bb9a6dd949 locking abstraction in IViewport
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1055
diff changeset
100 }
f3bb9a6dd949 locking abstraction in IViewport
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1055
diff changeset
101 };
f3bb9a6dd949 locking abstraction in IViewport
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1055
diff changeset
102
891
0aff28f15ea2 new abstraction: IViewport
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
103 public:
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
104 SdlOpenGLViewport(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
105 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
106 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
107 bool allowDpiScaling = true);
891
0aff28f15ea2 new abstraction: IViewport
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
108
1205
6009c59d8676 fix to sdl
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1203
diff changeset
109 virtual void Invalidate() ORTHANC_OVERRIDE;
6009c59d8676 fix to sdl
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1203
diff changeset
110
1213
86a8266b8888 moving the scene from IViewport to ViewportController
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1205
diff changeset
111 virtual void Paint(const Scene2D& scene) ORTHANC_OVERRIDE;
891
0aff28f15ea2 new abstraction: IViewport
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
112
1203
f3bb9a6dd949 locking abstraction in IViewport
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1055
diff changeset
113 virtual ILock* Lock() ORTHANC_OVERRIDE
891
0aff28f15ea2 new abstraction: IViewport
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
114 {
1203
f3bb9a6dd949 locking abstraction in IViewport
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1055
diff changeset
115 return new SdlLock(*this);
891
0aff28f15ea2 new abstraction: IViewport
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
116 }
909
7a7e4e1f558f SdlCairo resizable
Alain Mazy <alain@mazy.be>
parents: 907
diff changeset
117
942
685c9a2d115f Added missing ORTHANC_OVERRIDE + preparation for lost GL context handling + stubs for GL context event handlers
Benjamin Golinvaux <bgo@osimis.io>
parents: 909
diff changeset
118 virtual void UpdateSize(unsigned int width, unsigned int height) ORTHANC_OVERRIDE
909
7a7e4e1f558f SdlCairo resizable
Alain Mazy <alain@mazy.be>
parents: 907
diff changeset
119 {
7a7e4e1f558f SdlCairo resizable
Alain Mazy <alain@mazy.be>
parents: 907
diff changeset
120 // nothing to do in OpenGL, the OpenGLCompositor::UpdateSize will be called automatically
7a7e4e1f558f SdlCairo resizable
Alain Mazy <alain@mazy.be>
parents: 907
diff changeset
121 }
1205
6009c59d8676 fix to sdl
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1203
diff changeset
122
6009c59d8676 fix to sdl
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1203
diff changeset
123 virtual void ToggleMaximize() ORTHANC_OVERRIDE
6009c59d8676 fix to sdl
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1203
diff changeset
124 {
6009c59d8676 fix to sdl
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1203
diff changeset
125 boost::mutex::scoped_lock lock(mutex_);
6009c59d8676 fix to sdl
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1203
diff changeset
126 context_.ToggleMaximize();
6009c59d8676 fix to sdl
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1203
diff changeset
127 }
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
128 };
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
129
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
130
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
131 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
132 {
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
133 private:
1203
f3bb9a6dd949 locking abstraction in IViewport
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1055
diff changeset
134 class SdlLock : public LockBase
f3bb9a6dd949 locking abstraction in IViewport
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1055
diff changeset
135 {
f3bb9a6dd949 locking abstraction in IViewport
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1055
diff changeset
136 private:
f3bb9a6dd949 locking abstraction in IViewport
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1055
diff changeset
137 SdlCairoViewport& that_;
f3bb9a6dd949 locking abstraction in IViewport
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1055
diff changeset
138 boost::mutex::scoped_lock lock_;
f3bb9a6dd949 locking abstraction in IViewport
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1055
diff changeset
139
f3bb9a6dd949 locking abstraction in IViewport
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1055
diff changeset
140 public:
f3bb9a6dd949 locking abstraction in IViewport
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1055
diff changeset
141 SdlLock(SdlCairoViewport& viewport) :
f3bb9a6dd949 locking abstraction in IViewport
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1055
diff changeset
142 LockBase(viewport),
f3bb9a6dd949 locking abstraction in IViewport
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1055
diff changeset
143 that_(viewport),
f3bb9a6dd949 locking abstraction in IViewport
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1055
diff changeset
144 lock_(viewport.mutex_)
f3bb9a6dd949 locking abstraction in IViewport
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1055
diff changeset
145 {
f3bb9a6dd949 locking abstraction in IViewport
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1055
diff changeset
146 }
f3bb9a6dd949 locking abstraction in IViewport
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1055
diff changeset
147
f3bb9a6dd949 locking abstraction in IViewport
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1055
diff changeset
148 virtual bool HasCompositor() const ORTHANC_OVERRIDE
f3bb9a6dd949 locking abstraction in IViewport
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1055
diff changeset
149 {
f3bb9a6dd949 locking abstraction in IViewport
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1055
diff changeset
150 return true;
f3bb9a6dd949 locking abstraction in IViewport
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1055
diff changeset
151 }
f3bb9a6dd949 locking abstraction in IViewport
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1055
diff changeset
152
f3bb9a6dd949 locking abstraction in IViewport
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1055
diff changeset
153 virtual ICompositor& GetCompositor() ORTHANC_OVERRIDE
f3bb9a6dd949 locking abstraction in IViewport
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1055
diff changeset
154 {
f3bb9a6dd949 locking abstraction in IViewport
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1055
diff changeset
155 return that_.compositor_;
f3bb9a6dd949 locking abstraction in IViewport
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1055
diff changeset
156 }
f3bb9a6dd949 locking abstraction in IViewport
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1055
diff changeset
157 };
f3bb9a6dd949 locking abstraction in IViewport
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1055
diff changeset
158
1205
6009c59d8676 fix to sdl
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1203
diff changeset
159 boost::mutex mutex_;
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
160 SdlWindow window_;
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
161 CairoCompositor compositor_;
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
162 SDL_Surface* sdlSurface_;
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
163
1205
6009c59d8676 fix to sdl
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1203
diff changeset
164 void CreateSdlSurfaceFromCompositor();
1053
32b403a47b19 simplifying IViewport
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1047
diff changeset
165
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
166 public:
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
167 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
168 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
169 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
170 bool allowDpiScaling = true);
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 ~SdlCairoViewport();
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
1205
6009c59d8676 fix to sdl
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1203
diff changeset
174 virtual void Invalidate() ORTHANC_OVERRIDE;
6009c59d8676 fix to sdl
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1203
diff changeset
175
1213
86a8266b8888 moving the scene from IViewport to ViewportController
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1205
diff changeset
176 virtual void Paint(const Scene2D& scene) ORTHANC_OVERRIDE;
1205
6009c59d8676 fix to sdl
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1203
diff changeset
177
6009c59d8676 fix to sdl
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1203
diff changeset
178 virtual ILock* Lock() ORTHANC_OVERRIDE
6009c59d8676 fix to sdl
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1203
diff changeset
179 {
6009c59d8676 fix to sdl
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1203
diff changeset
180 return new SdlLock(*this);
6009c59d8676 fix to sdl
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1203
diff changeset
181 }
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
909
7a7e4e1f558f SdlCairo resizable
Alain Mazy <alain@mazy.be>
parents: 907
diff changeset
183 virtual void UpdateSize(unsigned int width,
942
685c9a2d115f Added missing ORTHANC_OVERRIDE + preparation for lost GL context handling + stubs for GL context event handlers
Benjamin Golinvaux <bgo@osimis.io>
parents: 909
diff changeset
184 unsigned int height) ORTHANC_OVERRIDE;
1205
6009c59d8676 fix to sdl
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1203
diff changeset
185
6009c59d8676 fix to sdl
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1203
diff changeset
186 virtual void ToggleMaximize() ORTHANC_OVERRIDE
6009c59d8676 fix to sdl
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1203
diff changeset
187 {
6009c59d8676 fix to sdl
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1203
diff changeset
188 boost::mutex::scoped_lock lock(mutex_);
6009c59d8676 fix to sdl
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1203
diff changeset
189 window_.ToggleMaximize();
6009c59d8676 fix to sdl
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1203
diff changeset
190 }
891
0aff28f15ea2 new abstraction: IViewport
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
191 };
0aff28f15ea2 new abstraction: IViewport
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
192 }