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

#include <kis_stroke_strategy.h>

+ Inheritance diagram for KisStrokeStrategy:

Public Member Functions

qreal balancingRatioOverride () const
 
bool canForgetAboutMe () const
 
bool clearsRedoOnStart () const
 
virtual KisStrokeJobDatacreateCancelData ()
 
virtual KisStrokeJobStrategycreateCancelStrategy ()
 
virtual KisStrokeJobStrategycreateDabStrategy ()
 
virtual KisStrokeJobDatacreateFinishData ()
 
virtual KisStrokeJobStrategycreateFinishStrategy ()
 
virtual KisStrokeJobDatacreateInitData ()
 
virtual KisStrokeJobStrategycreateInitStrategy ()
 
virtual KisStrokeStrategycreateLodClone (int levelOfDetail)
 
virtual KisStrokeJobDatacreateResumeData ()
 
virtual KisStrokeJobStrategycreateResumeStrategy ()
 
virtual KisStrokeJobDatacreateSuspendData ()
 
virtual KisStrokeJobStrategycreateSuspendStrategy ()
 
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

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 Attributes

bool m_asynchronouslyCancellable
 
qreal m_balancingRatioOverride
 
bool m_canForgetAboutMe
 
bool m_clearsRedoOnStart
 
bool m_exclusive
 
bool m_forceLodModeIfPossible
 
QLatin1String m_id
 
KisStrokesQueueMutatedJobInterfacem_mutatedJobsInterface
 
KUndo2MagicString m_name
 
bool m_needsExplicitCancel
 
bool m_requestsOtherStrokesToEnd
 
KisStrokeId m_strokeId
 
bool m_supportsWrapAroundMode
 

Friends

class KisMutatableDabStrategy
 

Detailed Description

Definition at line 20 of file kis_stroke_strategy.h.

Constructor & Destructor Documentation

◆ KisStrokeStrategy() [1/2]

KisStrokeStrategy::KisStrokeStrategy ( const QLatin1String & id,
const KUndo2MagicString & name = KUndo2MagicString() )

Definition at line 13 of file kis_stroke_strategy.cpp.

14 : m_exclusive(false),
18 m_canForgetAboutMe(false),
23 m_id(id),
24 m_name(name),
26{
27}
KUndo2MagicString m_name
KisStrokesQueueMutatedJobInterface * m_mutatedJobsInterface
KUndo2MagicString name() const

◆ ~KisStrokeStrategy()

KisStrokeStrategy::~KisStrokeStrategy ( )
virtual

Definition at line 57 of file kis_stroke_strategy.cpp.

58{
59}

◆ KisStrokeStrategy() [2/2]

KisStrokeStrategy::KisStrokeStrategy ( const KisStrokeStrategy & rhs)
protected

Member Function Documentation

◆ addMutatedJob()

void KisStrokeStrategy::addMutatedJob ( KisStrokeJobData * data)
protected

Convenience override for addMutatedJobs()

Definition at line 177 of file kis_stroke_strategy.cpp.

178{
179 addMutatedJobs({data});
180}
void addMutatedJobs(const QVector< KisStrokeJobData * > list)

References addMutatedJobs().

◆ addMutatedJobs()

void KisStrokeStrategy::addMutatedJobs ( const QVector< KisStrokeJobData * > list)
protected

This function is supposed to be called by internal asynchronous jobs. It allows adding subtasks that may be executed concurrently.

Requirements:

  • must be called only from within the context of the strokes worker thread during execution of one of its jobs

Guarantees:

  • the added job is guaranteed to be executed in some time after the currently executed job, before the next SEQUENTIAL or BARRIER job
  • if the currently executed job is CONCURRENT, the mutated job may start execution right after adding to the queue without waiting for its parent to complete. Though this behavior is not guaranteed, because addMutatedJob does not initiate processQueues(), because it may lead to a deadlock.

Definition at line 167 of file kis_stroke_strategy.cpp.

168{
170 qDeleteAll(list);
171 return;
172 }
173
175}
virtual void addMutatedJobs(KisStrokeId strokeId, const QVector< KisStrokeJobData * > list)=0
#define KIS_SAFE_ASSERT_RECOVER(cond)
Definition kis_assert.h:126

◆ balancingRatioOverride()

qreal KisStrokeStrategy::balancingRatioOverride ( ) const
See also
setBalancingRatioOverride() for details

Definition at line 242 of file kis_stroke_strategy.cpp.

243{
245}

References m_balancingRatioOverride.

◆ canForgetAboutMe()

bool KisStrokeStrategy::canForgetAboutMe ( ) const

