Commit 5cb02777 authored by Dmitry Kazakov's avatar Dmitry Kazakov
Browse files

Fix artifacts when using Rectangle Tool with lightness-mode colorsmudge

KisFigurePaintingHelper paints directly on the layer bypassing the paintop,
so we should instruct our interstroke data mecanism to reset interstroke
data before and after figure painting code.
parent c8a6a249
......@@ -13,6 +13,7 @@
#include <kis_paint_device.h>
#include <kis_pointer_utils.h>
#include <kis_command_utils.h>
namespace {
......@@ -92,12 +93,14 @@ struct KisInterstrokeDataTransactionWrapperFactory::Private
{
QScopedPointer<KisInterstrokeDataFactory> factory;
KisPaintDeviceSP device;
bool supportsContinuedInterstrokeData = true;
};
KisInterstrokeDataTransactionWrapperFactory::KisInterstrokeDataTransactionWrapperFactory(KisInterstrokeDataFactory *factory)
KisInterstrokeDataTransactionWrapperFactory::KisInterstrokeDataTransactionWrapperFactory(KisInterstrokeDataFactory *factory, bool supportsContinuedInterstrokeData)
: m_d(new Private())
{
m_d->factory.reset(factory);
m_d->supportsContinuedInterstrokeData = supportsContinuedInterstrokeData;
}
KisInterstrokeDataTransactionWrapperFactory::~KisInterstrokeDataTransactionWrapperFactory()
......@@ -108,7 +111,8 @@ KUndo2Command *KisInterstrokeDataTransactionWrapperFactory::createBeginTransacti
{
KisInterstrokeDataSP data = device->interstrokeData();
if (m_d->factory) {
if (!data ||
if (!m_d->supportsContinuedInterstrokeData ||
!data ||
!data->isStillCompatible() ||
!m_d->factory->isCompatible(data.data())) {
......@@ -130,5 +134,21 @@ KUndo2Command *KisInterstrokeDataTransactionWrapperFactory::createBeginTransacti
KUndo2Command *KisInterstrokeDataTransactionWrapperFactory::createEndTransactionCommand()
{
return m_d->device ? new EndInterstrokeDataTransactionCommand(m_d->device) : 0;
KUndo2Command *result = 0;
if (m_d->device) {
if (m_d->supportsContinuedInterstrokeData) {
result = new EndInterstrokeDataTransactionCommand(m_d->device);
} else {
KisCommandUtils::CompositeCommand *composite
= new KisCommandUtils::CompositeCommand();
composite->addCommand(new EndInterstrokeDataTransactionCommand(m_d->device));
composite->addCommand(new BeginInterstrokeDataTransactionCommand(m_d->device, 0));
result = composite;
}
}
return result;
}
......@@ -24,7 +24,7 @@ class KisInterstrokeDataFactory;
class KRITAIMAGE_EXPORT KisInterstrokeDataTransactionWrapperFactory : public KisTransactionWrapperFactory
{
public:
KisInterstrokeDataTransactionWrapperFactory(KisInterstrokeDataFactory *factory);
KisInterstrokeDataTransactionWrapperFactory(KisInterstrokeDataFactory *factory, bool supportsContinuedInterstrokeData = true);
~KisInterstrokeDataTransactionWrapperFactory() override;
KUndo2Command* createBeginTransactionCommand(KisPaintDeviceSP device) override;
......
......@@ -293,7 +293,10 @@ void KisToolFreehandHelper::initPaintImpl(qreal startAngle,
startDist);
KisStrokeStrategy *stroke =
new FreehandStrokeStrategy(m_d->resources, m_d->strokeInfos, m_d->transactionText);
new FreehandStrokeStrategy(m_d->resources,
m_d->strokeInfos,
m_d->transactionText,
FreehandStrokeStrategy::SupportsContinuedInterstrokeData);
m_d->strokeId = m_d->strokesFacade->startStroke(stroke);
......
......@@ -66,22 +66,24 @@ struct FreehandStrokeStrategy::Private
FreehandStrokeStrategy::FreehandStrokeStrategy(KisResourcesSnapshotSP resources,
KisFreehandStrokeInfo *strokeInfo,
const KUndo2MagicString &name)
const KUndo2MagicString &name,
Flags flags)
: KisPainterBasedStrokeStrategy(QLatin1String("FREEHAND_STROKE"), name,
resources, strokeInfo),
m_d(new Private(resources))
{
init();
init(flags);
}
FreehandStrokeStrategy::FreehandStrokeStrategy(KisResourcesSnapshotSP resources,
QVector<KisFreehandStrokeInfo*> strokeInfos,
const KUndo2MagicString &name)
const KUndo2MagicString &name,
Flags flags)
: KisPainterBasedStrokeStrategy(QLatin1String("FREEHAND_STROKE"), name,
resources, strokeInfos),
m_d(new Private(resources))
{
init();
init(flags);
}
FreehandStrokeStrategy::FreehandStrokeStrategy(const FreehandStrokeStrategy &rhs, int levelOfDetail)
......@@ -101,11 +103,12 @@ FreehandStrokeStrategy::~FreehandStrokeStrategy()
KisUpdateTimeMonitor::instance()->endStrokeMeasure();
}
void FreehandStrokeStrategy::init()
void FreehandStrokeStrategy::init(Flags flags)
{
setSupportsWrapAroundMode(true);
setSupportsMaskingBrush(true);
setSupportsIndirectPainting(true);
setSupportsContinuedInterstrokeData(flags & SupportsContinuedInterstrokeData);
enableJob(KisSimpleStrokeStrategy::JOB_DOSTROKE);
if (m_d->needsAsynchronousUpdates) {
......
......@@ -7,6 +7,7 @@
#ifndef __FREEHAND_STROKE_H
#define __FREEHAND_STROKE_H
#include "kritaui_export.h"
#include "kis_types.h"
#include "kis_node.h"
......@@ -20,6 +21,13 @@
class KRITAUI_EXPORT FreehandStrokeStrategy : public KisPainterBasedStrokeStrategy
{
public:
enum Flag {
None = 0x0,
SupportsContinuedInterstrokeData = 0x1
};
Q_DECLARE_FLAGS(Flags, Flag)
public:
class Data : public KisStrokeJobData {
public:
......@@ -167,11 +175,13 @@ public:
public:
FreehandStrokeStrategy(KisResourcesSnapshotSP resources,
KisFreehandStrokeInfo *strokeInfo,
const KUndo2MagicString &name);
const KUndo2MagicString &name,
Flags flags = None);
FreehandStrokeStrategy(KisResourcesSnapshotSP resources,
QVector<KisFreehandStrokeInfo*> strokeInfos,
const KUndo2MagicString &name);
const KUndo2MagicString &name,
Flags flags = None);
~FreehandStrokeStrategy() override;
......@@ -189,7 +199,7 @@ protected:
FreehandStrokeStrategy(const FreehandStrokeStrategy &rhs, int levelOfDetail);
private:
void init();
void init(FreehandStrokeStrategy::Flags flags);
void tryDoUpdate(bool forceEnd = false);
void issueSetDirtySignals();
......@@ -199,4 +209,6 @@ private:
const QScopedPointer<Private> m_d;
};
Q_DECLARE_OPERATORS_FOR_FLAGS(FreehandStrokeStrategy::Flags)
#endif /* __FREEHAND_STROKE_H */
......@@ -78,7 +78,8 @@ KisPainterBasedStrokeStrategy::KisPainterBasedStrokeStrategy(const KisPainterBas
m_transaction(rhs.m_transaction),
m_useMergeID(rhs.m_useMergeID),
m_supportsMaskingBrush(rhs.m_supportsMaskingBrush),
m_supportsIndirectPainting(rhs.m_supportsIndirectPainting)
m_supportsIndirectPainting(rhs.m_supportsIndirectPainting),
m_supportsContinuedInterstrokeData(rhs.m_supportsContinuedInterstrokeData)
{
Q_FOREACH (KisFreehandStrokeInfo *info, rhs.m_strokeInfos) {
m_strokeInfos.append(new KisFreehandStrokeInfo(info, levelOfDetail));
......@@ -153,6 +154,16 @@ bool KisPainterBasedStrokeStrategy::supportsIndirectPainting() const
return m_supportsIndirectPainting;
}
bool KisPainterBasedStrokeStrategy::supportsContinuedInterstrokeData() const
{
return m_supportsContinuedInterstrokeData;
}
void KisPainterBasedStrokeStrategy::setSupportsContinuedInterstrokeData(bool value)
{
m_supportsContinuedInterstrokeData = value;
}
void KisPainterBasedStrokeStrategy::initPainters(KisPaintDeviceSP targetDevice,
KisPaintDeviceSP maskingDevice,
KisSelectionSP selection,
......@@ -259,7 +270,9 @@ void KisPainterBasedStrokeStrategy::initStrokeCallback()
QScopedPointer<KisInterstrokeDataTransactionWrapperFactory> wrapper;
if (interstrokeDataFactory) {
wrapper.reset(new KisInterstrokeDataTransactionWrapperFactory(interstrokeDataFactory.take()));
wrapper.reset(new KisInterstrokeDataTransactionWrapperFactory(
interstrokeDataFactory.take(),
supportsContinuedInterstrokeData()));
}
if (m_useMergeID) {
......
......@@ -93,6 +93,9 @@ protected:
void setSupportsIndirectPainting(bool value);
bool supportsIndirectPainting() const;
bool supportsContinuedInterstrokeData() const;
void setSupportsContinuedInterstrokeData(bool value);
protected:
KisPainterBasedStrokeStrategy(const KisPainterBasedStrokeStrategy &rhs, int levelOfDetail);
......@@ -123,6 +126,7 @@ private:
bool m_supportsMaskingBrush;
bool m_supportsIndirectPainting;
bool m_supportsContinuedInterstrokeData;
};
#endif /* __KIS_PAINTER_BASED_STROKE_STRATEGY_H */
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