diff --git a/Userland/Applications/PixelPaint/Filters/Filter.cpp b/Userland/Applications/PixelPaint/Filters/Filter.cpp index 8ef7a228787..90afed06057 100644 --- a/Userland/Applications/PixelPaint/Filters/Filter.cpp +++ b/Userland/Applications/PixelPaint/Filters/Filter.cpp @@ -6,6 +6,7 @@ */ #include "Filter.h" +#include "../ImageProcessor.h" #include #include @@ -40,11 +41,10 @@ void Filter::apply() const { if (!m_editor) return; - if (auto* layer = m_editor->active_layer()) { - apply(layer->content_bitmap(), layer->content_bitmap()); - layer->did_modify_bitmap(layer->rect()); - m_editor->did_complete_action(String::formatted("Filter {}", filter_name())); - } + // FIXME: I am not thread-safe! + // If you try to edit the bitmap while the image processor is still running... :yaksplode: + if (auto* layer = m_editor->active_layer()) + MUST(ImageProcessor::the()->enqueue_command(make_ref_counted(*this, *layer))); } void Filter::update_preview() diff --git a/Userland/Applications/PixelPaint/Filters/Filter.h b/Userland/Applications/PixelPaint/Filters/Filter.h index 67792a46194..309f2415680 100644 --- a/Userland/Applications/PixelPaint/Filters/Filter.h +++ b/Userland/Applications/PixelPaint/Filters/Filter.h @@ -13,7 +13,11 @@ namespace PixelPaint { +class FilterApplicationCommand; + class Filter : public RefCounted { + friend class FilterApplicationCommand; + public: virtual void apply() const; virtual void apply(Gfx::Bitmap& target_bitmap, Gfx::Bitmap const& source_bitmap) const = 0; diff --git a/Userland/Applications/PixelPaint/ImageProcessor.cpp b/Userland/Applications/PixelPaint/ImageProcessor.cpp index c6573cb46da..ab16a604ddd 100644 --- a/Userland/Applications/PixelPaint/ImageProcessor.cpp +++ b/Userland/Applications/PixelPaint/ImageProcessor.cpp @@ -20,7 +20,7 @@ void FilterApplicationCommand::execute() m_filter->m_editor->gui_event_loop().deferred_invoke([strong_this = NonnullRefPtr(*this)]() { // HACK: we can't tell strong_this to not be const (*const_cast*>(&strong_this->m_target_layer))->did_modify_bitmap(strong_this->m_target_layer->rect()); - strong_this->m_filter->m_editor->did_complete_action(); + strong_this->m_filter->m_editor->did_complete_action(String::formatted("Filter {}", strong_this->m_filter->filter_name())); }); }