Krita Source Code Documentation
Loading...
Searching...
No Matches
KisAsynchronousStrokeUpdateHelper.cpp
Go to the documentation of this file.
1
/*
2
* SPDX-FileCopyrightText: 2019 Dmitry Kazakov <dimula73@gmail.com>
3
*
4
* SPDX-License-Identifier: GPL-2.0-or-later
5
*/
6
7
#include "
KisAsynchronousStrokeUpdateHelper.h
"
8
#include "
kis_image_interfaces.h
"
9
10
KisAsynchronousStrokeUpdateHelper::KisAsynchronousStrokeUpdateHelper
()
11
: m_strokesFacade(0)
12
{
13
m_updateThresholdTimer
.setSingleShot(
false
);
14
m_updateThresholdTimer
.setInterval(80
/* ms */
);
15
connect
(&
m_updateThresholdTimer
, SIGNAL(timeout()), SLOT(
slotAsyncUpdateCame
()));
16
}
17
18
KisAsynchronousStrokeUpdateHelper::~KisAsynchronousStrokeUpdateHelper
()
19
{
20
21
}
22
23
void
KisAsynchronousStrokeUpdateHelper::initUpdateStreamLowLevel
(
KisStrokesFacade
*strokesFacade,
KisStrokeId
strokeId)
24
{
25
m_strokesFacade
= strokesFacade;
26
m_strokeId
= strokeId;
27
}
28
29
void
KisAsynchronousStrokeUpdateHelper::startUpdateStreamLowLevel
()
30
{
31
KIS_SAFE_ASSERT_RECOVER_RETURN
(
m_strokesFacade
);
32
KIS_SAFE_ASSERT_RECOVER_RETURN
(
m_strokeId
);
33
34
m_updateThresholdTimer
.start();
35
}
36
37
void
KisAsynchronousStrokeUpdateHelper::startUpdateStream
(
KisStrokesFacade
*strokesFacade,
KisStrokeId
strokeId)
38
{
39
initUpdateStreamLowLevel
(strokesFacade, strokeId);
40
startUpdateStreamLowLevel
();
41
}
42
43
void
KisAsynchronousStrokeUpdateHelper::endUpdateStream
()
44
{
45
KIS_SAFE_ASSERT_RECOVER_RETURN
(
isActive
());
46
47
slotAsyncUpdateCame
(
true
);
48
cancelUpdateStream
();
49
}
50
51
void
KisAsynchronousStrokeUpdateHelper::cancelUpdateStream
()
52
{
53
KIS_SAFE_ASSERT_RECOVER_RETURN
(
isActive
());
54
55
m_updateThresholdTimer
.stop();
56
m_strokeId
.clear();
57
m_strokesFacade
= 0;
58
}
59
60
bool
KisAsynchronousStrokeUpdateHelper::isActive
()
const
61
{
62
return
bool(
m_strokeId
);
63
}
64
65
void
KisAsynchronousStrokeUpdateHelper::setCustomUpdateDataFactory
(
KisAsynchronousStrokeUpdateHelper::UpdateDataFactory
factory)
66
{
67
m_customUpdateFactory
= factory;
68
}
69
70
void
KisAsynchronousStrokeUpdateHelper::slotAsyncUpdateCame
(
bool
forceUpdate)
71
{
72
if
(!
m_strokeId
|| !
m_strokesFacade
)
return
;
73
m_strokesFacade
->
addJob
(
m_strokeId
,
74
m_customUpdateFactory
?
75
m_customUpdateFactory
(forceUpdate) :
76
new
UpdateData
(forceUpdate));
77
}
KisAsynchronousStrokeUpdateHelper.h
connect
connect(this, SIGNAL(optionsChanged()), this, SLOT(saveOptions()))
KisAsynchronousStrokeUpdateHelper::UpdateData
Definition
KisAsynchronousStrokeUpdateHelper.h:24
KisAsynchronousStrokeUpdateHelper::KisAsynchronousStrokeUpdateHelper
KisAsynchronousStrokeUpdateHelper()
Definition
KisAsynchronousStrokeUpdateHelper.cpp:10
KisAsynchronousStrokeUpdateHelper::setCustomUpdateDataFactory
void setCustomUpdateDataFactory(UpdateDataFactory factory)
Definition
KisAsynchronousStrokeUpdateHelper.cpp:65
KisAsynchronousStrokeUpdateHelper::m_customUpdateFactory
UpdateDataFactory m_customUpdateFactory
Definition
KisAsynchronousStrokeUpdateHelper.h:93
KisAsynchronousStrokeUpdateHelper::~KisAsynchronousStrokeUpdateHelper
~KisAsynchronousStrokeUpdateHelper()
Definition
KisAsynchronousStrokeUpdateHelper.cpp:18
KisAsynchronousStrokeUpdateHelper::startUpdateStreamLowLevel
void startUpdateStreamLowLevel()
Definition
KisAsynchronousStrokeUpdateHelper.cpp:29
KisAsynchronousStrokeUpdateHelper::initUpdateStreamLowLevel
void initUpdateStreamLowLevel(KisStrokesFacade *strokesFacade, KisStrokeId strokeId)
Definition
KisAsynchronousStrokeUpdateHelper.cpp:23
KisAsynchronousStrokeUpdateHelper::m_updateThresholdTimer
QTimer m_updateThresholdTimer
Definition
KisAsynchronousStrokeUpdateHelper.h:91
KisAsynchronousStrokeUpdateHelper::endUpdateStream
void endUpdateStream()
Definition
KisAsynchronousStrokeUpdateHelper.cpp:43
KisAsynchronousStrokeUpdateHelper::UpdateDataFactory
std::function< KisStrokeJobData *(bool)> UpdateDataFactory
Definition
KisAsynchronousStrokeUpdateHelper.h:49
KisAsynchronousStrokeUpdateHelper::slotAsyncUpdateCame
void slotAsyncUpdateCame(bool forceUpdate=false)
Definition
KisAsynchronousStrokeUpdateHelper.cpp:70
KisAsynchronousStrokeUpdateHelper::cancelUpdateStream
void cancelUpdateStream()
Definition
KisAsynchronousStrokeUpdateHelper.cpp:51
KisAsynchronousStrokeUpdateHelper::startUpdateStream
void startUpdateStream(KisStrokesFacade *strokesFacade, KisStrokeId strokeId)
Definition
KisAsynchronousStrokeUpdateHelper.cpp:37
KisAsynchronousStrokeUpdateHelper::m_strokesFacade
KisStrokesFacade * m_strokesFacade
Definition
KisAsynchronousStrokeUpdateHelper.h:90
KisAsynchronousStrokeUpdateHelper::isActive
bool isActive() const
Definition
KisAsynchronousStrokeUpdateHelper.cpp:60
KisAsynchronousStrokeUpdateHelper::m_strokeId
KisStrokeId m_strokeId
Definition
KisAsynchronousStrokeUpdateHelper.h:92
KisStrokesFacade
Definition
kis_image_interfaces.h:21
KisStrokesFacade::addJob
virtual void addJob(KisStrokeId id, KisStrokeJobData *data)=0
QWeakPointer
Definition
kis_uniform_paintop_property.h:72
KIS_SAFE_ASSERT_RECOVER_RETURN
#define KIS_SAFE_ASSERT_RECOVER_RETURN(cond)
Definition
kis_assert.h:128
kis_image_interfaces.h
libs
ui
tool
KisAsynchronousStrokeUpdateHelper.cpp
Generated at
2025-11-04 02:30:02+01:00
from
Krita
branch
master
, commit
c9dde2e79561a8aea4a7e8d9ac99c98a7bac9e52