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

#include <KisStrokeSpeedMonitor.h>

+ Inheritance diagram for KisStrokeSpeedMonitor:

Classes

struct  Private
 

Public Slots

void setHaveStrokeSpeedMeasurement (bool value)
 

Signals

void sigStatsUpdated ()
 

Public Member Functions

qreal avgCursorSpeed () const
 
qreal avgFps () const
 
qreal avgRenderingSpeed () const
 
bool haveStrokeSpeedMeasurement () const
 
 KisStrokeSpeedMonitor ()
 
qreal lastCursorSpeed () const
 
qreal lastFps () const
 
QString lastPresetName () const
 
qreal lastPresetSize () const
 
qreal lastRenderingSpeed () const
 
bool lastStrokeSaturated () const
 
void notifyStrokeFinished (qreal cursorSpeed, qreal renderingSpeed, qreal fps, KisPaintOpPresetSP preset)
 
 ~KisStrokeSpeedMonitor ()
 

Static Public Member Functions

static KisStrokeSpeedMonitorinstance ()
 

Properties

qreal avgCursorSpeed
 
qreal avgFps
 
qreal avgRenderingSpeed
 
qreal lastCursorSpeed
 
qreal lastFps
 
QString lastPresetName
 
qreal lastPresetSize
 
qreal lastRenderingSpeed
 
bool lastStrokeSaturated
 

Private Slots

void resetAccumulatedValues ()
 
void slotConfigChanged ()
 

Private Attributes

const QScopedPointer< Privatem_d
 

Detailed Description

Definition at line 15 of file KisStrokeSpeedMonitor.h.

Constructor & Destructor Documentation

◆ KisStrokeSpeedMonitor()

KisStrokeSpeedMonitor::KisStrokeSpeedMonitor ( )

Definition at line 58 of file KisStrokeSpeedMonitor.cpp.

59 : m_d(new Private())
60{
61 connect(KisImageConfigNotifier::instance(), SIGNAL(configChanged()), SLOT(resetAccumulatedValues()));
62 connect(KisImageConfigNotifier::instance(), SIGNAL(configChanged()), SIGNAL(sigStatsUpdated()));
63 connect(KisConfigNotifier::instance(), SIGNAL(configChanged()), SLOT(slotConfigChanged()));
64
66}
connect(this, SIGNAL(optionsChanged()), this, SLOT(saveOptions()))
static KisConfigNotifier * instance()
static KisImageConfigNotifier * instance()
const QScopedPointer< Private > m_d

References connect(), KisConfigNotifier::instance(), KisImageConfigNotifier::instance(), resetAccumulatedValues(), sigStatsUpdated(), and slotConfigChanged().

◆ ~KisStrokeSpeedMonitor()

KisStrokeSpeedMonitor::~KisStrokeSpeedMonitor ( )

Definition at line 68 of file KisStrokeSpeedMonitor.cpp.

69{
70}

Member Function Documentation

◆ avgCursorSpeed()

qreal KisStrokeSpeedMonitor::avgCursorSpeed ( ) const

Definition at line 185 of file KisStrokeSpeedMonitor.cpp.

186{
187 return m_d->cachedAvgCursorSpeed;
188}

References m_d.

◆ avgFps()

qreal KisStrokeSpeedMonitor::avgFps ( ) const

Definition at line 195 of file KisStrokeSpeedMonitor.cpp.

196{
197 return m_d->cachedAvgFps;
198}

References m_d.

◆ avgRenderingSpeed()

qreal KisStrokeSpeedMonitor::avgRenderingSpeed ( ) const

Definition at line 190 of file KisStrokeSpeedMonitor.cpp.

191{
192 return m_d->cachedAvgRenderingSpeed;
193}

References m_d.

◆ haveStrokeSpeedMeasurement()

bool KisStrokeSpeedMonitor::haveStrokeSpeedMeasurement ( ) const

Definition at line 77 of file KisStrokeSpeedMonitor.cpp.

78{
79 return m_d->haveStrokeSpeedMeasurement;
80}

