Mercurial > hg > orthanc-stone
comparison Framework/Viewport/SdlViewport.h @ 1205:6009c59d8676 broker
fix to sdl
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Mon, 02 Dec 2019 14:32:05 +0100 |
parents | f3bb9a6dd949 |
children | 86a8266b8888 |
comparison
equal
deleted
inserted
replaced
1204:b519c1c878f1 | 1205:6009c59d8676 |
---|---|
39 #include "../OpenGL/SdlOpenGLContext.h" | 39 #include "../OpenGL/SdlOpenGLContext.h" |
40 #include "../Scene2D/OpenGLCompositor.h" | 40 #include "../Scene2D/OpenGLCompositor.h" |
41 #include "../Scene2D/CairoCompositor.h" | 41 #include "../Scene2D/CairoCompositor.h" |
42 #include "ViewportBase.h" | 42 #include "ViewportBase.h" |
43 | 43 |
44 #include <SDL_events.h> | |
45 | |
44 namespace OrthancStone | 46 namespace OrthancStone |
45 { | 47 { |
46 class SdlViewport : public ViewportBase | 48 class SdlViewport : public ViewportBase |
47 { | 49 { |
50 private: | |
51 uint32_t refreshEvent_; | |
52 | |
48 protected: | 53 protected: |
49 boost::mutex mutex_; | 54 void SendRefreshEvent(); |
55 | |
56 public: | |
57 SdlViewport(); | |
50 | 58 |
51 public: | 59 bool IsRefreshEvent(const SDL_Event& event) const |
52 SdlViewport() | |
53 { | 60 { |
61 return (event.type == refreshEvent_); | |
54 } | 62 } |
55 | 63 |
56 virtual void UpdateSize(unsigned int width, | 64 virtual void UpdateSize(unsigned int width, |
57 unsigned int height) = 0; | 65 unsigned int height) = 0; |
66 | |
67 virtual void ToggleMaximize() = 0; | |
58 }; | 68 }; |
59 | 69 |
60 | 70 |
61 class SdlOpenGLViewport : public SdlViewport | 71 class SdlOpenGLViewport : public SdlViewport |
62 { | 72 { |
63 private: | 73 private: |
64 SdlOpenGLContext context_; | 74 boost::mutex mutex_; |
75 SdlOpenGLContext context_; | |
65 std::auto_ptr<OpenGLCompositor> compositor_; | 76 std::auto_ptr<OpenGLCompositor> compositor_; |
66 | 77 |
67 class SdlLock : public LockBase | 78 class SdlLock : public LockBase |
68 { | 79 { |
69 private: | 80 private: |
93 SdlOpenGLViewport(const char* title, | 104 SdlOpenGLViewport(const char* title, |
94 unsigned int width, | 105 unsigned int width, |
95 unsigned int height, | 106 unsigned int height, |
96 bool allowDpiScaling = true); | 107 bool allowDpiScaling = true); |
97 | 108 |
98 virtual void Refresh() ORTHANC_OVERRIDE; | 109 virtual void Invalidate() ORTHANC_OVERRIDE; |
110 | |
111 virtual void Paint() ORTHANC_OVERRIDE; | |
99 | 112 |
100 virtual ILock* Lock() ORTHANC_OVERRIDE | 113 virtual ILock* Lock() ORTHANC_OVERRIDE |
101 { | 114 { |
102 return new SdlLock(*this); | 115 return new SdlLock(*this); |
103 } | 116 } |
104 | 117 |
105 virtual void UpdateSize(unsigned int width, unsigned int height) ORTHANC_OVERRIDE | 118 virtual void UpdateSize(unsigned int width, unsigned int height) ORTHANC_OVERRIDE |
106 { | 119 { |
107 // nothing to do in OpenGL, the OpenGLCompositor::UpdateSize will be called automatically | 120 // nothing to do in OpenGL, the OpenGLCompositor::UpdateSize will be called automatically |
121 } | |
122 | |
123 virtual void ToggleMaximize() ORTHANC_OVERRIDE | |
124 { | |
125 boost::mutex::scoped_lock lock(mutex_); | |
126 context_.ToggleMaximize(); | |
108 } | 127 } |
109 }; | 128 }; |
110 | 129 |
111 | 130 |
112 class SdlCairoViewport : public SdlViewport | 131 class SdlCairoViewport : public SdlViewport |
135 { | 154 { |
136 return that_.compositor_; | 155 return that_.compositor_; |
137 } | 156 } |
138 }; | 157 }; |
139 | 158 |
159 boost::mutex mutex_; | |
140 SdlWindow window_; | 160 SdlWindow window_; |
141 CairoCompositor compositor_; | 161 CairoCompositor compositor_; |
142 SDL_Surface* sdlSurface_; | 162 SDL_Surface* sdlSurface_; |
143 | 163 |
144 void RefreshInternal(); | 164 void InvalidateInternal(); |
145 | 165 |
146 void UpdateSdlSurfaceSize(unsigned int width, | 166 void CreateSdlSurfaceFromCompositor(); |
147 unsigned int height); | |
148 | 167 |
149 public: | 168 public: |
150 SdlCairoViewport(const char* title, | 169 SdlCairoViewport(const char* title, |
151 unsigned int width, | 170 unsigned int width, |
152 unsigned int height, | 171 unsigned int height, |
153 bool allowDpiScaling = true); | 172 bool allowDpiScaling = true); |
154 | 173 |
155 ~SdlCairoViewport(); | 174 ~SdlCairoViewport(); |
156 | 175 |
157 virtual void Refresh() ORTHANC_OVERRIDE; | 176 virtual void Invalidate() ORTHANC_OVERRIDE; |
177 | |
178 virtual void Paint() ORTHANC_OVERRIDE; | |
179 | |
180 virtual ILock* Lock() ORTHANC_OVERRIDE | |
181 { | |
182 return new SdlLock(*this); | |
183 } | |
158 | 184 |
159 virtual void UpdateSize(unsigned int width, | 185 virtual void UpdateSize(unsigned int width, |
160 unsigned int height) ORTHANC_OVERRIDE; | 186 unsigned int height) ORTHANC_OVERRIDE; |
187 | |
188 virtual void ToggleMaximize() ORTHANC_OVERRIDE | |
189 { | |
190 boost::mutex::scoped_lock lock(mutex_); | |
191 window_.ToggleMaximize(); | |
192 } | |
161 }; | 193 }; |
162 } | 194 } |