MCPcopy Create free account
hub / github.com/NatronGitHub/Natron / scaleToTexture8bits_generic

Function scaleToTexture8bits_generic

Engine/ViewerInstance.cpp:2138–2365  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2136
2137template <typename PIX, int maxValue, bool opaque, bool applyMatte, int rOffset, int gOffset, int bOffset>
2138void
2139scaleToTexture8bits_generic(const RectI& roi,
2140 const RenderViewerArgs & args,
2141 int nComps,
2142 ViewerInstance* viewer,
2143 const UpdateViewerParams::CachedTile& tile,
2144 U32* tileBuffer)
2145{
2146 const size_t pixelSize = sizeof(PIX);
2147 const bool luminance = (args.channels == eDisplayChannelsY);
2148 Image::ReadAccess acc = Image::ReadAccess( args.inputImage.get() );
2149 const RectI srcImgBounds = args.inputImage->getBounds();
2150
2151 if ( (args.renderOnlyRoI && !tile.rect.contains(roi)) || (!args.renderOnlyRoI && !roi.contains(tile.rect)) ) {
2152 return;
2153 }
2154 assert(tile.rect.x2 > tile.rect.x1);
2155
2156 int dstRowElements;
2157 U32* dst_pixels;
2158 if (args.renderOnlyRoI) {
2159 dstRowElements = tile.rect.width();
2160 dst_pixels = tileBuffer + (roi.y1 - tile.rect.y1) * dstRowElements + (roi.x1 - tile.rect.x1);
2161 } else {
2162 dstRowElements = args.tileRowElements;
2163 dst_pixels = tileBuffer + (tile.rect.y1 - tile.rectRounded.y1) * args.tileRowElements + (tile.rect.x1 - tile.rectRounded.x1);
2164 }
2165
2166 const int y1 = args.renderOnlyRoI ? roi.y1 : tile.rect.y1;
2167 const int y2 = args.renderOnlyRoI ? roi.y2 : tile.rect.y2;
2168 const int x1 = args.renderOnlyRoI ? roi.x1 : tile.rect.x1;
2169 const int x2 = args.renderOnlyRoI ? roi.x2 : tile.rect.x2;
2170 const PIX* src_pixels = (const PIX*)acc.pixelAt(x1, y1);
2171 const int srcRowElements = (int)args.inputImage->getRowElements();
2172 Image::ReadAccessPtr matteAcc;
2173 if (applyMatte) {
2174 matteAcc = std::make_shared<Image::ReadAccess>( args.matteImage.get() );
2175 }
2176
2177 for (int y = y1; y < y2;
2178 ++y,
2179 dst_pixels += dstRowElements) {
2180 // coverity[dont_call]
2181 int start = (int)( rand() % (x2 - x1) );
2182
2183
2184 for (int backward = 0; backward < 2; ++backward) {
2185 int index = backward ? start - 1 : start;
2186
2187 assert( backward == 1 || ( index >= 0 && index < (x2 - x1) ) );
2188
2189 unsigned error_r = 0x80;
2190 unsigned error_g = 0x80;
2191 unsigned error_b = 0x80;
2192
2193 while (index < (x2 - x1) && index >= 0) {
2194 double r = 0.;
2195 double g = 0.;

Callers

nothing calls this directly

Calls 14

ReadAccessClass · 0.85
getRowElementsMethod · 0.80
interpolateGammaLutMethod · 0.80
toBGRAFunction · 0.70
getMethod · 0.45
getBoundsMethod · 0.45
containsMethod · 0.45

Tested by

no test coverage detected