Krita Source Code Documentation
Loading...
Searching...
No Matches
KisLayerUtils Namespace Reference

Namespaces

namespace  Private
 

Classes

struct  ActivateSelectionMask
 
struct  AddNewFrame
 
struct  CleanUpNodes
 
struct  ConvertToPaintLayerInfo
 
struct  CreateMergedLayer
 
struct  CreateMergedLayerMultiple
 
struct  DisableColorizeKeyStrokes
 
struct  DisableExtraCompositing
 
struct  DisableOnionSkins
 
struct  DisablePassThroughForHeadsOnly
 
struct  EphemeralCommandsWrapper
 
struct  FillSelectionMasks
 
struct  InitSplitAlphaSelectionMask
 
struct  InsertNode
 
struct  KeepMergedNodesSelected
 
class  KeepNodesSelectedCommand
 
class  KisSimpleUpdateCommand
 
struct  MergeDownInfo
 
struct  MergeDownInfoBase
 
struct  MergeLayers
 
struct  MergeLayersMultiple
 
struct  MergeMetaData
 
struct  MergeMultipleInfo
 
struct  MergeSelectionMasks
 
struct  RefreshDelayedUpdateLayers
 
struct  RefreshHiddenAreas
 
class  RemoveNodeHelper
 
struct  SelectGlobalSelectionMask
 
struct  SimpleAddNode
 
struct  SimpleRemoveLayers
 
struct  SplitAlphaCommand
 
struct  SplitAlphaToMaskInfo
 
struct  SwitchFrameCommand
 The SwitchFrameCommand struct Switches to frame with undo/redo support. More...
 
struct  UndoEphemeralCommands
 
struct  UploadProjectionToFrameCommand
 

Typedefs

typedef QSharedPointer< ConvertToPaintLayerInfo > ConvertToPaintLayerInfoSP
 
typedef QMap< int, QSet< KisNodeSP > > FrameJobs
 
typedef QSharedPointer< MergeDownInfoBase > MergeDownInfoBaseSP
 
typedef QSharedPointer< MergeDownInfo > MergeDownInfoSP
 
typedef QSharedPointer< MergeMultipleInfo > MergeMultipleInfoSP
 
typedef QSharedPointer< SplitAlphaToMaskInfo > SplitAlphaToMaskInfoSP
 

Enumerations

enum  MergeFlag { None , SkipMergingFrames = 0x1 }
 

Functions

void addCopyOfNameTag (KisNodeSP node)
 
bool canChangeImageProfileInvisibly (KisImageSP image)
 
void changeImageDefaultProjectionColor (KisImageSP image, const KoColor &color)
 
bool checkIsChildOf (KisNodeSP node, const KisNodeList &parents)
 
bool checkIsCloneOf (KisNodeSP node, const KisNodeList &nodes)
 
template<typename T >
bool checkNodesDiffer (KisNodeList nodes, std::function< T(KisNodeSP)> checkerFunc)
 
std::future< KisNodeSP > convertToPaintLayer (KisImageSP image, KisNodeSP src)
 
int fetchLayerActiveRasterFrameID (KisNodeSP node)
 
KisTimeSpan fetchLayerActiveRasterFrameSpan (KisNodeSP node, const int time)
 
int fetchLayerActiveRasterFrameTime (KisNodeSP node)
 
QSet< int > fetchLayerFrames (KisNodeSP node)
 
QSet< int > fetchLayerFramesRecursive (KisNodeSP rootNode)
 
QSet< int > fetchLayerIdenticalRasterFrameTimes (KisNodeSP node, const int &frameTime)
 
QSet< int > fetchLayerRasterFrameTimesMatchingID (KisNodeSP node, const int frameID)
 
QSet< int > fetchLayerRasterIDsAtTimes (KisNodeSP node, const QSet< int > &times)
 
QSet< int > fetchLayerUniqueRasterTimesMatchingIDs (KisNodeSP node, QSet< int > &frameIDs)
 
void fetchSelectionMasks (KisNodeList mergedNodes, QVector< KisSelectionMaskSP > &selectionMasks)
 
QSet< int > fetchUniqueFrameTimes (KisNodeSP node, QSet< int > selectedTimes, bool filterActiveFrameID)
 
KisNodeList filterInvisibleNodes (const KisNodeList &nodes, KisNodeList *invisibleNodes, KisNodeSP *putAfter)
 
void filterMergeableNodes (KisNodeList &nodes, bool allowMasks)
 
QSet< int > filterTimesForOnlyRasterKeyedTimes (KisNodeSP node, const QSet< int > &times)
 
void filterUnlockedNodes (KisNodeList &nodes)
 
KisImageSP findImageByHierarchy (KisNodeSP node)
 
KisNodeSP findIsolationRoot (KisNodeSP node)
 
KisNodeSP findNodeByName (KisNodeSP root, const QString &name)
 
template<class T >
T * findNodeByType (KisNodeSP root)
 
KisNodeSP findNodeByUuid (KisNodeSP root, const QUuid &uuid)
 
QList< KisNodeSP > findNodesByName (KisNodeSP root, const QString &name, bool recursive, bool partialMatch)
 
KisNodeList findNodesWithProps (KisNodeSP root, const KoProperties &props, bool excludeRoot)
 
KisNodeSP findRoot (KisNodeSP node)
 
void flattenImage (KisImageSP image, KisNodeSP activeNode, MergeFlags flags)
 
void flattenLayer (KisImageSP image, KisLayerSP layer, MergeFlags flags)
 
void forceAllDelayedNodesUpdate (KisNodeSP root)
 
void forceAllHiddenOriginalsUpdate (KisNodeSP root)
 
bool hasDelayedNodeWithUpdates (KisNodeSP root)
 
void mergeDown (KisImageSP image, KisLayerSP layer, const KisMetaData::MergeStrategy *strategy, MergeFlags flags)
 
void mergeMultipleLayers (KisImageSP image, KisNodeList mergedNodes, KisNodeSP putAfter, MergeFlags flags)
 
void mergeMultipleLayersImpl (KisImageSP image, KisNodeList mergedNodes, KisNodeSP putAfter, bool flattenSingleLayer, const KUndo2MagicString &actionName, bool cleanupNodes=true, const QString layerName=QString(), MergeFlags flags=None)
 
void mergeMultipleNodes (KisImageSP image, KisNodeList mergedNodes, KisNodeSP putAfter, MergeFlags flags)
 
void newLayerFromVisible (KisImageSP image, KisNodeSP putAfter, MergeFlags flags)
 
template<typename NodePointer , typename Functor >
void recursiveApplyNodes (NodePointer node, Functor func)
 
KisNodeSP recursiveFindNode (KisNodeSP node, std::function< bool(KisNodeSP)> func)
 
QRect recursiveTightNodeVisibleBounds (KisNodeSP rootNode)
 
void refreshHiddenAreaAsync (KisImageSP image, KisNodeSP rootNode, const QRect &preparedArea)
 
KisNodeList sortAndFilterAnyMergeableNodesSafe (const KisNodeList &nodes, KisImageSP image)
 
KisNodeList sortAndFilterMergeableInternalNodes (KisNodeList nodes, bool allowMasks)
 
KisNodeList sortMergeableInternalNodes (KisNodeList nodes)
 
void sortMergeableNodes (KisNodeSP root, KisNodeList &inputNodes, KisNodeList &outputNodes)
 
KisNodeList sortMergeableNodes (KisNodeSP root, KisNodeList nodes)
 
KRITAIMAGE_EXPORT void sortMergeableNodes (KisNodeSP root, QList< KisNodeSP > &inputNodes, QList< KisNodeSP > &outputNodes)
 
void splitAlphaToMask (KisImageSP image, KisNodeSP node, const QString &maskName)
 
void splitNonRemovableNodes (KisNodeList &nodesToRemove, KisNodeList &_nodesToHide)
 
bool tryMergeSelectionMasks (KisImageSP image, KisNodeList mergedNodes, KisNodeSP putAfter)
 
void updateFrameJobs (FrameJobs *jobs, KisNodeSP node)
 
void updateFrameJobsNonRecursive (FrameJobs *jobs, KisNodeSP rootNode, bool frameTimesRecursive=false)
 updateFrameJobsNonRecursive updates the frame jobs non-recursively, that is, on the rootNode only.
 
void updateFrameJobsRecursive (FrameJobs *jobs, KisNodeSP rootNode)
 

Typedef Documentation

◆ ConvertToPaintLayerInfoSP

◆ FrameJobs

typedef QMap<int, QSet<KisNodeSP> > KisLayerUtils::FrameJobs

Definition at line 94 of file kis_layer_utils.h.

◆ MergeDownInfoBaseSP

◆ MergeDownInfoSP

◆ MergeMultipleInfoSP

◆ SplitAlphaToMaskInfoSP

Enumeration Type Documentation

◆ MergeFlag

Enumerator
None 
SkipMergingFrames 

Definition at line 31 of file kis_layer_utils.h.

31 {
32 None,
34 };

Function Documentation

◆ addCopyOfNameTag()

KRITAIMAGE_EXPORT void KisLayerUtils::addCopyOfNameTag ( KisNodeSP node)

Definition at line 1735 of file kis_layer_utils.cpp.

1736 {
1737 if (!KisImageConfig(true).renameDuplicatedLayers()) { return; }
1738
1739 const QString prefix = i18n("Copy of");
1740 QString newName = node->name();
1741 if (!newName.startsWith(prefix)) {
1742 newName = QString("%1 %2").arg(prefix).arg(newName);
1743 node->setName(newName);
1744 }
1745 }
void setName(const QString &name)
QString name() const

References KisBaseNode::name(), and KisBaseNode::setName().

◆ canChangeImageProfileInvisibly()

