| 369 | |
| 370 | template<bool processR, bool processG, bool processB, bool processA> |
| 371 | void process(const OfxRectI& procWindow, const OfxPointD& rs) |
| 372 | { |
| 373 | unused(rs); |
| 374 | assert( (!processR && !processG && !processB) || (nComponents == 3 || nComponents == 4) ); |
| 375 | assert( !processA || (nComponents == 1 || nComponents == 4) ); |
| 376 | assert(nComponents == 3 || nComponents == 4); |
| 377 | assert(_dstImg); |
| 378 | float unpPix[4] = {0.f, 0.f, 0.f, 0.f}; |
| 379 | float tmpPix[4] = {0.f, 0.f, 0.f, 0.f}; |
| 380 | for (int y = procWindow.y1; y < procWindow.y2; y++) { |
| 381 | if ( _effect.abort() ) { |
| 382 | break; |
| 383 | } |
| 384 | |
| 385 | PIX *dstPix = (PIX *) _dstImg->getPixelAddress(procWindow.x1, y); |
| 386 | |
| 387 | for (int x = procWindow.x1; x < procWindow.x2; x++) { |
| 388 | const PIX *srcPix = (const PIX *) (_srcImg ? _srcImg->getPixelAddress(x, y) : 0); |
| 389 | ofxsUnPremult<PIX, nComponents, maxValue>(srcPix, unpPix, _premult, _premultChannel); |
| 390 | double t_r = unpPix[0]; |
| 391 | double t_g = unpPix[1]; |
| 392 | double t_b = unpPix[2]; |
| 393 | double t_a = unpPix[3]; |
| 394 | grade<processR, processG, processB, processA>(&t_r, &t_g, &t_b, &t_a); |
| 395 | tmpPix[0] = (float)t_r; |
| 396 | tmpPix[1] = (float)t_g; |
| 397 | tmpPix[2] = (float)t_b; |
| 398 | tmpPix[3] = (float)t_a; |
| 399 | ofxsPremultMaskMixPix<PIX, nComponents, maxValue, true>(tmpPix, _premult, _premultChannel, x, y, srcPix, _doMasking, _maskImg, (float)_mix, _maskInvert, dstPix); |
| 400 | // copy back original values from unprocessed channels |
| 401 | if (nComponents == 1) { |
| 402 | if (!processA) { |
| 403 | dstPix[0] = srcPix ? srcPix[0] : PIX(); |
| 404 | } |
| 405 | } else if ( (nComponents == 3) || (nComponents == 4) ) { |
| 406 | if (!processR) { |
| 407 | dstPix[0] = srcPix ? srcPix[0] : PIX(); |
| 408 | } |
| 409 | if (!processG) { |
| 410 | dstPix[1] = srcPix ? srcPix[1] : PIX(); |
| 411 | } |
| 412 | if (!processB) { |
| 413 | dstPix[2] = srcPix ? srcPix[2] : PIX(); |
| 414 | } |
| 415 | if ( !processA && (nComponents == 4) ) { |
| 416 | dstPix[3] = srcPix ? srcPix[3] : PIX(); |
| 417 | } |
| 418 | } |
| 419 | // increment the dst pixel |
| 420 | dstPix += nComponents; |
| 421 | } |
| 422 | } |
| 423 | } // process |
| 424 | }; |
| 425 | |
| 426 |
no test coverage detected