aboutsummaryrefslogtreecommitdiff
path: root/src/platform_win/win_graph_factory.cpp
blob: b21c58d504da5561c138852bcee935e449c0f6f6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
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