Returns true if the update scheduler can cancel this stroke when some other stroke is going to be started. This makes the "forgettable" stroke very low priority.

Default is 'false'.

Definition at line 212 of file kis_stroke_strategy.cpp.

213{
214 return m_canForgetAboutMe;
215}

References m_canForgetAboutMe.

◆ clearsRedoOnStart()

bool KisStrokeStrategy::clearsRedoOnStart ( ) const

Returns true if mere start of the stroke should cancel all the pending redo tasks.

This method should return true in almost all circumstances except if we are running an undo or redo stroke.

Definition at line 192 of file kis_stroke_strategy.cpp.

193{
194 return m_clearsRedoOnStart;
195}

References m_clearsRedoOnStart.

◆ createCancelData()

KisStrokeJobData * KisStrokeStrategy::createCancelData ( )
virtual

Reimplemented in KisSimpleStrokeStrategy.

Definition at line 109 of file kis_stroke_strategy.cpp.

110{
111 return 0;
112}

◆ createCancelStrategy()

KisStrokeJobStrategy * KisStrokeStrategy::createCancelStrategy ( )
virtual

Reimplemented in KisSimpleStrokeStrategy.

Definition at line 79 of file kis_stroke_strategy.cpp.

80{
81 return 0;
82}

◆ createDabStrategy()

KisStrokeJobStrategy * KisStrokeStrategy::createDabStrategy ( )
virtual

Reimplemented in KisSimpleStrokeStrategy.

Definition at line 84 of file kis_stroke_strategy.cpp.

85{
86 return 0;
87}

◆ createFinishData()

KisStrokeJobData * KisStrokeStrategy::createFinishData ( )
virtual

Reimplemented in KisSimpleStrokeStrategy.

Definition at line 104 of file kis_stroke_strategy.cpp.

105{
106 return 0;
107}

◆ createFinishStrategy()

KisStrokeJobStrategy * KisStrokeStrategy::createFinishStrategy ( )
virtual

Reimplemented in KisSimpleStrokeStrategy.

Definition at line 74 of file kis_stroke_strategy.cpp.

75{
76 return 0;
77}

◆ createInitData()

KisStrokeJobData * KisStrokeStrategy::createInitData ( )
virtual

Reimplemented in KisSimpleStrokeStrategy.

Definition at line 99 of file kis_stroke_strategy.cpp.

100{
101 return 0;
102}

◆ createInitStrategy()

KisStrokeJobStrategy * KisStrokeStrategy::createInitStrategy ( )
virtual

Reimplemented in KisSimpleStrokeStrategy.

Definition at line 69 of file kis_stroke_strategy.cpp.

70{
71 return 0;
72}

◆ createLodClone()

KisStrokeStrategy * KisStrokeStrategy::createLodClone ( int levelOfDetail)
virtual

◆ createResumeData()

KisStrokeJobData * KisStrokeStrategy::createResumeData ( )
virtual

Reimplemented in KisSimpleStrokeStrategy.

Definition at line 119 of file kis_stroke_strategy.cpp.

120{
121 return 0;
122}

◆ createResumeStrategy()

KisStrokeJobStrategy * KisStrokeStrategy::createResumeStrategy ( )
virtual

Reimplemented in KisSimpleStrokeStrategy.

Definition at line 94 of file kis_stroke_strategy.cpp.

95{
96 return 0;
97}

◆ createSuspendData()

KisStrokeJobData * KisStrokeStrategy::createSuspendData ( )
virtual

Reimplemented in KisSimpleStrokeStrategy.

Definition at line 114 of file kis_stroke_strategy.cpp.

115{
116 return 0;
117}

◆ createSuspendStrategy()

KisStrokeJobStrategy * KisStrokeStrategy::createSuspendStrategy ( )
virtual

Reimplemented in KisSimpleStrokeStrategy.

Definition at line 89 of file kis_stroke_strategy.cpp.

90{
91 return 0;
92}

◆ currentLodPreferences()

KisLodPreferences KisStrokeStrategy::currentLodPreferences ( ) const

Returns current lod preferences of the strokes queue

Definition at line 155 of file kis_stroke_strategy.cpp.

156{
159}
virtual KisLodPreferences lodPreferences() const =0
#define KIS_SAFE_ASSERT_RECOVER_RETURN_VALUE(cond, val)
Definition kis_assert.h:129

References KIS_SAFE_ASSERT_RECOVER_RETURN_VALUE, KisStrokesQueueMutatedJobInterface::lodPreferences(), and m_mutatedJobsInterface.

