# Changeset View

Changeset View

# Standalone View

Standalone View

# libs/image/kis_brush_mask_applicator_factories.cpp

Context not available. | |||||

21 | #include "kis_circle_mask_generator.h" | 21 | #include "kis_circle_mask_generator.h" | ||
---|---|---|---|---|---|

22 | #include "kis_circle_mask_generator_p.h" | 22 | #include "kis_circle_mask_generator_p.h" | ||

23 | #include "kis_gauss_circle_mask_generator_p.h" | 23 | #include "kis_gauss_circle_mask_generator_p.h" | ||

24 | #include "kis_curve_circle_mask_generator_p.h" | ||||

25 | | ||||

24 | #include "kis_brush_mask_applicators.h" | 26 | #include "kis_brush_mask_applicators.h" | ||

25 | #include "kis_brush_mask_applicator_base.h" | 27 | #include "kis_brush_mask_applicator_base.h" | ||

26 | 28 | | |||

Context not available. | |||||

51 | return new KisBrushMaskVectorApplicator<KisGaussCircleMaskGenerator,Vc::CurrentImplementation::current()>(maskGenerator); | 53 | return new KisBrushMaskVectorApplicator<KisGaussCircleMaskGenerator,Vc::CurrentImplementation::current()>(maskGenerator); | ||

52 | } | 54 | } | ||

53 | 55 | | |||

56 | | ||||

57 | template<> | ||||

58 | template<> | ||||

59 | MaskApplicatorFactory<KisCurveCircleMaskGenerator, KisBrushMaskVectorApplicator>::ReturnType | ||||

60 | MaskApplicatorFactory<KisCurveCircleMaskGenerator, KisBrushMaskVectorApplicator>::create<Vc::CurrentImplementation::current()>(ParamType maskGenerator) | ||||

61 | { | ||||

62 | return new KisBrushMaskVectorApplicator<KisCurveCircleMaskGenerator,Vc::CurrentImplementation::current()>(maskGenerator); | ||||

63 | } | ||||

64 | | ||||

65 | | ||||

54 | #if defined HAVE_VC | 66 | #if defined HAVE_VC | ||

55 | 67 | | |||

56 | struct KisCircleMaskGenerator::FastRowProcessor | 68 | struct KisCircleMaskGenerator::FastRowProcessor | ||

Context not available. | |||||

247 | } | 259 | } | ||

248 | } | 260 | } | ||

249 | 261 | | |||

262 | struct KisCurveCircleMaskGenerator::FastRowProcessor | ||||

263 | { | ||||

264 | FastRowProcessor(KisCurveCircleMaskGenerator *maskGenerator) | ||||

265 | : d(maskGenerator->d.data()) {} | ||||

266 | | ||||

267 | template<Vc::Implementation _impl> | ||||

268 | void process(float* buffer, int width, float y, float cosa, float sina, | ||||

269 | float centerX, float centerY); | ||||

270 | | ||||

271 | KisCurveCircleMaskGenerator::Private *d; | ||||

272 | }; | ||||

273 | | ||||

274 | | ||||

275 | template<> void KisCurveCircleMaskGenerator:: | ||||

276 | FastRowProcessor::process<Vc::CurrentImplementation::current()>(float* buffer, int width, float y, float cosa, float sina, | ||||

277 | float centerX, float centerY) | ||||

