The implementation of painting of a dab and updating spacing. This does NOT need to update the timing information.
67{
68#ifdef BENCHMARK
69 QTime time;
70 time.start();
71#endif
72
75
77
80
83
86
87 int divide;
90 }
91 else {
93 }
94
96
97
98 qreal posX = info.
pos().x() - (gridWidth/2) + (cellWidth/2) - horizontalOffset;
99 qreal posY = info.
pos().y() - (gridHeight/2) + (cellHeight/2) - verticalOffset;
100
101
102 posX = posX - std::fmod(posX, cellWidth) + horizontalOffset;
103 posY = posY - std::fmod(posY, cellHeight) + verticalOffset;
104 const QRectF dabRect(posX , posY , cellWidth, cellHeight);
105 const QRect dabRectAligned = dabRect.toAlignedRect();
106
107 divide = qMax(1, divide);
108 const qreal yStep = cellHeight / (qreal)divide;
109 const qreal xStep = cellWidth / (qreal)divide;
110
111 QRectF tile;
113
114 QScopedPointer<KisCrossDeviceColorSampler> colorSampler;
117 }
118
122 if (vertBorder == horzBorder) {
124 }
125 else {
128 }
129 }
130
131 bool shouldColor = true;
132
135 }
136 for (
int y = 0;
y < (gridHeight)/yStep;
y++) {
137 for (
int x = 0;
x < (gridWidth)/xStep;
x++) {
138
139 tile = QRectF(dabRect.x() + x * xStep, dabRect.y() + y * yStep, xStep, yStep);
140 tile.adjust(vertBorder, horzBorder, -vertBorder, -horzBorder);
141 tile = tile.normalized();
142
143
144 if (shouldColor) {
146 colorSampler->sampleOldColor(tile.center().x(), tile.center().y(), color.data());
147 }
148
149
152
153 const quint8 *colors[2];
154 colors[0] = color.data();
156
157 qint16 colorWeights[2];
158 int MAX_16BIT = 255;
160
161 colorWeights[0] =
static_cast<quint16
>(
blend * MAX_16BIT);
162 colorWeights[1] =
static_cast<quint16
>((1.0 -
blend) * MAX_16BIT);
163 mixOp->
mixColors(colors, colorWeights, 2, color.data());
164 }
165
167 QHash<QString, QVariant> params;
175 transfo->
transform(color.data(), color.data() , 1);
176 }
177
180 color.setOpacity(alpha);
182 }
183
185 shouldColor = false;
186 }
188 }
189
190
192 case 0: {
194 break;
195 }
196 case 1: {
197
198
199 m_dab->
fill(tile.topLeft().x(), tile.topLeft().y(), tile.width(), tile.height(), color.data());
200 break;
201 }
202 case 2: {
204 break;
205 }
206 case 3: {
208 break;
209 }
210 case 4: {
212 break;
213 }
214 default: {
215 break;
216 }
217 }
218
221 }
222 }
223 }
224
228
229#ifdef BENCHMARK
230 int msec = time.elapsed();
231 dbgKrita << msec <<
" ms/dab " <<
"[average: " << m_total / (qreal)m_count <<
"]";
232 m_total += msec;
233 m_count++;
234#endif
236}
KisSpacingInformation computeSpacing(qreal lodScale) const
void fill(const QRect &rc, const KoColor &color)
const KoColorSpace * colorSpace() const
void paintEllipse(const QRectF &rect)
void drawDDALine(const QPointF &start, const QPointF &end)
void drawThickLine(const QPointF &start, const QPointF &end, int startWidth, int endWidth)
void renderMirrorMask(QRect rc, KisFixedPaintDeviceSP dab)
void setOpacityF(qreal opacity)
void bitBlt(qint32 dstX, qint32 dstY, const KisPaintDeviceSP srcDev, qint32 srcX, qint32 srcY, qint32 srcWidth, qint32 srcHeight)
void drawLine(const QPointF &start, const QPointF &end)
qreal generateNormalized() const
KoColorTransformation * createColorTransformation(const QString &id, const QHash< QString, QVariant > ¶meters) const
KoMixColorsOp * mixColorsOp
virtual void mixColors(const quint8 *const *colors, const qint16 *weights, int nColors, quint8 *dst, int weightSum=255) const =0
KisCrossDeviceColorSamplerImpl< SamplerTraitReal > KisCrossDeviceColorSampler
T blend(T src, T srcAlpha, T dst, T dstAlpha, T cfValue)
virtual KisPaintDeviceSP paintDevice() const =0
qreal grid_vertical_border
bool grid_pressure_division
qreal grid_horizontal_border
int shape
Ellipse, rectangle, line, pixel, anti-aliased pixel.