mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-11 01:06:01 +03:00
PixelPaint: Reference-count filters
For multi-threading filter application, shared ownership is much easier to work with.
This commit is contained in:
parent
5f76ab9836
commit
056b081e2d
Notes:
sideshowbarker
2024-07-18 05:37:06 +09:00
Author: https://github.com/kleinesfilmroellchen Commit: https://github.com/SerenityOS/serenity/commit/056b081e2d Pull-request: https://github.com/SerenityOS/serenity/pull/14844 Reviewed-by: https://github.com/AtkinsSJ ✅ Reviewed-by: https://github.com/MacDue Reviewed-by: https://github.com/alimpfard Reviewed-by: https://github.com/demostanis
@ -32,7 +32,7 @@ ErrorOr<NonnullRefPtr<GUI::TreeViewModel>> create_filter_tree_model(ImageEditor*
|
||||
auto filter_tree_model = GUI::TreeViewModel::create();
|
||||
|
||||
auto add_filter_node = [&]<typename FilterType>(GUI::TreeViewModel::Node& node) {
|
||||
auto filter = adopt_own(*new FilterType(editor));
|
||||
auto filter = make_ref_counted<FilterType>(editor);
|
||||
(void)node.add_node<FilterNode>(filter->filter_name(), filter_icon, move(filter));
|
||||
};
|
||||
|
||||
|
@ -16,7 +16,7 @@ namespace PixelPaint {
|
||||
|
||||
class FilterNode final : public GUI::TreeViewModel::Node {
|
||||
public:
|
||||
FilterNode(String text, Optional<GUI::Icon> icon, Node* parent_node, NonnullOwnPtr<Filter> filter)
|
||||
FilterNode(String text, Optional<GUI::Icon> icon, Node* parent_node, NonnullRefPtr<Filter> filter)
|
||||
: Node(move(text), move(icon), parent_node)
|
||||
, m_filter(move(filter))
|
||||
{
|
||||
@ -26,7 +26,7 @@ public:
|
||||
Filter& filter() { return *m_filter; }
|
||||
|
||||
private:
|
||||
NonnullOwnPtr<Filter> m_filter;
|
||||
NonnullRefPtr<Filter> m_filter;
|
||||
};
|
||||
|
||||
ErrorOr<NonnullRefPtr<GUI::TreeViewModel>> create_filter_tree_model(ImageEditor*);
|
||||
|
@ -13,7 +13,7 @@
|
||||
|
||||
namespace PixelPaint {
|
||||
|
||||
class Filter {
|
||||
class Filter : public RefCounted<Filter> {
|
||||
public:
|
||||
virtual void apply() const;
|
||||
virtual void apply(Gfx::Bitmap& target_bitmap, Gfx::Bitmap const& source_bitmap) const = 0;
|
||||
|
Loading…
Reference in New Issue
Block a user