aboutsummaryrefslogtreecommitdiff
path: root/include/cru/win/graph/win_painter.hpp
diff options
context:
space:
mode:
authorcrupest <crupest@outlook.com>2019-04-10 19:42:46 +0800
committercrupest <crupest@outlook.com>2019-04-10 19:42:46 +0800
commit7351020a582d70a1495249fba87d342c8a1fb634 (patch)
treee80f225041dc3816b3dce21c7e15aadbb211602e /include/cru/win/graph/win_painter.hpp
parenta94a806f69586e08a30fff0cdb3e52b0ce7acfa5 (diff)
downloadcru-7351020a582d70a1495249fba87d342c8a1fb634.tar.gz
cru-7351020a582d70a1495249fba87d342c8a1fb634.tar.bz2
cru-7351020a582d70a1495249fba87d342c8a1fb634.zip
Refactor.
Diffstat (limited to 'include/cru/win/graph/win_painter.hpp')
-rw-r--r--include/cru/win/graph/win_painter.hpp48
1 files changed, 48 insertions, 0 deletions
diff --git a/include/cru/win/graph/win_painter.hpp b/include/cru/win/graph/win_painter.hpp
new file mode 100644
index 00000000..8351cb7b
--- /dev/null
+++ b/include/cru/win/graph/win_painter.hpp
@@ -0,0 +1,48 @@
+#pragma once
+#include "../win_pre_config.hpp"
+
+#include "cru/platform/graph/painter.hpp"
+
+namespace cru::win::graph {
+class GraphManager;
+
+class WinPainter : public Object, public virtual platform::graph::Painter {
+ public:
+ explicit WinPainter(ID2D1RenderTarget* render_target);
+ WinPainter(const WinPainter& other) = delete;
+ WinPainter(WinPainter&& other) = delete;
+ WinPainter& operator=(const WinPainter& other) = delete;
+ WinPainter& operator=(WinPainter&& other) = delete;
+ ~WinPainter() override;
+
+ platform::Matrix GetTransform() override;
+ void SetTransform(const platform::Matrix& matrix) override;
+ void Clear(const ui::Color& color) override;
+ void StrokeRectangle(const ui::Rect& rectangle, platform::graph::Brush* brush,
+ float width) override;
+ void FillRectangle(const ui::Rect& rectangle,
+ platform::graph::Brush* brush) override;
+ void StrokeGeometry(platform::graph::Geometry* geometry,
+ platform::graph::Brush* brush, float width) override;
+ void FillGeometry(platform::graph::Geometry* geometry,
+ platform::graph::Brush* brush) override;
+ void DrawText(const ui::Point& offset,
+ platform::graph::TextLayout* text_layout,
+ platform::graph::Brush* brush) override;
+ void EndDraw() override;
+ bool IsDisposed() override { return is_disposed_; }
+
+ void EndDrawAndDeleteThis() {
+ EndDraw();
+ delete this;
+ }
+
+ protected:
+ virtual void DoEndDraw();
+
+ private:
+ ID2D1RenderTarget* render_target_;
+
+ bool is_disposed_ = false;
+};
+} // namespace cru::win::graph