Krita Source Code Documentation
Loading...
Searching...
No Matches
KisPainterBasedStrokeStrategy Class Reference

#include <kis_painter_based_stroke_strategy.h>

+ Inheritance diagram for KisPainterBasedStrokeStrategy:

Classes

struct  FakeUndoData
 

Public Member Functions

void cancelStrokeCallback () override
 
void finishStrokeCallback () override
 
void initStrokeCallback () override
 
 KisPainterBasedStrokeStrategy (const QLatin1String &id, const KUndo2MagicString &name, KisResourcesSnapshotSP resources, KisFreehandStrokeInfo *strokeInfo)
 
 KisPainterBasedStrokeStrategy (const QLatin1String &id, const KUndo2MagicString &name, KisResourcesSnapshotSP resources, QVector< KisFreehandStrokeInfo * > strokeInfos)
 
void resumeStrokeCallback () override
 
void suspendStrokeCallback () override
 
 ~KisPainterBasedStrokeStrategy ()
 
- Public Member Functions inherited from KisRunnableBasedStrokeStrategy
void doStrokeCallback (KisStrokeJobData *data) override
 
 KisRunnableBasedStrokeStrategy (const KisRunnableBasedStrokeStrategy &rhs)
 
 KisRunnableBasedStrokeStrategy (const QLatin1String &id, const KUndo2MagicString &name=KUndo2MagicString())
 
KisRunnableStrokeJobsInterfacerunnableJobsInterface () const
 
 ~KisRunnableBasedStrokeStrategy ()
 
- Public Member Functions inherited from KisSimpleStrokeStrategy
KisStrokeJobDatacreateCancelData () override
 
KisStrokeJobStrategycreateCancelStrategy () override
 
KisStrokeJobStrategycreateDabStrategy () override
 
KisStrokeJobDatacreateFinishData () override
 
KisStrokeJobStrategycreateFinishStrategy () override
 
KisStrokeJobDatacreateInitData () override
 
KisStrokeJobStrategycreateInitStrategy () override
 
KisStrokeJobDatacreateResumeData () override
 
KisStrokeJobStrategycreateResumeStrategy () override
 
KisStrokeJobDatacreateSuspendData () override
 
KisStrokeJobStrategycreateSuspendStrategy () override
 
 KisSimpleStrokeStrategy (const QLatin1String &id, const KUndo2MagicString &name=KUndo2MagicString())
 
- Public Member Functions inherited from KisStrokeStrategy
qreal balancingRatioOverride () const
 
bool canForgetAboutMe () const
 
bool clearsRedoOnStart () const
 
virtual KisStrokeStrategycreateLodClone (int levelOfDetail)
 
KisLodPreferences currentLodPreferences () const
 
bool forceLodModeIfPossible () const
 
QString id () const
 
bool isAsynchronouslyCancellable () const
 
bool isExclusive () const
 
 KisStrokeStrategy (const QLatin1String &id, const KUndo2MagicString &name=KUndo2MagicString())
 
KUndo2MagicString name () const
 
bool needsExplicitCancel () const
 
virtual void notifyUserEndedStroke ()
 
virtual void notifyUserStartedStroke ()
 
bool requestsOtherStrokesToEnd () const
 
void setForceLodModeIfPossible (bool forceLodModeIfPossible)
 
void setMutatedJobsInterface (KisStrokesQueueMutatedJobInterface *mutatedJobsInterface, KisStrokeId strokeId)
 
bool supportsWrapAroundMode () const
 
virtual void tryCancelCurrentStrokeJobAsync ()
 tryCancelCurrentStrokeJobAsync is called by the strokes queue when the stroke is being cancelled. The stroke strategy may or may not handle this request and cancel the currently running long action.
 
virtual ~KisStrokeStrategy ()
 

Protected Member Functions

KisSelectionSP activeSelection () const
 
QVector< KisRunnableStrokeJobData * > doMaskingBrushUpdates (const QVector< QRect > &rects)
 
 KisPainterBasedStrokeStrategy (const KisPainterBasedStrokeStrategy &rhs, int levelOfDetail)
 
KisMaskedFreehandStrokePaintermaskedPainter (int strokeInfoId)
 
bool needsMaskingUpdates () const
 
int numMaskedPainters () const
 
void setSupportsContinuedInterstrokeData (bool value)
 
void setSupportsIndirectPainting (bool value)
 
void setSupportsMaskingBrush (bool value)
 
void setSupportsTimedMergeId (bool value)
 
void setUndoEnabled (bool value)
 
bool supportsContinuedInterstrokeData () const
 
