aboutsummaryrefslogtreecommitdiff
path: root/include/cru/platform/graph/graph_factory.hpp
diff options
context:
space:
mode:
Diffstat (limited to 'include/cru/platform/graph/graph_factory.hpp')
-rw-r--r--include/cru/platform/graph/graph_factory.hpp33
1 files changed, 21 insertions, 12 deletions
diff --git a/include/cru/platform/graph/graph_factory.hpp b/include/cru/platform/graph/graph_factory.hpp
index 51cf6f15..b2619e8d 100644
--- a/include/cru/platform/graph/graph_factory.hpp
+++ b/include/cru/platform/graph/graph_factory.hpp
@@ -1,26 +1,35 @@
#pragma once
#include "cru/common/base.hpp"
+#include "cru/common/auto_delete.hpp"
#include "cru/common/ui_base.hpp"
+#include "brush.hpp"
+#include "font.hpp"
+#include "geometry.hpp"
+#include "text_layout.hpp"
+
#include <memory>
#include <string>
#include <string_view>
namespace cru::platform::graph {
-struct SolidColorBrush;
-struct GeometryBuilder;
-struct FontDescriptor;
-struct TextLayout;
+// Entry point of the graph module.
+struct IGraphFactory : virtual Interface, virtual IAutoDelete {
+ // Create a platform-specific instance and save it as the global instance.
+ // Do not create the instance twice. Implements should assert for that.
+ // After the
+ // After creating, get the instance by GetInstance.
+ static IGraphFactory* CreateInstance();
-struct GraphFactory : virtual Interface {
- static GraphFactory* GetInstance();
+ // Get the global instance. If it is not created, then return nullptr.
+ static IGraphFactory* GetInstance();
- virtual SolidColorBrush* CreateSolidColorBrush(const ui::Color& color) = 0;
- virtual GeometryBuilder* CreateGeometryBuilder() = 0;
- virtual FontDescriptor* CreateFontDescriptor(
+ virtual ISolidColorBrush* CreateSolidColorBrush(const ui::Color& color) = 0;
+ virtual IGeometryBuilder* CreateGeometryBuilder() = 0;
+ virtual IFontDescriptor* CreateFontDescriptor(
const std::wstring_view& font_family, float font_size) = 0;
- virtual TextLayout* CreateTextLayout(std::shared_ptr<FontDescriptor> font,
- std::wstring text) = 0;
+ virtual ITextLayout* CreateTextLayout(std::shared_ptr<IFontDescriptor> font,
+ std::wstring text) = 0;
};
-} // namespace cru::platform
+} // namespace cru::platform::graph