diff options
author | crupest <crupest@outlook.com> | 2021-10-24 18:59:07 +0800 |
---|---|---|
committer | crupest <crupest@outlook.com> | 2021-10-24 18:59:07 +0800 |
commit | a4dafa3e2918f2cc28657145e6b0afe7bcf1ca7b (patch) | |
tree | 9ba8b9c960fdc830c272042e6b595e0a20e3bfb2 /include/cru/platform/graphics | |
parent | 3e84cf013b31c52405a76b8e8778a5991d096290 (diff) | |
download | cru-a4dafa3e2918f2cc28657145e6b0afe7bcf1ca7b.tar.gz cru-a4dafa3e2918f2cc28657145e6b0afe7bcf1ca7b.tar.bz2 cru-a4dafa3e2918f2cc28657145e6b0afe7bcf1ca7b.zip |
...
Diffstat (limited to 'include/cru/platform/graphics')
-rw-r--r-- | include/cru/platform/graphics/Painter.hpp | 6 | ||||
-rw-r--r-- | include/cru/platform/graphics/util/Painter.hpp | 5 |
2 files changed, 9 insertions, 2 deletions
diff --git a/include/cru/platform/graphics/Painter.hpp b/include/cru/platform/graphics/Painter.hpp index 24592f95..9bde0640 100644 --- a/include/cru/platform/graphics/Painter.hpp +++ b/include/cru/platform/graphics/Painter.hpp @@ -7,6 +7,8 @@ struct IPainter : virtual IPlatformResource { virtual Matrix GetTransform() = 0; virtual void SetTransform(const Matrix& matrix) = 0; + virtual void ConcatTransform(const Matrix& matrix) = 0; + virtual void Clear(const Color& color) = 0; virtual void DrawLine(const Point& start, const Point& end, IBrush* brush, @@ -26,6 +28,10 @@ struct IPainter : virtual IPlatformResource { virtual void PopLayer() = 0; + virtual void PushState() = 0; + + virtual void PopState() = 0; + virtual void EndDraw() = 0; }; } // namespace cru::platform::graphics diff --git a/include/cru/platform/graphics/util/Painter.hpp b/include/cru/platform/graphics/util/Painter.hpp index 90457cf4..2e0fbb51 100644 --- a/include/cru/platform/graphics/util/Painter.hpp +++ b/include/cru/platform/graphics/util/Painter.hpp @@ -10,8 +10,9 @@ void WithTransform(IPainter* painter, const Matrix& matrix, const Fn& action) { static_assert(std::is_invocable_v<decltype(action), IPainter*>, "Action must can be be invoked with painter."); const auto old = painter->GetTransform(); - painter->SetTransform(matrix * old); + painter->PushState(); + painter->ConcatTransform(matrix); action(painter); - painter->SetTransform(old); + painter->PopState(); } } // namespace cru::platform::graphics::util |