bool supportsIndirectPainting () const
 
bool supportsMaskingBrush () const
 
bool supportsTimedMergeId () const
 
KisPaintDeviceSP targetDevice () const
 
KisNodeSP targetNode () const
 
- Protected Member Functions inherited from KisSimpleStrokeStrategy
void enableJob (JobType type, bool enable=true, KisStrokeJobData::Sequentiality sequentiality=KisStrokeJobData::SEQUENTIAL, KisStrokeJobData::Exclusivity exclusivity=KisStrokeJobData::NORMAL)
 
 KisSimpleStrokeStrategy (const KisSimpleStrokeStrategy &rhs)
 
- Protected Member Functions inherited from KisStrokeStrategy
void addMutatedJob (KisStrokeJobData *data)
 
void addMutatedJobs (const QVector< KisStrokeJobData * > list)
 
 KisStrokeStrategy (const KisStrokeStrategy &rhs)
 
void setAsynchronouslyCancellable (bool value)
 
void setBalancingRatioOverride (qreal value)
 
void setCanForgetAboutMe (bool value)
 
void setClearsRedoOnStart (bool value)
 
void setExclusive (bool value)
 
void setNeedsExplicitCancel (bool value)
 
void setRequestsOtherStrokesToEnd (bool value)
 
void setSupportsWrapAroundMode (bool value)
 

Private Member Functions

void deletePainters ()
 
void init ()
 
void initPainters (KisPaintDeviceSP targetDevice, KisPaintDeviceSP maskingDevice, KisSelectionSP selection, bool hasIndirectPainting, const QString &indirectPaintingCompositeOp)
 
int timedID (const QString &id)
 

Private Attributes

KisSelectionSP m_activeSelection
 
QScopedPointer< KUndo2Commandm_autokeyCommand
 
QScopedPointer< FakeUndoDatam_fakeUndoData
 
KisIndirectPaintingSupport::FinalMergeSuspenderSP m_finalMergeSuspender
 
QVector< KisMaskedFreehandStrokePainter * > m_maskedPainters
 
QScopedPointer< KisMaskingBrushRendererm_maskingBrushRenderer
 
QVector< KisFreehandStrokeInfo * > m_maskStrokeInfos
 
KisResourcesSnapshotSP m_resources
 
QVector< KisFreehandStrokeInfo * > m_strokeInfos
 
bool m_supportsContinuedInterstrokeData {false}
 
bool m_supportsIndirectPainting {false}
 
bool m_supportsMaskingBrush {false}
 
KisPaintDeviceSP m_targetDevice
 
QScopedPointer< KisTransactionm_transaction
 
bool m_useMergeID {false}
 

Additional Inherited Members

- Public Types inherited from KisSimpleStrokeStrategy
enum  JobType {
  JOB_INIT = 0 , JOB_CANCEL , JOB_FINISH , JOB_DOSTROKE ,
  JOB_SUSPEND , JOB_RESUME , NJOBS
}
 
- Static Public Member Functions inherited from KisSimpleStrokeStrategy
static QLatin1String jobTypeToString (JobType type)
 

Detailed Description

Definition at line 26 of file kis_painter_based_stroke_strategy.h.

Constructor & Destructor Documentation

◆ KisPainterBasedStrokeStrategy() [1/3]

KisPainterBasedStrokeStrategy::KisPainterBasedStrokeStrategy ( const QLatin1String & id,
const KUndo2MagicString & name,
KisResourcesSnapshotSP resources,
QVector< KisFreehandStrokeInfo * > strokeInfos )

Definition at line 41 of file kis_painter_based_stroke_strategy.cpp.

References init().

◆ KisPainterBasedStrokeStrategy() [2/3]

KisPainterBasedStrokeStrategy::KisPainterBasedStrokeStrategy ( const QLatin1String & id,
const KUndo2MagicString & name,
KisResourcesSnapshotSP resources,
KisFreehandStrokeInfo * strokeInfo )

Definition at line 56 of file kis_painter_based_stroke_strategy.cpp.

References init().

◆ ~KisPainterBasedStrokeStrategy()

KisPainterBasedStrokeStrategy::~KisPainterBasedStrokeStrategy ( )

Definition at line 71 of file kis_painter_based_stroke_strategy.cpp.

72{
73}

◆ KisPainterBasedStrokeStrategy() [3/3]

KisPainterBasedStrokeStrategy::KisPainterBasedStrokeStrategy ( const KisPainterBasedStrokeStrategy & rhs,
int levelOfDetail )
protected

Definition at line 85 of file kis_painter_based_stroke_strategy.cpp.

