Constify variables in standalone modules

This commit is contained in:
Chuck Walbourn
2022-02-21 02:21:35 -08:00
parent 174539feb3
commit 3599374502
9 changed files with 71 additions and 71 deletions

View File

@@ -318,7 +318,7 @@ namespace
//---------------------------------------------------------------------------------
void FitPowerOf2(UINT origx, UINT origy, UINT& targetx, UINT& targety, size_t maxsize)
{
float origAR = float(origx) / float(origy);
const float origAR = float(origx) / float(origy);
if (origx > origy)
{
@@ -329,7 +329,7 @@ namespace
float bestScore = FLT_MAX;
for (size_t y = maxsize; y > 0; y >>= 1)
{
float score = fabsf((float(x) / float(y)) - origAR);
const float score = fabsf((float(x) / float(y)) - origAR);
if (score < bestScore)
{
bestScore = score;
@@ -346,7 +346,7 @@ namespace
float bestScore = FLT_MAX;
for (size_t x = maxsize; x > 0; x >>= 1)
{
float score = fabsf((float(x) / float(y)) - origAR);
const float score = fabsf((float(x) / float(y)) - origAR);
if (score < bestScore)
{
bestScore = score;
@@ -418,7 +418,7 @@ namespace
}
else if (width > maxsize || height > maxsize)
{
float ar = static_cast<float>(height) / static_cast<float>(width);
const float ar = static_cast<float>(height) / static_cast<float>(width);
if (width > height)
{
twidth = static_cast<UINT>(maxsize);
@@ -583,14 +583,14 @@ namespace
}
// Allocate temporary memory for image
uint64_t rowBytes = (uint64_t(twidth) * uint64_t(bpp) + 7u) / 8u;
uint64_t numBytes = rowBytes * uint64_t(theight);
const uint64_t rowBytes = (uint64_t(twidth) * uint64_t(bpp) + 7u) / 8u;
const uint64_t numBytes = rowBytes * uint64_t(theight);
if (rowBytes > UINT32_MAX || numBytes > UINT32_MAX)
return HRESULT_FROM_WIN32(ERROR_ARITHMETIC_OVERFLOW);
auto rowPitch = static_cast<size_t>(rowBytes);
auto imageSize = static_cast<size_t>(numBytes);
auto const rowPitch = static_cast<size_t>(rowBytes);
auto const imageSize = static_cast<size_t>(numBytes);
std::unique_ptr<uint8_t[]> temp(new (std::nothrow) uint8_t[imageSize]);
if (!temp)
@@ -777,7 +777,7 @@ namespace
if (texture || textureView)
{
CHAR strFileA[MAX_PATH];
int result = WideCharToMultiByte(CP_UTF8,
const int result = WideCharToMultiByte(CP_UTF8,
WC_NO_BEST_FIT_CHARS,
fileName,
-1,

View File

@@ -296,7 +296,7 @@ namespace
//---------------------------------------------------------------------------------
void FitPowerOf2(UINT origx, UINT origy, UINT& targetx, UINT& targety, size_t maxsize)
{
float origAR = float(origx) / float(origy);
const float origAR = float(origx) / float(origy);
if (origx > origy)
{
@@ -307,7 +307,7 @@ namespace
float bestScore = FLT_MAX;
for (size_t y = maxsize; y > 0; y >>= 1)
{
float score = fabsf((float(x) / float(y)) - origAR);
const float score = fabsf((float(x) / float(y)) - origAR);
if (score < bestScore)
{
bestScore = score;
@@ -324,7 +324,7 @@ namespace
float bestScore = FLT_MAX;
for (size_t x = maxsize; x > 0; x >>= 1)
{
float score = fabsf((float(x) / float(y)) - origAR);
const float score = fabsf((float(x) / float(y)) - origAR);
if (score < bestScore)
{
bestScore = score;
@@ -367,7 +367,7 @@ namespace
}
else if (width > maxsize || height > maxsize)
{
float ar = static_cast<float>(height) / static_cast<float>(width);
const float ar = static_cast<float>(height) / static_cast<float>(width);
if (width > height)
{
twidth = static_cast<UINT>(maxsize);
@@ -484,14 +484,14 @@ namespace
}
// Allocate memory for decoded image
uint64_t rowBytes = (uint64_t(twidth) * uint64_t(bpp) + 7u) / 8u;
uint64_t numBytes = rowBytes * uint64_t(theight);
const uint64_t rowBytes = (uint64_t(twidth) * uint64_t(bpp) + 7u) / 8u;
const uint64_t numBytes = rowBytes * uint64_t(theight);
if (rowBytes > UINT32_MAX || numBytes > UINT32_MAX)
return HRESULT_FROM_WIN32(ERROR_ARITHMETIC_OVERFLOW);
auto rowPitch = static_cast<size_t>(rowBytes);
auto imageSize = static_cast<size_t>(numBytes);
auto const rowPitch = static_cast<size_t>(rowBytes);
auto const imageSize = static_cast<size_t>(numBytes);
decodedData.reset(new (std::nothrow) uint8_t[imageSize]);
if (!decodedData)
@@ -587,7 +587,7 @@ namespace
}
// Count the number of mips
uint32_t mipCount = (loadFlags & (WIC_LOADER_MIP_AUTOGEN | WIC_LOADER_MIP_RESERVE))
const uint32_t mipCount = (loadFlags & (WIC_LOADER_MIP_AUTOGEN | WIC_LOADER_MIP_RESERVE))
? CountMips(twidth, theight) : 1u;
// Create texture
@@ -602,7 +602,7 @@ namespace
desc.Flags = resFlags;
desc.Dimension = D3D12_RESOURCE_DIMENSION_TEXTURE2D;
CD3DX12_HEAP_PROPERTIES defaultHeapProperties(D3D12_HEAP_TYPE_DEFAULT);
const CD3DX12_HEAP_PROPERTIES defaultHeapProperties(D3D12_HEAP_TYPE_DEFAULT);
ID3D12Resource* tex = nullptr;
hr = d3dDevice->CreateCommittedResource(

View File

@@ -229,7 +229,7 @@ namespace
//---------------------------------------------------------------------------------
void FitPowerOf2(UINT origx, UINT origy, UINT& targetx, UINT& targety, size_t maxsize)
{
float origAR = float(origx) / float(origy);
const float origAR = float(origx) / float(origy);
if (origx > origy)
{
@@ -240,7 +240,7 @@ namespace
float bestScore = FLT_MAX;
for (size_t y = maxsize; y > 0; y >>= 1)
{
float score = fabsf((float(x) / float(y)) - origAR);
const float score = fabsf((float(x) / float(y)) - origAR);
if (score < bestScore)
{
bestScore = score;
@@ -257,7 +257,7 @@ namespace
float bestScore = FLT_MAX;
for (size_t x = maxsize; x > 0; x >>= 1)
{
float score = fabsf((float(x) / float(y)) - origAR);
const float score = fabsf((float(x) / float(y)) - origAR);
if (score < bestScore)
{
bestScore = score;
@@ -302,7 +302,7 @@ namespace
}
else if (width > maxsize || height > maxsize)
{
float ar = static_cast<float>(height) / static_cast<float>(width);
const float ar = static_cast<float>(height) / static_cast<float>(width);
if (width > height)
{
twidth = static_cast<UINT>(maxsize);
@@ -387,7 +387,7 @@ namespace
if (FAILED(hr))
return hr;
uint64_t numBytes = uint64_t(LockedRect.Pitch) * uint64_t(theight);
const uint64_t numBytes = uint64_t(LockedRect.Pitch) * uint64_t(theight);
pStagingTexture->UnlockRect(0);