KRITAIMAGE_EXPORT bool KisLayerUtils::canChangeImageProfileInvisibly ( KisImageSP image)

Definition at line 2375 of file kis_layer_utils.cpp.

2376 {
2377 int numLayers = 0;
2378 bool hasNonNormalLayers = false;
2379 bool hasTransparentLayer = false;
2380
2381
2382 recursiveApplyNodes(image->root(),
2383 [&numLayers, &hasNonNormalLayers, &hasTransparentLayer, image] (KisNodeSP node) {
2384 if (!node->inherits("KisLayer")) return;
2385
2386 numLayers++;
2387
2388 if (node->exactBounds().isEmpty()) return;
2389
2390 // this is only an approximation! it is not exact!
2391 if (!hasTransparentLayer &&
2392 node->exactBounds() != image->bounds()) {
2393
2394 hasTransparentLayer = true;
2395 }
2396
2397 if (!hasNonNormalLayers &&
2398 node->compositeOpId() != COMPOSITE_OVER) {
2399
2400 hasNonNormalLayers = true;
2401 }
2402 });
2403
2404 return numLayers == 1 || (!hasNonNormalLayers && !hasTransparentLayer);
2405 }
const QString COMPOSITE_OVER
void recursiveApplyNodes(NodePointer node, Functor func)
const QString & compositeOpId() const

References COMPOSITE_OVER, KisBaseNode::compositeOpId(), recursiveApplyNodes(), and KisNodeFacade::root.

◆ changeImageDefaultProjectionColor()

KRITAIMAGE_EXPORT void KisLayerUtils::changeImageDefaultProjectionColor ( KisImageSP image,
const KoColor & color )

◆ checkIsChildOf()

KRITAIMAGE_EXPORT bool KisLayerUtils::checkIsChildOf ( KisNodeSP node,
const KisNodeList & parents )

Definition at line 1571 of file kis_layer_utils.cpp.

1572 {
1573 KisNodeList nodeParents;
1574
1575 KisNodeSP parent = node->parent();
1576 while (parent) {
1577 nodeParents << parent;
1578 parent = parent->parent();
1579 }
1580
1581 foreach(KisNodeSP perspectiveParent, parents) {
1582 if (nodeParents.contains(perspectiveParent)) {
1583 return true;
1584 }
1585 }
1586
1587 return false;
1588 }
KisNodeWSP parent
Definition kis_node.cpp:86

References KisNode::parent.

◆ checkIsCloneOf()

KRITAIMAGE_EXPORT bool KisLayerUtils::checkIsCloneOf ( KisNodeSP node,
const KisNodeList & nodes )

Returns true if: o node is a clone of some layer in nodes o node is a clone any child layer of any layer in nodes o node is a clone of a clone of a ..., that in the end points to any layer in nodes of their children.

Definition at line 1590 of file kis_layer_utils.cpp.

1591 {
1592 bool result = false;
1593
1594 KisCloneLayer *clone = dynamic_cast<KisCloneLayer*>(node.data());
1595 if (clone) {
1596 KisNodeSP cloneSource = KisNodeSP(clone->copyFrom());
1597
1598 Q_FOREACH(KisNodeSP subtree, nodes) {
1599 result =
1600 recursiveFindNode(subtree,
1601 [cloneSource](KisNodeSP node) -> bool
1602 {
1603 return node == cloneSource;
1604 });
1605
1606 if (!result) {
1607 result = checkIsCloneOf(cloneSource, nodes);
1608 }
1609
1610 if (result) {
1611 break;
1612 }
1613 }
1614 }
1615
1616 return result;
1617 }
KisSharedPtr< KisNode > KisNodeSP
Definition kis_types.h:86
KisNodeSP recursiveFindNode(KisNodeSP node, std::function< bool(KisNodeSP)> func)
KisLayerSP copyFrom

References checkIsCloneOf(), KisCloneLayer::copyFrom, KisSharedPtr< T >::data(), and recursiveFindNode().

◆ checkNodesDiffer()

template<typename T >
bool KisLayerUtils::checkNodesDiffer ( KisNodeList nodes,
std::function< T(KisNodeSP)> checkerFunc )

Definition at line 220 of file kis_layer_utils.h.

221 {
222 bool valueDiffers = false;
223 bool initialized = false;
224 T currentValue = T();
225 Q_FOREACH (KisNodeSP node, nodes) {
226 if (!initialized) {
227 currentValue = checkerFunc(node);
228 initialized = true;
229 } else if (currentValue != checkerFunc(node)) {
230 valueDiffers = true;
231 break;
232 }
233 }
234 return valueDiffers;
235 }

◆ convertToPaintLayer()

KRITAIMAGE_EXPORT std::future< KisNodeSP > KisLayerUtils::convertToPaintLayer ( KisImageSP image,
KisNodeSP src )

Definition at line 2432 of file kis_layer_utils.cpp.

2433 {
2434 //Initialize all operation dependencies.
2435 ConvertToPaintLayerInfoSP info( new ConvertToPaintLayerInfo(image, src) );
2436
2437 if (!info->hasTargetNode())
2439
2440 KisImageSignalVector emitSignals;
2441 KisProcessingApplicator applicator(image, 0, KisProcessingApplicator::NONE, emitSignals, kundo2_i18n("Convert to a Paint Layer"));
2442
2443 applicator.applyCommand(new SimpleAddNode(info->image(), info->targetNode(), info->insertionParent(), info->insertionPutAfter()), KisStrokeJobData::BARRIER);
2444
2445 if (info->frames().count() > 0) {
2446 Q_FOREACH(const int& frame, info->frames()) {
2447 applicator.applyCommand(new SwitchFrameCommand(info->image(), frame, false, info->storage));
2448 applicator.applyCommand(new RefreshDelayedUpdateLayers(info->sourceNodes()), KisStrokeJobData::BARRIER);
2449 applicator.applyCommand(new RefreshHiddenAreas(info->image(), info->sourceNode()), KisStrokeJobData::BARRIER);
2450 applicator.applyCommand(new AddNewFrame(info->targetNode(), frame, info->sourceNode()), KisStrokeJobData::BARRIER);
2451 applicator.applyCommand(new UploadProjectionToFrameCommand(info->sourceNode(), info->targetNode(), frame));
2452 applicator.applyCommand(new SwitchFrameCommand(info->image(), frame, true, info->storage));
2453 }
2454 }
2455
2456 applicator.applyCommand(new SimpleRemoveLayers(info->toRemove(), info->image()));
2457
2458 applicator.end();
2459
2460 return kismpl::then(applicator.successfullyCompletedFuture(),
2461 [node = info->targetNode()] (std::future<bool> completed) {
2462 return completed.get() ? node : KisNodeSP();
2463 });
2464 }
auto then(std::future< T > &&future, Function &&func) -> std::future< decltype(func(std::move(future)))>
std::future< void > make_ready_future()
The SwitchFrameCommand struct Switches to frame with undo/redo support.

References KisProcessingApplicator::applyCommand(), KisStrokeJobData::BARRIER, KisProcessingApplicator::end(), kundo2_i18n(), kismpl::make_ready_future(), KisProcessingApplicator::NONE, KisProcessingApplicator::successfullyCompletedFuture(), and kismpl::then().

◆ fetchLayerActiveRasterFrameID()

int KisLayerUtils::fetchLayerActiveRasterFrameID ( KisNodeSP node)

Definition at line 2468 of file kis_layer_utils.cpp.

2469 {
2471 KisPaintDeviceSP paintDevice = node->paintDevice();
2472 KIS_SAFE_ASSERT_RECOVER_RETURN_VALUE(paintDevice, -1);
2473
2474 if (!paintDevice->keyframeChannel()) {
2475 return -1;
2476 }
2477
2478 const int activeTime = paintDevice->keyframeChannel()->activeKeyframeTime();
2479 KisRasterKeyframeSP keyframe = paintDevice->keyframeChannel()->activeKeyframeAt<KisRasterKeyframe>(activeTime);
2481
2482 return keyframe->frameID();
2483 }
KisKeyframeSP activeKeyframeAt(int time) const
int activeKeyframeTime(int time) const
Get the time of the active keyframe. Useful for snapping any time to that of the most recent keyframe...
KisRasterKeyframeChannel * keyframeChannel() const
The KisRasterKeyframe class is a concrete subclass of KisKeyframe that wraps a physical raster image ...
#define KIS_SAFE_ASSERT_RECOVER_RETURN_VALUE(cond, val)
Definition kis_assert.h:129
virtual KisPaintDeviceSP paintDevice() const =0

References KisKeyframeChannel::activeKeyframeAt(), KisKeyframeChannel::activeKeyframeTime(), KisPaintDevice::keyframeChannel(), KIS_SAFE_ASSERT_RECOVER_RETURN_VALUE, and KisBaseNode::paintDevice().

◆ fetchLayerActiveRasterFrameSpan()

KRITAIMAGE_EXPORT KisTimeSpan KisLayerUtils::fetchLayerActiveRasterFrameSpan ( KisNodeSP node,
const int time )

Definition at line 2498 of file kis_layer_utils.cpp.

2499 {
2501 KisPaintDeviceSP paintDevice = node->paintDevice();
2503 if (!paintDevice->keyframeChannel()) {
2504 return KisTimeSpan::infinite(0);
2505 }
2506
2507 return paintDevice->keyframeChannel()->affectedFrames(time);
2508 }
virtual KisTimeSpan affectedFrames(int time) const
Get the set of frames affected by any changes to the value or content of the active keyframe at the g...
static KisTimeSpan infinite(int start)

References KisKeyframeChannel::affectedFrames(), KisTimeSpan::infinite(), KisPaintDevice::keyframeChannel(), KIS_SAFE_ASSERT_RECOVER_RETURN_VALUE, and KisBaseNode::paintDevice().

