Commit ca810f85 authored by Dmitry Kazakov's avatar Dmitry Kazakov

Fix invert filter for devices with alpha color spaces

This patch implements a special callback for KisFilter that tells if
the filter wants to process fully transparent pixels of the device.
If that is the case, applyRect will contain the full image bounds.

BUG:349059
Fixes T2085
parent 992ea4f3
......@@ -164,3 +164,11 @@ void KisFilter::setSupportsLevelOfDetail(bool value)
{
m_supportsLevelOfDetail = value;
}
bool KisFilter::needsTransparentPixels(const KisFilterConfiguration *config, const KoColorSpace *cs) const
{
Q_UNUSED(config);
Q_UNUSED(cs);
return false;
}
......@@ -125,6 +125,8 @@ public:
*/
virtual bool supportsLevelOfDetail(const KisFilterConfiguration *config, int lod) const;
virtual bool needsTransparentPixels(const KisFilterConfiguration *config, const KoColorSpace *cs) const;
protected:
QString configEntryGroup() const;
......
......@@ -252,7 +252,15 @@ void KisFilterManager::apply(KisSafeFilterConfigurationSP filterConfig)
d->currentStrokeId.clear();
} else {
image->waitForDone();
d->currentApplyRect = d->view->activeNode()->exactBounds();
}
d->currentApplyRect = d->view->activeNode()->exactBounds();
KisPaintDeviceSP paintDevice = d->view->activeNode()->paintDevice();
if (paintDevice &&
filter->needsTransparentPixels(filterConfig.data(), paintDevice->colorSpace())) {
d->currentApplyRect |= image->bounds();
}
KisPostExecutionUndoAdapter *undoAdapter =
......
......@@ -35,6 +35,7 @@
#include <kis_layer.h>
#include <filter/kis_filter_registry.h>
#include <kis_global.h>
#include "KoColorModelStandardIds.h"
K_PLUGIN_FACTORY_WITH_JSON(KritaExampleFactory, "kritaexample.json", registerPlugin<KritaExample>();)
......@@ -54,6 +55,7 @@ KisFilterInvert::KisFilterInvert() : KisColorTransformationFilter(id(), category
setColorSpaceIndependence(FULLY_INDEPENDENT);
setSupportsPainting(true);
setShowConfigurationWidget(false);
setSupportsLevelOfDetail(true);
}
KoColorTransformation* KisFilterInvert::createTransformation(const KoColorSpace* cs, const KisFilterConfiguration* config) const
......@@ -62,4 +64,10 @@ KoColorTransformation* KisFilterInvert::createTransformation(const KoColorSpace*
return cs->createInvertTransformation();
}
bool KisFilterInvert::needsTransparentPixels(const KisFilterConfiguration *config, const KoColorSpace *cs) const
{
Q_UNUSED(config);
return cs->colorModelId() == AlphaColorModelID;
}
#include "example.moc"
......@@ -45,6 +45,7 @@ public:
return KoID("invert", i18n("Invert"));
}
bool needsTransparentPixels(const KisFilterConfiguration *config, const KoColorSpace *cs) const;
};
#endif
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment