@@ -22,10 +22,6 @@ class ISurface : public core::IReferenceCounted
22
22
ISurface (core::smart_refctd_ptr<IAPIConnection>&& api) : m_api(std::move(api)) {}
23
23
virtual ~ISurface () = default ;
24
24
25
- // impl of getSurfaceCapabilitiesForPhysicalDevice() needs this
26
- virtual uint32_t getWidth () const = 0;
27
- virtual uint32_t getHeight () const = 0;
28
-
29
25
core::smart_refctd_ptr<IAPIConnection> m_api;
30
26
31
27
public:
@@ -194,22 +190,25 @@ class ISurface : public core::IReferenceCounted
194
190
195
191
virtual bool getSurfaceCapabilitiesForPhysicalDevice (const IPhysicalDevice* physicalDevice, ISurface::SCapabilities& capabilities) const = 0;
196
192
197
- virtual ui::IWindow* getWindow () = 0;
198
- inline const ui::IWindow* getWindow () const {return const_cast <ui::IWindow*>(const_cast <ISurface*>(this )->getWindow ());}
199
-
200
193
// used by some drivers
201
194
virtual const void * getNativeWindowHandle () const = 0;
202
195
};
203
196
204
- // Base for use with Nabla's window wrappers
205
- template <class Window , class ImmediateBase >
197
+ // Base for use with Nabla's window wrappers, should maybe be called `CSurfaceWindow` instead, but oh well
198
+ template <class Window , class ImmediateBase > requires (std::is_base_of_v<ui::IWindow,Window> && std::is_base_of_v<ISurface,ImmediateBase>)
206
199
class CSurface : public ImmediateBase
207
200
{
201
+ using this_t = CSurface<Window, ImmediateBase>;
202
+
208
203
public:
209
- inline ui::IWindow* getWindow () override final
204
+ using window_t = Window;
205
+ using immediate_base_t = ImmediateBase;
206
+
207
+ inline window_t * getWindow ()
210
208
{
211
209
return m_window.get ();
212
210
}
211
+ inline const window_t * getWindow () const {return const_cast <window_t *>(const_cast <this_t *>(this )->getWindow ());}
213
212
214
213
inline const void * getNativeWindowHandle () const override final
215
214
{
@@ -218,17 +217,14 @@ class CSurface : public ImmediateBase
218
217
219
218
protected:
220
219
template <typename ... Args>
221
- CSurface (core::smart_refctd_ptr<Window >&& window, Args&&... args) : ImmediateBase (std::forward<Args>(args)...), m_window(std::move(window)) {}
220
+ CSurface (core::smart_refctd_ptr<window_t >&& window, Args&&... args) : immediate_base_t (std::forward<Args>(args)...), m_window (std::move (window)) {}
222
221
virtual ~CSurface () = default ;
223
222
224
- uint32_t getWidth () const override { return m_window->getWidth (); }
225
- uint32_t getHeight () const override { return m_window->getHeight (); }
226
-
227
- core::smart_refctd_ptr<Window> m_window;
223
+ core::smart_refctd_ptr<window_t > m_window;
228
224
};
229
225
230
- // Base to make surfaces directly from Native OS window handles
231
- template <class Window , class ImmediateBase >
226
+ // Base to make surfaces directly from Native OS window handles (TODO: while merging Erfan, template on the handle instead of the Window)
227
+ template <class Window , class ImmediateBase > requires std::is_base_of_v<ISurface,ImmediateBase>
232
228
class CSurfaceNative : public ImmediateBase
233
229
{
234
230
public:
0 commit comments