◆ fetchLayerActiveRasterFrameTime()

KRITAIMAGE_EXPORT int KisLayerUtils::fetchLayerActiveRasterFrameTime ( KisNodeSP node)

Definition at line 2485 of file kis_layer_utils.cpp.

2486 {
2488 KisPaintDeviceSP paintDevice = node->paintDevice();
2489 KIS_SAFE_ASSERT_RECOVER_RETURN_VALUE(paintDevice, -1);
2490
2491 if (!paintDevice->keyframeChannel()) {
2492 return -1;
2493 }
2494
2495 return paintDevice->keyframeChannel()->activeKeyframeTime();
2496 }

References KisKeyframeChannel::activeKeyframeTime(), KisPaintDevice::keyframeChannel(), KIS_SAFE_ASSERT_RECOVER_RETURN_VALUE, and KisBaseNode::paintDevice().

◆ fetchLayerFrames()

KRITAIMAGE_EXPORT QSet< int > KisLayerUtils::fetchLayerFrames ( KisNodeSP node)

Definition at line 1353 of file kis_layer_utils.cpp.

1353 {
1354 QSet<int> frames;
1355 Q_FOREACH(KisKeyframeChannel *channel, node->keyframeChannels()) {
1356 if (!channel) {
1357 continue;
1358 }
1359
1360 KisRasterKeyframeChannel *rasterChan = dynamic_cast<KisRasterKeyframeChannel*>(channel);
1361 if (rasterChan) {
1362 frames.unite(rasterChan->allKeyframeTimes());
1363 continue;
1364 }
1365
1366 KisScalarKeyframeChannel *scalarChan = dynamic_cast<KisScalarKeyframeChannel*>(channel);
1367 if (scalarChan) {
1368 const int initialKeyframe = scalarChan->firstKeyframeTime();
1369
1370 if (initialKeyframe == -1) {
1371 continue;
1372 }
1373
1374 const int lastKeyframe = scalarChan->lastKeyframeTime();
1375 KisTimeSpan currentSpan = scalarChan->identicalFrames(initialKeyframe);
1376 while (!currentSpan.isInfinite() && currentSpan.isValid() && currentSpan.start() < lastKeyframe) {
1377 frames.insert(currentSpan.start());
1378 currentSpan = scalarChan->identicalFrames(currentSpan.end() + 1);
1379 }
1380
1381 frames.insert(lastKeyframe);
1382 }
1383
1384 }
1385
1386 return frames;
1387 }
KisKeyframeChannel stores and manages KisKeyframes. Maps units of time to virtual keyframe values....
QSet< int > allKeyframeTimes() const
Get a set of all integer times that map to a keyframe.
The KisRasterKeyframeChannel is a concrete KisKeyframeChannel subclass that stores and manages KisRas...
The KisScalarKeyframeChannel is a concrete KisKeyframeChannel subclass that stores and manages KisSca...
virtual KisTimeSpan identicalFrames(int time) const override
Get a span of times for which the channel gives identical results compared to frame at a given time....
int start() const
bool isInfinite() const
int end() const
bool isValid() const
QMap< QString, KisKeyframeChannel * > keyframeChannels

References KisKeyframeChannel::allKeyframeTimes(), KisTimeSpan::end(), KisKeyframeChannel::firstKeyframeTime(), KisScalarKeyframeChannel::identicalFrames(), KisTimeSpan::isInfinite(), KisTimeSpan::isValid(), KisBaseNode::keyframeChannels, KisKeyframeChannel::lastKeyframeTime(), and KisTimeSpan::start().

◆ fetchLayerFramesRecursive()

KRITAIMAGE_EXPORT QSet< int > KisLayerUtils::fetchLayerFramesRecursive ( KisNodeSP rootNode)

Definition at line 1389 of file kis_layer_utils.cpp.

1389 {
1390 if (!rootNode->visible()) return QSet<int>();
1391
1392 QSet<int> frames = fetchLayerFrames(rootNode);
1393
1394 KisNodeSP node = rootNode->firstChild();
1395 while(node) {
1396 frames |= fetchLayerFramesRecursive(node);
1397 node = node->nextSibling();
1398 }
1399
1400 return frames;
1401 }
QSet< int > fetchLayerFrames(KisNodeSP node)
QSet< int > fetchLayerFramesRecursive(KisNodeSP rootNode)
virtual bool visible(bool recursive=false) const
KisNodeSP firstChild() const
Definition kis_node.cpp:361
KisNodeSP nextSibling() const
Definition kis_node.cpp:408

References fetchLayerFrames(), fetchLayerFramesRecursive(), KisNode::firstChild(), KisNode::nextSibling(), and KisBaseNode::visible().

◆ fetchLayerIdenticalRasterFrameTimes()

KRITAIMAGE_EXPORT QSet< int > KisLayerUtils::fetchLayerIdenticalRasterFrameTimes ( KisNodeSP node,
const int & frameTime )

Definition at line 2510 of file kis_layer_utils.cpp.

2511 {
2512 KIS_SAFE_ASSERT_RECOVER_RETURN_VALUE(node, QSet<int>());
2513 KisPaintDeviceSP paintDevice = node->paintDevice();
2514 KIS_SAFE_ASSERT_RECOVER_RETURN_VALUE(paintDevice, QSet<int>());
2515 if (!paintDevice->keyframeChannel()) {
2516 return QSet<int>();
2517 }
2518
2519 return paintDevice->keyframeChannel()->clonesOf(node.data(), frameTime);
2520 }

References KisRasterKeyframeChannel::clonesOf(), KisSharedPtr< T >::data(), KisPaintDevice::keyframeChannel(), KIS_SAFE_ASSERT_RECOVER_RETURN_VALUE, and KisBaseNode::paintDevice().

◆ fetchLayerRasterFrameTimesMatchingID()

QSet< int > KisLayerUtils::fetchLayerRasterFrameTimesMatchingID ( KisNodeSP node,
const int frameID )

Definition at line 2523 of file kis_layer_utils.cpp.

2523 {
2524 KIS_ASSERT(node);
2525 KisRasterKeyframeChannel* rasterChannel = dynamic_cast<KisRasterKeyframeChannel*>(node->getKeyframeChannel(KisKeyframeChannel::Raster.id(), false));
2526
2527 if (!rasterChannel) {
2528 return QSet<int>();
2529 }
2530
2531 return rasterChannel->timesForFrameID(frameID);
2532 }
static const KoID Raster
QSet< int > timesForFrameID(int frameID) const
#define KIS_ASSERT(cond)
Definition kis_assert.h:33
KisKeyframeChannel * getKeyframeChannel(const QString &id, bool create)

References KisBaseNode::getKeyframeChannel(), KIS_ASSERT, KisKeyframeChannel::Raster, and KisRasterKeyframeChannel::timesForFrameID().

◆ fetchLayerRasterIDsAtTimes()

QSet< int > KisLayerUtils::fetchLayerRasterIDsAtTimes ( KisNodeSP node,
const QSet< int > & times )

Definition at line 2534 of file kis_layer_utils.cpp.

2535 {
2536 KIS_SAFE_ASSERT_RECOVER_RETURN_VALUE(node, QSet<int>());
2537 KisPaintDeviceSP paintDevice = node->paintDevice();
2538 KIS_SAFE_ASSERT_RECOVER_RETURN_VALUE(paintDevice, QSet<int>());
2539 if (!paintDevice->keyframeChannel()) {
2540 return QSet<int>();
2541 }
2542
2543 QSet<int> frameIDs;
2544
2545 Q_FOREACH( const int& frame, times ) {
2547 frameIDs << raster->frameID();
2548 }
2549
2550 return frameIDs;
2551 }

References KisKeyframeChannel::activeKeyframeAt(), KisPaintDevice::keyframeChannel(), KIS_SAFE_ASSERT_RECOVER_RETURN_VALUE, and KisBaseNode::paintDevice().

◆ fetchLayerUniqueRasterTimesMatchingIDs()

QSet< int > KisLayerUtils::fetchLayerUniqueRasterTimesMatchingIDs ( KisNodeSP node,
QSet< int > & frameIDs )

Definition at line 2565 of file kis_layer_utils.cpp.

2566 {
2567 KIS_SAFE_ASSERT_RECOVER_RETURN_VALUE(node, QSet<int>());
2568 KisPaintDeviceSP paintDevice = node->paintDevice();
2569 KIS_SAFE_ASSERT_RECOVER_RETURN_VALUE(paintDevice, QSet<int>());
2570 KIS_SAFE_ASSERT_RECOVER_RETURN_VALUE(paintDevice->framesInterface(), QSet<int>());
2571
2572 QSet<int> uniqueTimes;
2573
2574 Q_FOREACH( const int& id, frameIDs) {
2575 QSet<int> times = fetchLayerRasterFrameTimesMatchingID(node, id);
2576 if (times.count() > 0) {
2577 uniqueTimes.insert(*times.begin());
2578 }
2579 }
2580
2581 return uniqueTimes;
2582 }
KisPaintDeviceFramesInterface * framesInterface()
QSet< int > fetchLayerRasterFrameTimesMatchingID(KisNodeSP node, const int frameID)

References fetchLayerRasterFrameTimesMatchingID(), KisPaintDevice::framesInterface(), KIS_SAFE_ASSERT_RECOVER_RETURN_VALUE, and KisBaseNode::paintDevice().

◆ fetchSelectionMasks()

void KisLayerUtils::fetchSelectionMasks ( KisNodeList mergedNodes,
QVector< KisSelectionMaskSP > & selectionMasks )

Definition at line 66 of file kis_layer_utils.cpp.

