First try to use fast-patch merge of layers of the same type (given that composition method is uniform)
Blendmode and other properties are expected to be filled in by the called function
624 {
625 QString mergedLayerName;
627 const QString mergedLayerSuffix = i18n("Merged");
628 mergedLayerName =
m_info->mergedNodes.first()->name();
629
630 if (
KisImageConfig(
true).renameMergedLayers() && !mergedLayerName.endsWith(mergedLayerSuffix)) {
631 mergedLayerName = QString("%1 %2")
632 .arg(mergedLayerName).arg(mergedLayerSuffix);
633 }
634 } else {
636 }
637
638 auto channelFlagsLazy = [](
KisNodeSP node) {
641 };
642
643 QString compositeOpId;
644 QBitArray channelFlags;
645 bool compositionVaries = false;
646 bool isFirstCycle = true;
647
649 if (isFirstCycle) {
651 channelFlags = channelFlagsLazy(node);
652 isFirstCycle = false;
654 channelFlags != channelFlagsLazy(node)) {
655 compositionVaries = true;
656 break;
657 }
658
661 compositionVaries = true;
662 break;
663 }
664 }
665
670 if (!compositionVaries &&
m_info->frames.isEmpty()) {
674 if (!layer) {
675 layers.clear();
676 break;
677 }
678 layers << layer;
679 }
680
681 if (!layers.isEmpty()) {
686 m_info->dstNode = layers.first()->tryCreateInternallyMergedLayerFromMutipleLayers(layers);
687 }
688 }
689
696
697 if (
m_info->frames.size() > 0) {
698 m_info->dstNode->enableAnimation();
700 }
701
702 if (!compositionVaries) {
703 if (!compositeOpId.isEmpty()) {
704 m_info->dstNode->setCompositeOpId(compositeOpId);
705 }
706 if (
m_info->dstLayer() && !channelFlags.isEmpty()) {
707 m_info->dstLayer()->setChannelFlags(channelFlags);
708 }
709 }
710
711 m_info->dstNode->setPinnedToTimeline(
m_info->pinnedToTimeline);
712 m_info->dstNode->setColorLabelIndex(
m_info->allSrcNodes().first()->colorLabelIndex());
713
714 m_info->rasterizedDstLayer->setOnionSkinEnabled(
m_info->enableOnionSkins);
715 }
716
717 m_info->nodesCompositingVaries = compositionVaries;
718 }
const quint8 OPACITY_OPAQUE_U8
const QString & compositeOpId() const
KisPSDLayerStyleSP layerStyle