Krita Source Code Documentation
Loading...
Searching...
No Matches
KisBatchNodeUpdate.cpp
Go to the documentation of this file.
1
/*
2
* SPDX-FileCopyrightText: 2021 Dmitry Kazakov <dimula73@gmail.com>
3
*
4
* SPDX-License-Identifier: GPL-2.0-or-later
5
*/
6
7
#include "
KisBatchNodeUpdate.h
"
8
9
#include "
kis_node.h
"
10
#include "
kis_layer_utils.h
"
11
12
KisBatchNodeUpdate::KisBatchNodeUpdate
(
const
std::vector<std::pair<KisNodeSP, QRect>> &rhs)
13
:
std
::vector<
std
::pair<
KisNodeSP
, QRect>>(rhs)
14
{
15
16
}
17
18
void
KisBatchNodeUpdate::addUpdate
(
KisNodeSP
node,
const
QRect &rc)
19
{
20
push_back(std::make_pair(node, rc));
21
}
22
23
void
KisBatchNodeUpdate::compress
()
24
{
25
*
this
=
compressed
();
26
}
27
28
KisBatchNodeUpdate
KisBatchNodeUpdate::compressed
()
const
29
{
30
KisBatchNodeUpdate
newUpdateData;
31
32
KisNodeList
rootNodes;
33
34
std::transform(begin(), end(), std::back_inserter(rootNodes),
35
[] (
const
std::pair<KisNodeSP, QRect> &update) {
return
update.first; });
36
37
rootNodes =
KisLayerUtils::sortAndFilterMergeableInternalNodes
(rootNodes,
true
);
38
39
Q_FOREACH (
KisNodeSP
root, rootNodes) {
40
QRect dirtyRect;
41
42
for
(
auto
it = begin(); it != end(); ++it) {
43
if
(it->first == root ||
KisLayerUtils::checkIsChildOf
(it->first, {root})) {
44
dirtyRect |= it->second;
45
}
46
}
47
48
newUpdateData.push_back(std::make_pair(root, dirtyRect));
49
}
50
51
return
newUpdateData;
52
}
53
54
KisBatchNodeUpdate
&
KisBatchNodeUpdate::operator|=
(
const
KisBatchNodeUpdate
&rhs)
55
{
56
if
(
this
== &rhs)
57
return
*
this
;
58
59
reserve(size() + rhs.size());
60
61
std::copy(rhs.begin(), rhs.end(), std::back_inserter(*
this
));
62
std::sort(begin(), end(), [](
const
std::pair<KisNodeSP, QRect> &lhs,
const
std::pair<KisNodeSP, QRect> &rhs) {
return
lhs.first.data() < rhs.first.data(); });
63
64
if
(size() <= 1)
65
return
*
this
;
66
67
for
(
auto
prevIt = begin(), it = next(prevIt); it != end();) {
68
if
(prevIt->first == it->first) {
69
prevIt->second |= it->second;
70
it = erase(it);
71
}
else
{
72
++prevIt;
73
++it;
74
}
75
}
76
77
return
*
this
;
78
}
79
80
QDebug
operator<<
(QDebug dbg,
const
KisBatchNodeUpdate
&update)
81
{
82
dbg.nospace() <<
"KisBatchNodeUpdate ("
;
83
84
for
(
auto
it = update.begin(); it != update.end(); ++it) {
85
dbg.nospace() << it->first <<
"->"
<< it->second;
86
87
if
(next(it) != update.end()) {
88
dbg.nospace() <<
"; "
;
89
}
90
}
91
92
return
dbg;
93
}
operator<<
QDebug operator<<(QDebug dbg, const KisBatchNodeUpdate &update)
Definition
KisBatchNodeUpdate.cpp:80
KisBatchNodeUpdate.h
KisBatchNodeUpdate
Definition
KisBatchNodeUpdate.h:26
KisBatchNodeUpdate::KisBatchNodeUpdate
KisBatchNodeUpdate()=default
KisBatchNodeUpdate::operator|=
KisBatchNodeUpdate & operator|=(const KisBatchNodeUpdate &rhs)
Definition
KisBatchNodeUpdate.cpp:54
KisBatchNodeUpdate::compressed
KisBatchNodeUpdate compressed() const
Definition
KisBatchNodeUpdate.cpp:28
KisBatchNodeUpdate::addUpdate
void addUpdate(KisNodeSP node, const QRect &rc)
Definition
KisBatchNodeUpdate.cpp:18
KisBatchNodeUpdate::compress
void compress()
Definition
KisBatchNodeUpdate.cpp:23
KisSharedPtr< KisNode >
QList< KisNodeSP >
kis_layer_utils.h
kis_node.h
KisLayerUtils::sortAndFilterMergeableInternalNodes
KisNodeList sortAndFilterMergeableInternalNodes(KisNodeList nodes, bool allowMasks)
Definition
kis_layer_utils.cpp:1640
KisLayerUtils::checkIsChildOf
bool checkIsChildOf(KisNodeSP node, const KisNodeList &parents)
Definition
kis_layer_utils.cpp:1545
std
Definition
propagate_const.h:43
libs
image
KisBatchNodeUpdate.cpp
Generated at
2025-11-04 02:30:02+01:00
from
Krita
branch
master
, commit
c9dde2e79561a8aea4a7e8d9ac99c98a7bac9e52