References KIS_ASSERT_RECOVER_NOOP, m_activeSelection, m_maskStrokeInfos, m_strokeInfos, m_targetDevice, and m_transaction.

Member Function Documentation

◆ activeSelection()

KisSelectionSP KisPainterBasedStrokeStrategy::activeSelection ( ) const
protected

Definition at line 110 of file kis_painter_based_stroke_strategy.cpp.

111{
112 return m_activeSelection;
113}

References m_activeSelection.

◆ cancelStrokeCallback()

void KisPainterBasedStrokeStrategy::cancelStrokeCallback ( )
overridevirtual

Reimplemented from KisSimpleStrokeStrategy.

Definition at line 471 of file kis_painter_based_stroke_strategy.cpp.

472{
473 if (!m_transaction) return;
474
475 if (m_autokeyCommand) {
476 m_autokeyCommand->undo();
477 }
478
481 dynamic_cast<KisIndirectPaintingSupport*>(node.data());
482
483 bool revert = true;
484 if (indirect) {
485 KisPaintDeviceSP t = indirect->temporaryTarget();
486 if (t) {
487 m_transaction.reset();
489
490 KisRegion region = t->region();
491 indirect->setTemporaryTarget(nullptr);
492 node->setDirty(region);
493 revert = false;
494 }
495 }
496
497 if (revert) {
498 m_transaction->revert();
499 m_transaction.reset();
501 }
502}
KisRegion region() const
QScopedPointer< KUndo2Command > m_autokeyCommand
QAction * revert(const QObject *recvr, const char *slot, QObject *parent)
virtual void setDirty()
Definition kis_node.cpp:577

References KisResourcesSnapshot::currentNode(), KisSharedPtr< T >::data(), deletePainters(), m_autokeyCommand, m_resources, m_transaction, KisPaintDevice::region(), KisNode::setDirty(), KisIndirectPaintingSupport::setTemporaryTarget(), and KisIndirectPaintingSupport::temporaryTarget.

◆ deletePainters()

void KisPainterBasedStrokeStrategy::deletePainters ( )
private

Definition at line 229 of file kis_painter_based_stroke_strategy.cpp.

230{
231 Q_FOREACH (KisFreehandStrokeInfo *info, m_strokeInfos) {
232 delete info;
233 }
234
235 m_strokeInfos.clear();
236
237 Q_FOREACH (KisFreehandStrokeInfo *info, m_maskStrokeInfos) {
238 delete info;
239 }
240
241 m_maskStrokeInfos.clear();
242
244 delete info;
245 }
246
247 m_maskedPainters.clear();
248}
QVector< KisMaskedFreehandStrokePainter * > m_maskedPainters

References m_maskedPainters, m_maskStrokeInfos, and m_strokeInfos.

◆ doMaskingBrushUpdates()

QVector< KisRunnableStrokeJobData * > KisPainterBasedStrokeStrategy::doMaskingBrushUpdates ( const QVector< QRect > & rects)
protected

Create a list of update jobs that should be run before issuing the setDirty() call on the node

See also
needsMaskingUpdates()

Definition at line 130 of file kis_painter_based_stroke_strategy.cpp.

131{
134
135 Q_FOREACH (const QRect &rc, rects) {
137 [this, rc] () {
138 this->m_maskingBrushRenderer->updateProjection(rc);
139 }
140 );
141 }
142
143 return jobs;
144}
QScopedPointer< KisMaskingBrushRenderer > m_maskingBrushRenderer
#define KIS_SAFE_ASSERT_RECOVER_RETURN_VALUE(cond, val)
Definition kis_assert.h:129
void addJobConcurrent(QVector< Job * > &jobs, Func func)

References KritaUtils::addJobConcurrent(), KIS_SAFE_ASSERT_RECOVER_RETURN_VALUE, and m_maskingBrushRenderer.

◆ finishStrokeCallback()

void KisPainterBasedStrokeStrategy::finishStrokeCallback ( )
overridevirtual

When the transaction is reset to zero, cancel job does nothing. Therefore, we should ensure that the merging jobs are never cancelled.

Reimplemented from KisSimpleStrokeStrategy.

Definition at line 389 of file kis_painter_based_stroke_strategy.cpp.

