mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-12-07 21:59:54 +00:00
LibGfx: Add a method to reset a Painter to its initial state
This commit is contained in:
parent
dbf041aa98
commit
017e8a5b8d
Notes:
github-actions[bot]
2025-10-23 16:53:48 +00:00
Author: https://github.com/tcl3
Commit: 017e8a5b8d
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/6536
Reviewed-by: https://github.com/gmta ✅
3 changed files with 14 additions and 0 deletions
|
|
@ -43,6 +43,8 @@ public:
|
|||
virtual void restore() = 0;
|
||||
|
||||
virtual void clip(Gfx::Path const&, Gfx::WindingRule) = 0;
|
||||
|
||||
virtual void reset() = 0;
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -134,6 +134,9 @@ static SkPaint to_skia_paint(Gfx::PaintStyle const& style, Optional<Gfx::Filter
|
|||
PainterSkia::PainterSkia(NonnullRefPtr<Gfx::PaintingSurface> painting_surface)
|
||||
: m_impl(adopt_own(*new Impl { move(painting_surface) }))
|
||||
{
|
||||
m_impl->with_canvas([this](auto& canvas) {
|
||||
m_initial_save_count = canvas.save();
|
||||
});
|
||||
}
|
||||
|
||||
PainterSkia::~PainterSkia() = default;
|
||||
|
|
@ -335,4 +338,11 @@ void PainterSkia::clip(Gfx::Path const& path, Gfx::WindingRule winding_rule)
|
|||
});
|
||||
}
|
||||
|
||||
void PainterSkia::reset()
|
||||
{
|
||||
impl().with_canvas([&](auto& canvas) {
|
||||
canvas.restoreToCount(m_initial_save_count);
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -32,11 +32,13 @@ public:
|
|||
virtual void save() override;
|
||||
virtual void restore() override;
|
||||
virtual void clip(Gfx::Path const&, Gfx::WindingRule) override;
|
||||
virtual void reset() override;
|
||||
|
||||
private:
|
||||
struct Impl;
|
||||
Impl& impl() { return *m_impl; }
|
||||
NonnullOwnPtr<Impl> m_impl;
|
||||
u32 m_initial_save_count { 0 };
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue