mirror of
https://github.com/microsoft/DirectXTex.git
synced 2026-02-04 12:16:14 +01:00
code review for command-line tool
This commit is contained in:
@@ -60,7 +60,7 @@ enum COMMANDS
|
||||
CMD_MAX
|
||||
};
|
||||
|
||||
enum OPTIONS
|
||||
enum OPTIONS : uint32_t
|
||||
{
|
||||
OPT_RECURSIVE = 1,
|
||||
OPT_FORMAT,
|
||||
@@ -81,7 +81,7 @@ enum OPTIONS
|
||||
OPT_MAX
|
||||
};
|
||||
|
||||
static_assert(OPT_MAX <= 32, "dwOptions is a DWORD bitfield");
|
||||
static_assert(OPT_MAX <= 32, "dwOptions is a unsigned int bitfield");
|
||||
|
||||
struct SConversion
|
||||
{
|
||||
@@ -90,8 +90,8 @@ struct SConversion
|
||||
|
||||
struct SValue
|
||||
{
|
||||
LPCWSTR pName;
|
||||
DWORD dwValue;
|
||||
const wchar_t* name;
|
||||
uint32_t value;
|
||||
};
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
@@ -375,12 +375,12 @@ namespace
|
||||
#pragma prefast(disable : 26018, "Only used with static internal arrays")
|
||||
#endif
|
||||
|
||||
DWORD LookupByName(const wchar_t *pName, const SValue *pArray)
|
||||
uint32_t LookupByName(const wchar_t *pName, const SValue *pArray)
|
||||
{
|
||||
while (pArray->pName)
|
||||
while (pArray->name)
|
||||
{
|
||||
if (!_wcsicmp(pName, pArray->pName))
|
||||
return pArray->dwValue;
|
||||
if (!_wcsicmp(pName, pArray->name))
|
||||
return pArray->value;
|
||||
|
||||
pArray++;
|
||||
}
|
||||
@@ -388,12 +388,12 @@ namespace
|
||||
return 0;
|
||||
}
|
||||
|
||||
const wchar_t* LookupByValue(DWORD pValue, const SValue *pArray)
|
||||
const wchar_t* LookupByValue(uint32_t pValue, const SValue *pArray)
|
||||
{
|
||||
while (pArray->pName)
|
||||
while (pArray->name)
|
||||
{
|
||||
if (pValue == pArray->dwValue)
|
||||
return pArray->pName;
|
||||
if (pValue == pArray->value)
|
||||
return pArray->name;
|
||||
|
||||
pArray++;
|
||||
}
|
||||
@@ -477,20 +477,20 @@ namespace
|
||||
|
||||
void PrintFormat(DXGI_FORMAT Format)
|
||||
{
|
||||
for (const SValue *pFormat = g_pFormats; pFormat->pName; pFormat++)
|
||||
for (auto pFormat = g_pFormats; pFormat->name; pFormat++)
|
||||
{
|
||||
if (static_cast<DXGI_FORMAT>(pFormat->dwValue) == Format)
|
||||
if (static_cast<DXGI_FORMAT>(pFormat->value) == Format)
|
||||
{
|
||||
wprintf(L"%ls", pFormat->pName);
|
||||
wprintf(L"%ls", pFormat->name);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
for (const SValue *pFormat = g_pReadOnlyFormats; pFormat->pName; pFormat++)
|
||||
for (auto pFormat = g_pReadOnlyFormats; pFormat->name; pFormat++)
|
||||
{
|
||||
if (static_cast<DXGI_FORMAT>(pFormat->dwValue) == Format)
|
||||
if (static_cast<DXGI_FORMAT>(pFormat->value) == Format)
|
||||
{
|
||||
wprintf(L"%ls", pFormat->pName);
|
||||
wprintf(L"%ls", pFormat->name);
|
||||
return;
|
||||
}
|
||||
}
|
||||
@@ -500,9 +500,9 @@ namespace
|
||||
|
||||
void PrintList(size_t cch, const SValue *pValue)
|
||||
{
|
||||
while (pValue->pName)
|
||||
while (pValue->name)
|
||||
{
|
||||
size_t cchName = wcslen(pValue->pName);
|
||||
size_t cchName = wcslen(pValue->name);
|
||||
|
||||
if (cch + cchName + 2 >= 80)
|
||||
{
|
||||
@@ -510,7 +510,7 @@ namespace
|
||||
cch = 6;
|
||||
}
|
||||
|
||||
wprintf(L"%ls ", pValue->pName);
|
||||
wprintf(L"%ls ", pValue->name);
|
||||
cch += cchName + 2;
|
||||
pValue++;
|
||||
}
|
||||
@@ -629,7 +629,7 @@ namespace
|
||||
|
||||
HRESULT LoadImage(
|
||||
const wchar_t *fileName,
|
||||
DWORD dwOptions,
|
||||
uint32_t dwOptions,
|
||||
TEX_FILTER_FLAGS dwFilter,
|
||||
TexMetadata& info,
|
||||
std::unique_ptr<ScratchImage>& image)
|
||||
@@ -705,7 +705,7 @@ namespace
|
||||
}
|
||||
}
|
||||
|
||||
HRESULT SaveImage(const Image* image, const wchar_t *fileName, DWORD codec)
|
||||
HRESULT SaveImage(const Image* image, const wchar_t *fileName, uint32_t codec)
|
||||
{
|
||||
switch (codec)
|
||||
{
|
||||
@@ -3101,7 +3101,7 @@ int __cdecl wmain(_In_ int argc, _In_z_count_(argc) wchar_t* argv[])
|
||||
int pixelx = -1;
|
||||
int pixely = -1;
|
||||
DXGI_FORMAT diffFormat = DXGI_FORMAT_B8G8R8A8_UNORM;
|
||||
DWORD fileType = WIC_CODEC_BMP;
|
||||
uint32_t fileType = WIC_CODEC_BMP;
|
||||
wchar_t szOutputFile[MAX_PATH] = {};
|
||||
|
||||
// Initialize COM (needed for WIC)
|
||||
@@ -3119,7 +3119,7 @@ int __cdecl wmain(_In_ int argc, _In_z_count_(argc) wchar_t* argv[])
|
||||
return 0;
|
||||
}
|
||||
|
||||
DWORD dwCommand = LookupByName(argv[1], g_pCommands);
|
||||
uint32_t dwCommand = LookupByName(argv[1], g_pCommands);
|
||||
switch (dwCommand)
|
||||
{
|
||||
case CMD_INFO:
|
||||
@@ -3135,7 +3135,7 @@ int __cdecl wmain(_In_ int argc, _In_z_count_(argc) wchar_t* argv[])
|
||||
return 1;
|
||||
}
|
||||
|
||||
DWORD dwOptions = 0;
|
||||
uint32_t dwOptions = 0;
|
||||
std::list<SConversion> conversion;
|
||||
|
||||
for (int iArg = 2; iArg < argc; iArg++)
|
||||
@@ -3152,7 +3152,7 @@ int __cdecl wmain(_In_ int argc, _In_z_count_(argc) wchar_t* argv[])
|
||||
if (*pValue)
|
||||
*pValue++ = 0;
|
||||
|
||||
DWORD dwOption = LookupByName(pArg, g_pOptions);
|
||||
uint32_t dwOption = LookupByName(pArg, g_pOptions);
|
||||
|
||||
if (!dwOption || (dwOptions & (1 << dwOption)))
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user