The implementation of painting of a dab and updating spacing. This does NOT need to update the timing information.
The saved layer might have been deleted by then, so check if it still belongs to a graph
74{
76
78 if (!brush)
80
81 if (!brush->canPaintFor(info))
83
87 }
88
90
93 }
94 else {
96
101 if (!externalSourceNode || !externalSourceNode->
graphListener()) {
102 externalSourceNode =
m_node;
103 }
104
105 realSourceDevice = externalSourceNode->
projection();
106 }
107
109
111
113
116
117
119 static KoColor color(Qt::black, cs);
120
121 QRect dstRect;
124 shape,
125 info, 1.0,
126 &dstRect);
127
129
130
131 QPoint srcPoint;
132
135 }
136 else {
137 QPointF hotSpot = brush->hotSpot(shape, info);
139 }
140
141 qint32 sw = dstRect.width();
142 qint32 sh = dstRect.height();
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183 {
186 copyPainter.bitBltOldData(0, 0, realSourceDevice, srcPoint.x(), srcPoint.y(), sw, sh);
187 copyPainter.end();
188 }
189
190
192 QRect healRect(dstRect);
193
194 const bool smallWidth = healRect.width() < 3;
195 const bool smallHeight = healRect.height() < 3;
196
197 if (smallWidth || smallHeight) {
198 healRect.adjust(-1, -1, 1, 1);
199 }
200
201 const int healSW = healRect.width();
202 const int healSH = healRect.height();
203
204
205 quint16 srcData[4];
206 quint16 tmpData[4];
207 std::unique_ptr<qreal[]> matrix(new qreal[ 3 * healSW * healSH ]);
208
213 qreal* matrixIt = matrix.get();
214 for (int j = 0; j < healSH; j++) {
215 for (int i = 0; i < healSW; i++) {
217 tmpCs->
toLabA16(tmpIt->rawData(), (quint8*)tmpData, 1);
218
219 for (int k = 0; k < 3; k++) {
220 matrixIt[k] = srcData[k] / (qreal)qMax((int)tmpData [k], 1);
221 }
223 tmpIt->nextPixel();
224 matrixIt += 3;
225 }
227 tmpIt->nextRow();
228 }
229
230 {
231 int iter = 0;
232 qreal err;
233 std::unique_ptr<qreal[]> solution(new qreal[ 3 * healSW * healSH ]);
234
235 do {
237
238 solution.swap(matrix);
239
240 iter++;
241 } while (err > 0.00001 && iter < 100);
242 }
243
244
246 matrixIt = &matrix[0];
247 for (int j = 0; j < healSH; j++) {
248 for (int i = 0; i < healSW; i++) {
249 tmpCs->
toLabA16(tmpIt2->rawData(), (quint8*)tmpData, 1);
250
251 for (int k = 0; k < 3; k++) {
252 tmpData[k] = (int)
CLAMP(matrixIt[k] * qMax((
int) tmpData[k], 1), 0, 65535);
253 }
254 tmpCs->
fromLabA16((quint8*)tmpData, tmpIt2->rawData(), 1);
255 tmpIt2->nextPixel();
256 matrixIt += 3;
257 }
258 tmpIt2->nextRow();
259 }
260 }
261
264 dstRect.width(),
265 dstRect.height());
266
269
271}
const QString COMPOSITE_COPY
virtual const quint8 * oldRawData() const =0
virtual bool nextPixel()=0
KisSpacingInformation effectiveSpacing(qreal scale) const
bool checkSizeTooSmall(qreal scale)
bool needSeparateOriginal() const
KisFixedPaintDeviceSP fetchDab(const KoColorSpace *cs, KisColorSource *colorSource, const QPointF &cursorPoint, KisDabShape const &, const KisPaintInformation &info, qreal softnessFactor, QRect *dstDabRect, qreal lightnessStrength=1.0)
KisNodeWSP sourceNode() const
bool m_duplicateStartIsSet
KisPaintDeviceSP projection() const
void apply(KisPainter *painter, const KisPaintInformation &info) const
KisHLineIteratorSP createHLineIteratorNG(qint32 x, qint32 y, qint32 w)
const KoColorSpace * colorSpace() const
KisHLineConstIteratorSP createHLineConstIteratorNG(qint32 x, qint32 y, qint32 w) const
void renderMirrorMaskSafe(QRect rc, KisFixedPaintDeviceSP dab, bool preserveDab)
void bitBltWithFixedSelection(qint32 dstX, qint32 dstY, const KisPaintDeviceSP srcDev, const KisFixedPaintDeviceSP selection, qint32 selX, qint32 selY, qint32 srcX, qint32 srcY, qint32 srcWidth, qint32 srcHeight)
qreal apply(const KisPaintInformation &info) const
qreal apply(const KisPaintInformation &info) const
virtual void toLabA16(const quint8 *src, quint8 *dst, quint32 nPixels) const
virtual void fromLabA16(const quint8 *src, quint8 *dst, quint32 nPixels) const
qreal minimizeEnergy(const qreal *m, qreal *sol, int w, int h)
virtual KisPaintDeviceSP projection() const =0
KisNodeGraphListener * graphListener
KisFixedPaintDeviceSP dab
static KoColorSpaceRegistry * instance()
const KoColorSpace * alpha8()