comparison Framework/Viewport/SdlViewport.h @ 1053:32b403a47b19

simplifying IViewport
author Sebastien Jodogne <s.jodogne@gmail.com>
date Thu, 10 Oct 2019 15:24:48 +0200
parents efc5b62b9539
children af456106576c
comparison
equal deleted inserted replaced
1052:0cc62db7e61b 1053:32b403a47b19
46 class SdlViewport : public ViewportBase 46 class SdlViewport : public ViewportBase
47 { 47 {
48 public: 48 public:
49 SdlViewport(const std::string& identifier) 49 SdlViewport(const std::string& identifier)
50 : ViewportBase(identifier) 50 : ViewportBase(identifier)
51 {} 51 {
52 }
52 53
53 SdlViewport(const std::string& identifier, 54 SdlViewport(const std::string& identifier,
54 boost::shared_ptr<Scene2D>& scene) 55 boost::shared_ptr<Scene2D>& scene)
55 : ViewportBase(identifier, scene) 56 : ViewportBase(identifier, scene)
56 { 57 {
57
58 } 58 }
59 59
60 virtual SdlWindow& GetWindow() = 0; 60 virtual SdlWindow& GetWindow() = 0;
61 61
62 virtual void UpdateSize(unsigned int width, 62 virtual void UpdateSize(unsigned int width,
63 unsigned int height) = 0; 63 unsigned int height) = 0;
64 };
64 65
65 };
66 66
67 class SdlOpenGLViewport : public SdlViewport 67 class SdlOpenGLViewport : public SdlViewport
68 { 68 {
69 private: 69 private:
70 SdlOpenGLContext context_; 70 SdlOpenGLContext context_;
85 virtual SdlWindow& GetWindow() ORTHANC_OVERRIDE 85 virtual SdlWindow& GetWindow() ORTHANC_OVERRIDE
86 { 86 {
87 return context_.GetWindow(); 87 return context_.GetWindow();
88 } 88 }
89 89
90 virtual void Refresh() ORTHANC_OVERRIDE;
91
90 virtual void UpdateSize(unsigned int width, unsigned int height) ORTHANC_OVERRIDE 92 virtual void UpdateSize(unsigned int width, unsigned int height) ORTHANC_OVERRIDE
91 { 93 {
92 // nothing to do in OpenGL, the OpenGLCompositor::UpdateSize will be called automatically 94 // nothing to do in OpenGL, the OpenGLCompositor::UpdateSize will be called automatically
93 } 95 }
94 virtual void Refresh() ORTHANC_OVERRIDE;
95 96
96 protected: 97 virtual bool HasCompositor() const ORTHANC_OVERRIDE
97 virtual ICompositor* GetCompositor() ORTHANC_OVERRIDE
98 { 98 {
99 return compositor_.get(); 99 return true;
100 }
101
102 virtual ICompositor& GetCompositor() ORTHANC_OVERRIDE
103 {
104 return *compositor_.get();
100 } 105 }
101 }; 106 };
102 107
103 108
104 class SdlCairoViewport : public SdlViewport 109 class SdlCairoViewport : public SdlViewport
105 { 110 {
106 private: 111 private:
107 SdlWindow window_; 112 SdlWindow window_;
108 CairoCompositor compositor_; 113 CairoCompositor compositor_;
109 SDL_Surface* sdlSurface_; 114 SDL_Surface* sdlSurface_;
115
116 private:
117 void UpdateSdlSurfaceSize(unsigned int width,
118 unsigned int height);
110 119
111 public: 120 public:
112 SdlCairoViewport(const char* title, 121 SdlCairoViewport(const char* title,
113 unsigned int width, 122 unsigned int width,
114 unsigned int height, 123 unsigned int height,
124 133
125 virtual SdlWindow& GetWindow() ORTHANC_OVERRIDE 134 virtual SdlWindow& GetWindow() ORTHANC_OVERRIDE
126 { 135 {
127 return window_; 136 return window_;
128 } 137 }
129 138
130 virtual void Refresh() ORTHANC_OVERRIDE; 139 virtual void Refresh() ORTHANC_OVERRIDE;
131 140
132 virtual void UpdateSize(unsigned int width, 141 virtual void UpdateSize(unsigned int width,
133 unsigned int height) ORTHANC_OVERRIDE; 142 unsigned int height) ORTHANC_OVERRIDE;
134 protected: 143
135 virtual ICompositor* GetCompositor() ORTHANC_OVERRIDE 144 virtual bool HasCompositor() const ORTHANC_OVERRIDE
136 { 145 {
137 return &compositor_; 146 return true;
138 } 147 }
139 148
140 private: 149 virtual ICompositor& GetCompositor() ORTHANC_OVERRIDE
141 void UpdateSdlSurfaceSize(unsigned int width, 150 {
142 unsigned int height); 151 return compositor_;
152 }
143 }; 153 };
144 } 154 }