References haveStrokeSpeedMeasurement(), and m_d.

◆ instance()

KisStrokeSpeedMonitor * KisStrokeSpeedMonitor::instance ( )
static

Definition at line 72 of file KisStrokeSpeedMonitor.cpp.

73{
74 return s_instance;
75}

◆ lastCursorSpeed()

qreal KisStrokeSpeedMonitor::lastCursorSpeed ( ) const

Definition at line 165 of file KisStrokeSpeedMonitor.cpp.

166{
167 return m_d->lastCursorSpeed;
168}

References m_d.

◆ lastFps()

qreal KisStrokeSpeedMonitor::lastFps ( ) const

Definition at line 175 of file KisStrokeSpeedMonitor.cpp.

176{
177 return m_d->lastFps;
178}

References m_d.

◆ lastPresetName()

QString KisStrokeSpeedMonitor::lastPresetName ( ) const

Definition at line 155 of file KisStrokeSpeedMonitor.cpp.

156{
157 return m_d->lastPresetName;
158}

References m_d.

◆ lastPresetSize()

qreal KisStrokeSpeedMonitor::lastPresetSize ( ) const

Definition at line 160 of file KisStrokeSpeedMonitor.cpp.

161{
162 return m_d->lastPresetSize;
163}

References m_d.

◆ lastRenderingSpeed()

qreal KisStrokeSpeedMonitor::lastRenderingSpeed ( ) const

Definition at line 170 of file KisStrokeSpeedMonitor.cpp.

171{
172 return m_d->lastRenderingSpeed;
173}

References m_d.

◆ lastStrokeSaturated()

bool KisStrokeSpeedMonitor::lastStrokeSaturated ( ) const

Definition at line 180 of file KisStrokeSpeedMonitor.cpp.

181{
182 return m_d->lastStrokeSaturated;
183}

References m_d.

◆ notifyStrokeFinished()

void KisStrokeSpeedMonitor::notifyStrokeFinished ( qreal cursorSpeed,
qreal renderingSpeed,
qreal fps,
KisPaintOpPresetSP preset )

Definition at line 102 of file KisStrokeSpeedMonitor.cpp.

103{
104 if (qFuzzyCompare(cursorSpeed, 0.0) || qFuzzyCompare(renderingSpeed, 0.0)) return;
105
106 QMutexLocker locker(&m_d->mutex);
107
108 const bool isSamePreset =
109 m_d->lastPresetName == preset->name() &&
110 qFuzzyCompare(m_d->lastPresetSize, preset->settings()->paintOpSize());
111
112 //ENTER_FUNCTION() << ppVar(isSamePreset);
113
114 if (!isSamePreset) {
116 m_d->lastPresetName = preset->name();
117 m_d->lastPresetSize = preset->settings()->paintOpSize();
118 }
119
120 m_d->lastCursorSpeed = cursorSpeed;
121 m_d->lastRenderingSpeed = renderingSpeed;
122 m_d->lastFps = fps;
123
124
125 static const qreal saturationSpeedThreshold = 0.30; // cursor speed should be at least 30% higher
126 m_d->lastStrokeSaturated = cursorSpeed / renderingSpeed > (1.0 + saturationSpeedThreshold);
127
128
129 if (m_d->lastStrokeSaturated) {
130 m_d->avgCursorSpeed(cursorSpeed);
131 m_d->avgRenderingSpeed(renderingSpeed);
132 m_d->avgFps(fps);
133
134 m_d->cachedAvgCursorSpeed = m_d->avgCursorSpeed.rollingMean();
135 m_d->cachedAvgRenderingSpeed = m_d->avgRenderingSpeed.rollingMean();
136 m_d->cachedAvgFps = m_d->avgFps.rollingMean();
137 }
138
139 Q_EMIT sigStatsUpdated();
140
141
142 ENTER_FUNCTION() <<
143 QString(" CS: %1 RS: %2 FPS: %3 %4")
144 .arg(m_d->lastCursorSpeed, 5)
145 .arg(m_d->lastRenderingSpeed, 5)
146 .arg(m_d->lastFps, 5)
147 .arg(m_d->lastStrokeSaturated ? "(saturated)" : "");
148 ENTER_FUNCTION() <<
149 QString("ACS: %1 ARS: %2 AFPS: %3")
150 .arg(m_d->cachedAvgCursorSpeed, 5)
151 .arg(m_d->cachedAvgRenderingSpeed, 5)
152 .arg(m_d->cachedAvgFps, 5);
153}
static bool qFuzzyCompare(half p1, half p2)
#define ENTER_FUNCTION()
Definition kis_debug.h:178