278 | { | ||||

279 | const bool antialiasOn = d->fadeMaker.getAliasingEnabled(); | ||||

280 | | ||||

281 | float y_ = y - centerY; | ||||

282 | float sinay_ = sina * y_; | ||||

283 | float cosay_ = cosa * y_; | ||||

284 | | ||||

285 | float* bufferPointer = buffer; | ||||

286 | | ||||

287 | qreal* curveDataPointer = d->curveData.data(); | ||||

288 | | ||||

289 | Vc::float_v currentIndices = Vc::float_v::IndexesFromZero(); | ||||

290 | | ||||

291 | Vc::float_v increment((float)Vc::float_v::size()); | ||||

292 | Vc::float_v vCenterX(centerX); | ||||

293 | | ||||

294 | Vc::float_v vCosa(cosa); | ||||

295 | Vc::float_v vSina(sina); | ||||

296 | Vc::float_v vCosaY_(cosay_); | ||||

297 | Vc::float_v vSinaY_(sinay_); | ||||

298 | | ||||

299 | Vc::float_v vYCoeff(d->ycoef); | ||||

300 | Vc::float_v vXCoeff(d->xcoef); | ||||

301 | Vc::float_v vCurveResolution(d->curveResolution); | ||||

302 | | ||||

303 | Vc::float_v vCurvedData(Vc::Zero); | ||||

304 | Vc::float_v vCurvedData1(Vc::Zero); | ||||

305 | | ||||

306 | Vc::float_v vFadeRadius(d->fadeMaker.getRadius()); | ||||

307 | Vc::float_v vFadeStartValue(d->fadeMaker.getFadeStartValue()); | ||||

308 | Vc::float_v vFadeAFadeStart(d->fadeMaker.getAntialiasingFadeStart()); | ||||

309 | Vc::float_v vFadeAFadeCoeff(d->fadeMaker.getAntialiasingFadeCoeff()); | ||||

310 | | ||||

311 | Vc::float_v vOne(Vc::One); | ||||

312 | Vc::float_v vZero(Vc::Zero); | ||||

313 | Vc::float_v vValMax(255.f); | ||||

314 | | ||||

315 | for (int i=0; i < width; i+= Vc::float_v::size()){ | ||||

316 | | ||||

317 | Vc::float_v x_ = currentIndices - vCenterX; | ||||

318 | | ||||

319 | Vc::float_v xr = x_ * vCosa - vSinaY_; | ||||

320 | Vc::float_v yr = x_ * vSina + vCosaY_; | ||||

321 | | ||||

322 | Vc::float_v dist = pow2(xr * vXCoeff) + pow2(yr * vYCoeff); | ||||

323 | | ||||

324 | // BEGIN FadeMaker needFade vectorized | ||||

325 | // follow fademaker rules for outsideMask | ||||

326 | Vc::float_m outsideMask = dist > vFadeRadius; | ||||

327 | dist(outsideMask) = vOne; | ||||

328 | | ||||

329 | Vc::float_m fadeStartMask(false); | ||||

330 | // if antialias is off, do not process | ||||

331 | if(antialiasOn){ | ||||

332 | fadeStartMask = dist > vFadeAFadeStart; | ||||

333 | dist((outsideMask ^ fadeStartMask) & fadeStartMask) = (vFadeStartValue + (dist - vFadeAFadeStart) * vFadeAFadeCoeff) / vValMax; | ||||

334 | } | ||||

335 | | ||||

336 | Vc::float_m excludeMask = outsideMask | fadeStartMask; | ||||

337 | | ||||

338 | if (!excludeMask.isFull()) { | ||||

339 | Vc::float_v valDist = dist * vCurveResolution; | ||||

340 | // truncate | ||||

341 | Vc::SimdArray<quint16,Vc::float_v::size()> vAlphaValue(valDist); | ||||

342 | Vc::float_v vFloatAlphaValue = vAlphaValue; | ||||

343 | | ||||

344 | Vc::float_v alphaValueF = valDist - vFloatAlphaValue; | ||||

345 | | ||||

346 | vCurvedData.gather(curveDataPointer,vAlphaValue); | ||||

347 | vCurvedData1.gather(curveDataPointer,vAlphaValue + 1); | ||||

348 | // Vc::float_v vCurvedData1(curveDataPointer,vAlphaValue + 1); | ||||

349 | | ||||

350 | // vAlpha | ||||

351 | Vc::float_v fullFade = ( | ||||

352 | (1.0f - alphaValueF) * vCurvedData + | ||||

353 | alphaValueF * vCurvedData1); | ||||

354 | | ||||

355 | Vc::float_m mask; | ||||

356 | // Mask in the inner circe of the mask | ||||

357 | mask = fullFade < vZero; | ||||

358 | fullFade.setZero(mask); | ||||

359 | | ||||

360 | // Mask outer circle of mask | ||||

361 | mask = fullFade >= vOne; | ||||

362 | Vc::float_v vFade = (1.0f - fullFade); | ||||

363 | vFade.setZero(mask); | ||||

364 | | ||||

365 | // return original dist values before vFade transform | ||||

366 | vFade(excludeMask) = dist; | ||||

367 | vFade.store(bufferPointer, Vc::Aligned); | ||||

368 | | ||||

369 | } else { | ||||

370 | dist.store(bufferPointer, Vc::Aligned); | ||||

371 | } | ||||

372 | currentIndices = currentIndices + increment; | ||||

373 | | ||||

374 | bufferPointer += Vc::float_v::size(); | ||||

375 | } | ||||

376 | } | ||||

377 | | ||||

250 | #endif /* defined HAVE_VC */ | 378 | #endif /* defined HAVE_VC */ | ||

Context not available. |