◆ forceLodModeIfPossible()

bool KisStrokeStrategy::forceLodModeIfPossible ( ) const

Definition at line 47 of file kis_stroke_strategy.cpp.

48{
50}

References m_forceLodModeIfPossible.

◆ id()

QString KisStrokeStrategy::id ( ) const

Definition at line 145 of file kis_stroke_strategy.cpp.

146{
147 return m_id;
148}

References m_id.

◆ isAsynchronouslyCancellable()

bool KisStrokeStrategy::isAsynchronouslyCancellable ( ) const

Returns true if the stroke can be cancelled by the engine, e.g. when the user presses Esc key or Ctrl+Z shortcut. Default value is true. The only exception right now are the strokes that perform undo/redo operations.

The owner of the stroke can still cancel the stroke via the strokeId handle (though it is not used for undo/redo strokes).

Definition at line 222 of file kis_stroke_strategy.cpp.

223{
225}

References m_asynchronouslyCancellable.

◆ isExclusive()

bool KisStrokeStrategy::isExclusive ( ) const

Definition at line 135 of file kis_stroke_strategy.cpp.

136{
137 return m_exclusive;
138}

References m_exclusive.

◆ name()

KUndo2MagicString KisStrokeStrategy::name ( ) const

Definition at line 150 of file kis_stroke_strategy.cpp.

151{
152 return m_name;
153}

References m_name.

◆ needsExplicitCancel()

bool KisStrokeStrategy::needsExplicitCancel ( ) const

Definition at line 232 of file kis_stroke_strategy.cpp.

233{
235}

References m_needsExplicitCancel.

◆ notifyUserEndedStroke()

void KisStrokeStrategy::notifyUserEndedStroke ( )
virtual

notifyUserEndedStroke() is a callback used by the strokes system to notify when the user ends the stroke. That moment corresponds to the user calling strokesFacade->endStroke(id) and might happen much earlier when the stroke even started its execution.

NOTE: this method will be executed in the context of the GUI thread!

Reimplemented in FreehandStrokeStrategy.

Definition at line 65 of file kis_stroke_strategy.cpp.

66{
67}

◆ notifyUserStartedStroke()

void KisStrokeStrategy::notifyUserStartedStroke ( )
virtual

notifyUserStartedStroke() is a callback used by the strokes system to notify when the user adds the stroke to the strokes queue. That moment corresponds to the user calling strokesFacade->startStroke(strategy) and might happen much earlier than the first job being executed.

NOTE: this method will be executed in the context of the GUI thread!

Reimplemented in FreehandStrokeStrategy.

Definition at line 61 of file kis_stroke_strategy.cpp.

62{
63}

◆ requestsOtherStrokesToEnd()

bool KisStrokeStrategy::requestsOtherStrokesToEnd ( ) const

Returns true if the other currently running strokes should be politely asked to exit. The default value is 'true'.

The only known exception right now is KisRegenerateFrameStrokeStrategy which does not requests ending of any actions, since it performs purely background action.

Definition at line 202 of file kis_stroke_strategy.cpp.

203{
205}

References m_requestsOtherStrokesToEnd.

◆ setAsynchronouslyCancellable()

void KisStrokeStrategy::setAsynchronouslyCancellable ( bool value)
protected

Definition at line 227 of file kis_stroke_strategy.cpp.

228{
230}
float value(const T *src, size_t ch)

References m_asynchronouslyCancellable, and value().

◆ setBalancingRatioOverride()

void KisStrokeStrategy::setBalancingRatioOverride ( qreal value)
protected

Set override for the desired scheduler balancing ratio:

ratio = stroke jobs / update jobs

If value < 1.0, then the priority is given to updates, if the value is higher than 1.0, then the priority is given to stroke jobs.

Special value -1.0, suggests the scheduler to use the default value set by the user's config file (which is 100.0 by default).

Definition at line 247 of file kis_stroke_strategy.cpp.

248{
250}

References m_balancingRatioOverride, and value().

◆ setCanForgetAboutMe()

void KisStrokeStrategy::setCanForgetAboutMe ( bool value)
protected

Definition at line 217 of file kis_stroke_strategy.cpp.

218{
220}

References m_canForgetAboutMe, and value().

◆ setClearsRedoOnStart()

void KisStrokeStrategy::setClearsRedoOnStart ( bool value)
protected

Definition at line 197 of file kis_stroke_strategy.cpp.

198{
200}

References m_clearsRedoOnStart, and value().

◆ setExclusive()

void KisStrokeStrategy::setExclusive ( bool value)
protected

