Krita is a free and open source cross-platform application that offers an end-to-end solution for creating digital art files from scratch built on the KDE and Qt frameworks.
C++
Load vector stroke data and load vectors as shape layers.
Wolthera van Hövell tot Westerflier5c06258de478
diff --git a/libs/psd/psd_additional_layer_info_block.cpp b/libs/psd/psd_additional_layer_info_block.cppindex d8f9776442..7a490edd0e 100644--- a/libs/psd/psd_additional_layer_info_block.cpp+++ b/libs/psd/psd_additional_layer_info_block.cpp@@ -321,7 +321,8 @@ void PsdAdditionalLayerInfoBlock::readImpl(QIODevice &io)} else if (key == "anFX") {} else if (key == "FMsk") {} else if (key == "SoLd") {- } else if (key == "vstk") {+ } else if (key == "vstk") { // vector stroke info+ vectorStroke = KisAslReader::readVectorStroke(io, byteOrder);} else if (key == "vsCg") {} else if (key == "sn2P") {} else if (key == "vogk") {diff --git a/libs/psd/psd_additional_layer_info_block.h b/libs/psd/psd_additional_layer_info_block.hindex 7fbb39d130..c35009e674 100644--- a/libs/psd/psd_additional_layer_info_block.h+++ b/libs/psd/psd_additional_layer_info_block.h@@ -24,9 +24,14 @@#include <KisGlobalResourcesInterface.h>#include <KoStopGradient.h>#include <KoSegmentGradient.h>+#include <KoShapeBackground.h>+#include <KoColorBackground.h>+#include <KoGradientBackground.h>+#include <KoPatternBackground.h>#include <psd.h>#include <asl/kis_asl_xml_writer.h>+#include <asl/kis_asl_callback_object_catcher.h>#include "psd_header.h"@@ -174,6 +179,11 @@ struct KRITAPSD_EXPORT psd_layer_solid_color {colorSpace(LABAColorModelID.id(), Float32BitsColorDepthID.id(), 0));}}++ static void setupCatcher(const QString path, KisAslCallbackObjectCatcher &catcher, psd_layer_solid_color *data) {+ catcher.subscribeColor(path + "/Clr ", std::bind(&psd_layer_solid_color::setColor, data, std::placeholders::_1));+ }+QDomDocument getFillLayerConfig() {KisFilterConfigurationSP cfg;cfg = KisGeneratorRegistry::instance()->value("color")->defaultConfiguration(KisGlobalResourcesInterface::instance());@@ -206,6 +216,16 @@ struct KRITAPSD_EXPORT psd_layer_solid_color {return w.document();}++ QBrush getBrush() {+ QColor c;+ fill_color.toQColor(&c);+ return QBrush(c, Qt::SolidPattern);+ }++ QSharedPointer<KoShapeBackground> getBackground() {+ return QSharedPointer<KoColorBackground>(new KoColorBackground(getBrush().color()));+ }};struct KRITAPSD_EXPORT psd_layer_gradient_fill {@@ -279,6 +299,17 @@ struct KRITAPSD_EXPORT psd_layer_gradient_fill {offset = Ofst;}+ static void setupCatcher(const QString path, KisAslCallbackObjectCatcher &catcher, psd_layer_gradient_fill *data) {+ catcher.subscribeGradient(path + "/Grad", std::bind(&psd_layer_gradient_fill::setGradient, data, std::placeholders::_1));+ catcher.subscribeBoolean(path + "/Dthr", std::bind(&psd_layer_gradient_fill::setDither, data, std::placeholders::_1));+ catcher.subscribeBoolean(path + "/Rvrs", std::bind(&psd_layer_gradient_fill::setReverse, data, std::placeholders::_1));+ catcher.subscribeUnitFloat(path + "/Angl", "#Ang", std::bind(&psd_layer_gradient_fill::setAngle, data, std::placeholders::_1));+ catcher.subscribeEnum(path + "/Type", "GrdT", std::bind(&psd_layer_gradient_fill::setType, data, std::placeholders::_1));+ catcher.subscribeBoolean(path + "/Algn", std::bind(&psd_layer_gradient_fill::setAlignWithLayer, data, std::placeholders::_1));+ catcher.subscribeUnitFloat(path + "/Scl ", "#Prc", std::bind(&psd_layer_gradient_fill::setScale, data, std::placeholders::_1));+ catcher.subscribePoint(path + "/Ofst", std::bind(&psd_layer_gradient_fill::setOffset, data, std::placeholders::_1));+ }+QDomDocument getFillLayerConfig() {KisFilterConfigurationSP cfg;cfg = KisGeneratorRegistry::instance()->value("gradient")->defaultConfiguration(KisGlobalResourcesInterface::instance());@@ -474,6 +505,46 @@ struct KRITAPSD_EXPORT psd_layer_gradient_fill {return w.document();}++ QBrush getBrush() {+ QGradient *grad = getGradient();+ if (grad) {+ grad->setCoordinateMode(QGradient::ObjectBoundingMode);+ QBrush brush = *grad;+ return brush;+ }+ return QBrush(Qt::transparent);+ }+ QGradient *getGradient() {+ QGradient *pointer = nullptr;+ if (!gradient.isNull()) {+ const QDomElement gradientElement = gradient.firstChildElement();+ if (!gradientElement.isNull()) {+ const QString gradientType = gradientElement.attribute("type");+ if (gradientType == "stop") {+ const KoStopGradient grad = KoStopGradient::fromXML(gradientElement);+ if (grad.valid()) {+ pointer = grad.toQGradient();+ }+ } else if (gradientType == "segment") {+ const KoSegmentGradient grad = KoSegmentGradient::fromXML(gradientElement);+ if (grad.valid()) {+ pointer = grad.toQGradient();+ }+ }+ }+ }+ return pointer;+ }+ QSharedPointer<KoShapeBackground> getBackground() {+ QGradient *pointer = getGradient();+ pointer->setCoordinateMode(QGradient::ObjectBoundingMode);+ if (repeat == "alternate") {+ pointer->setSpread(QGradient::RepeatSpread);+ }+ QSharedPointer<KoGradientBackground> bg = QSharedPointer<KoGradientBackground>(new KoGradientBackground(pointer));+ return bg;+ }};struct KRITAPSD_EXPORT psd_layer_pattern_fill {@@ -503,6 +574,14 @@ struct KRITAPSD_EXPORT psd_layer_pattern_fill {void setAlignWithLayer(bool align) {align_with_layer = align;}++ static void setupCatcher(const QString path, KisAslCallbackObjectCatcher &catcher, psd_layer_pattern_fill *data) {+ catcher.subscribeUnitFloat(path + "/Angl", "#Ang", std::bind(&psd_layer_pattern_fill::setAngle, data, std::placeholders::_1));+ catcher.subscribeUnitFloat(path + "/Scl ", "#Prc", std::bind(&psd_layer_pattern_fill::setScale, data, std::placeholders::_1));+ catcher.subscribeBoolean(path + "/Algn", std::bind(&psd_layer_pattern_fill::setAlignWithLayer, data, std::placeholders::_1));+ catcher.subscribePoint(path + "/phase", std::bind(&psd_layer_pattern_fill::setOffset, data, std::placeholders::_1));+ catcher.subscribePatternRef(path + "/Ptrn", std::bind(&psd_layer_pattern_fill::setPatternRef, data, std::placeholders::_1, std::placeholders::_2));+ }QDomDocument getFillLayerConfig() const {KisFilterConfigurationSP cfg;@@ -582,6 +661,21 @@ struct KRITAPSD_EXPORT psd_layer_pattern_fill {return w.document();}++ QSharedPointer<KoShapeBackground> getBackground() {+ QSharedPointer<KoPatternBackground> bg = QSharedPointer<KoPatternBackground>(new KoPatternBackground());++ const QString patternMD5 = "";+ const QString patternNameTemp = QString(patternID + ".pat");+ const QString patternFileName = patternName;+ KoResourceLoadResult res = KisGlobalResourcesInterface::instance()->source(ResourceType::Patterns).bestMatchLoadResult(patternMD5, patternFileName, patternNameTemp);+ pattern = res.resource<KoPattern>();+ if (pattern) {+ bg->setPattern(pattern->pattern());+ }+ bg->setTileRepeatOffset(offset);+ return bg;+ }};struct KRITAPSD_EXPORT psd_layer_type_face {@@ -745,6 +839,123 @@ struct KRITAPSD_EXPORT psd_vector_mask {psd_path path;};+struct KRITAPSD_EXPORT psd_vector_stroke_data {+ bool strokeEnabled {false};+ bool fillEnabled {true};++ QPen pen;++ QVector<double> dashPattern;++ double opacity {1.0};++ double resolution {72};++ void setStrokeEnabled(bool enabled) {+ strokeEnabled = enabled;+ }+ void setFillEnabled(bool enabled) {+ fillEnabled = enabled;+ }+ void setStrokeWidth(double width) {+ pen.setWidthF(width);+ }++ void setStrokeDashOffset(double dashOffset) {+ pen.setDashOffset(dashOffset);+ }+ void setStrokeMiterLimit(double limit) {+ pen.setMiterLimit(limit);+ }+ void setLineCapType(const QString val) {+ if (val == "strokeStyleButtCap") {+ pen.setCapStyle(Qt::FlatCap);+ } else if (val == "strokeStyleSquareCap") {+ pen.setCapStyle(Qt::SquareCap);+ } else if (val == "strokeStyleRoundCap") {+ pen.setCapStyle(Qt::RoundCap);+ }+ }+ void setLineJoinType(const QString val) {+ if (val == "strokeStyleMiterJoin") {+ pen.setJoinStyle(Qt::MiterJoin);+ } else if (val == "strokeStyleBevelJoin") {+ pen.setJoinStyle(Qt::BevelJoin);+ } else if (val == "strokeStyleRoundJoin") {+ pen.setJoinStyle(Qt::RoundJoin);+ }+ }++ void appendToDashPattern(double val) {+ dashPattern.append(val);+ }+ void setOpacityFromPercentage(double o) {+ opacity = o * 0.01;+ }+ void setResolution(double res) {+ resolution = res;+ }++ static void setupCatcher(const QString path, KisAslCallbackObjectCatcher &catcher, psd_vector_stroke_data *data) {+ catcher.subscribeBoolean(path + "/strokeStyle/strokeEnabled", std::bind(&psd_vector_stroke_data::setStrokeEnabled, data, std::placeholders::_1));+ catcher.subscribeBoolean(path + "/strokeStyle/fillEnabled", std::bind(&psd_vector_stroke_data::setFillEnabled, data, std::placeholders::_1));+ catcher.subscribeUnitFloat(path + "/strokeStyle/strokeStyleLineWidth", "#Pnt", std::bind(&psd_vector_stroke_data::setStrokeWidth, data, std::placeholders::_1));+ catcher.subscribeUnitFloat(path + "/strokeStyle/strokeStyleLineDashOffset", "#Pnt", std::bind(&psd_vector_stroke_data::setStrokeDashOffset, data, std::placeholders::_1));+ catcher.subscribeDouble(path + "/strokeStyle/strokeStyleMiterLimit", std::bind(&psd_vector_stroke_data::setStrokeMiterLimit, data, std::placeholders::_1));+ catcher.subscribeEnum(path + "/strokeStyle/strokeStyleLineCapType", "strokeStyleLineCapType", std::bind(&psd_vector_stroke_data::setLineCapType, data, std::placeholders::_1));+ catcher.subscribeEnum(path + "/strokeStyle/strokeStyleLineJoinType", "strokeStyleLineJoinType", std::bind(&psd_vector_stroke_data::setLineJoinType, data, std::placeholders::_1));+ catcher.subscribeUnitFloat(path + "/strokeStyle/strokeStyleLineDashSet/", "#Nne", std::bind(&psd_vector_stroke_data::appendToDashPattern, data, std::placeholders::_1));+ catcher.subscribeUnitFloat(path + "/strokeStyle/strokeStyleOpacity", "#Prc", std::bind(&psd_vector_stroke_data::setOpacityFromPercentage, data, std::placeholders::_1));+ catcher.subscribeDouble(path + "/strokeStyle/strokeStyleResolution", std::bind(&psd_vector_stroke_data::setResolution, data, std::placeholders::_1));+ }++ QDomDocument ASLXML() {+ KisAslXmlWriter w;+ w.enterDescriptor("", "", "strokeStyle");++ w.writeInteger("strokeStyleVersion", 2);+ w.writeBoolean("strokeEnabled", strokeEnabled);+ w.writeBoolean("fillEnabled", fillEnabled);++ w.writeUnitFloat("strokeStyleLineWidth", "#Pnt", pen.widthF());+ w.writeUnitFloat("strokeStyleLineDashOffset ", "#Pnt", pen.dashOffset());+ w.writeDouble("strokeStyleMiterLimit", pen.miterLimit());++ QString linecap = "strokeStyleButtCap";+ QString linejoin = "strokeStyleMiterJoin";+ w.writeEnum("strokeStyleLineCapType", "strokeStyleLineCapType", linecap);+ w.writeEnum("strokeStyleLineJoinType", "strokeStyleLineJoinType", linejoin);++ // Other values are "strokeStyleAlignInside" and "strokeStyleAlignOutside" but we don't support these.+ w.writeEnum("strokeStyleLineAlignment", "strokeStyleLineAlignment", "strokeStyleAlignCenter");++ w.writeBoolean("strokeStyleScaleLock", false);+ w.writeBoolean("strokeStyleStrokeAdjust", false);++ w.enterList("strokeStyleLineDashSet");+ Q_FOREACH(qreal val, dashPattern) {+ w.writeUnitFloat("", "#Nne", val);+ }+ w.leaveList();++ w.writeEnum("strokeStyleBlendMode", "BlnM", "Nrml");+ w.writeUnitFloat("strokeStyleOpacity ", "#Prc", opacity * 100.0);++ // Color Descriptor+ // Others are "gradientLayer" and "patternLayer"+ w.enterDescriptor("strokeStyleContent", "", "solidColorLayer");+ w.writeColor("Clr ", KoColor());+ w.leaveDescriptor();++ w.writeDouble("strokeStyleResolution", resolution);+++ w.leaveDescriptor();++ return w.document();+ }+};+/*** @brief The PsdAdditionalLayerInfoBlock class implements the Additional Layer Information block*@@ -792,6 +1003,7 @@ public:QDomDocument textData;psd_vector_mask vectorMask;+ QDomDocument vectorStroke;psd_section_type sectionDividerType;QString sectionDividerBlendMode;diff --git a/libs/psdutils/asl/kis_asl_reader.cpp b/libs/psdutils/asl/kis_asl_reader.cppindex 39308f1db4..812e9b977c 100644--- a/libs/psdutils/asl/kis_asl_reader.cpp+++ b/libs/psdutils/asl/kis_asl_reader.cpp@@ -884,6 +884,48 @@ QDomDocument readTypeToolObjectSettingsImpl(QIODevice &device, QTransform &transreturn doc;}+template<psd_byte_order byteOrder = psd_byte_order::psdBigEndian>+QDomDocument readVectorStrokeImpl(QIODevice &device);++QDomDocument KisAslReader::readVectorStroke(QIODevice &device, psd_byte_order byteOrder)+{+ switch (byteOrder) {+ case psd_byte_order::psdLittleEndian:+ return readVectorStrokeImpl<psd_byte_order::psdLittleEndian>(device);+ default:+ return readVectorStrokeImpl(device);+ }+}++template<psd_byte_order byteOrder>+QDomDocument readVectorStrokeImpl(QIODevice &device)+{+ QDomDocument doc;++ if (device.isSequential()) {+ warnKrita << "WARNING: *** KisAslReader::readVectorStroke: the supplied"+ << "IO device is sequential. Chances are that"+ << "the fill config will *not* be loaded correctly!";+ }+ try {++ {+ quint32 descriptorVersion = GARBAGE_VALUE_MARK;+ SAFE_READ_SIGNATURE_EX(byteOrder, device, descriptorVersion, 16);+ }++ QDomElement root = doc.createElement("asl");+ doc.appendChild(root);++ Private::readDescriptor<byteOrder>(device, "", &root, &doc);++ } catch (KisAslReaderUtils::ASLParseException &e) {+ warnKrita << "WARNING: PSD: vmsk section:" << e.what();+ }++ return doc;+}+template<psd_byte_order byteOrder = psd_byte_order::psdBigEndian>QDomDocument readPsdSectionPatternImpl(QIODevice &device, qint64 bytesLeft);diff --git a/libs/psdutils/asl/kis_asl_reader.h b/libs/psdutils/asl/kis_asl_reader.hindex 4cb73d961f..0e752f8c3a 100644--- a/libs/psdutils/asl/kis_asl_reader.h+++ b/libs/psdutils/asl/kis_asl_reader.h@@ -22,6 +22,7 @@ public:static QDomDocument readLfx2PsdSection(QIODevice &device, psd_byte_order byteOrder = psd_byte_order::psdBigEndian);static QDomDocument readFillLayer(QIODevice &device, psd_byte_order byteOrder = psd_byte_order::psdBigEndian);static QDomDocument readTypeToolObjectSettings(QIODevice &device, QTransform &transform, psd_byte_order byteOrder = psd_byte_order::psdBigEndian);+ static QDomDocument readVectorStroke(QIODevice &device, psd_byte_order byteOrder = psd_byte_order::psdBigEndian);static QDomDocument readPsdSectionPattern(QIODevice &device, qint64 bytesLeft, psd_byte_order byteOrder = psd_byte_order::psdBigEndian);};diff --git a/plugins/impex/psd/psd_loader.cpp b/plugins/impex/psd/psd_loader.cppindex b18e1e0d1e..015f477269 100644--- a/plugins/impex/psd/psd_loader.cpp+++ b/plugins/impex/psd/psd_loader.cpp@@ -19,6 +19,7 @@#include <KoSvgTextShapeMarkupConverter.h>#include <kis_shape_layer.h>#include <KoPathShape.h>+#include <KoShapeStroke.h>#include <kis_shape_selection.h>#include <kis_annotation.h>@@ -315,54 +316,110 @@ KisImportExportErrorCode PSDLoader::decode(QIODevice &io)KisFilterConfigurationSP cfg;QDomDocument fillConfig;KisAslCallbackObjectCatcher catcher;++ KoPathShape *vectorMask = nullptr;+ if (layerRecord->infoBlocks.keys.contains("vmsk") || layerRecord->infoBlocks.keys.contains("vsms")) {+ double width = m_image->width() / m_image->xRes();+ double height = m_image->height() / m_image->yRes();+ vectorMask = layerRecord->constructPathShape(layerRecord->infoBlocks.vectorMask.path, width, height);+ vectorMask->setUserData(new KisShapeSelectionMarker);+ }if (layerRecord->infoBlocks.fillType == psd_fill_gradient) {cfg = KisGeneratorRegistry::instance()->value("gradient")->defaultConfiguration(resourceProxy.resourcesInterface());psd_layer_gradient_fill fill;fill.imageWidth = m_image->width();fill.imageHeight = m_image->height();- catcher.subscribeGradient("/null/Grad", std::bind(&psd_layer_gradient_fill::setGradient, &fill, _1));- catcher.subscribeBoolean("/null/Dthr", std::bind(&psd_layer_gradient_fill::setDither, &fill, _1));- catcher.subscribeBoolean("/null/Rvrs", std::bind(&psd_layer_gradient_fill::setReverse, &fill, _1));- catcher.subscribeUnitFloat("/null/Angl", "#Ang", std::bind(&psd_layer_gradient_fill::setAngle, &fill, _1));- catcher.subscribeEnum("/null/Type", "GrdT", std::bind(&psd_layer_gradient_fill::setType, &fill, _1));- catcher.subscribeBoolean("/null/Algn", std::bind(&psd_layer_gradient_fill::setAlignWithLayer, &fill, _1));- catcher.subscribeUnitFloat("/null/Scl ", "#Prc", std::bind(&psd_layer_gradient_fill::setScale, &fill, _1));- catcher.subscribePoint("/null/Ofst", std::bind(&psd_layer_gradient_fill::setOffset, &fill, _1));+ psd_layer_gradient_fill::setupCatcher("/null", catcher, &fill);KisAslXmlParser parser;parser.parseXML(layerRecord->infoBlocks.fillConfig, catcher);fillConfig = fill.getFillLayerConfig();+ if (vectorMask) {+ vectorMask->setBackground(fill.getBackground());+ }} else if (layerRecord->infoBlocks.fillType == psd_fill_pattern) {cfg = KisGeneratorRegistry::instance()->value("pattern")->defaultConfiguration(resourceProxy.resourcesInterface());psd_layer_pattern_fill fill;- catcher.subscribeUnitFloat("/null/Angl", "#Ang", std::bind(&psd_layer_pattern_fill::setAngle, &fill, _1));- catcher.subscribeUnitFloat("/null/Scl ", "#Prc", std::bind(&psd_layer_pattern_fill::setScale, &fill, _1));- catcher.subscribeBoolean("/null/Algn", std::bind(&psd_layer_pattern_fill::setAlignWithLayer, &fill, _1));- catcher.subscribePoint("/null/phase", std::bind(&psd_layer_pattern_fill::setOffset, &fill, _1));- catcher.subscribePatternRef("/null/Ptrn", std::bind(&psd_layer_pattern_fill::setPatternRef, &fill, _1, _2));+ psd_layer_pattern_fill::setupCatcher("/null", catcher, &fill);KisAslXmlParser parser;parser.parseXML(layerRecord->infoBlocks.fillConfig, catcher);fillConfig = fill.getFillLayerConfig();+ if (vectorMask) {+ vectorMask->setBackground(fill.getBackground());+ }} else {cfg = KisGeneratorRegistry::instance()->value("color")->defaultConfiguration(resourceProxy.resourcesInterface());psd_layer_solid_color fill;fill.cs = m_image->colorSpace();- catcher.subscribeColor("/null/Clr ", std::bind(&psd_layer_solid_color::setColor, &fill, _1));+ psd_layer_solid_color::setupCatcher("/null", catcher, &fill);KisAslXmlParser parser;parser.parseXML(layerRecord->infoBlocks.fillConfig, catcher);fillConfig = fill.getFillLayerConfig();+ if (vectorMask) {+ vectorMask->setBackground(fill.getBackground());+ }+ }+ if (vectorMask) {+ KisShapeLayerSP shapeLayer = new KisShapeLayer(m_doc->shapeController(), m_image, layerRecord->layerName, layerRecord->opacity);+++ if (!layerRecord->infoBlocks.vectorStroke.isNull()) {+ KoShapeStrokeSP stroke(new KoShapeStroke());+ psd_vector_stroke_data data;+ psd_layer_solid_color fill;+ psd_layer_gradient_fill grad;+ fill.cs = m_image->colorSpace();+ KisAslCallbackObjectCatcher strokeCatcher;+ psd_vector_stroke_data::setupCatcher("", strokeCatcher, &data);+ psd_layer_solid_color::setupCatcher("/strokeStyle/strokeStyleContent", strokeCatcher, &fill);+ psd_layer_gradient_fill::setupCatcher("/strokeStyle/strokeStyleContent", strokeCatcher, &grad);+ KisAslXmlParser parser;+ parser.parseXML(layerRecord->infoBlocks.vectorStroke, strokeCatcher);++ if (!data.fillEnabled) {+ vectorMask->setBackground(QSharedPointer<KoShapeBackground>(0));+ }+ if (data.strokeEnabled) {+ QColor c = fill.getBrush().color();+ c.setAlphaF(data.opacity);+ stroke->setColor(c);+ if (!grad.getBrush().isOpaque()) {+ stroke->setLineBrush(fill.getBrush());+ } else {+ stroke->setLineBrush(grad.getBrush());+ }+ } else {+ stroke->setColor(Qt::transparent);+ }+ stroke->setLineWidth(data.pen.widthF());+ stroke->setCapStyle(data.pen.capStyle());+ stroke->setJoinStyle(data.pen.joinStyle());+ stroke->setDashOffset(data.pen.dashOffset());+ stroke->setMiterLimit(data.pen.miterLimit());+ if (data.dashPattern.isEmpty()) {+ stroke->setLineStyle(Qt::SolidLine, QVector<double>());+ } else {+ stroke->setLineStyle(Qt::CustomDashLine, data.dashPattern);+ }++ vectorMask->setStroke(stroke);+ }++ shapeLayer->addShape(vectorMask);+ layer = shapeLayer;+ } else {+ cfg->fromXML(fillConfig.firstChildElement());+ cfg->createLocalResourcesSnapshot();+ KisGeneratorLayerSP genlayer = new KisGeneratorLayer(m_image, layerRecord->layerName, cfg, m_image->globalSelection());+ genlayer->setFilter(cfg);+ layer = genlayer;}- cfg->fromXML(fillConfig.firstChildElement());- cfg->createLocalResourcesSnapshot();- KisGeneratorLayerSP genlayer = new KisGeneratorLayer(m_image, layerRecord->layerName, cfg, m_image->globalSelection());- genlayer->setFilter(cfg);- layer = genlayer;} else if (!layerRecord->infoBlocks.textData.isNull()) {@@ -416,6 +473,7 @@ KisImportExportErrorCode PSDLoader::decode(QIODevice &io)Q_FOREACH (ChannelInfo *channelInfo, layerRecord->channelInfoRecords) {if (channelInfo->channelId < -1) {const KisGeneratorLayer *fillLayer = qobject_cast<KisGeneratorLayer *>(newLayer.data());+ const KisShapeLayer *shapeLayer = qobject_cast<KisShapeLayer *>(newLayer.data());KoPathShape *vectorMask = new KoPathShape();if (layerRecord->infoBlocks.keys.contains("vmsk") || layerRecord->infoBlocks.keys.contains("vsms")) {double width = m_image->width() / m_image->xRes();@@ -435,18 +493,20 @@ KisImportExportErrorCode PSDLoader::decode(QIODevice &io)fillLayer->internalSelection()->updateProjection();}} else {- KisTransparencyMaskSP mask = new KisTransparencyMask(m_image, i18n("Transparency Mask"));- mask->initSelection(newLayer);- if (!layerRecord->readMask(io, mask->paintDevice(), channelInfo)) {- dbgFile << "failed reading masks for layer: " << layerRecord->layerName << layerRecord->error;- }- if (hasVectorMask) {- KisShapeSelection* shapeSelection = new KisShapeSelection(m_doc->shapeController(), mask->selection());- mask->selection()->convertToVectorSelectionNoUndo(shapeSelection);- shapeSelection->addShape(vectorMask);- mask->selection()->updateProjection();+ if (!(shapeLayer && hasVectorMask)) {+ KisTransparencyMaskSP mask = new KisTransparencyMask(m_image, i18n("Transparency Mask"));+ mask->initSelection(newLayer);+ if (!layerRecord->readMask(io, mask->paintDevice(), channelInfo)) {+ dbgFile << "failed reading masks for layer: " << layerRecord->layerName << layerRecord->error;+ }+ if (hasVectorMask) {+ KisShapeSelection* shapeSelection = new KisShapeSelection(m_doc->shapeController(), mask->selection());+ mask->selection()->convertToVectorSelectionNoUndo(shapeSelection);+ shapeSelection->addShape(vectorMask);+ mask->selection()->updateProjection();+ }+ m_image->addNode(mask, newLayer);}- m_image->addNode(mask, newLayer);}}}