Widgets: Reuse materials to improve performance
This commit is contained in:
@@ -159,18 +159,18 @@ namespace Nz
|
||||
|
||||
std::optional<entt::entity> m_backgroundEntity;
|
||||
std::size_t m_canvasIndex;
|
||||
std::shared_ptr<Nz::Sprite> m_backgroundSprite;
|
||||
std::shared_ptr<Sprite> m_backgroundSprite;
|
||||
std::vector<WidgetEntity> m_entities;
|
||||
std::vector<std::unique_ptr<BaseWidget>> m_children;
|
||||
entt::registry* m_registry;
|
||||
Canvas* m_canvas;
|
||||
Color m_backgroundColor;
|
||||
Nz::Rectf m_renderingRect;
|
||||
Nz::SystemCursor m_cursor;
|
||||
Nz::Vector2f m_maximumSize;
|
||||
Nz::Vector2f m_minimumSize;
|
||||
Nz::Vector2f m_preferredSize;
|
||||
Nz::Vector2f m_size;
|
||||
Rectf m_renderingRect;
|
||||
SystemCursor m_cursor;
|
||||
Vector2f m_maximumSize;
|
||||
Vector2f m_minimumSize;
|
||||
Vector2f m_preferredSize;
|
||||
Vector2f m_size;
|
||||
BaseWidget* m_widgetParent;
|
||||
bool m_visible;
|
||||
};
|
||||
|
||||
@@ -15,6 +15,9 @@
|
||||
|
||||
namespace Nz
|
||||
{
|
||||
class Material;
|
||||
class MaterialPass;
|
||||
|
||||
class NAZARA_WIDGETS_API Widgets : public ModuleBase<Widgets>
|
||||
{
|
||||
friend ModuleBase;
|
||||
@@ -27,9 +30,22 @@ namespace Nz
|
||||
Widgets(Config config);
|
||||
~Widgets() = default;
|
||||
|
||||
inline const std::shared_ptr<Material>& GetOpaqueMaterial() const;
|
||||
inline const std::shared_ptr<MaterialPass>& GetOpaqueMaterialPass() const;
|
||||
|
||||
inline const std::shared_ptr<Material>& GetTransparentMaterial() const;
|
||||
inline const std::shared_ptr<MaterialPass>& GetTransparentMaterialPass() const;
|
||||
|
||||
struct Config {};
|
||||
|
||||
private:
|
||||
void CreateDefaultMaterials();
|
||||
|
||||
std::shared_ptr<Material> m_opaqueMaterial;
|
||||
std::shared_ptr<Material> m_transparentMaterial;
|
||||
std::shared_ptr<MaterialPass> m_opaqueMaterialPass;
|
||||
std::shared_ptr<MaterialPass> m_transparentMaterialPass;
|
||||
|
||||
static Widgets* s_instance;
|
||||
};
|
||||
}
|
||||
|
||||
@@ -7,6 +7,25 @@
|
||||
|
||||
namespace Nz
|
||||
{
|
||||
inline const std::shared_ptr<Material>& Widgets::GetOpaqueMaterial() const
|
||||
{
|
||||
return m_opaqueMaterial;
|
||||
}
|
||||
|
||||
inline const std::shared_ptr<MaterialPass>& Widgets::GetOpaqueMaterialPass() const
|
||||
{
|
||||
return m_opaqueMaterialPass;
|
||||
}
|
||||
|
||||
inline const std::shared_ptr<Material>& Widgets::GetTransparentMaterial() const
|
||||
{
|
||||
return m_transparentMaterial;
|
||||
}
|
||||
|
||||
inline const std::shared_ptr<MaterialPass>& Widgets::GetTransparentMaterialPass() const
|
||||
{
|
||||
return m_transparentMaterialPass;
|
||||
}
|
||||
}
|
||||
|
||||
#include <Nazara/Widgets/DebugOff.hpp>
|
||||
|
||||
Reference in New Issue
Block a user