References ENTER_FUNCTION, m_d, qFuzzyCompare(), resetAccumulatedValues(), and sigStatsUpdated().

◆ resetAccumulatedValues

void KisStrokeSpeedMonitor::resetAccumulatedValues ( )
privateslot

Definition at line 87 of file KisStrokeSpeedMonitor.cpp.

88{
89 m_d->avgCursorSpeed.reset(m_d->averageWindow);
90 m_d->avgRenderingSpeed.reset(m_d->averageWindow);
91 m_d->avgFps.reset(m_d->averageWindow);
92}

References m_d.

◆ setHaveStrokeSpeedMeasurement

void KisStrokeSpeedMonitor::setHaveStrokeSpeedMeasurement ( bool value)
slot

Definition at line 82 of file KisStrokeSpeedMonitor.cpp.

83{
84 m_d->haveStrokeSpeedMeasurement = value;
85}
float value(const T *src, size_t ch)

References m_d, and value().

◆ sigStatsUpdated

void KisStrokeSpeedMonitor::sigStatsUpdated ( )
signal

◆ slotConfigChanged

void KisStrokeSpeedMonitor::slotConfigChanged ( )
privateslot

Definition at line 94 of file KisStrokeSpeedMonitor.cpp.

95{
96 KisConfig cfg(true);
97 m_d->haveStrokeSpeedMeasurement = cfg.enableBrushSpeedLogging();
99 Q_EMIT sigStatsUpdated();
100}

References KisConfig::enableBrushSpeedLogging(), m_d, resetAccumulatedValues(), and sigStatsUpdated().

Member Data Documentation

◆ m_d

const QScopedPointer<Private> KisStrokeSpeedMonitor::m_d
private

Definition at line 68 of file KisStrokeSpeedMonitor.h.

Property Documentation

◆ avgCursorSpeed

qreal KisStrokeSpeedMonitor::avgCursorSpeed
read

Definition at line 28 of file KisStrokeSpeedMonitor.h.

◆ avgFps

qreal KisStrokeSpeedMonitor::avgFps
read

Definition at line 30 of file KisStrokeSpeedMonitor.h.

◆ avgRenderingSpeed

qreal KisStrokeSpeedMonitor::avgRenderingSpeed
read

Definition at line 29 of file KisStrokeSpeedMonitor.h.

◆ lastCursorSpeed

qreal KisStrokeSpeedMonitor::lastCursorSpeed
read

Definition at line 22 of file KisStrokeSpeedMonitor.h.

◆ lastFps

qreal KisStrokeSpeedMonitor::lastFps
read

Definition at line 24 of file KisStrokeSpeedMonitor.h.

◆ lastPresetName

QString KisStrokeSpeedMonitor::lastPresetName
read

Definition at line 19 of file KisStrokeSpeedMonitor.h.

◆ lastPresetSize

qreal KisStrokeSpeedMonitor::lastPresetSize
read

Definition at line 20 of file KisStrokeSpeedMonitor.h.

◆ lastRenderingSpeed

qreal KisStrokeSpeedMonitor::lastRenderingSpeed
read

Definition at line 23 of file KisStrokeSpeedMonitor.h.

◆ lastStrokeSaturated

bool KisStrokeSpeedMonitor::lastStrokeSaturated
read

Definition at line 26 of file KisStrokeSpeedMonitor.h.


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