390{
393 dynamic_cast<KisIndirectPaintingSupport*>(node.data());
394
395 KisPostExecutionUndoAdapter *undoAdapter =
397
398
399 if (!undoAdapter) {
400 m_fakeUndoData.reset(new FakeUndoData());
401 undoAdapter = m_fakeUndoData->undoAdapter.data();
402 }
403
404 QSharedPointer<KUndo2Command> parentCommand;
405
406 if (!m_useMergeID) {
407 parentCommand.reset(new KUndo2Command());
408 } else {
409 parentCommand.reset(new MergeableStrokeUndoCommand(m_resources));
410 parentCommand->setTimedID(timedID(this->id()));
411 }
412
413 parentCommand->setText(name());
414 parentCommand->setTime(m_transaction->undoCommand()->time());
415 parentCommand->setEndTime(QTime::currentTime());
416
417 if (m_autokeyCommand) {
418 KisCommandUtils::CompositeCommand *wrapper = new KisCommandUtils::CompositeCommand(parentCommand.data());
419 wrapper->addCommand(m_autokeyCommand.take());
420 }
421
422 if (indirect && indirect->hasTemporaryTarget()) {
423 KUndo2MagicString transactionText = m_transaction->text();
424 m_transaction->end();
425 m_transaction.reset();
427
429
430 indirect->mergeToLayerThreaded(node,
431 parentCommand.data(),
433 -1,
434 &jobs);
435
437 [parentCommand, undoAdapter] () {
438 parentCommand->redo();
439
440 if (undoAdapter) {
441 undoAdapter->addCommand(parentCommand);
442 }
443 });
444
448
449 Q_FOREACH (KisRunnableStrokeJobData *job, jobs) {
450 job->setCancellable(false);
451 }
452
454 }
455 else {
456 KisCommandUtils::CompositeCommand *wrapper = new KisCommandUtils::CompositeCommand(parentCommand.data());
457 wrapper->addCommand(m_transaction->endAndTake());
458
459 m_transaction.reset();
461
462 if (undoAdapter) {
463 parentCommand->redo();
464 undoAdapter->addCommand(parentCommand);
465 }
466
467 }
468
469}
QScopedPointer< FakeUndoData > m_fakeUndoData
KisPostExecutionUndoAdapter * postExecutionUndoAdapter() const
KisRunnableStrokeJobsInterface * runnableJobsInterface() const
virtual void addRunnableJobs(const QVector< KisRunnableStrokeJobDataBase * > &list)=0
void setCancellable(bool value)
void addJobBarrier(QVector< Job * > &jobs, Func func)
virtual void mergeToLayerThreaded(KisNodeSP layer, KUndo2Command *parentCommand, const KUndo2MagicString &transactionText, int timedID, QVector< KisRunnableStrokeJobData * > *jobs)

References KisCommandUtils::CompositeCommand::addCommand(), KisPostExecutionUndoAdapter::addCommand(), KritaUtils::addJobBarrier(), KisRunnableStrokeJobsInterface::addRunnableJobs(), KisResourcesSnapshot::currentNode(), KisSharedPtr< T >::data(), deletePainters(), KisIndirectPaintingSupport::hasTemporaryTarget(), m_autokeyCommand, m_fakeUndoData, m_resources, m_transaction, m_useMergeID, KisIndirectPaintingSupport::mergeToLayerThreaded(), KisStrokeStrategy::name(), KisResourcesSnapshot::postExecutionUndoAdapter(), KisRunnableBasedStrokeStrategy::runnableJobsInterface(), KisStrokeJobData::setCancellable(), and timedID().

◆ init()

void KisPainterBasedStrokeStrategy::init ( )
private

Definition at line 75 of file kis_painter_based_stroke_strategy.cpp.

References KisSimpleStrokeStrategy::enableJob(), KisStrokeJobData::EXCLUSIVE, KisSimpleStrokeStrategy::JOB_CANCEL, KisSimpleStrokeStrategy::JOB_FINISH, KisSimpleStrokeStrategy::JOB_INIT, KisSimpleStrokeStrategy::JOB_RESUME, KisSimpleStrokeStrategy::JOB_SUSPEND, and KisStrokeJobData::SEQUENTIAL.

◆ initPainters()

void KisPainterBasedStrokeStrategy::initPainters ( KisPaintDeviceSP targetDevice,
KisPaintDeviceSP maskingDevice,
KisSelectionSP selection,
bool hasIndirectPainting,
const QString & indirectPaintingCompositeOp )
private

Definition at line 186 of file kis_painter_based_stroke_strategy.cpp.