67 {
68 foreach (KisNodeSP node, mergedNodes) {
69
70 Q_FOREACH(KisNodeSP child, node->childNodes(QStringList("KisSelectionMask"), KoProperties())) {
71
72 KisSelectionMaskSP mask = qobject_cast<KisSelectionMask*>(child.data());
73 if (mask) {
74 selectionMasks.append(mask);
75 }
76 }
77 }
78 }
QList< KisNodeSP > childNodes(const QStringList &nodeTypes, const KoProperties &properties) const
Definition kis_node.cpp:439

References KisNode::childNodes(), and KisSharedPtr< T >::data().

◆ fetchUniqueFrameTimes()

KRITAIMAGE_EXPORT QSet< int > KisLayerUtils::fetchUniqueFrameTimes ( KisNodeSP node,
QSet< int > selectedTimes,
bool filterActiveFrameID )

Definition at line 2584 of file kis_layer_utils.cpp.

2585 {
2586 if (selectedTimes.isEmpty() || !node->supportsKeyframeChannel(KisKeyframeChannel::Raster.id()))
2587 return selectedTimes;
2588
2589 // Convert a set of selected keyframe times into set of selected "frameIDs"...
2590 QSet<int> selectedFrameIDs = KisLayerUtils::fetchLayerRasterIDsAtTimes(node, selectedTimes);
2591
2592 if (filterActiveFrameID) {
2593 // Current frame was already filtered e.g. during filter preview in `KisFilterManager::apply`...
2594 // So let's remove it...
2595 const int currentActiveFrameID = KisLayerUtils::fetchLayerActiveRasterFrameID(node);
2596 selectedFrameIDs.remove(currentActiveFrameID);
2597 }
2598
2599 // Convert frameIDs to any arbitrary frame time associated with the frameID...
2600 QSet<int> uniqueFrameTimes = node->paintDevice()->framesInterface() ? KisLayerUtils::fetchLayerUniqueRasterTimesMatchingIDs(node, selectedFrameIDs) : QSet<int>();
2601
2602 return uniqueFrameTimes;
2603 }
QString id() const
Definition KoID.cpp:63
int fetchLayerActiveRasterFrameID(KisNodeSP node)
QSet< int > fetchLayerUniqueRasterTimesMatchingIDs(KisNodeSP node, QSet< int > &frameIDs)
QSet< int > fetchLayerRasterIDsAtTimes(KisNodeSP node, const QSet< int > &times)
virtual bool supportsKeyframeChannel(const QString &id)

References fetchLayerActiveRasterFrameID(), fetchLayerRasterIDsAtTimes(), fetchLayerUniqueRasterTimesMatchingIDs(), KisPaintDevice::framesInterface(), KoID::id(), KisBaseNode::paintDevice(), KisKeyframeChannel::Raster, and KisBaseNode::supportsKeyframeChannel().

◆ filterInvisibleNodes()

KisNodeList KisLayerUtils::filterInvisibleNodes ( const KisNodeList & nodes,
KisNodeList * invisibleNodes,
KisNodeSP * putAfter )

When a layer is invisible and user-locked we should just skip it and do neither merge nor remove it.

Definition at line 1764 of file kis_layer_utils.cpp.

1765 {
1766 KIS_ASSERT_RECOVER(invisibleNodes) { return nodes; }
1767 KIS_ASSERT_RECOVER(putAfter) { return nodes; }
1768
1769 KisNodeList visibleNodes;
1770 int putAfterIndex = -1;
1771
1772 Q_FOREACH(KisNodeSP node, nodes) {
1773 if (node->visible()) {
1774 visibleNodes << node;
1775 } else if (node->userLocked()) {
1780 } else {
1781 *invisibleNodes << node;
1782
1783 if (node == *putAfter) {
1784 putAfterIndex = visibleNodes.size() - 1;
1785 }
1786 }
1787 }
1788
1789 if (!visibleNodes.isEmpty() && putAfterIndex >= 0) {
1790 putAfterIndex = qBound(0, putAfterIndex, visibleNodes.size() - 1);
1791 *putAfter = visibleNodes[putAfterIndex];
1792 }
1793
1794 return visibleNodes;
1795 }
#define KIS_ASSERT_RECOVER(cond)
Definition kis_assert.h:55
bool userLocked() const

References KIS_ASSERT_RECOVER, KisBaseNode::userLocked(), and KisBaseNode::visible().

◆ filterMergeableNodes()

KRITAIMAGE_EXPORT void KisLayerUtils::filterMergeableNodes ( KisNodeList & nodes,
bool allowMasks )

Definition at line 1619 of file kis_layer_utils.cpp.

1620 {
1621 KisNodeList::iterator it = nodes.begin();
1622
1623 while (it != nodes.end()) {
1624 if ((!allowMasks && !qobject_cast<KisLayer*>(it->data())) ||
1625 checkIsChildOf(*it, nodes)) {
1626 //qDebug() << "Skipping node" << ppVar((*it)->name());
1627 it = nodes.erase(it);
1628 } else {
1629 ++it;
1630 }
1631 }
1632 }
bool checkIsChildOf(KisNodeSP node, const KisNodeList &parents)

References checkIsChildOf().

◆ filterTimesForOnlyRasterKeyedTimes()

KRITAIMAGE_EXPORT QSet< int > KisLayerUtils::filterTimesForOnlyRasterKeyedTimes ( KisNodeSP node,
const QSet< int > & times )

Definition at line 2553 of file kis_layer_utils.cpp.

2554 {
2556 KisPaintDeviceSP paintDevice = node->paintDevice();
2557 KIS_SAFE_ASSERT_RECOVER_RETURN_VALUE(paintDevice, times);
2558 if (!paintDevice->keyframeChannel()) {
2559 return times;
2560 }
2561
2562 return paintDevice->keyframeChannel()->allKeyframeTimes().intersect(times);
2563 }

References KisKeyframeChannel::allKeyframeTimes(), KisPaintDevice::keyframeChannel(), KIS_SAFE_ASSERT_RECOVER_RETURN_VALUE, and KisBaseNode::paintDevice().

◆ filterUnlockedNodes()

KRITAIMAGE_EXPORT void KisLayerUtils::filterUnlockedNodes ( KisNodeList & nodes)

Definition at line 1797 of file kis_layer_utils.cpp.

1798 {
1799 KisNodeList::iterator it = nodes.begin();
1800
1801 while (it != nodes.end()) {
1802 if ((*it)->userLocked()) {
1803 it = nodes.erase(it);
1804 } else {
1805 ++it;
1806 }
1807 }
1808 }

◆ findImageByHierarchy()

KRITAIMAGE_EXPORT KisImageSP KisLayerUtils::findImageByHierarchy ( KisNodeSP node)

Definition at line 2297 of file kis_layer_utils.cpp.

2298 {
2299 while (node) {
2300 const KisLayer *layer = dynamic_cast<const KisLayer*>(node.data());
2301 if (layer) {
2302 return layer->image();
2303 }
2304
2305 node = node->parent();
2306 }
2307
2308 return 0;
2309 }
KisImageWSP image

References KisSharedPtr< T >::data(), KisBaseNode::image, and KisNode::parent.

◆ findIsolationRoot()

KRITAIMAGE_EXPORT KisNodeSP KisLayerUtils::findIsolationRoot ( KisNodeSP node)

Definition at line 2254 of file kis_layer_utils.cpp.

2255 {
2256 KisImageSP image = node->image();
2257 if (image)
2258 return image->isolationRootNode();
2259 return nullptr;
2260 }
KisNodeSP isolationRootNode() const

References KisBaseNode::image, and KisImage::isolationRootNode().

◆ findNodeByName()

KRITAIMAGE_EXPORT KisNodeSP KisLayerUtils::findNodeByName ( KisNodeSP root,
const QString & name )

Definition at line 2246 of file kis_layer_utils.cpp.

2247 {
2248 return recursiveFindNode(root,
2249 [name] (KisNodeSP node) {
2250 return node->name() == name;
2251 });
2252 }

References KisBaseNode::name(), and recursiveFindNode().

◆ findNodeByType()

template<class T >
T * KisLayerUtils::findNodeByType ( KisNodeSP root)

Definition at line 275 of file kis_layer_utils.h.

275 {
276 return dynamic_cast<T*>(recursiveFindNode(root, [] (KisNodeSP node) {
277 return bool(dynamic_cast<T*>(node.data()));
278 }).data());
279 }

References KisSharedPtr< T >::data(), and recursiveFindNode().

◆ findNodeByUuid()

KRITAIMAGE_EXPORT KisNodeSP KisLayerUtils::findNodeByUuid ( KisNodeSP root,
const QUuid & uuid )

Recursively searches for a node with specified Uuid

Definition at line 2220 of file kis_layer_utils.cpp.

2221 {
2222 return recursiveFindNode(root,
2223 [uuid] (KisNodeSP node) {
2224 return node->uuid() == uuid;
2225 });
2226 }
QUuid uuid() const

References recursiveFindNode(), and KisBaseNode::uuid().

◆ findNodesByName()

KRITAIMAGE_EXPORT QList< KisNodeSP > KisLayerUtils::findNodesByName ( KisNodeSP root,
const QString & name,
bool recursive,
bool partialMatch )

Definition at line 2228 of file kis_layer_utils.cpp.

2229 {
2230 KisNodeList nodeList;
2231 KisNodeSP child = root->firstChild();
2232
2233 while (child) {
2234 if (name.isEmpty() || (!partialMatch && child->name() == name) || (partialMatch && child->name().contains(name, Qt::CaseInsensitive))) {
2235 nodeList << child;
2236 }
2237 if (recursive && child->childCount() > 0) {
2238 nodeList << findNodesByName(child, name, recursive, partialMatch);
2239 }
2240 child = child->nextSibling();
2241 }
2242
2243 return nodeList;
2244 }
quint32 childCount() const
Definition kis_node.cpp:414

