aboutsummaryrefslogtreecommitdiff
path: root/src/platform_win/win_graph_factory.cpp
diff options
context:
space:
mode:
authorcrupest <crupest@outlook.com>2019-04-01 15:28:07 +0800
committercrupest <crupest@outlook.com>2019-04-01 15:28:07 +0800
commit3e89aa733587043645f5fda72596e4ff3cd21d2a (patch)
tree7daadddf1073f537bb580a0cdf77208cf26e6271 /src/platform_win/win_graph_factory.cpp
parent8ca0873597eb05a2f120d3ea107660abcff4533c (diff)
downloadcru-3e89aa733587043645f5fda72596e4ff3cd21d2a.tar.gz
cru-3e89aa733587043645f5fda72596e4ff3cd21d2a.tar.bz2
cru-3e89aa733587043645f5fda72596e4ff3cd21d2a.zip
...
Diffstat (limited to 'src/platform_win/win_graph_factory.cpp')
-rw-r--r--src/platform_win/win_graph_factory.cpp31
1 files changed, 31 insertions, 0 deletions
diff --git a/src/platform_win/win_graph_factory.cpp b/src/platform_win/win_graph_factory.cpp
new file mode 100644
index 00000000..b21c58d5
--- /dev/null
+++ b/src/platform_win/win_graph_factory.cpp
@@ -0,0 +1,31 @@
+#include "cru/platform/win/win_graph_factory.hpp"
+
+#include "cru/platform/win/d2d_util.hpp"
+#include "cru/platform/win/exception.hpp"
+#include "cru/platform/win/graph_manager.hpp"
+#include "cru/platform/win/win_brush.hpp"
+#include "cru/platform/win/win_geometry.hpp"
+
+#include <cassert>
+
+namespace cru::platform::win {
+WinGraphFactory::WinGraphFactory(GraphManager* graph_manager) {
+ assert(graph_manager);
+ graph_manager_ = graph_manager;
+}
+
+SolidColorBrush* WinGraphFactory::CreateSolidColorBrush(
+ const ui::Color& color) {
+ Microsoft::WRL::ComPtr<ID2D1SolidColorBrush> brush;
+ ThrowIfFailed(graph_manager_->GetD2D1DeviceContext()->CreateSolidColorBrush(
+ util::Convert(color), &brush));
+ return new WinSolidColorBrush(std::move(brush));
+}
+
+GeometryBuilder* WinGraphFactory::CreateGeometryBuilder() {
+ Microsoft::WRL::ComPtr<ID2D1PathGeometry> geometry;
+ ThrowIfFailed(
+ graph_manager_->GetD2D1Factory()->CreatePathGeometry(&geometry));
+ return new WinGeometryBuilder(std::move(geometry));
+}
+} // namespace cru::platform::win