191{
192 Q_FOREACH (KisFreehandStrokeInfo *info, m_strokeInfos) {
193 KisPainter *painter = info->painter;
194
195 painter->begin(targetDevice, !hasIndirectPainting ? selection : nullptr);
197 m_resources->setupPainter(painter);
198
199 if(hasIndirectPainting) {
200 painter->setCompositeOpId(indirectPaintingCompositeOp);
201 painter->setOpacityToUnit();
202 painter->setChannelFlags(QBitArray());
203 }
204 }
205
206 if (maskingDevice) {
207 for (int i = 0; i < m_strokeInfos.size(); i++) {
208 KisFreehandStrokeInfo *maskingInfo =
209 new KisFreehandStrokeInfo(*m_strokeInfos[i]->dragDistance);
210
211 KisPainter *painter = maskingInfo->painter;
212
213 painter->begin(maskingDevice, nullptr);
215
216 KIS_SAFE_ASSERT_RECOVER_NOOP(hasIndirectPainting);
217 m_maskStrokeInfos.append(maskingInfo);
218 }
219 }
220
221 for (int i = 0; i < m_strokeInfos.size(); i++) {
222 m_maskedPainters.append(
224 !m_maskStrokeInfos.isEmpty() ?
225 m_maskStrokeInfos[i] : nullptr));
226 }
227}
void begin(KisPaintDeviceSP device)
void setOpacityToUnit()
void setRunnableStrokeJobsInterface(KisRunnableStrokeJobsInterface *interface)
void setChannelFlags(QBitArray channelFlags)
void setCompositeOpId(const KoCompositeOp *op)
void setupPainter(KisPainter *painter)
void setupMaskingBrushPainter(KisPainter *painter)
#define KIS_SAFE_ASSERT_RECOVER_NOOP(cond)
Definition kis_assert.h:130

References KisPainter::begin(), KIS_SAFE_ASSERT_RECOVER_NOOP, m_maskedPainters, m_maskStrokeInfos, m_resources, m_strokeInfos, KisFreehandStrokeInfo::painter, KisRunnableBasedStrokeStrategy::runnableJobsInterface(), KisPainter::setChannelFlags(), KisPainter::setCompositeOpId(), KisPainter::setOpacityToUnit(), KisPainter::setRunnableStrokeJobsInterface(), KisResourcesSnapshot::setupMaskingBrushPainter(), KisResourcesSnapshot::setupPainter(), and targetDevice().

◆ initStrokeCallback()

void KisPainterBasedStrokeStrategy::initStrokeCallback ( )
overridevirtual

Reimplemented from KisSimpleStrokeStrategy.

Definition at line 250 of file kis_painter_based_stroke_strategy.cpp.

