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

Method getImageRectangleDisplayedRoundedToTileSize

Gui/ViewerGL.cpp:1380–1441  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1378}
1379
1380RectI
1381ViewerGL::getImageRectangleDisplayedRoundedToTileSize(int texIndex,
1382 const RectD & rod,
1383 const double par,
1384 unsigned int mipMapLevel,
1385 std::vector<RectI>* tiles,
1386 std::vector<RectI>* tilesRounded,
1387 int *viewerTileSize,
1388 RectI* roiNotRounded)
1389{
1390 bool clipToProject = isClippingImageToFormat();
1391 RectD clippedRod;
1392
1393 if (clipToProject) {
1394 rod.intersect(_imp->displayTextures[texIndex].format, &clippedRod);
1395 } else {
1396 clippedRod = rod;
1397 }
1398
1399 RectI bounds;
1400 clippedRod.toPixelEnclosing(mipMapLevel, par, &bounds);
1401 RectI roi = getImageRectangleDisplayed(bounds, par, mipMapLevel);
1402
1403 ////Texrect is the coordinates of the 4 corners of the texture in the bounds with the current zoom
1404 ////factor taken into account.
1405 RectI texRect;
1406 int tileSize = ipow( 2, appPTR->getCurrentSettings()->getViewerTilesPowerOf2() );
1407 texRect.x1 = std::floor( ( (double)roi.x1 ) / tileSize ) * (double)tileSize;
1408 texRect.y1 = std::floor( ( (double)roi.y1 ) / tileSize ) * (double)tileSize;
1409 texRect.x2 = std::ceil( ( (double)roi.x2 ) / tileSize ) * (double)tileSize;
1410 texRect.y2 = std::ceil( ( (double)roi.y2 ) / tileSize ) * (double)tileSize;
1411
1412 // Make sure the bounds of the area to render in the texture lies in the bounds
1413 if (roiNotRounded) {
1414 *roiNotRounded = roi;
1415 }
1416 if (tilesRounded) {
1417 for (int y = texRect.y1; y < texRect.y2; y += tileSize) {
1418 int y2 = std::min(y + tileSize, texRect.y2);
1419 for (int x = texRect.x1; x < texRect.x2; x += tileSize) {
1420 tilesRounded->resize(tilesRounded->size() + 1);
1421 RectI& tile = tilesRounded->back();
1422 tile.x1 = x;
1423 tile.x2 = std::min(x + tileSize, texRect.x2);
1424 tile.y1 = y;
1425 tile.y2 = y2;
1426
1427 if (tiles) {
1428 RectI tileRectRounded;
1429 tile.intersect(bounds, &tileRectRounded);
1430 tiles->push_back(tileRectRounded);
1431 }
1432 assert( texRect.contains(tile) );
1433 }
1434 }
1435 }
1436
1437 if (viewerTileSize) {

Callers 1

Calls 11

ipowFunction · 0.85
toPixelEnclosingMethod · 0.80
getCurrentSettingsMethod · 0.80
floorFunction · 0.50
ceilFunction · 0.50
intersectMethod · 0.45
resizeMethod · 0.45
sizeMethod · 0.45
push_backMethod · 0.45
containsMethod · 0.45

Tested by

no test coverage detected