47 if (!
p->m_viewManager)
50 KisSelectionSP selection =
p->m_viewManager->image()->globalSelection();
54 return selectionRect.size();
65 p->m_viewManager->activeNode());
66 if (nodes->isEmpty()) {
70 switch (
p->m_inputMode) {
80 const auto activeLayer = nodes->last();
86 if (activeLayer && activeLayer->paintDevice()) {
87 const QSize layerSize = activeLayer->exactBounds().size();
88 const QSize imageSize = activeLayer->image()->bounds().size();
89 size = size.expandedTo(layerSize).expandedTo(imageSize);
95 for (
auto &node : *nodes) {
96 if (node && node->paintDevice()) {
102 const QSize layerSize = node->exactBounds().size();
103 const QSize imageSize = node->image()->bounds().size();
104 size = size.expandedTo(layerSize).expandedTo(imageSize);
111 warnPlugins <<
"Inputmode" <<
static_cast<int>(
p->m_inputMode)
112 <<
"is not supported by GMic anymore";
117 <<
"Inputmode" <<
static_cast<int>(
p->m_inputMode)
118 <<
"must be specified by GMic or is not implemented in Krita";
133 if (!
p->m_viewManager)
136 if (!
p->m_viewManager->image()->tryBarrierLock(
true))
return {};
138 KisImageBarrierLock lock(
p->m_viewManager->image(), std::adopt_lock);
142 dbgPlugins <<
"prepareCroppedImages()" << message << rc << inputMode;
147 p->m_viewManager->activeNode());
148 if (nodes->isEmpty()) {
152 for (
auto &node : *nodes) {
153 if (node && node->paintDevice()) {
154 KisSelectionSP selection =
p->m_viewManager->image()->globalSelection();
156 const QRect cropRect = [&]() {
161 const QRect nodeBounds = node->exactBounds();
162 const QRect imageBounds = node->image()->bounds();
164 if (imageBounds.contains(nodeBounds)) {
167 return nodeBounds.united(imageBounds);
172 dbgPlugins <<
"Converting node" << node->name() << cropRect;
175 const QRect resultRect = mappedRect.toAlignedRect();
177 QString noParenthesisName(node->name());
178 noParenthesisName.replace(QChar(
'('), QChar(21)).replace(QChar(
')'), QChar(22));
182 const QString name = QString(
"mode(%1),opacity(%2),pos(%3,%4),name(%5)")
184 .arg(node->percentOpacity())
187 .arg(noParenthesisName);
189 auto m = KisQMicImageSP::create(name, resultRect.width(), resultRect.height(), 4);
190 p->m_sharedMemorySegments << m;
193 QMutexLocker lock(&m->m_mutex);
221 errPlugins <<
"Requested mode" <<
static_cast<int>(
p->m_outputMode) <<
"which is not implemented yet";
225 dbgPlugins <<
"slotStartApplicator();" << layers;
226 if (!
p->m_viewManager)
229 dbgPlugins <<
"Got" << layers.size() <<
"gmic images";
238 p->m_viewManager->activeNode());
250 dbgPlugins <<
"Created applicator " << &applicator;
253 KisSelectionSP selection =
p->m_viewManager->image()->globalSelection();
257 layerSize = QRect(0, 0,
p->m_viewManager->image()->width(),
p->m_viewManager->image()->height());
270 p->m_viewManager->image(),