251{
253
254 KritaUtils::addJobSequential(jobs, [this] () {
256
257 KUndo2Command *autoKeyframeCommand =
261 if (autoKeyframeCommand) {
262 m_autokeyCommand.reset(autoKeyframeCommand);
263 }
264 });
265
266 KritaUtils::addJobSequential(jobs, [this] () mutable {
268 KisPaintDeviceSP paintDevice = node->paintDevice();
269 KisPaintDeviceSP targetDevice = paintDevice;
271 bool hasIndirectPainting = supportsIndirectPainting() && m_resources->needsIndirectPainting();
272 const QString indirectCompositeOp = m_resources->indirectPaintingCompositeOp();
273
274 if (hasIndirectPainting) {
276 dynamic_cast<KisIndirectPaintingSupport*>(node.data());
277
278 if (indirect) {
283
286 indirect->setTemporarySelection(selection);
287
288 QBitArray channelLockFlags = m_resources->channelLockFlags();
289 indirect->setTemporaryChannelFlags(channelLockFlags);
290 }
291 else {
292 hasIndirectPainting = false;
293 }
294 }
295
296 QScopedPointer<KisInterstrokeDataFactory> interstrokeDataFactory(
298
299 KIS_SAFE_ASSERT_RECOVER(!interstrokeDataFactory || !hasIndirectPainting) {
300 interstrokeDataFactory.reset();
301 }
302
303 QScopedPointer<KisInterstrokeDataTransactionWrapperFactory> wrapper;
304
305 if (interstrokeDataFactory) {
307 interstrokeDataFactory.take(),
309 }
310
312 -1,
313 wrapper.take()));
314
315 // WARNING: masked brush cannot work without indirect painting mode!
317 m_resources->needsMaskingBrushRendering()) || hasIndirectPainting);
318
319 if (hasIndirectPainting &&
322
323 const QString compositeOpId =
324 m_resources->currentPaintOpPreset()->settings()->maskingBrushCompositeOp();
325
327
328 initPainters(m_maskingBrushRenderer->strokeDevice(),
329 m_maskingBrushRenderer->maskDevice(),
330 selection,
331 hasIndirectPainting,
332 indirectCompositeOp);
333
334 } else {
335 initPainters(targetDevice, nullptr, selection, hasIndirectPainting, indirectCompositeOp);
336 }
337
339 m_activeSelection = selection;
340
341 // sanity check: selection should be applied only once
342 if (selection && !m_strokeInfos.isEmpty()) {
344 dynamic_cast<KisIndirectPaintingSupport*>(node.data());
345 KIS_ASSERT_RECOVER_RETURN(hasIndirectPainting || m_strokeInfos.first()->painter->selection());
346 // when hasIndirectPainting is true, indirect cannot be null
347 KIS_ASSERT_RECOVER_RETURN(!hasIndirectPainting || indirect);
348 KIS_ASSERT_RECOVER_RETURN(!hasIndirectPainting || !indirect->temporarySelection() || !m_strokeInfos.first()->painter->selection());
349 }
350 });
351
353}
KisPaintDeviceSP createCompositionSourceDevice() const
void setParentNode(KisNodeWSP parent)
static KisPaintOpRegistry * instance()
void initPainters(KisPaintDeviceSP targetDevice, KisPaintDeviceSP maskingDevice, KisSelectionSP selection, bool hasIndirectPainting, const QString &indirectPaintingCompositeOp)
KisPaintOpPresetSP currentPaintOpPreset() const
QString indirectPaintingCompositeOp() const
KisSelectionSP activeSelection() const
#define KIS_SAFE_ASSERT_RECOVER(cond)
Definition kis_assert.h:126
#define KIS_ASSERT_RECOVER_RETURN(cond)
Definition kis_assert.h:75
KUndo2Command * tryAutoCreateDuplicatedFrame(KisPaintDeviceSP device, AutoCreateKeyframeFlags flags)
create a new duplicated keyframe if auto-keyframe mode is on
void addJobSequential(QVector< Job * > &jobs, Func func)
KisInterstrokeDataFactory * createInterstrokeDataFactory(const KisPaintOpSettingsSP settings, KisResourcesInterfaceSP resourcesInterface, std::enable_if_t< has_create_interstroke_data_factory< T >::value > *=0)
virtual KisPaintDeviceSP paintDevice() const =0
void setTemporaryChannelFlags(const QBitArray &channelFlags)
virtual void setCurrentColor(const KoColor &color)
void setTemporarySelection(KisSelectionSP selection)
void setTemporaryCompositeOp(const QString &id)

References KisResourcesSnapshot::activeSelection(), KritaUtils::addJobSequential(), KisRunnableStrokeJobsInterface::addRunnableJobs(), KisAutoKey::AllowBlankMode, KisResourcesSnapshot::channelLockFlags(), KisResourcesSnapshot::compositeOpId(), KisPaintDevice::createCompositionSourceDevice(), KisResourcesSnapshot::currentFgColor(), KisResourcesSnapshot::currentNode(), KisResourcesSnapshot::currentPaintOpPreset(), KisSharedPtr< T >::data(), KisResourcesSnapshot::indirectPaintingCompositeOp(), initPainters(), KisPaintOpRegistry::instance(), KIS_ASSERT_RECOVER_RETURN, KIS_SAFE_ASSERT_RECOVER, KIS_SAFE_ASSERT_RECOVER_NOOP, m_activeSelection, m_autokeyCommand, m_maskingBrushRenderer, m_resources, m_strokeInfos, m_targetDevice, m_transaction, KisResourcesSnapshot::needsIndirectPainting(), KisResourcesSnapshot::needsMaskingBrushRendering(), KisResourcesSnapshot::opacity(), KisBaseNode::paintDevice(), KisRunnableBasedStrokeStrategy::runnableJobsInterface(), KisIndirectPaintingSupport::setCurrentColor(), KisPaintDevice::setParentNode(), KisIndirectPaintingSupport::setTemporaryChannelFlags(), KisIndirectPaintingSupport::setTemporaryCompositeOp(), KisIndirectPaintingSupport::setTemporaryOpacity(), KisIndirectPaintingSupport::setTemporarySelection(), KisIndirectPaintingSupport::setTemporaryTarget(), supportsContinuedInterstrokeData(), supportsIndirectPainting(), KisAutoKey::SupportsLod, supportsMaskingBrush(), targetDevice(), KisIndirectPaintingSupport::temporarySelection(), and KisAutoKey::tryAutoCreateDuplicatedFrame().

◆ maskedPainter()

KisMaskedFreehandStrokePainter * KisPainterBasedStrokeStrategy::maskedPainter ( int strokeInfoId)
protected

Definition at line 115 of file kis_painter_based_stroke_strategy.cpp.

116{
117 return m_maskedPainters[strokeInfoId];
118}

