| 2555 | |
| 2556 | template <typename PIX, int maxValue, bool opaque, bool applyMatte, int rOffset, int gOffset, int bOffset> |
| 2557 | void |
| 2558 | scaleToTexture32bitsGeneric(const RectI& roi, |
| 2559 | const RenderViewerArgs & args, |
| 2560 | int nComps, |
| 2561 | const UpdateViewerParams::CachedTile& tile, |
| 2562 | float *tileBuffer) |
| 2563 | { |
| 2564 | const size_t pixelSize = sizeof(PIX); |
| 2565 | const bool luminance = (args.channels == eDisplayChannelsY); |
| 2566 | const int dstRowElements = args.renderOnlyRoI ? tile.rect.width() * 4 : args.tileRowElements; |
| 2567 | Image::ReadAccess acc = Image::ReadAccess( args.inputImage.get() ); |
| 2568 | Image::ReadAccessPtr matteAcc; |
| 2569 | |
| 2570 | if (applyMatte) { |
| 2571 | matteAcc = std::make_shared<Image::ReadAccess>( args.matteImage.get() ); |
| 2572 | } |
| 2573 | |
| 2574 | assert( (args.renderOnlyRoI && roi.x1 >= tile.rect.x1 && roi.x2 <= tile.rect.x2 && roi.y1 >= tile.rect.y1 && roi.y2 <= tile.rect.y2) || (!args.renderOnlyRoI && tile.rect.x1 >= roi.x1 && tile.rect.x2 <= roi.x2 && tile.rect.y1 >= roi.y1 && tile.rect.y2 <= roi.y2) ); |
| 2575 | assert(tile.rect.x2 > tile.rect.x1); |
| 2576 | |
| 2577 | float* dst_pixels; |
| 2578 | if (args.renderOnlyRoI) { |
| 2579 | dst_pixels = tileBuffer + (roi.y1 - tile.rect.y1) * dstRowElements + (roi.x1 - tile.rect.x1) * 4; |
| 2580 | } else { |
| 2581 | dst_pixels = tileBuffer + (tile.rect.y1 - tile.rectRounded.y1) * dstRowElements + (tile.rect.x1 - tile.rectRounded.x1) * 4; |
| 2582 | } |
| 2583 | |
| 2584 | const int y1 = args.renderOnlyRoI ? roi.y1 : tile.rect.y1; |
| 2585 | const int y2 = args.renderOnlyRoI ? roi.y2 : tile.rect.y2; |
| 2586 | const int x1 = args.renderOnlyRoI ? roi.x1 : tile.rect.x1; |
| 2587 | const int x2 = args.renderOnlyRoI ? roi.x2 : tile.rect.x2; |
| 2588 | const float* src_pixels = (const float*)acc.pixelAt(x1, y1); |
| 2589 | const int srcRowElements = (const int)args.inputImage->getRowElements(); |
| 2590 | |
| 2591 | for (int y = y1; y < y2; |
| 2592 | ++y, |
| 2593 | dst_pixels += dstRowElements) { |
| 2594 | for (int x = 0; x < (x2 - x1); |
| 2595 | ++x) { |
| 2596 | double r = 0.; |
| 2597 | double g = 0.; |
| 2598 | double b = 0.; |
| 2599 | double a = 0.; |
| 2600 | |
| 2601 | if (nComps >= 4) { |
| 2602 | r = (src_pixels && rOffset < nComps) ? src_pixels[x * nComps + rOffset] : 0.; |
| 2603 | g = (src_pixels && gOffset < nComps) ? src_pixels[x * nComps + gOffset] : 0.; |
| 2604 | b = (src_pixels && bOffset < nComps) ? src_pixels[x * nComps + bOffset] : 0.; |
| 2605 | if (opaque) { |
| 2606 | a = 1.; |
| 2607 | } else { |
| 2608 | a = src_pixels ? src_pixels[x * nComps + 3] : 0.; |
| 2609 | } |
| 2610 | } else if (nComps == 3) { |
| 2611 | // coverity[dead_error_line] |
| 2612 | r = (src_pixels && rOffset < nComps) ? src_pixels[x * nComps + rOffset] : 0.; |
| 2613 | // coverity[dead_error_line] |
| 2614 | g = (src_pixels && gOffset < nComps) ? src_pixels[x * nComps + gOffset] : 0.; |
nothing calls this directly
no test coverage detected