Skip to content

Commit fbd289a

Browse files
make Erfan happy for n4ce
1 parent ca6f5e4 commit fbd289a

File tree

3 files changed

+19
-21
lines changed

3 files changed

+19
-21
lines changed

include/nbl/video/surface/CSurfaceVulkan.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,10 @@ class NBL_API2 ISurfaceVulkan : public ISurface
3434
};
3535

3636
#ifdef _NBL_PLATFORM_WINDOWS_
37-
class NBL_API2 CSurfaceVulkanWin32 final : public CSurface<ui::IWindowWin32, ISurfaceVulkan>
37+
class NBL_API2 CSurfaceVulkanWin32 final : public CSurface<ui::IWindowWin32,ISurfaceVulkan>
3838
{
3939
using this_t = CSurfaceVulkanWin32;
40-
using base_t = CSurface<ui::IWindowWin32, ISurfaceVulkan>;
40+
using base_t = CSurface<ui::IWindowWin32,ISurfaceVulkan>;
4141
public:
4242
inline CSurfaceVulkanWin32(core::smart_refctd_ptr<ui::IWindowWin32>&& window, core::smart_refctd_ptr<IAPIConnection>&& api, VkSurfaceKHR surf) :
4343
base_t(std::move(window), std::move(api), surf) {}

include/nbl/video/surface/ISurface.h

Lines changed: 13 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,6 @@ class ISurface : public core::IReferenceCounted
2222
ISurface(core::smart_refctd_ptr<IAPIConnection>&& api) : m_api(std::move(api)) {}
2323
virtual ~ISurface() = default;
2424

25-
//impl of getSurfaceCapabilitiesForPhysicalDevice() needs this
26-
virtual uint32_t getWidth() const = 0;
27-
virtual uint32_t getHeight() const = 0;
28-
2925
core::smart_refctd_ptr<IAPIConnection> m_api;
3026

3127
public:
@@ -194,22 +190,25 @@ class ISurface : public core::IReferenceCounted
194190

195191
virtual bool getSurfaceCapabilitiesForPhysicalDevice(const IPhysicalDevice* physicalDevice, ISurface::SCapabilities& capabilities) const = 0;
196192

197-
virtual ui::IWindow* getWindow() = 0;
198-
inline const ui::IWindow* getWindow() const {return const_cast<ui::IWindow*>(const_cast<ISurface*>(this)->getWindow());}
199-
200193
// used by some drivers
201194
virtual const void* getNativeWindowHandle() const = 0;
202195
};
203196

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>)
206199
class CSurface : public ImmediateBase
207200
{
201+
using this_t = CSurface<Window, ImmediateBase>;
202+
208203
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()
210208
{
211209
return m_window.get();
212210
}
211+
inline const window_t* getWindow() const {return const_cast<window_t*>(const_cast<this_t*>(this)->getWindow());}
213212

214213
inline const void* getNativeWindowHandle() const override final
215214
{
@@ -218,17 +217,14 @@ class CSurface : public ImmediateBase
218217

219218
protected:
220219
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)) {}
222221
virtual ~CSurface() = default;
223222

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;
228224
};
229225

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>
232228
class CSurfaceNative : public ImmediateBase
233229
{
234230
public:

include/nbl/video/utilities/CResizableSurface.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -423,9 +423,11 @@ template<typename SwapchainResources> requires std::is_base_of_v<IResizableSurfa
423423
class CResizableSurface final : public IResizableSurface
424424
{
425425
public:
426-
using this_t = CResizableSurface<SwapchainResources>;
426+
using this_t = CResizableSurface<SwapchainResources>;
427+
427428
// Factory method so we can fail, requires a `_surface` created from a window and with a callback that inherits from `ICallback` declared just above
428-
static inline core::smart_refctd_ptr<this_t> create(core::smart_refctd_ptr<ISurface>&& _surface)
429+
template<typename Surface> requires std::is_base_of_v<CSurface<typename Surface::window_t,typename Surface::immediate_base_t>,Surface>
430+
static inline core::smart_refctd_ptr<this_t> create(core::smart_refctd_ptr<Surface>&& _surface)
429431
{
430432
if (!_surface)
431433
return nullptr;

0 commit comments

Comments
 (0)