Definition at line 182 of file kis_stroke_strategy.cpp.

183{
185}

References m_exclusive, and value().

◆ setForceLodModeIfPossible()

void KisStrokeStrategy::setForceLodModeIfPossible ( bool forceLodModeIfPossible)

Definition at line 52 of file kis_stroke_strategy.cpp.

References m_forceLodModeIfPossible, and value().

◆ setMutatedJobsInterface()

void KisStrokeStrategy::setMutatedJobsInterface ( KisStrokesQueueMutatedJobInterface * mutatedJobsInterface,
KisStrokeId strokeId )

Definition at line 161 of file kis_stroke_strategy.cpp.

162{
163 m_mutatedJobsInterface = mutatedJobsInterface;
164 m_strokeId = strokeId;
165}

References m_mutatedJobsInterface, and m_strokeId.

◆ setNeedsExplicitCancel()

void KisStrokeStrategy::setNeedsExplicitCancel ( bool value)
protected

Definition at line 237 of file kis_stroke_strategy.cpp.

238{
240}

References m_needsExplicitCancel, and value().

◆ setRequestsOtherStrokesToEnd()

void KisStrokeStrategy::setRequestsOtherStrokesToEnd ( bool value)
protected

Definition at line 207 of file kis_stroke_strategy.cpp.

References m_requestsOtherStrokesToEnd, and value().

◆ setSupportsWrapAroundMode()

void KisStrokeStrategy::setSupportsWrapAroundMode ( bool value)
protected

Definition at line 187 of file kis_stroke_strategy.cpp.

188{
190}

References m_supportsWrapAroundMode, and value().

◆ supportsWrapAroundMode()

bool KisStrokeStrategy::supportsWrapAroundMode ( ) const

Definition at line 140 of file kis_stroke_strategy.cpp.

141{
143}

References m_supportsWrapAroundMode.

◆ tryCancelCurrentStrokeJobAsync()

void KisStrokeStrategy::tryCancelCurrentStrokeJobAsync ( )
virtual

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.

Reimplemented in KisColorizeStrokeStrategy.

Definition at line 130 of file kis_stroke_strategy.cpp.

131{
132 // noop
133}

Friends And Related Symbol Documentation

◆ KisMutatableDabStrategy

friend class KisMutatableDabStrategy
friend

Definition at line 136 of file kis_stroke_strategy.h.

Member Data Documentation

◆ m_asynchronouslyCancellable

bool KisStrokeStrategy::m_asynchronouslyCancellable
private

Definition at line 202 of file kis_stroke_strategy.h.

◆ m_balancingRatioOverride

qreal KisStrokeStrategy::m_balancingRatioOverride
private

Definition at line 205 of file kis_stroke_strategy.h.

◆ m_canForgetAboutMe

bool KisStrokeStrategy::m_canForgetAboutMe
private

Definition at line 201 of file kis_stroke_strategy.h.

◆ m_clearsRedoOnStart

bool KisStrokeStrategy::m_clearsRedoOnStart
private

Definition at line 199 of file kis_stroke_strategy.h.

◆ m_exclusive

bool KisStrokeStrategy::m_exclusive
private

Definition at line 196 of file kis_stroke_strategy.h.

◆ m_forceLodModeIfPossible

bool KisStrokeStrategy::m_forceLodModeIfPossible
private

Definition at line 204 of file kis_stroke_strategy.h.

◆ m_id

QLatin1String KisStrokeStrategy::m_id
private

Definition at line 207 of file kis_stroke_strategy.h.

◆ m_mutatedJobsInterface

KisStrokesQueueMutatedJobInterface* KisStrokeStrategy::m_mutatedJobsInterface
private

Definition at line 211 of file kis_stroke_strategy.h.

◆ m_name

KUndo2MagicString KisStrokeStrategy::m_name
private

Definition at line 208 of file kis_stroke_strategy.h.

◆ m_needsExplicitCancel

bool KisStrokeStrategy::m_needsExplicitCancel
private

Definition at line 203 of file kis_stroke_strategy.h.

◆ m_requestsOtherStrokesToEnd

bool KisStrokeStrategy::m_requestsOtherStrokesToEnd
private

Definition at line 200 of file kis_stroke_strategy.h.

◆ m_strokeId

KisStrokeId KisStrokeStrategy::m_strokeId
private

Definition at line 210 of file kis_stroke_strategy.h.

◆ m_supportsWrapAroundMode

bool KisStrokeStrategy::m_supportsWrapAroundMode
private

Definition at line 197 of file kis_stroke_strategy.h.


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