8#include <KoCanvasResourceProvider.h>
10#include <kis_canvas_resource_provider.h>
11#include <kis_filter.h>
12#include <kis_properties_configuration.h>
13#include <kis_filter_configuration.h>
14#include <kis_filter_manager.h>
15#include <kis_filter_registry.h>
16#include <KisDocument.h>
17#include <kis_paint_device.h>
18#include <kis_paint_device_frames_interface.h>
22#include <strokes/kis_filter_stroke_strategy.h>
23#include <krita_utils.h>
24#include <KisGlobalResourcesInterface.h>
28#include "InfoObject.h"
31struct Filter::Private {
45 delete d->configuration;
49bool Filter::operator==(
const Filter &other)
const
51 return (d->name == other.d->name
52 && d->configuration == other.d->configuration);
55bool Filter::operator!=(
const Filter &other)
const
57 return !(operator==(other));
69 delete d->configuration;
71 KisFilterSP filter = KisFilterRegistry::instance()->value(d->name);
72 d->configuration =
new InfoObject(filter->defaultConfiguration(KisGlobalResourcesInterface::instance()));
77 return d->configuration;
82 d->configuration = value;
87 if (node->
locked())
return false;
89 KisFilterSP filter = KisFilterRegistry::instance()->value(d->name);
90 if (!filter)
return false;
92 KisPaintDeviceSP dev = node->paintDevice();
93 if (!dev)
return false;
96 KisFilterConfigurationSP config =
static_cast<KisFilterConfiguration*
>(d->configuration->configuration().data());
97 filter->process(dev, applyRect, config->cloneWithResourcesSnapshot());
103 if (node->
locked())
return false;
105 KisFilterSP filter = KisFilterRegistry::instance()->value(d->name);
106 if (!filter)
return false;
108 KisImageWSP image = node->image();
109 if (!image)
return false;
111 KisFilterConfigurationSP filterConfig =
static_cast<KisFilterConfiguration*
>(d->configuration->configuration().data());
113 image->waitForDone();
116 QRect applyRect = initialApplyRect;
118 KisPaintDeviceSP paintDevice = node->paintDevice();
119 if (paintDevice && filter->needsTransparentPixels(filterConfig.data(), paintDevice->colorSpace())) {
120 applyRect |= image->bounds();
123 KisResourcesSnapshotSP resources =
new KisResourcesSnapshot(image, node->node());
126 if (document && KisPart::instance()->viewCount(document->document()) > 0) {
128 if (view && view->document() == document->document()) {
129 resources =
new KisResourcesSnapshot(image, node->node(), view->resourceProvider()->resourceManager());
136 KisStrokeId currentStrokeId = image->startStroke(
new KisFilterStrokeStrategy(filter,
137 KisFilterConfigurationSP(filterConfig),
140 QRect processRect = filter->changedRect(applyRect, filterConfig.data(), 0);
141 processRect &= image->bounds();
143 image->addJob(currentStrokeId,
new KisFilterStrokeStrategy::FilterJobData());
146 image->endStroke(currentStrokeId);
147 image->waitForDone();
152KisFilterConfigurationSP Filter::filterConfig()
154 KisFilterConfigurationSP config = KisFilterRegistry::instance()->get(d->name)->factoryConfiguration(KisGlobalResourcesInterface::instance());
The Document class encapsulates a Krita Document/Image.
Filter: represents a filter and its configuration.
bool startFilter(Node *node, int x, int y, int w, int h)
startFilter starts the given filter on the given node.
QString name() const
name the internal name of this filter.
void setConfiguration(InfoObject *value)
setConfiguration set the configuration object for the filter
InfoObject * configuration() const
Filter()
Filter: create an empty filter object.
void setName(const QString &name)
setName set the filter's name to the given name.
bool apply(Node *node, int x, int y, int w, int h)
Apply the filter to the given node.
InfoObject wrap a properties map.
QVariant property(const QString &key)
return the value for the property identified by key, or None if there is no such key.
QMap< QString, QVariant > properties() const
Return all properties this InfoObject manages.
Document * activeDocument() const
static Krita * instance()
instance retrieve the singleton instance of the Application object.
Node represents a layer or mask in a Krita image's Node hierarchy.
bool locked() const
locked checks whether the Node is locked.
QVariant property(const char *name) const const