References KisNode::childCount(), findNodesByName(), KisNode::firstChild(), KisBaseNode::name(), and KisNode::nextSibling().

◆ findNodesWithProps()

KRITAIMAGE_EXPORT KisNodeList KisLayerUtils::findNodesWithProps ( KisNodeSP root,
const KoProperties & props,
bool excludeRoot )

Definition at line 1747 of file kis_layer_utils.cpp.

1748 {
1749 KisNodeList nodes;
1750
1751 if ((!excludeRoot || root->parent()) && root->check(props)) {
1752 nodes << root;
1753 }
1754
1755 KisNodeSP node = root->firstChild();
1756 while (node) {
1757 nodes += findNodesWithProps(node, props, excludeRoot);
1758 node = node->nextSibling();
1759 }
1760
1761 return nodes;
1762 }
bool check(const KoProperties &properties) const

References KisBaseNode::check(), findNodesWithProps(), KisNode::firstChild(), KisNode::nextSibling(), and KisNode::parent.

◆ findRoot()

KRITAIMAGE_EXPORT KisNodeSP KisLayerUtils::findRoot ( KisNodeSP node)

Definition at line 2365 of file kis_layer_utils.cpp.

2366 {
2367 if (!node) return node;
2368
2369 while (node->parent()) {
2370 node = node->parent();
2371 }
2372 return node;
2373 }

References KisNode::parent.

◆ flattenImage()

KRITAIMAGE_EXPORT void KisLayerUtils::flattenImage ( KisImageSP image,
KisNodeSP activeNode,
MergeFlags flags )

Definition at line 2170 of file kis_layer_utils.cpp.

2171 {
2172 if (!activeNode) {
2173 activeNode = image->root()->lastChild();
2174 }
2175
2176
2177 KisNodeList mergedNodes;
2178 mergedNodes << image->root();
2179
2180 mergeMultipleLayersImpl(image, mergedNodes, activeNode,
2181 true, kundo2_i18n("Flatten Image"),
2182 true, QString(),
2183 flags);
2184 }
KisNodeSP lastChild() const
Definition kis_node.cpp:367

References kundo2_i18n(), KisNode::lastChild(), mergeMultipleLayersImpl(), and KisNodeFacade::root.

◆ flattenLayer()

KRITAIMAGE_EXPORT void KisLayerUtils::flattenLayer ( KisImageSP image,
KisLayerSP layer,
MergeFlags flags )

Definition at line 2156 of file kis_layer_utils.cpp.

2157 {
2158 if (!layer->childCount() && !layer->layerStyle())
2159 return;
2160
2161 KisNodeList mergedNodes;
2162 mergedNodes << layer;
2163
2164 mergeMultipleLayersImpl(image, mergedNodes, layer,
2165 true, kundo2_i18n("Flatten Layer"),
2166 true, QString(),
2167 flags);
2168 }
void mergeMultipleLayersImpl(KisImageSP image, KisNodeList mergedNodes, KisNodeSP putAfter, bool flattenSingleLayer, const KUndo2MagicString &actionName, bool cleanupNodes=true, const QString layerName=QString(), MergeFlags flags=None)
KisPSDLayerStyleSP layerStyle
Definition kis_layer.cc:171

References KisNode::childCount(), kundo2_i18n(), KisLayer::layerStyle, and mergeMultipleLayersImpl().

◆ forceAllDelayedNodesUpdate()

KRITAIMAGE_EXPORT void KisLayerUtils::forceAllDelayedNodesUpdate ( KisNodeSP root)

Definition at line 2262 of file kis_layer_utils.cpp.

2263 {
2265 [] (KisNodeSP node) {
2266 KisDelayedUpdateNodeInterface *delayedUpdate =
2267 dynamic_cast<KisDelayedUpdateNodeInterface*>(node.data());
2268 if (delayedUpdate) {
2269 delayedUpdate->forceUpdateTimedNode();
2270 }
2271 });
2272 }
The KisDelayedUpdateNodeInterface class is an interface for nodes that delay their real updates with ...
virtual void forceUpdateTimedNode()=0
forceUpdateTimedNode forces the node to regenerate its project. The update might be asynchronous,...

References KisSharedPtr< T >::data(), KisDelayedUpdateNodeInterface::forceUpdateTimedNode(), and recursiveApplyNodes().

◆ forceAllHiddenOriginalsUpdate()

KRITAIMAGE_EXPORT void KisLayerUtils::forceAllHiddenOriginalsUpdate ( KisNodeSP root)

Definition at line 2285 of file kis_layer_utils.cpp.

2286 {
2288 [] (KisNodeSP node) {
2289 KisCroppedOriginalLayerInterface *croppedUpdate =
2290 dynamic_cast<KisCroppedOriginalLayerInterface*>(node.data());
2291 if (croppedUpdate) {
2292 croppedUpdate->forceUpdateHiddenAreaOnOriginal();
2293 }
2294 });
2295 }
virtual void forceUpdateHiddenAreaOnOriginal()=0

References KisSharedPtr< T >::data(), KisCroppedOriginalLayerInterface::forceUpdateHiddenAreaOnOriginal(), and recursiveApplyNodes().

◆ hasDelayedNodeWithUpdates()

KRITAIMAGE_EXPORT bool KisLayerUtils::hasDelayedNodeWithUpdates ( KisNodeSP root)

Definition at line 2274 of file kis_layer_utils.cpp.

2275 {
2276 return recursiveFindNode(root,
2277 [] (KisNodeSP node) {
2278 KisDelayedUpdateNodeInterface *delayedUpdate =
2279 dynamic_cast<KisDelayedUpdateNodeInterface*>(node.data());
2280
2281 return delayedUpdate ? delayedUpdate->hasPendingTimedUpdates() : false;
2282 });
2283 }
virtual bool hasPendingTimedUpdates() const =0

References KisSharedPtr< T >::data(), KisDelayedUpdateNodeInterface::hasPendingTimedUpdates(), and recursiveFindNode().

◆ mergeDown()

KRITAIMAGE_EXPORT void KisLayerUtils::mergeDown ( KisImageSP image,
KisLayerSP layer,
const KisMetaData::MergeStrategy * strategy,
MergeFlags flags )
See also
a comment in mergeMultipleLayersImpl()

Save the original time before we start switching is with asynchronous SwitchFrameCommand.

When switching frames we need to update the entire image, not only the new extent of the layer, hence we pass refresh_entire_image to the command to make sure that the entire image bounds rect is added to the update rect

If source layer is not animated, then just merge that into the current frame to avoid unintentional destruction of the animation on the layer below. To merge the source into all the frames, just make the source animated.

See https://bugs.kde.org/show_bug.cgi?id=475550

Definition at line 1446 of file kis_layer_utils.cpp.

