diff options
| author | crupest <crupest@outlook.com> | 2019-04-19 23:20:09 +0800 |
|---|---|---|
| committer | crupest <crupest@outlook.com> | 2019-04-19 23:20:09 +0800 |
| commit | ea87825d58ab5b58dd360c3f080518c07a865db0 (patch) | |
| tree | 4b497ef3687d682368e0fde4b86293565583a63a /src/win/graph/win_painter.cpp | |
| parent | 7351020a582d70a1495249fba87d342c8a1fb634 (diff) | |
| download | cru-ea87825d58ab5b58dd360c3f080518c07a865db0.tar.gz cru-ea87825d58ab5b58dd360c3f080518c07a865db0.tar.bz2 cru-ea87825d58ab5b58dd360c3f080518c07a865db0.zip | |
...
Diffstat (limited to 'src/win/graph/win_painter.cpp')
| -rw-r--r-- | src/win/graph/win_painter.cpp | 99 |
1 files changed, 0 insertions, 99 deletions
diff --git a/src/win/graph/win_painter.cpp b/src/win/graph/win_painter.cpp deleted file mode 100644 index 69ce1141..00000000 --- a/src/win/graph/win_painter.cpp +++ /dev/null @@ -1,99 +0,0 @@ -#include "cru/win/graph/win_painter.hpp" - -#include "cru/win/exception.hpp" -#include "cru/win/graph/d2d_util.hpp" -#include "cru/win/graph/graph_manager.hpp" -#include "cru/win/graph/win_brush.hpp" -#include "cru/win/graph/win_geometry.hpp" -#include "cru/win/graph/win_text_layout.hpp" - -#include <cassert> - -namespace cru::win::graph { -WinPainter::WinPainter(ID2D1RenderTarget* render_target) { - assert(render_target); - render_target_ = render_target; -} - -WinPainter::~WinPainter() { EndDraw(); } - -platform::Matrix WinPainter::GetTransform() { - assert(!IsDisposed()); - D2D1_MATRIX_3X2_F m; - render_target_->GetTransform(&m); - return util::Convert(m); -} - -void WinPainter::SetTransform(const platform::Matrix& matrix) { - assert(!IsDisposed()); - render_target_->SetTransform(util::Convert(matrix)); -} - -void WinPainter::Clear(const ui::Color& color) { - assert(!IsDisposed()); - render_target_->Clear(util::Convert(color)); -} - -void WinPainter::StrokeRectangle(const ui::Rect& rectangle, - platform::graph::Brush* brush, float width) { - assert(!IsDisposed()); - const auto b = dynamic_cast<WinBrush*>(brush); - assert(b); - render_target_->DrawRectangle(util::Convert(rectangle), b->GetD2DBrush(), - width); -} - -void WinPainter::FillRectangle(const ui::Rect& rectangle, - platform::graph::Brush* brush) { - assert(!IsDisposed()); - const auto b = dynamic_cast<WinBrush*>(brush); - assert(b); - render_target_->FillRectangle(util::Convert(rectangle), b->GetD2DBrush()); -} - -void WinPainter::StrokeGeometry(platform::graph::Geometry* geometry, - platform::graph::Brush* brush, float width) { - assert(!IsDisposed()); - const auto g = dynamic_cast<WinGeometry*>(geometry); - assert(g); - const auto b = dynamic_cast<WinBrush*>(brush); - assert(b); - - render_target_->DrawGeometry(g->GetNative(), b->GetD2DBrush(), width); -} - -void WinPainter::FillGeometry(platform::graph::Geometry* geometry, - platform::graph::Brush* brush) { - assert(!IsDisposed()); - const auto g = dynamic_cast<WinGeometry*>(geometry); - assert(g); - const auto b = dynamic_cast<WinBrush*>(brush); - assert(b); - - render_target_->FillGeometry(g->GetNative(), b->GetD2DBrush()); -} - -void WinPainter::DrawText(const ui::Point& offset, - platform::graph::TextLayout* text_layout, - platform::graph::Brush* brush) { - assert(!IsDisposed()); - const auto t = dynamic_cast<WinTextLayout*>(text_layout); - assert(t); - const auto b = dynamic_cast<WinBrush*>(brush); - assert(b); - - render_target_->DrawTextLayout(util::Convert(offset), - t->GetDWriteTextLayout(), b->GetD2DBrush()); -} - -void WinPainter::EndDraw() { - if (!IsDisposed()) { - DoEndDraw(); - } -} - -void WinPainter::DoEndDraw() { - ThrowIfFailed(render_target_->EndDraw()); - is_disposed_ = true; -} -} // namespace cru::win::graph |
