// =========================================================================== // Copyright 2018 Autodesk, Inc. All rights reserved. // // Use of this software is subject to the terms of the Autodesk license // agreement provided at the time of installation or download, or which // otherwise accompanies this software in either electronic or hard copy form. // =========================================================================== global proc mayaSoftwareRefreshIprImage() // // Description: // Update the entire resolution of the iprImage for maya software. // { string $iprEngine = "defaultIprEngine"; int $fileSizeInMB = 500; int $memoryAvailableInMB = 50; int $resolution[] = `iprEngine -q -resolution $iprEngine`; int $width = $resolution[0]; int $height = $resolution[1]; int $oldRegion[] = `iprEngine -q -region $iprEngine`; int $x1_oldRegion = $oldRegion[0]; int $y1_oldRegion = $oldRegion[1]; int $x2_oldRegion = $oldRegion[2]; int $y2_oldRegion = $oldRegion[3]; int $numPixelsInRegion = 0; int $regionIsUpToDate = 0; if ($regionIsUpToDate) { $numPixelsInRegion = 100; } int $numPixelsToRender = ($width*$height) - $numPixelsInRegion; // Compute pixel aspect ratio if ($width <= 0) { string $msg = (uiRes("m_mayaSoftwareRefreshIprImage.kInvalidRes")); error(`format -stringArg $width -stringArg $height $msg`); return; } float $pixelAspectRatio = (float) $height / (float) $width; // Compute the number of tiles if ($memoryAvailableInMB <= 0) { error ((uiRes("m_mayaSoftwareRefreshIprImage.kNoMemory"))); return; } float $numberOfTiles = $fileSizeInMB / $memoryAvailableInMB; // Compute the pixels per tile if ($numberOfTiles <= 0) { warning ((uiRes("m_mayaSoftwareRefreshIprImage.kNothingToRender"))); return; } float $pixelsPerTile = $numPixelsToRender / $numberOfTiles; // Compute the resolution of the tiles float $fltXtileSize = sqrt($pixelsPerTile / $pixelAspectRatio); float $fltYtileSize = $fltXtileSize * $pixelAspectRatio; int $xTileSize = $fltXtileSize; int $yTileSize = $fltYtileSize; string $msg = (uiRes("m_mayaSoftwareRefreshIprImage.kMaxTileSize")); print (`format -stringArg $xTileSize -stringArg $yTileSize $msg`); int $x1 = 0; int $y1 = 0; int $x2 = $xTileSize; int $y2 = $yTileSize; int $done = false; int $count = 0; int $row = 0; while (!$done) { int $new_x1 = $x2; int $new_x2 = $x2 + $xTileSize; int $new_y1 = $row*$yTileSize; int $new_y2 = $new_y1 + $yTileSize; if ($new_y2 > $height) $new_y2 = $height; if ($x2 > $width) { $x2 = $width; $new_x1 = 0; $new_x2 = $xTileSize; $row++; $new_y1 = $row*$yTileSize; $new_y2 = $new_y1 + $yTileSize; if ($new_y2 > $height) { $new_y2 = $height; } } iprEngine -e -region $x1 $y1 $x2 $y2 $iprEngine; int $startTuningProblem = catch( `iprEngine -e -startTuning $iprEngine`); updateIPRMemoryEstimate(); if (!$startTuningProblem) { iprEngine -e -u $iprEngine; if ($x2 == $width && $y2 == $height) { $done = 1; } $x1 = $new_x1; $y1 = $new_y1; $x2 = $new_x2; $y2 = $new_y2; $count++; } else break; } // Marquee the oldRegion iprEngine -e -region $x1_oldRegion $y1_oldRegion $x2_oldRegion $y2_oldRegion $iprEngine; int $startedTuning = catch(`iprEngine -e -startTuning $iprEngine`); updateIPRMemoryEstimate(); }