| 301 | |
| 302 | template<bool processR, bool processG, bool processB, bool processA> |
| 303 | void process(const OfxRectI& procWindow, const OfxPointD& rs) |
| 304 | { |
| 305 | unused(rs); |
| 306 | assert(nComponents == 1 || nComponents == 3 || nComponents == 4); |
| 307 | assert(_dstImg); |
| 308 | float unpPix[4] = {0.f, 0.f, 0.f, 0.f}; |
| 309 | float tmpPix[4] = {0.f, 0.f, 0.f, 0.f}; |
| 310 | for (int y = procWindow.y1; y < procWindow.y2; y++) { |
| 311 | if ( _effect.abort() ) { |
| 312 | break; |
| 313 | } |
| 314 | |
| 315 | PIX *dstPix = (PIX *) _dstImg->getPixelAddress(procWindow.x1, y); |
| 316 | |
| 317 | for (int x = procWindow.x1; x < procWindow.x2; x++) { |
| 318 | const PIX *srcPix = (const PIX *) (_srcImg ? _srcImg->getPixelAddress(x, y) : 0); |
| 319 | ofxsUnPremult<PIX, nComponents, maxValue>(srcPix, unpPix, _premult, _premultChannel); |
| 320 | for (int c = 0; c < 4; ++c) { // tmpPix has 4 components |
| 321 | if ( ( processR && (c == 0) ) || |
| 322 | ( processG && ( c == 1) ) || |
| 323 | ( processB && ( c == 2) ) || |
| 324 | ( processA && ( c == 3) ) ) { |
| 325 | tmpPix[c] = (float)apply(c, unpPix[0], unpPix[1], unpPix[2], unpPix[3]); |
| 326 | } else { |
| 327 | tmpPix[c] = unpPix[c]; |
| 328 | } |
| 329 | } |
| 330 | ofxsPremultMaskMixPix<PIX, nComponents, maxValue, true>(tmpPix, _premult, _premultChannel, x, y, srcPix, _doMasking, _maskImg, (float)_mix, _maskInvert, dstPix); |
| 331 | // copy back original values from unprocessed channels |
| 332 | if (nComponents == 1) { |
| 333 | if (!processA) { |
| 334 | dstPix[0] = srcPix ? srcPix[0] : PIX(); |
| 335 | } |
| 336 | } else if ( (nComponents == 3) || (nComponents == 4) ) { |
| 337 | if (!processR) { |
| 338 | dstPix[0] = srcPix ? srcPix[0] : PIX(); |
| 339 | } |
| 340 | if (!processG) { |
| 341 | dstPix[1] = srcPix ? srcPix[1] : PIX(); |
| 342 | } |
| 343 | if (!processB) { |
| 344 | dstPix[2] = srcPix ? srcPix[2] : PIX(); |
| 345 | } |
| 346 | if ( !processA && (nComponents == 4) ) { |
| 347 | dstPix[3] = srcPix ? srcPix[3] : PIX(); |
| 348 | } |
| 349 | } |
| 350 | // increment the dst pixel |
| 351 | dstPix += nComponents; |
| 352 | } |
| 353 | } |
| 354 | } // process |
| 355 | }; |
| 356 | |
| 357 |
no test coverage detected