122 {
123
124 Q_UNUSED(self);
125 Q_UNUSED(lock_alpha);
126 const float one_over_radius2 = 1.0f / (radius * radius);
128 const float cs = cos(angle_rad);
129 const float sn =
sin(angle_rad);
130 float normal_mode;
131 float segment1_slope;
132 float segment2_slope;
133 float r_aa_start;
134
135 hardness =
CLAMP (hardness, 0.0f, 1.0f);
136 segment1_slope = -(1.0f / hardness - 1.0f);
137 segment2_slope = -hardness / (1.0f - hardness);
138 aspect_ratio =
max(1.0f, aspect_ratio);
139
140 r_aa_start = radius - 1.0f;
141 r_aa_start =
max(r_aa_start, 0.0f);
142 r_aa_start = (r_aa_start * r_aa_start) / aspect_ratio;
143
144 normal_mode = opaque * (1.0f - colorize);
145 colorize = opaque * colorize;
146
147 const QPoint pt = QPoint(x - radius - 1, y - radius - 1);
148 const QSize sz = QSize(2 * (radius+1), 2 * (radius+1));
149
150 const QRect dabRectAligned = QRect(pt, sz);
151 const QPointF center = QPointF(x, y);
152
157
159
163
164
167
168
169
170
172
173
174 while(it.nextPixel()) {
175
176
177 *maskPointer = 0;
178
179 QPoint pt(it.x(), it.y());
180
181 if(outer.fadeSq(pt) > 1.0f) {
182 maskPointer++;
183 continue;
184 }
185
186 float rr, base_alpha, alpha, dst_alpha,
r, g,
b, a;
187
188 if (radius < 3.0) {
190 }
191 else {
192 rr =
calculate_rr (it.x(), it.y(), x, y, aspect_ratio, sn, cs, one_over_radius2);
193 }
194
196
198 alpha = base_alpha * normal_mode;
199
200
201 if (alpha > minValue) {
202 *maskPointer = (quint8)(maskUnitValue);
203 }
204
205 channelType* nativeArray = reinterpret_cast<channelType*>(it.rawData());
206
211
212 if (unitValue == 1.0f) {
214 }
215
216 a = alpha * (color_a - dst_alpha) + dst_alpha;
217
218 if (eraser) {
219 alpha = 1 - (opaque*base_alpha);
220 a = dst_alpha * alpha ;
221 } else {
222 if (a > 0.0f) {
223 float src_term = (alpha * color_a) / a;
224 float dst_term = 1.0f - src_term;
225 r = color_r * src_term +
r * dst_term;
226 g = color_g * src_term + g * dst_term;
227 b = color_b * src_term +
b * dst_term;
228 }
229
230 if (colorize > 0.0f && base_alpha > 0.0f) {
231
232 alpha = base_alpha * colorize;
233 a = alpha + dst_alpha - alpha * dst_alpha;
234
235 if (a > 0.0f) {
236
237 float pixel_h, pixel_s, pixel_l, out_h, out_s, out_l;
238 float out_r =
r, out_g = g, out_b =
b;
239
240 float src_term = alpha / a;
241 float dst_term = 1.0f - src_term;
242
243 RGBToHSL(color_r, color_g, color_b, &pixel_h, &pixel_s, &pixel_l);
244 RGBToHSL(out_r, out_g, out_b, &out_h, &out_s, &out_l);
245
246 out_h = pixel_h;
247 out_s = pixel_s;
248
249 HSLToRGB(out_h, out_s, out_l, &out_r, &out_g, &out_b);
250
251 r = (float)out_r * src_term + r * dst_term;
252 g = (float)out_g * src_term + g * dst_term;
253 b = (float)out_b * src_term + b * dst_term;
254 }
255 }
256 }
257
258 if (unitValue == 1.0f) {
260 }
265
266 maskPointer++;
267 }
268
269
270 m_tempPainter->bitBltWithFixedSelection(dabRectAligned.x(), dabRectAligned.y(),
m_dab,
m_maskDevice, dabRectAligned.x(), dabRectAligned.y(), dabRectAligned.x(), dabRectAligned.y(), dabRectAligned.width(), dabRectAligned.height());
275 return 1;
276}
void RGBToHSL(float r, float g, float b, float *h, float *s, float *l)
void HSLToRGB(float h, float sl, float l, float *r, float *g, float *b)
const QString COMPOSITE_ERASE
void setRect(const QRect &rc)
void lazyGrowBufferWithoutInitialization()
float calculate_alpha_for_rr(float rr, float hardness, float slope1, float slope2)
float calculate_rr_antialiased(int xp, int yp, float x, float y, float aspect_ratio, float sn, float cs, float one_over_radius2, float r_aa_start)
float calculate_rr(int xp, int yp, float x, float y, float aspect_ratio, float sn, float cs, float one_over_radius2)
void writeRects(const QVector< QRect > &rects, int index=0)
void readRects(const QVector< QRect > &rects)
void addDirtyRects(const QVector< QRect > &rects)
static _Tdst scaleToA(_T a)
T kisDegreesToRadians(T degrees)
PROPAGATE_CONST_CONSTEXPR void swap(propagate_const< T > &pt, propagate_const< T > &pu) noexcept(noexcept(swap(declval< T & >(), declval< T & >())))
constexpr std::enable_if< sizeof...(values)==0, size_t >::type max()