From ea87825d58ab5b58dd360c3f080518c07a865db0 Mon Sep 17 00:00:00 2001 From: crupest Date: Fri, 19 Apr 2019 23:20:09 +0800 Subject: ... --- include/cru/win/graph/d2d_painter.hpp | 48 +++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) create mode 100644 include/cru/win/graph/d2d_painter.hpp (limited to 'include/cru/win/graph/d2d_painter.hpp') diff --git a/include/cru/win/graph/d2d_painter.hpp b/include/cru/win/graph/d2d_painter.hpp new file mode 100644 index 00000000..d33dced4 --- /dev/null +++ b/include/cru/win/graph/d2d_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 D2DPainter : public Object, public virtual platform::graph::Painter { + public: + explicit D2DPainter(ID2D1RenderTarget* render_target); + D2DPainter(const D2DPainter& other) = delete; + D2DPainter(D2DPainter&& other) = delete; + D2DPainter& operator=(const D2DPainter& other) = delete; + D2DPainter& operator=(D2DPainter&& other) = delete; + ~D2DPainter() override = default; + + 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 final; + bool IsDisposed() override final { return is_disposed_; } + + void EndDrawAndDeleteThis() { + EndDraw(); + delete this; + } + + protected: + virtual void DoEndDraw() = 0; + + private: + ID2D1RenderTarget* render_target_; + + bool is_disposed_ = false; +}; +} // namespace cru::win::graph -- cgit v1.2.3