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

Function scaleToTexture8bits_generic

Engine/ViewerInstance.cpp:2139–2366  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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

Callers

nothing calls this directly

Calls 15

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