References m_maskedPainters.

◆ needsMaskingUpdates()

bool KisPainterBasedStrokeStrategy::needsMaskingUpdates ( ) const
protected

Return true if the descendant should execute a few more jobs before issuing setDirty() call on the layer.

If the returned value is true, then the stroke actually paints not on the layer's paint device, but on some intermediate device owned by KisPainterBasedStrokeStrategy and one should merge it first before asking the update.

The value can be true only when the stroke is declared to support masked brush!

See also
supportsMaskingBrush()

Definition at line 125 of file kis_painter_based_stroke_strategy.cpp.

126{
127 return bool(m_maskingBrushRenderer);
128}

References m_maskingBrushRenderer.

◆ numMaskedPainters()

int KisPainterBasedStrokeStrategy::numMaskedPainters ( ) const
protected

Definition at line 120 of file kis_painter_based_stroke_strategy.cpp.

121{
122 return m_maskedPainters.size();
123}

References m_maskedPainters.

◆ resumeStrokeCallback()

void KisPainterBasedStrokeStrategy::resumeStrokeCallback ( )
overridevirtual

Reimplemented from KisSimpleStrokeStrategy.

Definition at line 516 of file kis_painter_based_stroke_strategy.cpp.

517{
520 dynamic_cast<KisIndirectPaintingSupport*>(node.data());
521
522 if(indirect) {
523 // todo: don't ask about paint device
524 // todo:change to an assert
525 if (node->paintDevice() != m_targetDevice) {
530
531 QBitArray channelLockFlags = m_resources->channelLockFlags();
532 indirect->setTemporaryChannelFlags(channelLockFlags);
533 }
534 }
535
536 m_finalMergeSuspender.clear();
537}
KisIndirectPaintingSupport::FinalMergeSuspenderSP m_finalMergeSuspender

References KisResourcesSnapshot::channelLockFlags(), KisResourcesSnapshot::compositeOpId(), KisResourcesSnapshot::currentNode(), KisSharedPtr< T >::data(), m_activeSelection, m_finalMergeSuspender, m_resources, m_targetDevice, KisResourcesSnapshot::opacity(), KisBaseNode::paintDevice(), KisIndirectPaintingSupport::setTemporaryChannelFlags(), KisIndirectPaintingSupport::setTemporaryCompositeOp(), KisIndirectPaintingSupport::setTemporaryOpacity(), KisIndirectPaintingSupport::setTemporarySelection(), and KisIndirectPaintingSupport::setTemporaryTarget().

◆ setSupportsContinuedInterstrokeData()

void KisPainterBasedStrokeStrategy::setSupportsContinuedInterstrokeData ( bool value)
protected

Definition at line 171 of file kis_painter_based_stroke_strategy.cpp.

172{
174}
float value(const T *src, size_t ch)

References m_supportsContinuedInterstrokeData, and value().

◆ setSupportsIndirectPainting()

void KisPainterBasedStrokeStrategy::setSupportsIndirectPainting ( bool value)
protected

◆ setSupportsMaskingBrush()

void KisPainterBasedStrokeStrategy::setSupportsMaskingBrush ( bool value)
protected

The descendants may declare if this stroke should support auto-creation of the masked brush. Default value: false

Definition at line 146 of file kis_painter_based_stroke_strategy.cpp.

147{
149}

References m_supportsMaskingBrush, and value().

◆ setSupportsTimedMergeId()

void KisPainterBasedStrokeStrategy::setSupportsTimedMergeId ( bool value)
protected

Definition at line 181 of file kis_painter_based_stroke_strategy.cpp.

182{
184}

References m_useMergeID, and value().

◆ setUndoEnabled()

void KisPainterBasedStrokeStrategy::setUndoEnabled ( bool value)
protected

◆ supportsContinuedInterstrokeData()

bool KisPainterBasedStrokeStrategy::supportsContinuedInterstrokeData ( ) const
protected

◆ supportsIndirectPainting()

bool KisPainterBasedStrokeStrategy::supportsIndirectPainting ( ) const
protected

Definition at line 161 of file kis_painter_based_stroke_strategy.cpp.

162{
164}

References m_supportsIndirectPainting.

◆ supportsMaskingBrush()

bool KisPainterBasedStrokeStrategy::supportsMaskingBrush ( ) const
protected

Return if the stroke should auto-create a masked brush from the provided paintop preset or not

Definition at line 151 of file kis_painter_based_stroke_strategy.cpp.

152{
154}

References m_supportsMaskingBrush.

◆ supportsTimedMergeId()

