PixelPaint: Reference-count filters

For multi-threading filter application, shared ownership is much easier
to work with.
This commit is contained in:
kleines Filmröllchen 2022-08-13 13:02:22 +02:00 committed by Sam Atkins
parent 5f76ab9836
commit 056b081e2d
Notes: sideshowbarker 2024-07-18 05:37:06 +09:00
3 changed files with 4 additions and 4 deletions

View File

@ -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));
};

View File

@ -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*);

View File

@ -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;