From 056b081e2d6fde75929ed56c3ce7054105d4e763 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?kleines=20Filmr=C3=B6llchen?= Date: Sat, 13 Aug 2022 13:02:22 +0200 Subject: [PATCH] PixelPaint: Reference-count filters For multi-threading filter application, shared ownership is much easier to work with. --- Userland/Applications/PixelPaint/FilterTreeModel.cpp | 2 +- Userland/Applications/PixelPaint/FilterTreeModel.h | 4 ++-- Userland/Applications/PixelPaint/Filters/Filter.h | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Userland/Applications/PixelPaint/FilterTreeModel.cpp b/Userland/Applications/PixelPaint/FilterTreeModel.cpp index fd58238e992..11a2b7486d1 100644 --- a/Userland/Applications/PixelPaint/FilterTreeModel.cpp +++ b/Userland/Applications/PixelPaint/FilterTreeModel.cpp @@ -32,7 +32,7 @@ ErrorOr> create_filter_tree_model(ImageEditor* auto filter_tree_model = GUI::TreeViewModel::create(); auto add_filter_node = [&](GUI::TreeViewModel::Node& node) { - auto filter = adopt_own(*new FilterType(editor)); + auto filter = make_ref_counted(editor); (void)node.add_node(filter->filter_name(), filter_icon, move(filter)); }; diff --git a/Userland/Applications/PixelPaint/FilterTreeModel.h b/Userland/Applications/PixelPaint/FilterTreeModel.h index 48a4645c893..fa3c16e175d 100644 --- a/Userland/Applications/PixelPaint/FilterTreeModel.h +++ b/Userland/Applications/PixelPaint/FilterTreeModel.h @@ -16,7 +16,7 @@ namespace PixelPaint { class FilterNode final : public GUI::TreeViewModel::Node { public: - FilterNode(String text, Optional icon, Node* parent_node, NonnullOwnPtr filter) + FilterNode(String text, Optional icon, Node* parent_node, NonnullRefPtr filter) : Node(move(text), move(icon), parent_node) , m_filter(move(filter)) { @@ -26,7 +26,7 @@ public: Filter& filter() { return *m_filter; } private: - NonnullOwnPtr m_filter; + NonnullRefPtr m_filter; }; ErrorOr> create_filter_tree_model(ImageEditor*); diff --git a/Userland/Applications/PixelPaint/Filters/Filter.h b/Userland/Applications/PixelPaint/Filters/Filter.h index 9d0ac330fe4..67792a46194 100644 --- a/Userland/Applications/PixelPaint/Filters/Filter.h +++ b/Userland/Applications/PixelPaint/Filters/Filter.h @@ -13,7 +13,7 @@ namespace PixelPaint { -class Filter { +class Filter : public RefCounted { public: virtual void apply() const; virtual void apply(Gfx::Bitmap& target_bitmap, Gfx::Bitmap const& source_bitmap) const = 0;