bool KisPainterBasedStrokeStrategy::supportsTimedMergeId ( ) const
protected

Definition at line 176 of file kis_painter_based_stroke_strategy.cpp.

177{
178 return m_useMergeID;
179}

References m_useMergeID.

◆ suspendStrokeCallback()

void KisPainterBasedStrokeStrategy::suspendStrokeCallback ( )
overridevirtual

◆ targetDevice()

KisPaintDeviceSP KisPainterBasedStrokeStrategy::targetDevice ( ) const
protected

Definition at line 105 of file kis_painter_based_stroke_strategy.cpp.

106{
107 return m_targetDevice;
108}

References m_targetDevice.

◆ targetNode()

KisNodeSP KisPainterBasedStrokeStrategy::targetNode ( ) const
protected

Definition at line 539 of file kis_painter_based_stroke_strategy.cpp.

540{
541 return m_resources->currentNode();
542}

References KisResourcesSnapshot::currentNode(), and m_resources.

◆ timedID()

int KisPainterBasedStrokeStrategy::timedID ( const QString & id)
inlineprivate

Definition at line 113 of file kis_painter_based_stroke_strategy.h.

113 {
114 return int(qHash(id));
115 }
uint qHash(const KoInputDevice &key)

References qHash().

Member Data Documentation

◆ m_activeSelection

KisSelectionSP KisPainterBasedStrokeStrategy::m_activeSelection
private

Definition at line 128 of file kis_painter_based_stroke_strategy.h.

◆ m_autokeyCommand

QScopedPointer<KUndo2Command> KisPainterBasedStrokeStrategy::m_autokeyCommand
private

Definition at line 130 of file kis_painter_based_stroke_strategy.h.

◆ m_fakeUndoData

QScopedPointer<FakeUndoData> KisPainterBasedStrokeStrategy::m_fakeUndoData
private

Definition at line 146 of file kis_painter_based_stroke_strategy.h.

◆ m_finalMergeSuspender

KisIndirectPaintingSupport::FinalMergeSuspenderSP KisPainterBasedStrokeStrategy::m_finalMergeSuspender
private

Definition at line 138 of file kis_painter_based_stroke_strategy.h.

◆ m_maskedPainters

QVector<KisMaskedFreehandStrokePainter*> KisPainterBasedStrokeStrategy::m_maskedPainters
private

Definition at line 121 of file kis_painter_based_stroke_strategy.h.

◆ m_maskingBrushRenderer

QScopedPointer<KisMaskingBrushRenderer> KisPainterBasedStrokeStrategy::m_maskingBrushRenderer
private

Definition at line 125 of file kis_painter_based_stroke_strategy.h.

◆ m_maskStrokeInfos

QVector<KisFreehandStrokeInfo*> KisPainterBasedStrokeStrategy::m_maskStrokeInfos
private

Definition at line 120 of file kis_painter_based_stroke_strategy.h.

◆ m_resources

KisResourcesSnapshotSP KisPainterBasedStrokeStrategy::m_resources
private

Definition at line 118 of file kis_painter_based_stroke_strategy.h.

◆ m_strokeInfos

QVector<KisFreehandStrokeInfo*> KisPainterBasedStrokeStrategy::m_strokeInfos
private

Definition at line 119 of file kis_painter_based_stroke_strategy.h.

◆ m_supportsContinuedInterstrokeData

bool KisPainterBasedStrokeStrategy::m_supportsContinuedInterstrokeData {false}
private

Definition at line 136 of file kis_painter_based_stroke_strategy.h.

136{false};

◆ m_supportsIndirectPainting

bool KisPainterBasedStrokeStrategy::m_supportsIndirectPainting {false}
private

Definition at line 135 of file kis_painter_based_stroke_strategy.h.

135{false};

◆ m_supportsMaskingBrush

bool KisPainterBasedStrokeStrategy::m_supportsMaskingBrush {false}
private

Definition at line 134 of file kis_painter_based_stroke_strategy.h.

134{false};

◆ m_targetDevice

KisPaintDeviceSP KisPainterBasedStrokeStrategy::m_targetDevice
private

Definition at line 127 of file kis_painter_based_stroke_strategy.h.

◆ m_transaction

QScopedPointer<KisTransaction> KisPainterBasedStrokeStrategy::m_transaction
private

Definition at line 123 of file kis_painter_based_stroke_strategy.h.

◆ m_useMergeID

bool KisPainterBasedStrokeStrategy::m_useMergeID {false}
private

Definition at line 132 of file kis_painter_based_stroke_strategy.h.

132{false};

The documentation for this class was generated from the following files: