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
73{
75
77 if (!brush)
79
80 if (!brush->canPaintFor(info))
82
86 }
87
89
92 }
93 else {
95
100 if (!externalSourceNode || !externalSourceNode->
graphListener()) {
101 externalSourceNode =
m_node;
102 }
103
104 realSourceDevice = externalSourceNode->
projection();
105 }
106
108
110
112
115
116
118 static KoColor color(Qt::black, cs);
119
120 QRect dstRect;
123 shape,
124 info, 1.0,
125 &dstRect);
126
128
129
130 QPoint srcPoint;
131
134 }
135 else {
136 QPointF hotSpot = brush->hotSpot(shape, info);
138 }
139
140 qint32 sw = dstRect.width();
141 qint32 sh = dstRect.height();
142
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 {
185 copyPainter.bitBltOldData(0, 0, realSourceDevice, srcPoint.x(), srcPoint.y(), sw, sh);
186 copyPainter.end();
187 }
188
189
191 QRect healRect(dstRect);
192
193 const bool smallWidth = healRect.width() < 3;
194 const bool smallHeight = healRect.height() < 3;
195
196 if (smallWidth || smallHeight) {
197 healRect.adjust(-1, -1, 1, 1);
198 }
199
200 const int healSW = healRect.width();
201 const int healSH = healRect.height();
202
203
204 quint16 srcData[4];
205 quint16 tmpData[4];
206 QScopedArrayPointer<qreal> matrix(new qreal[ 3 * healSW * healSH ]);
207
212 qreal* matrixIt = matrix.
data();
213 for (int j = 0; j < healSH; j++) {
214 for (int i = 0; i < healSW; i++) {
216 tmpCs->
toLabA16(tmpIt->rawData(), (quint8*)tmpData, 1);
217
218 for (int k = 0; k < 3; k++) {
219 matrixIt[k] = srcData[k] / (qreal)qMax((int)tmpData [k], 1);
220 }
222 tmpIt->nextPixel();
223 matrixIt += 3;
224 }
226 tmpIt->nextRow();
227 }
228
229 {
230 int iter = 0;
231 qreal err;
232 QScopedArrayPointer<qreal> solution(new qreal[ 3 * healSW * healSH ]);
233
234 do {
236
237 solution.swap(matrix);
238
239 iter++;
240 } while (err > 0.00001 && iter < 100);
241 }
242
243
245 matrixIt = &matrix[0];
246 for (int j = 0; j < healSH; j++) {
247 for (int i = 0; i < healSW; i++) {
248 tmpCs->
toLabA16(tmpIt2->rawData(), (quint8*)tmpData, 1);
249
250 for (int k = 0; k < 3; k++) {
251 tmpData[k] = (int)
CLAMP(matrixIt[k] * qMax((
int) tmpData[k], 1), 0, 65535);
252 }
253 tmpCs->
fromLabA16((quint8*)tmpData, tmpIt2->rawData(), 1);
254 tmpIt2->nextPixel();
255 matrixIt += 3;
256 }
257 tmpIt2->nextRow();
258 }
259 }
260
263 dstRect.width(),
264 dstRect.height());
265
268
270}
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()