1447 {
1448 if (!layer->prevSibling()) return;
1449
1450 // XXX: this breaks if we allow free mixing of masks and layers
1451 KisLayerSP prevLayer = qobject_cast<KisLayer*>(layer->prevSibling().data());
1452
1453 while (prevLayer && prevLayer->isFakeNode()) {
1454 prevLayer = qobject_cast<KisLayer*>(prevLayer->prevSibling().data());
1455 }
1456
1457 if (!prevLayer) return;
1458
1459 if (!layer->visible() && !prevLayer->visible()) {
1460 return;
1461 }
1462
1463 KisImageSignalVector emitSignals;
1464 KisProcessingApplicator applicator(image, 0,
1466 emitSignals,
1467 kundo2_i18n("Merge Down"));
1468
1469 if (layer->visible() && prevLayer->visible()) {
1470 MergeDownInfoSP info(new MergeDownInfo(image, prevLayer, layer, flags));
1471
1472 // disable key strokes on all colorize masks, all onion skins on
1473 // paint layers and wait until update is finished with a barrier
1474 applicator.applyCommand(new DisableColorizeKeyStrokes(info));
1475 applicator.applyCommand(new DisableOnionSkins(info));
1476 applicator.applyCommand(new KUndo2Command(), KisStrokeJobData::BARRIER);
1477
1478 applicator.applyCommand(new KeepMergedNodesSelected(info, false));
1479 applicator.applyCommand(new FillSelectionMasks(info));
1480 applicator.applyCommand(new CreateMergedLayer(info), KisStrokeJobData::BARRIER);
1481
1482 // NOTE: shape layer may have emitted spontaneous jobs during layer creation,
1483 // wait for them to complete!
1484 applicator.applyCommand(new RefreshDelayedUpdateLayers(info), KisStrokeJobData::BARRIER);
1485 applicator.applyCommand(new KUndo2Command(), KisStrokeJobData::BARRIER);
1486
1487 // in two-layer mode we disable pass through only when the destination layer
1488 // is not a group layer
1489 applicator.applyCommand(new DisablePassThroughForHeadsOnly(info, true));
1490 applicator.applyCommand(new KUndo2Command(), KisStrokeJobData::BARRIER);
1491
1492 if (info->frames.size() > 0) {
1497 const int currentTimeOnStart = info->image->animationInterface()->currentTime();
1498
1499 foreach (int frame, info->frames) {
1500 applicator.applyCommand(new SwitchFrameCommand(info->image, frame, false, info->storage));
1501
1502 applicator.applyCommand(new AddNewFrame(info, frame));
1509 applicator.applyCommand(new RefreshHiddenAreas(info, RefreshHiddenAreas::refresh_entire_image));
1510 applicator.applyCommand(new RefreshDelayedUpdateLayers(info), KisStrokeJobData::BARRIER);
1511
1520 const bool skipMergingSourceLayer = !layer->isAnimated() &&
1521 frame != currentTimeOnStart;
1522
1523 applicator.applyCommand(new MergeLayers(info, skipMergingSourceLayer), KisStrokeJobData::BARRIER);
1524
1525 applicator.applyCommand(new SwitchFrameCommand(info->image, frame, true, info->storage), KisStrokeJobData::BARRIER);
1526 }
1527 } else {
1528 applicator.applyCommand(new RefreshHiddenAreas(info));
1529 applicator.applyCommand(new RefreshDelayedUpdateLayers(info), KisStrokeJobData::BARRIER);
1530 applicator.applyCommand(new MergeLayers(info, false), KisStrokeJobData::BARRIER);
1531 }
1532
1533 applicator.applyCommand(new MergeMetaData(info, strategy), KisStrokeJobData::BARRIER);
1534 applicator.applyCommand(new CleanUpNodes(info, layer),
1537 applicator.applyCommand(new KeepMergedNodesSelected(info, true));
1538 } else if (layer->visible()) {
1539 applicator.applyCommand(new KeepNodesSelectedCommand(KisNodeList(), KisNodeList(),
1540 layer, KisNodeSP(),
1541 image, false));
1542
1543 applicator.applyCommand(
1544 new SimpleRemoveLayers(KisNodeList() << prevLayer,
1545 image),
1548
1549 applicator.applyCommand(new KeepNodesSelectedCommand(KisNodeList(), KisNodeList(),
1550 KisNodeSP(), layer,
1551 image, true));
1552 } else if (prevLayer->visible()) {
1553 applicator.applyCommand(new KeepNodesSelectedCommand(KisNodeList(), KisNodeList(),
1554 layer, KisNodeSP(),
1555 image, false));
1556
1557 applicator.applyCommand(
1558 new SimpleRemoveLayers(KisNodeList() << layer,
1559 image),
1562
1563 applicator.applyCommand(new KeepNodesSelectedCommand(KisNodeList(), KisNodeList(),
1564 KisNodeSP(), prevLayer,
1565 image, true));
1566 }
1567
1568 applicator.end();
1569 }
QList< KisNodeSP > KisNodeList
Definition kis_types.h:264
QSharedPointer< MergeDownInfo > MergeDownInfoSP
bool isAnimated() const
virtual bool isFakeNode() const
KisNodeSP prevSibling() const
Definition kis_node.cpp:402

References KisProcessingApplicator::applyCommand(), KisStrokeJobData::BARRIER, KisSharedPtr< T >::data(), KisProcessingApplicator::end(), KisStrokeJobData::EXCLUSIVE, KisBaseNode::isAnimated(), KisBaseNode::isFakeNode(), kundo2_i18n(), KisProcessingApplicator::NONE, KisNode::prevSibling(), KisLayerUtils::RefreshHiddenAreas::refresh_entire_image, KisStrokeJobData::SEQUENTIAL, and KisBaseNode::visible().

◆ mergeMultipleLayers()

KRITAIMAGE_EXPORT void KisLayerUtils::mergeMultipleLayers ( KisImageSP image,
KisNodeList mergedNodes,
KisNodeSP putAfter,
MergeFlags flags )

Definition at line 2040 of file kis_layer_utils.cpp.

2041 {
2042 mergeMultipleLayersImpl(image, mergedNodes, putAfter,
2043 false, kundo2_i18n("Merge Selected Nodes"),
2044 true, QString(),
2045 flags);
2046 }

References kundo2_i18n(), and mergeMultipleLayersImpl().

◆ mergeMultipleLayersImpl()

void KisLayerUtils::mergeMultipleLayersImpl ( KisImageSP image,
KisNodeList mergedNodes,
KisNodeSP putAfter,
bool flattenSingleLayer,
const KUndo2MagicString & actionName,
bool cleanupNodes = true,
const QString layerName = QString(),
MergeFlags flags = None )

There might be two approaches for merging multiple layers:

1) Consider the selected nodes as a distinct "group" and merge them as if they were isolated from the rest of the image. The key point of this approach is that the look of the image will change, when merging "weird" layers, like adjustment layers or layers with non-normal blending mode.

2) Merge layers in a way to keep the look of the image as unchanged as possible. With this approach one uses a few heuristics:

  • when merging multiple layers with non-normal (but equal) blending mode, first merge these layers together using Normal blending mode, then set blending mode of the result to the original blending mode
  • when merging multiple layers with different blending modes or layer styles, they are first rasterized, and then laid over each other with their own composite op. The blending mode of the final layer is set to Normal, so the user could clearly see that he should choose the correct blending mode.

Krita uses the second approach: after merge operation, the image should look as if nothing has happened (if it is technically possible).

We have reached the root of the layer hierarchy and didn't manage to find a node that was editable enough for putting our merged result into it. That shouldn't happen in normal circumstances, unless the user chose to make the root layer visible and lock it manually.

When switching frames we need to update the entire image, not only the new extent of the layer, hence we pass refresh_entire_image to the command to make sure that the entire image bounds rect is added to the update rect

Definition at line 1897 of file kis_layer_utils.cpp.

1901 {
1902 if (!putAfter) {
1903 putAfter = mergedNodes.first();
1904 }
1905
1906 filterMergeableNodes(mergedNodes);
1907 {
1908 KisNodeList tempNodes;
1909 std::swap(mergedNodes, tempNodes);
1910 sortMergeableNodes(image->root(), tempNodes, mergedNodes);
1911 }
1912
1913 if (mergedNodes.size() <= 1 &&
1914 (!flattenSingleLayer && mergedNodes.size() == 1)) return;
1915
1916 KisImageSignalVector emitSignals;
1917 emitSignals << ComplexNodeReselectionSignal(KisNodeSP(), KisNodeList(), KisNodeSP(), mergedNodes);
1918
1919
1920
1921 KisNodeList originalNodes = mergedNodes;
1922 KisNodeList invisibleNodes;
1923 mergedNodes = filterInvisibleNodes(originalNodes, &invisibleNodes, &putAfter);
1924
1925 if (mergedNodes.isEmpty()) return;
1926
1927
1928 // make sure we don't add the new layer into a locked group
1930 while (putAfter->parent() && !putAfter->parent()->isEditable()) {
1931 putAfter = putAfter->parent();
1932 }
1933
1941 if (!putAfter->parent()) {
1942 return;
1943 }
1944
1945 KisProcessingApplicator applicator(image, 0,
1947 emitSignals,
1948 actionName);
1949
1950
1951 if (!invisibleNodes.isEmpty() && cleanupNodes) {
1952
1953 /* If the putAfter node is invisible,
1954 * we should instead pick one of the nodes
1955 * to be merged to avoid a null putAfter
1956 * after we remove all invisible layers from
1957 * the image.
1958 * (The assumption is that putAfter is among
1959 * the layers to merge, so if it's invisible,
1960 * it's going to be removed)
1961 */
1962 if (!putAfter->visible()){
1963 putAfter = mergedNodes.first();
1964 }
1965
1966 applicator.applyCommand(
1967 new SimpleRemoveLayers(invisibleNodes,
1968 image),
1971 }
1972
1973 if (mergedNodes.size() > 1 || invisibleNodes.isEmpty()) {
1974 MergeMultipleInfoSP info(new MergeMultipleInfo(image, mergedNodes, flags));
1975
1976 // disable key strokes on all colorize masks, all onion skins on
1977 // paint layers and wait until update is finished with a barrier
1978 //
1979 // when doing "new layer from visible" we should undo these changes
1980 // before the action stops, because the source layers are **not**
1981 // removed as a result of this action
1982 applicator.applyCommand(
1983 new EphemeralCommandsWrapper(info,
1984 {
1985 new DisableColorizeKeyStrokes(info),
1986 new DisableOnionSkins(info),
1987 new DisablePassThroughForHeadsOnly(info)
1988 },
1989 cleanupNodes));
1990 applicator.applyCommand(new KUndo2Command(), KisStrokeJobData::BARRIER);
1991
1992 applicator.applyCommand(new KeepMergedNodesSelected(info, putAfter, false));
1993 applicator.applyCommand(new FillSelectionMasks(info));
1994 applicator.applyCommand(new CreateMergedLayerMultiple(info, layerName), KisStrokeJobData::BARRIER);
1995 applicator.applyCommand(new EphemeralCommandsWrapper(info, { new DisableExtraCompositing(info) } , cleanupNodes));
1996 applicator.applyCommand(new KUndo2Command(), KisStrokeJobData::BARRIER);
1997
1998 if (!info->frames.isEmpty()) {
1999 foreach (int frame, info->frames) {
2000 applicator.applyCommand(new SwitchFrameCommand(info->image, frame, false, info->storage));
2001
2002 applicator.applyCommand(new AddNewFrame(info, frame));
2009 applicator.applyCommand(new RefreshHiddenAreas(info, RefreshHiddenAreas::refresh_entire_image));
2010 applicator.applyCommand(new RefreshDelayedUpdateLayers(info), KisStrokeJobData::BARRIER);
2011 applicator.applyCommand(new MergeLayersMultiple(info), KisStrokeJobData::BARRIER);
2012
2013 applicator.applyCommand(new SwitchFrameCommand(info->image, frame, true, info->storage));
2014 }
2015 } else {
2016 applicator.applyCommand(new RefreshHiddenAreas(info));
2017 applicator.applyCommand(new RefreshDelayedUpdateLayers(info), KisStrokeJobData::BARRIER);
2018 applicator.applyCommand(new MergeLayersMultiple(info), KisStrokeJobData::BARRIER);
2019 }
2020
2021 //applicator.applyCommand(new MergeMetaData(info, strategy), KisStrokeJobData::BARRIER);
2022 if (cleanupNodes){
2023 applicator.applyCommand(new CleanUpNodes(info, putAfter, flattenSingleLayer),
2026 } else {
2027 applicator.applyCommand(new UndoEphemeralCommands(info));
2028 applicator.applyCommand(new InsertNode(info, putAfter),
2031 }
2032
2033 applicator.applyCommand(new KeepMergedNodesSelected(info, putAfter, true));
2034 }
2035
2036 applicator.end();
2037
2038 }
#define KIS_SAFE_ASSERT_RECOVER_RETURN(cond)
Definition kis_assert.h:128
KisNodeList filterInvisibleNodes(const KisNodeList &nodes, KisNodeList *invisibleNodes, KisNodeSP *putAfter)
QSharedPointer< MergeMultipleInfo > MergeMultipleInfoSP
bool isEditable(bool checkVisibility=true) const

References KisProcessingApplicator::applyCommand(), KisStrokeJobData::BARRIER, KisProcessingApplicator::end(), KisStrokeJobData::EXCLUSIVE, filterInvisibleNodes(), filterMergeableNodes(), KisBaseNode::isEditable(), KIS_SAFE_ASSERT_RECOVER_RETURN, KisProcessingApplicator::NONE, KisNode::parent, KisLayerUtils::RefreshHiddenAreas::refresh_entire_image, KisNodeFacade::root, KisStrokeJobData::SEQUENTIAL, sortMergeableNodes(), and KisBaseNode::visible().

◆ mergeMultipleNodes()

KRITAIMAGE_EXPORT void KisLayerUtils::mergeMultipleNodes ( KisImageSP image,
KisNodeList mergedNodes,
KisNodeSP putAfter,
MergeFlags flags = None )

Same as mergeMultipleLayers() but tries to merge masks with tryMergeSelectionMasks() first.

Definition at line 2048 of file kis_layer_utils.cpp.

2049 {
2050 if (!tryMergeSelectionMasks(image, mergedNodes, putAfter)) {
2051 mergeMultipleLayers(image, mergedNodes, putAfter, flags);
2052 }
2053 }
bool tryMergeSelectionMasks(KisNodeSP currentNode, KisImageSP image)
void mergeMultipleLayers(KisImageSP image, KisNodeList mergedNodes, KisNodeSP putAfter, MergeFlags flags)

References mergeMultipleLayers(), and tryMergeSelectionMasks().

◆ newLayerFromVisible()

KRITAIMAGE_EXPORT void KisLayerUtils::newLayerFromVisible ( KisImageSP image,
KisNodeSP putAfter,
MergeFlags flags )

Definition at line 2055 of file kis_layer_utils.cpp.

2056 {
2057 KisNodeList mergedNodes;
2058 mergedNodes << image->root();
2059
2060 mergeMultipleLayersImpl(image, mergedNodes, putAfter,
2061 true, kundo2_i18n("New From Visible"),
2062 false, i18nc("New layer created from all the visible layers", "Visible"),
2063 flags);
2064 }

References kundo2_i18n(), mergeMultipleLayersImpl(), and KisNodeFacade::root.

◆ recursiveApplyNodes()

template<typename NodePointer , typename Functor >
void KisLayerUtils::recursiveApplyNodes ( NodePointer node,
Functor func )

Applies func to node and all its children recursively

Definition at line 241 of file kis_layer_utils.h.

242 {
243 func(node);
244
245 node = node->firstChild();
246 while (node) {
247 recursiveApplyNodes(node, func);
248 node = node->nextSibling();
249 }
250 }

References recursiveApplyNodes().

◆ recursiveFindNode()

KRITAIMAGE_EXPORT KisNodeSP KisLayerUtils::recursiveFindNode ( KisNodeSP node,
std::function< bool(KisNodeSP)> func )

Walks through node and all its children recursively until func returns true. When func returns true, the node is considered to be found, the search is stopped and the found node is returned to the caller.

Definition at line 2202 of file kis_layer_utils.cpp.

2203 {
2204 if (func(node)) {
2205 return node;
2206 }
2207
2208 node = node->firstChild();
2209 while (node) {
2210 KisNodeSP resultNode = recursiveFindNode(node, func);
2211 if (resultNode) {
2212 return resultNode;
2213 }
2214 node = node->nextSibling();
2215 }
2216
2217 return 0;
2218 }

References KisNode::firstChild(), KisNode::nextSibling(), and recursiveFindNode().

◆ recursiveTightNodeVisibleBounds()

KRITAIMAGE_EXPORT QRect KisLayerUtils::recursiveTightNodeVisibleBounds ( KisNodeSP rootNode)

Definition at line 2356 of file kis_layer_utils.cpp.

2357 {
2358 QRect exactBounds;
2359 recursiveApplyNodes(rootNode, [&exactBounds] (KisNodeSP node) {
2360 exactBounds |= node->projectionPlane()->tightUserVisibleBounds();
2361 });
2362 return exactBounds;
2363 }
virtual KisAbstractProjectionPlaneSP projectionPlane() const
Definition kis_node.cpp:240

References KisNode::projectionPlane(), and recursiveApplyNodes().

◆ refreshHiddenAreaAsync()

KRITAIMAGE_EXPORT void KisLayerUtils::refreshHiddenAreaAsync ( KisImageSP image,
KisNodeSP rootNode,
const QRect & preparedArea )

Definition at line 2352 of file kis_layer_utils.cpp.

2352 {
2353 Private::refreshHiddenAreaAsync(image, rootNode, preparedArea, QRect());
2354 }

References KisLayerUtils::Private::refreshHiddenAreaAsync().

◆ sortAndFilterAnyMergeableNodesSafe()

KRITAIMAGE_EXPORT KisNodeList KisLayerUtils::sortAndFilterAnyMergeableNodesSafe ( const KisNodeList & nodes,
KisImageSP image )

Definition at line 1711 of file kis_layer_utils.cpp.

1711 {
1712 KisNodeList filteredNodes = nodes;
1713 KisNodeList sortedNodes;
1714
1715 KisLayerUtils::filterMergeableNodes(filteredNodes, true);
1716
1717 bool haveExternalNodes = false;
1718 Q_FOREACH (KisNodeSP node, nodes) {
1719 if (node->graphListener() != image->root()->graphListener()) {
1720 haveExternalNodes = true;
1721 break;
1722 }
1723 }
1724
1725 if (!haveExternalNodes) {
1726 KisLayerUtils::sortMergeableNodes(image->root(), filteredNodes, sortedNodes);
1727 } else {
1728 sortedNodes = filteredNodes;
1729 }
1730
1731 return sortedNodes;
1732 }
void sortMergeableNodes(KisNodeSP root, KisNodeList &inputNodes, KisNodeList &outputNodes)
void filterMergeableNodes(KisNodeList &nodes, bool allowMasks)
KisNodeGraphListener * graphListener
Definition kis_node.cpp:87

References filterMergeableNodes(), KisNode::graphListener, KisNodeFacade::root, and sortMergeableNodes().

◆ sortAndFilterMergeableInternalNodes()

KRITAIMAGE_EXPORT KisNodeList KisLayerUtils::sortAndFilterMergeableInternalNodes ( KisNodeList nodes,
bool allowMasks )

Definition at line 1666 of file kis_layer_utils.cpp.

1667 {
1668 KIS_SAFE_ASSERT_RECOVER(!nodes.isEmpty()) { return nodes; }
1669
1670 KisNodeSP root;
1671 Q_FOREACH(KisNodeSP node, nodes) {
1672 KisNodeSP localRoot = node;
1673 while (localRoot->parent()) {
1674 localRoot = localRoot->parent();
1675 }
1676
1677 if (!root) {
1678 root = localRoot;
1679 }
1680 KIS_SAFE_ASSERT_RECOVER(root == localRoot) { return nodes; }
1681 }
1682
1683 KisNodeList result;
1684 sortMergeableNodes(root, nodes, result);
1685 filterMergeableNodes(result, allowMasks);
1686 return result;
1687 }
#define KIS_SAFE_ASSERT_RECOVER(cond)
Definition kis_assert.h:126

References filterMergeableNodes(), KIS_SAFE_ASSERT_RECOVER, KisNode::parent, and sortMergeableNodes().

◆ sortMergeableInternalNodes()

KRITAIMAGE_EXPORT KisNodeList KisLayerUtils::sortMergeableInternalNodes ( KisNodeList nodes)

Definition at line 1689 of file kis_layer_utils.cpp.

1690 {
1691 KIS_SAFE_ASSERT_RECOVER(!nodes.isEmpty()) { return nodes; }
1692
1693 KisNodeSP root;
1694 Q_FOREACH(KisNodeSP node, nodes) {
1695 KisNodeSP localRoot = node;
1696 while (localRoot->parent()) {
1697 localRoot = localRoot->parent();
1698 }
1699
1700 if (!root) {
1701 root = localRoot;
1702 }
1703 KIS_SAFE_ASSERT_RECOVER(root == localRoot) { return nodes; }
1704 }
1705
1706 KisNodeList result;
1707 sortMergeableNodes(root, nodes, result);
1708 return result;
1709 }

References KIS_SAFE_ASSERT_RECOVER, KisNode::parent, and sortMergeableNodes().

◆ sortMergeableNodes() [1/3]

void KisLayerUtils::sortMergeableNodes ( KisNodeSP root,
KisNodeList & inputNodes,
KisNodeList & outputNodes )

By the end of recursion inputNodes must be empty

Definition at line 1634 of file kis_layer_utils.cpp.

1635 {
1636 KisNodeList::iterator it = std::find(inputNodes.begin(), inputNodes.end(), root);
1637
1638 if (it != inputNodes.end()) {
1639 outputNodes << *it;
1640 inputNodes.erase(it);
1641 }
1642
1643 if (inputNodes.isEmpty()) {
1644 return;
1645 }
1646
1647 KisNodeSP child = root->firstChild();
1648 while (child) {
1649 sortMergeableNodes(child, inputNodes, outputNodes);
1650 child = child->nextSibling();
1651 }
1652
1656 KIS_ASSERT_RECOVER_NOOP(root->parent() || inputNodes.isEmpty());
1657 }
#define KIS_ASSERT_RECOVER_NOOP(cond)
Definition kis_assert.h:97
KisNodeListSP inputNodes(KisImageSP image, InputLayerMode inputMode, KisNodeSP currentNode)

References KisNode::firstChild(), KIS_ASSERT_RECOVER_NOOP, KisNode::nextSibling(), KisNode::parent, and sortMergeableNodes().

◆ sortMergeableNodes() [2/3]

KRITAIMAGE_EXPORT KisNodeList KisLayerUtils::sortMergeableNodes ( KisNodeSP root,
KisNodeList nodes )

Definition at line 1659 of file kis_layer_utils.cpp.

1660 {
1661 KisNodeList result;
1662 sortMergeableNodes(root, nodes, result);
1663 return result;
1664 }

References sortMergeableNodes().

◆ sortMergeableNodes() [3/3]

KRITAIMAGE_EXPORT void KisLayerUtils::sortMergeableNodes ( KisNodeSP root,
QList< KisNodeSP > & inputNodes,
QList< KisNodeSP > & outputNodes )

◆ splitAlphaToMask()

KRITAIMAGE_EXPORT void KisLayerUtils::splitAlphaToMask ( KisImageSP image,
KisNodeSP node,
const QString & maskName )

Definition at line 2407 of file kis_layer_utils.cpp.

2408 {
2409 SplitAlphaToMaskInfoSP info( new SplitAlphaToMaskInfo(node->image(), node, maskName) );
2410
2411 KisImageSignalVector emitSignals;
2412 KisProcessingApplicator applicator(image, node,
2414 emitSignals,
2415 kundo2_i18n("Split Alpha into a Mask"));
2416
2417 applicator.applyCommand(new SimpleAddNode(info->image, info->getMask(), info->node), KisStrokeJobData::BARRIER);
2418 applicator.applyCommand(new InitSplitAlphaSelectionMask(info));
2419 if (info->frames.count() > 0) {
2420 Q_FOREACH(const int& frame, info->frames) {
2421 applicator.applyCommand(new SwitchFrameCommand(info->image, frame, false, info->storage));
2422 applicator.applyCommand(new AddNewFrame(info->getMask(), frame, info->node));
2423 applicator.applyCommand(new SplitAlphaCommand(info), KisStrokeJobData::BARRIER);
2424 applicator.applyCommand(new SwitchFrameCommand(info->image, frame, true, info->storage));
2425 }
2426 } else {
2427 applicator.applyCommand(new SplitAlphaCommand(info), KisStrokeJobData::BARRIER);
2428 }
2429 applicator.end();
2430 }

References KisProcessingApplicator::applyCommand(), KisStrokeJobData::BARRIER, KisProcessingApplicator::end(), KisBaseNode::image, kundo2_i18n(), and KisProcessingApplicator::NONE.

◆ splitNonRemovableNodes()

void KisLayerUtils::splitNonRemovableNodes ( KisNodeList & nodesToRemove,
KisNodeList & _nodesToHide )

Definition at line 1116 of file kis_layer_utils.cpp.

1117 {
1118 QSet<KisNodeSP> nodesToHide;
1119 QSet<KisNodeSP> extraNodesToRemove;
1120
1121 for (auto it = nodesToRemove.begin(); it != nodesToRemove.end(); ++it) {
1122 KisNodeSP root = *it;
1124
1125 if (!root->isEditable(false)) {
1126 nodesToHide.insert(root);
1127 } else {
1128 bool rootNeedsCarefulRemoval = false;
1129
1130 recursiveApplyNodes(root,
1131 [root, &nodesToHide, &rootNeedsCarefulRemoval] (KisNodeSP node) {
1132 if (!node->isEditable(false)) {
1133 while (node != root) {
1134 nodesToHide.insert(node);
1135 node = node->parent();
1136 KIS_SAFE_ASSERT_RECOVER_BREAK(node);
1137 }
1138 nodesToHide.insert(root);
1139 rootNeedsCarefulRemoval = true;
1140 }
1141 });
1142
1143 if (rootNeedsCarefulRemoval) {
1145 [&extraNodesToRemove] (KisNodeSP node) {
1146 extraNodesToRemove.insert(node);
1147 });
1148 }
1149 }
1150 }
1151 nodesToRemove += KisNodeList(extraNodesToRemove.begin(), extraNodesToRemove.end());
1152 KritaUtils::filterContainer<KisNodeList>(nodesToRemove,
1153 [nodesToHide](KisNodeSP node) {
1154 return !nodesToHide.contains(node);
1155 });
1156 _nodesToHide = KisNodeList(nodesToHide.begin(), nodesToHide.end());
1157 }
#define KIS_SAFE_ASSERT_RECOVER_NOOP(cond)
Definition kis_assert.h:130

References KisBaseNode::isEditable(), KIS_SAFE_ASSERT_RECOVER_NOOP, recursiveApplyNodes(), and KisBaseNode::visible().

◆ tryMergeSelectionMasks()

KRITAIMAGE_EXPORT bool KisLayerUtils::tryMergeSelectionMasks ( KisImageSP image,
KisNodeList mergedNodes,
KisNodeSP putAfter )

Definition at line 2117 of file kis_layer_utils.cpp.

2118 {
2119 QList<KisSelectionMaskSP> selectionMasks;
2120
2121 for (auto it = mergedNodes.begin(); it != mergedNodes.end(); /*noop*/) {
2122 KisSelectionMaskSP mask = dynamic_cast<KisSelectionMask*>(it->data());
2123 if (!mask) {
2124 it = mergedNodes.erase(it);
2125 } else {
2126 selectionMasks.append(mask);
2127 ++it;
2128 }
2129 }
2130
2131 if (mergedNodes.isEmpty()) return false;
2132
2133 KisLayerSP parentLayer = qobject_cast<KisLayer*>(selectionMasks.first()->parent().data());
2134 KIS_ASSERT_RECOVER(parentLayer) { return 0; }
2135
2136 KisImageSignalVector emitSignals;
2137
2138 KisProcessingApplicator applicator(image, 0,
2140 emitSignals,
2141 kundo2_i18n("Merge Selection Masks"));
2142
2143 MergeMultipleInfoSP info(new MergeMultipleInfo(image, mergedNodes, None));
2144
2145
2146 applicator.applyCommand(new MergeSelectionMasks(info, putAfter));
2147 applicator.applyCommand(new CleanUpNodes(info, putAfter),
2150 applicator.applyCommand(new ActivateSelectionMask(info));
2151 applicator.end();
2152
2153 return true;
2154 }

References KisProcessingApplicator::applyCommand(), KisProcessingApplicator::end(), KisStrokeJobData::EXCLUSIVE, KIS_ASSERT_RECOVER, kundo2_i18n(), None, KisProcessingApplicator::NONE, and KisStrokeJobData::SEQUENTIAL.

◆ updateFrameJobs()

void KisLayerUtils::updateFrameJobs ( FrameJobs * jobs,
KisNodeSP node )

Definition at line 1403 of file kis_layer_utils.cpp.

1403 {
1404 QSet<int> frames = fetchLayerFrames(node);
1405 frames = fetchUniqueFrameTimes(node, frames, false);
1406
1407 if (frames.isEmpty()) {
1408 (*jobs)[0].insert(node);
1409 } else {
1410 foreach (int frame, frames) {
1411 (*jobs)[frame].insert(node);
1412 }
1413 }
1414 }
QSet< int > fetchUniqueFrameTimes(KisNodeSP node, QSet< int > selectedTimes, bool filterActiveFrameID)

References fetchLayerFrames(), and fetchUniqueFrameTimes().

◆ updateFrameJobsNonRecursive()

void KisLayerUtils::updateFrameJobsNonRecursive ( FrameJobs * jobs,
KisNodeSP rootNode,
bool frameTimesRecursive = false )

updateFrameJobsNonRecursive updates the frame jobs non-recursively, that is, on the rootNode only.

Parameters
frameTimesRecursive– whether to make the frame times themselves recursive, or to only use the frames on the root node.

Definition at line 1426 of file kis_layer_utils.cpp.

1427 {
1428 if (frameTimesRecursive) {
1429 QSet<int> frames = fetchLayerFramesRecursive(rootNode);
1430
1431 if (frames.isEmpty()) {
1432 (*jobs)[0].insert(rootNode);
1433 } else {
1434 foreach (int frame, frames) {
1435 (*jobs)[frame].insert(rootNode);
1436 }
1437 }
1438 } else {
1439 updateFrameJobs(jobs, rootNode);
1440 }
1441 }
void updateFrameJobs(FrameJobs *jobs, KisNodeSP node)

References fetchLayerFramesRecursive(), and updateFrameJobs().

◆ updateFrameJobsRecursive()

void KisLayerUtils::updateFrameJobsRecursive ( FrameJobs * jobs,
KisNodeSP rootNode )

Definition at line 1416 of file kis_layer_utils.cpp.

1416 {
1417 updateFrameJobs(jobs, rootNode);
1418
1419 KisNodeSP node = rootNode->firstChild();
1420 while(node) {
1421 updateFrameJobsRecursive(jobs, node);
1422 node = node->nextSibling();
1423 }
1424 }
void updateFrameJobsRecursive(FrameJobs *jobs, KisNodeSP rootNode)

References KisNode::firstChild(), KisNode::nextSibling(), updateFrameJobs(), and updateFrameJobsRecursive().