1
0
mirror of https://github.com/microsoft/DirectXTex synced 2024-11-21 12:00:06 +00:00

Use fixed width integers for underlying enum types (#538)

This commit is contained in:
Chuck Walbourn 2024-10-24 11:44:33 -07:00 committed by GitHub
parent cea630ac4c
commit 6e7801e324
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
16 changed files with 112 additions and 106 deletions

View File

@ -41,6 +41,9 @@
#include <d3d11_1.h> #include <d3d11_1.h>
#endif #endif
#include <cstdint>
#include <utility>
#define DIRECTX_TEX_XBOX_VERSION 150 #define DIRECTX_TEX_XBOX_VERSION 150
namespace Xbox namespace Xbox
@ -95,13 +98,13 @@ namespace Xbox
// Image I/O // Image I/O
HRESULT __cdecl GetMetadataFromDDSMemory( HRESULT __cdecl GetMetadataFromDDSMemory(
_In_reads_bytes_(size) const void* pSource, _In_ size_t size, _In_reads_bytes_(size) const uint8_t* pSource, _In_ size_t size,
_Out_ DirectX::TexMetadata& metadata, _Out_ bool& isXbox); _Out_ DirectX::TexMetadata& metadata, _Out_ bool& isXbox);
HRESULT __cdecl GetMetadataFromDDSFile( HRESULT __cdecl GetMetadataFromDDSFile(
_In_z_ const wchar_t* szFile, _Out_ DirectX::TexMetadata& metadata, _Out_ bool& isXbox); _In_z_ const wchar_t* szFile, _Out_ DirectX::TexMetadata& metadata, _Out_ bool& isXbox);
HRESULT __cdecl GetMetadataFromDDSMemoryEx( HRESULT __cdecl GetMetadataFromDDSMemoryEx(
_In_reads_bytes_(size) const void* pSource, _In_ size_t size, _In_reads_bytes_(size) const uint8_t* pSource, _In_ size_t size,
_Out_ DirectX::TexMetadata& metadata, _Out_ bool& isXbox, _Out_ DirectX::TexMetadata& metadata, _Out_ bool& isXbox,
_Out_opt_ DirectX::DDSMetaData* ddPixelFormat); _Out_opt_ DirectX::DDSMetaData* ddPixelFormat);
HRESULT __cdecl GetMetadataFromDDSFileEx( HRESULT __cdecl GetMetadataFromDDSFileEx(
@ -109,14 +112,14 @@ namespace Xbox
_Out_opt_ DirectX::DDSMetaData* ddPixelFormat); _Out_opt_ DirectX::DDSMetaData* ddPixelFormat);
HRESULT __cdecl LoadFromDDSMemory( HRESULT __cdecl LoadFromDDSMemory(
_In_reads_bytes_(size) const void* pSource, _In_ size_t size, _In_reads_bytes_(size) const uint8_t* pSource, _In_ size_t size,
_Out_opt_ DirectX::TexMetadata* metadata, _Out_ XboxImage& image); _Out_opt_ DirectX::TexMetadata* metadata, _Out_ XboxImage& image);
HRESULT __cdecl LoadFromDDSFile( HRESULT __cdecl LoadFromDDSFile(
_In_z_ const wchar_t* szFile, _In_z_ const wchar_t* szFile,
_Out_opt_ DirectX::TexMetadata* metadata, _Out_ XboxImage& image); _Out_opt_ DirectX::TexMetadata* metadata, _Out_ XboxImage& image);
HRESULT __cdecl LoadFromDDSMemoryEx( HRESULT __cdecl LoadFromDDSMemoryEx(
_In_reads_bytes_(size) const void* pSource, _In_ size_t size, _In_reads_bytes_(size) const uint8_t* pSource, _In_ size_t size,
_Out_opt_ DirectX::TexMetadata* metadata, _Out_opt_ DirectX::TexMetadata* metadata,
_Out_opt_ DirectX::DDSMetaData* ddPixelFormat, _Out_opt_ DirectX::DDSMetaData* ddPixelFormat,
_Out_ XboxImage& image); _Out_ XboxImage& image);
@ -173,6 +176,6 @@ namespace Xbox
// DDS helper functions // DDS helper functions
HRESULT __cdecl EncodeDDSHeader( HRESULT __cdecl EncodeDDSHeader(
const XboxImage& xbox, const XboxImage& xbox,
_Out_writes_bytes_(maxsize) void* pDestination, _In_ size_t maxsize) noexcept; _Out_writes_bytes_(maxsize) uint8_t* pDestination, _In_ size_t maxsize) noexcept;
} // namespace } // namespace

View File

@ -27,7 +27,7 @@ namespace
// Decodes DDS header using XBOX extended header (variant of DX10 header) // Decodes DDS header using XBOX extended header (variant of DX10 header)
//------------------------------------------------------------------------------------- //-------------------------------------------------------------------------------------
HRESULT DecodeDDSHeader( HRESULT DecodeDDSHeader(
_In_reads_bytes_(size) const void* pSource, _In_reads_bytes_(size) const uint8_t* pSource,
size_t size, size_t size,
DirectX::TexMetadata& metadata, DirectX::TexMetadata& metadata,
_Out_opt_ DDSMetaData* ddPixelFormat, _Out_opt_ DDSMetaData* ddPixelFormat,
@ -229,7 +229,7 @@ namespace
_Use_decl_annotations_ _Use_decl_annotations_
HRESULT Xbox::EncodeDDSHeader( HRESULT Xbox::EncodeDDSHeader(
const XboxImage& xbox, const XboxImage& xbox,
void* pDestination, uint8_t* pDestination,
size_t maxsize) noexcept size_t maxsize) noexcept
{ {
if (!pDestination) if (!pDestination)
@ -383,7 +383,7 @@ HRESULT Xbox::EncodeDDSHeader(
_Use_decl_annotations_ _Use_decl_annotations_
HRESULT Xbox::GetMetadataFromDDSMemory( HRESULT Xbox::GetMetadataFromDDSMemory(
const void* pSource, const uint8_t* pSource,
size_t size, size_t size,
TexMetadata& metadata, TexMetadata& metadata,
bool& isXbox) bool& isXbox)
@ -393,7 +393,7 @@ HRESULT Xbox::GetMetadataFromDDSMemory(
_Use_decl_annotations_ _Use_decl_annotations_
HRESULT Xbox::GetMetadataFromDDSMemoryEx( HRESULT Xbox::GetMetadataFromDDSMemoryEx(
const void* pSource, const uint8_t* pSource,
size_t size, size_t size,
TexMetadata& metadata, TexMetadata& metadata,
bool& isXbox, bool& isXbox,
@ -498,7 +498,7 @@ HRESULT Xbox::GetMetadataFromDDSFileEx(
//------------------------------------------------------------------------------------- //-------------------------------------------------------------------------------------
_Use_decl_annotations_ _Use_decl_annotations_
HRESULT Xbox::LoadFromDDSMemory( HRESULT Xbox::LoadFromDDSMemory(
const void* pSource, const uint8_t* pSource,
size_t size, size_t size,
TexMetadata* metadata, TexMetadata* metadata,
XboxImage& xbox) XboxImage& xbox)
@ -508,7 +508,7 @@ HRESULT Xbox::LoadFromDDSMemory(
_Use_decl_annotations_ _Use_decl_annotations_
HRESULT Xbox::LoadFromDDSMemoryEx( HRESULT Xbox::LoadFromDDSMemoryEx(
const void* pSource, const uint8_t* pSource,
size_t size, size_t size,
TexMetadata* metadata, TexMetadata* metadata,
DDSMetaData* ddPixelFormat, DDSMetaData* ddPixelFormat,
@ -694,7 +694,7 @@ HRESULT Xbox::SaveToDDSMemory(const XboxImage& xbox, Blob& blob)
return hr; return hr;
// Copy header // Copy header
auto pDestination = reinterpret_cast<uint8_t*>(blob.GetBufferPointer()); auto pDestination = blob.GetBufferPointer();
assert(pDestination); assert(pDestination);
hr = EncodeDDSHeader(xbox, pDestination, DDS_XBOX_HEADER_SIZE); hr = EncodeDDSHeader(xbox, pDestination, DDS_XBOX_HEADER_SIZE);

View File

@ -53,7 +53,7 @@ namespace DirectX
#pragma clang diagnostic ignored "-Wdeprecated-dynamic-exception-spec" #pragma clang diagnostic ignored "-Wdeprecated-dynamic-exception-spec"
#endif #endif
DEFINE_ENUM_FLAG_OPERATORS(DDS_LOADER_FLAGS); DEFINE_ENUM_FLAG_OPERATORS(DDS_LOADER_FLAGS)
#ifdef __clang__ #ifdef __clang__
#pragma clang diagnostic pop #pragma clang diagnostic pop

View File

@ -70,7 +70,7 @@ namespace DirectX
#pragma clang diagnostic ignored "-Wdeprecated-dynamic-exception-spec" #pragma clang diagnostic ignored "-Wdeprecated-dynamic-exception-spec"
#endif #endif
DEFINE_ENUM_FLAG_OPERATORS(DDS_LOADER_FLAGS); DEFINE_ENUM_FLAG_OPERATORS(DDS_LOADER_FLAGS)
#ifdef __clang__ #ifdef __clang__
#pragma clang diagnostic pop #pragma clang diagnostic pop

View File

@ -86,7 +86,7 @@ namespace DirectX
FORMAT_TYPE __cdecl FormatDataType(_In_ DXGI_FORMAT fmt) noexcept; FORMAT_TYPE __cdecl FormatDataType(_In_ DXGI_FORMAT fmt) noexcept;
enum CP_FLAGS : unsigned long enum CP_FLAGS : uint32_t
{ {
CP_FLAGS_NONE = 0x0, CP_FLAGS_NONE = 0x0,
// Normal operation // Normal operation
@ -144,13 +144,13 @@ namespace DirectX
TEX_DIMENSION_TEXTURE3D = 4, TEX_DIMENSION_TEXTURE3D = 4,
}; };
enum TEX_MISC_FLAG : unsigned long enum TEX_MISC_FLAG : uint32_t
// Subset here matches D3D10_RESOURCE_MISC_FLAG and D3D11_RESOURCE_MISC_FLAG // Subset here matches D3D10_RESOURCE_MISC_FLAG and D3D11_RESOURCE_MISC_FLAG
{ {
TEX_MISC_TEXTURECUBE = 0x4L, TEX_MISC_TEXTURECUBE = 0x4L,
}; };
enum TEX_MISC_FLAG2 : unsigned long enum TEX_MISC_FLAG2 : uint32_t
{ {
TEX_MISC2_ALPHA_MODE_MASK = 0x7L, TEX_MISC2_ALPHA_MODE_MASK = 0x7L,
}; };
@ -210,7 +210,7 @@ namespace DirectX
bool __cdecl IsDX10() const noexcept { return (fourCC == 0x30315844); } bool __cdecl IsDX10() const noexcept { return (fourCC == 0x30315844); }
}; };
enum DDS_FLAGS : unsigned long enum DDS_FLAGS : uint32_t
{ {
DDS_FLAGS_NONE = 0x0, DDS_FLAGS_NONE = 0x0,
@ -257,7 +257,7 @@ namespace DirectX
// Enables the loader to read large dimension .dds files (i.e. greater than known hardware requirements) // Enables the loader to read large dimension .dds files (i.e. greater than known hardware requirements)
}; };
enum TGA_FLAGS : unsigned long enum TGA_FLAGS : uint32_t
{ {
TGA_FLAGS_NONE = 0x0, TGA_FLAGS_NONE = 0x0,
@ -280,7 +280,7 @@ namespace DirectX
// If no colorspace is specified in TGA 2.0 metadata, assume sRGB // If no colorspace is specified in TGA 2.0 metadata, assume sRGB
}; };
enum WIC_FLAGS : unsigned long enum WIC_FLAGS : uint32_t
{ {
WIC_FLAGS_NONE = 0x0, WIC_FLAGS_NONE = 0x0,
@ -325,7 +325,7 @@ namespace DirectX
}; };
HRESULT __cdecl GetMetadataFromDDSMemory( HRESULT __cdecl GetMetadataFromDDSMemory(
_In_reads_bytes_(size) const void* pSource, _In_ size_t size, _In_reads_bytes_(size) const uint8_t* pSource, _In_ size_t size,
_In_ DDS_FLAGS flags, _In_ DDS_FLAGS flags,
_Out_ TexMetadata& metadata) noexcept; _Out_ TexMetadata& metadata) noexcept;
HRESULT __cdecl GetMetadataFromDDSFile( HRESULT __cdecl GetMetadataFromDDSFile(
@ -334,7 +334,7 @@ namespace DirectX
_Out_ TexMetadata& metadata) noexcept; _Out_ TexMetadata& metadata) noexcept;
HRESULT __cdecl GetMetadataFromDDSMemoryEx( HRESULT __cdecl GetMetadataFromDDSMemoryEx(
_In_reads_bytes_(size) const void* pSource, _In_ size_t size, _In_reads_bytes_(size) const uint8_t* pSource, _In_ size_t size,
_In_ DDS_FLAGS flags, _In_ DDS_FLAGS flags,
_Out_ TexMetadata& metadata, _Out_ TexMetadata& metadata,
_Out_opt_ DDSMetaData* ddPixelFormat) noexcept; _Out_opt_ DDSMetaData* ddPixelFormat) noexcept;
@ -345,14 +345,14 @@ namespace DirectX
_Out_opt_ DDSMetaData* ddPixelFormat) noexcept; _Out_opt_ DDSMetaData* ddPixelFormat) noexcept;
HRESULT __cdecl GetMetadataFromHDRMemory( HRESULT __cdecl GetMetadataFromHDRMemory(
_In_reads_bytes_(size) const void* pSource, _In_ size_t size, _In_reads_bytes_(size) const uint8_t* pSource, _In_ size_t size,
_Out_ TexMetadata& metadata) noexcept; _Out_ TexMetadata& metadata) noexcept;
HRESULT __cdecl GetMetadataFromHDRFile( HRESULT __cdecl GetMetadataFromHDRFile(
_In_z_ const wchar_t* szFile, _In_z_ const wchar_t* szFile,
_Out_ TexMetadata& metadata) noexcept; _Out_ TexMetadata& metadata) noexcept;
HRESULT __cdecl GetMetadataFromTGAMemory( HRESULT __cdecl GetMetadataFromTGAMemory(
_In_reads_bytes_(size) const void* pSource, _In_ size_t size, _In_reads_bytes_(size) const uint8_t* pSource, _In_ size_t size,
_In_ TGA_FLAGS flags, _In_ TGA_FLAGS flags,
_Out_ TexMetadata& metadata) noexcept; _Out_ TexMetadata& metadata) noexcept;
HRESULT __cdecl GetMetadataFromTGAFile( HRESULT __cdecl GetMetadataFromTGAFile(
@ -362,7 +362,7 @@ namespace DirectX
#ifdef _WIN32 #ifdef _WIN32
HRESULT __cdecl GetMetadataFromWICMemory( HRESULT __cdecl GetMetadataFromWICMemory(
_In_reads_bytes_(size) const void* pSource, _In_ size_t size, _In_reads_bytes_(size) const uint8_t* pSource, _In_ size_t size,
_In_ WIC_FLAGS flags, _In_ WIC_FLAGS flags,
_Out_ TexMetadata& metadata, _Out_ TexMetadata& metadata,
_In_ std::function<void __cdecl(IWICMetadataQueryReader*)> getMQR = nullptr); _In_ std::function<void __cdecl(IWICMetadataQueryReader*)> getMQR = nullptr);
@ -376,7 +376,7 @@ namespace DirectX
// Compatability helpers // Compatability helpers
HRESULT __cdecl GetMetadataFromTGAMemory( HRESULT __cdecl GetMetadataFromTGAMemory(
_In_reads_bytes_(size) const void* pSource, _In_ size_t size, _In_reads_bytes_(size) const uint8_t* pSource, _In_ size_t size,
_Out_ TexMetadata& metadata) noexcept; _Out_ TexMetadata& metadata) noexcept;
HRESULT __cdecl GetMetadataFromTGAFile( HRESULT __cdecl GetMetadataFromTGAFile(
_In_z_ const wchar_t* szFile, _In_z_ const wchar_t* szFile,
@ -461,7 +461,10 @@ namespace DirectX
void __cdecl Release() noexcept; void __cdecl Release() noexcept;
void *__cdecl GetBufferPointer() const noexcept { return m_buffer; } uint8_t* __cdecl GetBufferPointer() const noexcept { return m_buffer; }
const uint8_t* __cdecl GetConstBufferPointer() const noexcept { return m_buffer; }
size_t __cdecl GetBufferSize() const noexcept { return m_size; } size_t __cdecl GetBufferSize() const noexcept { return m_size; }
HRESULT __cdecl Resize(size_t size) noexcept; HRESULT __cdecl Resize(size_t size) noexcept;
@ -471,7 +474,7 @@ namespace DirectX
// Shorten size without reallocation // Shorten size without reallocation
private: private:
void* m_buffer; uint8_t* m_buffer;
size_t m_size; size_t m_size;
}; };
@ -480,7 +483,7 @@ namespace DirectX
// DDS operations // DDS operations
HRESULT __cdecl LoadFromDDSMemory( HRESULT __cdecl LoadFromDDSMemory(
_In_reads_bytes_(size) const void* pSource, _In_ size_t size, _In_reads_bytes_(size) const uint8_t* pSource, _In_ size_t size,
_In_ DDS_FLAGS flags, _In_ DDS_FLAGS flags,
_Out_opt_ TexMetadata* metadata, _Out_ ScratchImage& image) noexcept; _Out_opt_ TexMetadata* metadata, _Out_ ScratchImage& image) noexcept;
HRESULT __cdecl LoadFromDDSFile( HRESULT __cdecl LoadFromDDSFile(
@ -489,7 +492,7 @@ namespace DirectX
_Out_opt_ TexMetadata* metadata, _Out_ ScratchImage& image) noexcept; _Out_opt_ TexMetadata* metadata, _Out_ ScratchImage& image) noexcept;
HRESULT __cdecl LoadFromDDSMemoryEx( HRESULT __cdecl LoadFromDDSMemoryEx(
_In_reads_bytes_(size) const void* pSource, _In_ size_t size, _In_reads_bytes_(size) const uint8_t* pSource, _In_ size_t size,
_In_ DDS_FLAGS flags, _In_ DDS_FLAGS flags,
_Out_opt_ TexMetadata* metadata, _Out_opt_ TexMetadata* metadata,
_Out_opt_ DDSMetaData* ddPixelFormat, _Out_opt_ DDSMetaData* ddPixelFormat,
@ -517,7 +520,7 @@ namespace DirectX
// HDR operations // HDR operations
HRESULT __cdecl LoadFromHDRMemory( HRESULT __cdecl LoadFromHDRMemory(
_In_reads_bytes_(size) const void* pSource, _In_ size_t size, _In_reads_bytes_(size) const uint8_t* pSource, _In_ size_t size,
_Out_opt_ TexMetadata* metadata, _Out_ ScratchImage& image) noexcept; _Out_opt_ TexMetadata* metadata, _Out_ ScratchImage& image) noexcept;
HRESULT __cdecl LoadFromHDRFile( HRESULT __cdecl LoadFromHDRFile(
_In_z_ const wchar_t* szFile, _In_z_ const wchar_t* szFile,
@ -528,7 +531,7 @@ namespace DirectX
// TGA operations // TGA operations
HRESULT __cdecl LoadFromTGAMemory( HRESULT __cdecl LoadFromTGAMemory(
_In_reads_bytes_(size) const void* pSource, _In_ size_t size, _In_reads_bytes_(size) const uint8_t* pSource, _In_ size_t size,
_In_ TGA_FLAGS flags, _In_ TGA_FLAGS flags,
_Out_opt_ TexMetadata* metadata, _Out_ ScratchImage& image) noexcept; _Out_opt_ TexMetadata* metadata, _Out_ ScratchImage& image) noexcept;
HRESULT __cdecl LoadFromTGAFile( HRESULT __cdecl LoadFromTGAFile(
@ -546,7 +549,7 @@ namespace DirectX
// WIC operations // WIC operations
#ifdef _WIN32 #ifdef _WIN32
HRESULT __cdecl LoadFromWICMemory( HRESULT __cdecl LoadFromWICMemory(
_In_reads_bytes_(size) const void* pSource, _In_ size_t size, _In_reads_bytes_(size) const uint8_t* pSource, _In_ size_t size,
_In_ WIC_FLAGS flags, _In_ WIC_FLAGS flags,
_Out_opt_ TexMetadata* metadata, _Out_ ScratchImage& image, _Out_opt_ TexMetadata* metadata, _Out_ ScratchImage& image,
_In_ std::function<void __cdecl(IWICMetadataQueryReader*)> getMQR = nullptr); _In_ std::function<void __cdecl(IWICMetadataQueryReader*)> getMQR = nullptr);
@ -578,7 +581,7 @@ namespace DirectX
// Compatability helpers // Compatability helpers
HRESULT __cdecl LoadFromTGAMemory( HRESULT __cdecl LoadFromTGAMemory(
_In_reads_bytes_(size) const void* pSource, _In_ size_t size, _In_reads_bytes_(size) const uint8_t* pSource, _In_ size_t size,
_Out_opt_ TexMetadata* metadata, _Out_ ScratchImage& image) noexcept; _Out_opt_ TexMetadata* metadata, _Out_ ScratchImage& image) noexcept;
HRESULT __cdecl LoadFromTGAFile( HRESULT __cdecl LoadFromTGAFile(
_In_z_ const wchar_t* szFile, _In_z_ const wchar_t* szFile,
@ -590,7 +593,7 @@ namespace DirectX
//--------------------------------------------------------------------------------- //---------------------------------------------------------------------------------
// Texture conversion, resizing, mipmap generation, and block compression // Texture conversion, resizing, mipmap generation, and block compression
enum TEX_FR_FLAGS : unsigned long enum TEX_FR_FLAGS : uint32_t
{ {
TEX_FR_ROTATE0 = 0x0, TEX_FR_ROTATE0 = 0x0,
TEX_FR_ROTATE90 = 0x1, TEX_FR_ROTATE90 = 0x1,
@ -608,7 +611,7 @@ namespace DirectX
// Flip and/or rotate image // Flip and/or rotate image
#endif #endif
enum TEX_FILTER_FLAGS : unsigned long enum TEX_FILTER_FLAGS : uint32_t
{ {
TEX_FILTER_DEFAULT = 0, TEX_FILTER_DEFAULT = 0,
@ -662,9 +665,9 @@ namespace DirectX
// Forces use of the WIC path even when logic would have picked a non-WIC path when both are an option // Forces use of the WIC path even when logic would have picked a non-WIC path when both are an option
}; };
constexpr unsigned long TEX_FILTER_DITHER_MASK = 0xF0000; constexpr uint32_t TEX_FILTER_DITHER_MASK = 0xF0000;
constexpr unsigned long TEX_FILTER_MODE_MASK = 0xF00000; constexpr uint32_t TEX_FILTER_MODE_MASK = 0xF00000;
constexpr unsigned long TEX_FILTER_SRGB_MASK = 0xF000000; constexpr uint32_t TEX_FILTER_SRGB_MASK = 0xF000000;
HRESULT __cdecl Resize( HRESULT __cdecl Resize(
_In_ const Image& srcImage, _In_ size_t width, _In_ size_t height, _In_ const Image& srcImage, _In_ size_t width, _In_ size_t height,
@ -731,7 +734,7 @@ namespace DirectX
_In_ float alphaReference, _Inout_ ScratchImage& mipChain) noexcept; _In_ float alphaReference, _Inout_ ScratchImage& mipChain) noexcept;
enum TEX_PMALPHA_FLAGS : unsigned long enum TEX_PMALPHA_FLAGS : uint32_t
{ {
TEX_PMALPHA_DEFAULT = 0, TEX_PMALPHA_DEFAULT = 0,
@ -754,7 +757,7 @@ namespace DirectX
_In_ TEX_PMALPHA_FLAGS flags, _Out_ ScratchImage& result) noexcept; _In_ TEX_PMALPHA_FLAGS flags, _Out_ ScratchImage& result) noexcept;
// Converts to/from a premultiplied alpha version of the texture // Converts to/from a premultiplied alpha version of the texture
enum TEX_COMPRESS_FLAGS : unsigned long enum TEX_COMPRESS_FLAGS : uint32_t
{ {
TEX_COMPRESS_DEFAULT = 0, TEX_COMPRESS_DEFAULT = 0,
@ -840,7 +843,7 @@ namespace DirectX
//--------------------------------------------------------------------------------- //---------------------------------------------------------------------------------
// Normal map operations // Normal map operations
enum CNMAP_FLAGS : unsigned long enum CNMAP_FLAGS : uint32_t
{ {
CNMAP_DEFAULT = 0, CNMAP_DEFAULT = 0,
@ -889,7 +892,7 @@ namespace DirectX
_In_ const Image& srcImage, _In_ const Rect& srcRect, _In_ const Image& dstImage, _In_ const Image& srcImage, _In_ const Rect& srcRect, _In_ const Image& dstImage,
_In_ TEX_FILTER_FLAGS filter, _In_ size_t xOffset, _In_ size_t yOffset) noexcept; _In_ TEX_FILTER_FLAGS filter, _In_ size_t xOffset, _In_ size_t yOffset) noexcept;
enum CMSE_FLAGS : unsigned long enum CMSE_FLAGS : uint32_t
{ {
CMSE_DEFAULT = 0, CMSE_DEFAULT = 0,
@ -953,7 +956,7 @@ namespace DirectX
// DDS helper functions // DDS helper functions
HRESULT __cdecl EncodeDDSHeader( HRESULT __cdecl EncodeDDSHeader(
_In_ const TexMetadata& metadata, DDS_FLAGS flags, _In_ const TexMetadata& metadata, DDS_FLAGS flags,
_Out_writes_bytes_to_opt_(maxsize, required) void* pDestination, _In_ size_t maxsize, _Out_writes_bytes_to_opt_(maxsize, required) uint8_t* pDestination, _In_ size_t maxsize,
_Out_ size_t& required) noexcept; _Out_ size_t& required) noexcept;
//--------------------------------------------------------------------------------- //---------------------------------------------------------------------------------

View File

@ -14,29 +14,29 @@
//===================================================================================== //=====================================================================================
// Bitmask flags enumerator operators // Bitmask flags enumerator operators
//===================================================================================== //=====================================================================================
DEFINE_ENUM_FLAG_OPERATORS(CP_FLAGS); DEFINE_ENUM_FLAG_OPERATORS(CP_FLAGS)
DEFINE_ENUM_FLAG_OPERATORS(DDS_FLAGS); DEFINE_ENUM_FLAG_OPERATORS(DDS_FLAGS)
DEFINE_ENUM_FLAG_OPERATORS(TGA_FLAGS); DEFINE_ENUM_FLAG_OPERATORS(TGA_FLAGS)
DEFINE_ENUM_FLAG_OPERATORS(WIC_FLAGS); DEFINE_ENUM_FLAG_OPERATORS(WIC_FLAGS)
DEFINE_ENUM_FLAG_OPERATORS(TEX_FR_FLAGS); DEFINE_ENUM_FLAG_OPERATORS(TEX_FR_FLAGS)
DEFINE_ENUM_FLAG_OPERATORS(TEX_FILTER_FLAGS); DEFINE_ENUM_FLAG_OPERATORS(TEX_FILTER_FLAGS)
DEFINE_ENUM_FLAG_OPERATORS(TEX_PMALPHA_FLAGS); DEFINE_ENUM_FLAG_OPERATORS(TEX_PMALPHA_FLAGS)
DEFINE_ENUM_FLAG_OPERATORS(TEX_COMPRESS_FLAGS); DEFINE_ENUM_FLAG_OPERATORS(TEX_COMPRESS_FLAGS)
DEFINE_ENUM_FLAG_OPERATORS(CNMAP_FLAGS); DEFINE_ENUM_FLAG_OPERATORS(CNMAP_FLAGS)
DEFINE_ENUM_FLAG_OPERATORS(CMSE_FLAGS); DEFINE_ENUM_FLAG_OPERATORS(CMSE_FLAGS)
DEFINE_ENUM_FLAG_OPERATORS(CREATETEX_FLAGS); DEFINE_ENUM_FLAG_OPERATORS(CREATETEX_FLAGS)
// WIC_FILTER modes match TEX_FILTER modes // WIC_FILTER modes match TEX_FILTER modes
constexpr WIC_FLAGS operator|(WIC_FLAGS a, TEX_FILTER_FLAGS b) { return static_cast<WIC_FLAGS>(static_cast<unsigned long>(a) | static_cast<unsigned long>(b & TEX_FILTER_MODE_MASK)); } constexpr WIC_FLAGS operator|(WIC_FLAGS a, TEX_FILTER_FLAGS b) { return static_cast<WIC_FLAGS>(static_cast<uint32_t>(a) | static_cast<uint32_t>(b & TEX_FILTER_MODE_MASK)); }
constexpr WIC_FLAGS operator|(TEX_FILTER_FLAGS a, WIC_FLAGS b) { return static_cast<WIC_FLAGS>(static_cast<unsigned long>(a & TEX_FILTER_MODE_MASK) | static_cast<unsigned long>(b)); } constexpr WIC_FLAGS operator|(TEX_FILTER_FLAGS a, WIC_FLAGS b) { return static_cast<WIC_FLAGS>(static_cast<uint32_t>(a & TEX_FILTER_MODE_MASK) | static_cast<uint32_t>(b)); }
// TEX_PMALPHA_SRGB match TEX_FILTER_SRGB // TEX_PMALPHA_SRGB match TEX_FILTER_SRGB
constexpr TEX_PMALPHA_FLAGS operator|(TEX_PMALPHA_FLAGS a, TEX_FILTER_FLAGS b) { return static_cast<TEX_PMALPHA_FLAGS>(static_cast<unsigned long>(a) | static_cast<unsigned long>(b & TEX_FILTER_SRGB_MASK)); } constexpr TEX_PMALPHA_FLAGS operator|(TEX_PMALPHA_FLAGS a, TEX_FILTER_FLAGS b) { return static_cast<TEX_PMALPHA_FLAGS>(static_cast<uint32_t>(a) | static_cast<uint32_t>(b & TEX_FILTER_SRGB_MASK)); }
constexpr TEX_PMALPHA_FLAGS operator|(TEX_FILTER_FLAGS a, TEX_PMALPHA_FLAGS b) { return static_cast<TEX_PMALPHA_FLAGS>(static_cast<unsigned long>(a & TEX_FILTER_SRGB_MASK) | static_cast<unsigned long>(b)); } constexpr TEX_PMALPHA_FLAGS operator|(TEX_FILTER_FLAGS a, TEX_PMALPHA_FLAGS b) { return static_cast<TEX_PMALPHA_FLAGS>(static_cast<uint32_t>(a & TEX_FILTER_SRGB_MASK) | static_cast<uint32_t>(b)); }
// TEX_COMPRESS_SRGB match TEX_FILTER_SRGB // TEX_COMPRESS_SRGB match TEX_FILTER_SRGB
constexpr TEX_COMPRESS_FLAGS operator|(TEX_COMPRESS_FLAGS a, TEX_FILTER_FLAGS b) { return static_cast<TEX_COMPRESS_FLAGS>(static_cast<unsigned long>(a) | static_cast<unsigned long>(b & TEX_FILTER_SRGB_MASK)); } constexpr TEX_COMPRESS_FLAGS operator|(TEX_COMPRESS_FLAGS a, TEX_FILTER_FLAGS b) { return static_cast<TEX_COMPRESS_FLAGS>(static_cast<uint32_t>(a) | static_cast<uint32_t>(b & TEX_FILTER_SRGB_MASK)); }
constexpr TEX_COMPRESS_FLAGS operator|(TEX_FILTER_FLAGS a, TEX_COMPRESS_FLAGS b) { return static_cast<TEX_COMPRESS_FLAGS>(static_cast<unsigned long>(a & TEX_FILTER_SRGB_MASK) | static_cast<unsigned long>(b)); } constexpr TEX_COMPRESS_FLAGS operator|(TEX_FILTER_FLAGS a, TEX_COMPRESS_FLAGS b) { return static_cast<TEX_COMPRESS_FLAGS>(static_cast<uint32_t>(a & TEX_FILTER_SRGB_MASK) | static_cast<uint32_t>(b)); }
//===================================================================================== //=====================================================================================
@ -156,7 +156,7 @@ inline HRESULT __cdecl SaveToDDSFile(const Image& image, DDS_FLAGS flags, const
// Compatability helpers // Compatability helpers
//===================================================================================== //=====================================================================================
_Use_decl_annotations_ _Use_decl_annotations_
inline HRESULT __cdecl GetMetadataFromTGAMemory(const void* pSource, size_t size, TexMetadata& metadata) noexcept inline HRESULT __cdecl GetMetadataFromTGAMemory(const uint8_t* pSource, size_t size, TexMetadata& metadata) noexcept
{ {
return GetMetadataFromTGAMemory(pSource, size, TGA_FLAGS_NONE, metadata); return GetMetadataFromTGAMemory(pSource, size, TGA_FLAGS_NONE, metadata);
} }
@ -168,7 +168,7 @@ inline HRESULT __cdecl GetMetadataFromTGAFile(const wchar_t* szFile, TexMetadata
} }
_Use_decl_annotations_ _Use_decl_annotations_
inline HRESULT __cdecl LoadFromTGAMemory(const void* pSource, size_t size, TexMetadata* metadata, ScratchImage& image) noexcept inline HRESULT __cdecl LoadFromTGAMemory(const uint8_t* pSource, size_t size, TexMetadata* metadata, ScratchImage& image) noexcept
{ {
return LoadFromTGAMemory(pSource, size, TGA_FLAGS_NONE, metadata, image); return LoadFromTGAMemory(pSource, size, TGA_FLAGS_NONE, metadata, image);
} }

View File

@ -675,7 +675,7 @@ _Use_decl_annotations_
HRESULT DirectX::EncodeDDSHeader( HRESULT DirectX::EncodeDDSHeader(
const TexMetadata& metadata, const TexMetadata& metadata,
DDS_FLAGS flags, DDS_FLAGS flags,
void* pDestination, uint8_t* pDestination,
size_t maxsize, size_t maxsize,
size_t& required) noexcept size_t& required) noexcept
{ {
@ -851,7 +851,7 @@ HRESULT DirectX::EncodeDDSHeader(
if (maxsize < required) if (maxsize < required)
return E_NOT_SUFFICIENT_BUFFER; return E_NOT_SUFFICIENT_BUFFER;
*static_cast<uint32_t*>(pDestination) = DDS_MAGIC; *reinterpret_cast<uint32_t*>(pDestination) = DDS_MAGIC;
auto header = reinterpret_cast<DDS_HEADER*>(static_cast<uint8_t*>(pDestination) + sizeof(uint32_t)); auto header = reinterpret_cast<DDS_HEADER*>(static_cast<uint8_t*>(pDestination) + sizeof(uint32_t));
assert(header); assert(header);
@ -1835,7 +1835,7 @@ namespace
_Use_decl_annotations_ _Use_decl_annotations_
HRESULT DirectX::GetMetadataFromDDSMemory( HRESULT DirectX::GetMetadataFromDDSMemory(
const void* pSource, const uint8_t* pSource,
size_t size, size_t size,
DDS_FLAGS flags, DDS_FLAGS flags,
TexMetadata& metadata) noexcept TexMetadata& metadata) noexcept
@ -1845,7 +1845,7 @@ HRESULT DirectX::GetMetadataFromDDSMemory(
_Use_decl_annotations_ _Use_decl_annotations_
HRESULT DirectX::GetMetadataFromDDSMemoryEx( HRESULT DirectX::GetMetadataFromDDSMemoryEx(
const void* pSource, const uint8_t* pSource,
size_t size, size_t size,
DDS_FLAGS flags, DDS_FLAGS flags,
TexMetadata& metadata, TexMetadata& metadata,
@ -1957,7 +1957,7 @@ HRESULT DirectX::GetMetadataFromDDSFileEx(
//------------------------------------------------------------------------------------- //-------------------------------------------------------------------------------------
_Use_decl_annotations_ _Use_decl_annotations_
HRESULT DirectX::LoadFromDDSMemory( HRESULT DirectX::LoadFromDDSMemory(
const void* pSource, const uint8_t* pSource,
size_t size, size_t size,
DDS_FLAGS flags, DDS_FLAGS flags,
TexMetadata* metadata, TexMetadata* metadata,
@ -1968,7 +1968,7 @@ HRESULT DirectX::LoadFromDDSMemory(
_Use_decl_annotations_ _Use_decl_annotations_
HRESULT DirectX::LoadFromDDSMemoryEx( HRESULT DirectX::LoadFromDDSMemoryEx(
const void* pSource, const uint8_t* pSource,
size_t size, size_t size,
DDS_FLAGS flags, DDS_FLAGS flags,
TexMetadata* metadata, TexMetadata* metadata,
@ -2355,7 +2355,7 @@ HRESULT DirectX::SaveToDDSMemory(
if (FAILED(hr)) if (FAILED(hr))
return hr; return hr;
auto pDestination = static_cast<uint8_t*>(blob.GetBufferPointer()); auto pDestination = blob.GetBufferPointer();
assert(pDestination); assert(pDestination);
hr = EncodeDDSHeader(metadata, flags, pDestination, blob.GetBufferSize(), required); hr = EncodeDDSHeader(metadata, flags, pDestination, blob.GetBufferSize(), required);

View File

@ -94,7 +94,7 @@ namespace
// Decodes HDR header // Decodes HDR header
//------------------------------------------------------------------------------------- //-------------------------------------------------------------------------------------
HRESULT DecodeHDRHeader( HRESULT DecodeHDRHeader(
_In_reads_bytes_(size) const void* pSource, _In_reads_bytes_(size) const uint8_t* pSource,
size_t size, size_t size,
_Out_ TexMetadata& metadata, _Out_ TexMetadata& metadata,
size_t& offset, size_t& offset,
@ -121,7 +121,7 @@ namespace
// Process first part of header // Process first part of header
bool formatFound = false; bool formatFound = false;
auto info = static_cast<const char*>(pSource); auto info = reinterpret_cast<const char*>(pSource);
while (size > 0) while (size > 0)
{ {
if (*info == '\n') if (*info == '\n')
@ -310,7 +310,7 @@ namespace
return E_FAIL; return E_FAIL;
} }
offset = size_t(info - static_cast<const char*>(pSource)); offset = size_t(info - reinterpret_cast<const char*>(pSource));
metadata.width = width; metadata.width = width;
metadata.height = height; metadata.height = height;
@ -600,7 +600,7 @@ namespace
// Obtain metadata from HDR file in memory/on disk // Obtain metadata from HDR file in memory/on disk
//------------------------------------------------------------------------------------- //-------------------------------------------------------------------------------------
_Use_decl_annotations_ _Use_decl_annotations_
HRESULT DirectX::GetMetadataFromHDRMemory(const void* pSource, size_t size, TexMetadata& metadata) noexcept HRESULT DirectX::GetMetadataFromHDRMemory(const uint8_t* pSource, size_t size, TexMetadata& metadata) noexcept
{ {
if (!pSource || size == 0) if (!pSource || size == 0)
return E_INVALIDARG; return E_INVALIDARG;
@ -696,7 +696,7 @@ HRESULT DirectX::GetMetadataFromHDRFile(const wchar_t* szFile, TexMetadata& meta
// Load a HDR file in memory // Load a HDR file in memory
//------------------------------------------------------------------------------------- //-------------------------------------------------------------------------------------
_Use_decl_annotations_ _Use_decl_annotations_
HRESULT DirectX::LoadFromHDRMemory(const void* pSource, size_t size, TexMetadata* metadata, ScratchImage& image) noexcept HRESULT DirectX::LoadFromHDRMemory(const uint8_t* pSource, size_t size, TexMetadata* metadata, ScratchImage& image) noexcept
{ {
if (!pSource || size == 0) if (!pSource || size == 0)
return E_INVALIDARG; return E_INVALIDARG;
@ -1045,7 +1045,7 @@ HRESULT DirectX::SaveToHDRMemory(const Image& image, Blob& blob) noexcept
return hr; return hr;
// Copy header // Copy header
auto dPtr = static_cast<uint8_t*>(blob.GetBufferPointer()); auto dPtr = blob.GetBufferPointer();
assert(dPtr != nullptr); assert(dPtr != nullptr);
memcpy(dPtr, header, headerLen); memcpy(dPtr, header, headerLen);
dPtr += headerLen; dPtr += headerLen;
@ -1097,7 +1097,7 @@ HRESULT DirectX::SaveToHDRMemory(const Image& image, Blob& blob) noexcept
} }
#endif #endif
hr = blob.Trim(size_t(dPtr - static_cast<uint8_t*>(blob.GetBufferPointer()))); hr = blob.Trim(size_t(dPtr - blob.GetConstBufferPointer()));
if (FAILED(hr)) if (FAILED(hr))
{ {
blob.Release(); blob.Release();
@ -1184,7 +1184,7 @@ HRESULT DirectX::SaveToHDRFile(const Image& image, const wchar_t* szFile) noexce
#ifdef _WIN32 #ifdef _WIN32
auto const bytesToWrite = static_cast<const DWORD>(blob.GetBufferSize()); auto const bytesToWrite = static_cast<const DWORD>(blob.GetBufferSize());
DWORD bytesWritten; DWORD bytesWritten;
if (!WriteFile(hFile.get(), blob.GetBufferPointer(), bytesToWrite, &bytesWritten, nullptr)) if (!WriteFile(hFile.get(), blob.GetConstBufferPointer(), bytesToWrite, &bytesWritten, nullptr))
{ {
return HRESULT_FROM_WIN32(GetLastError()); return HRESULT_FROM_WIN32(GetLastError());
} }
@ -1194,7 +1194,7 @@ HRESULT DirectX::SaveToHDRFile(const Image& image, const wchar_t* szFile) noexce
return E_FAIL; return E_FAIL;
} }
#else #else
outFile.write(reinterpret_cast<char*>(blob.GetBufferPointer()), outFile.write(reinterpret_cast<const char*>(blob.GetConstBufferPointer()),
static_cast<std::streamsize>(blob.GetBufferSize())); static_cast<std::streamsize>(blob.GetBufferSize()));
if (!outFile) if (!outFile)

View File

@ -2955,7 +2955,7 @@ HRESULT DirectX::GenerateMipMaps(
mdata.mipLevels = levels; mdata.mipLevels = levels;
mdata.format = baseImage.format; mdata.format = baseImage.format;
unsigned long filter_select = (filter & TEX_FILTER_MODE_MASK); uint32_t filter_select = (filter & TEX_FILTER_MODE_MASK);
if (!filter_select) if (!filter_select)
{ {
// Default filter choice // Default filter choice
@ -3170,7 +3170,7 @@ HRESULT DirectX::GenerateMipMaps(
TexMetadata mdata2 = metadata; TexMetadata mdata2 = metadata;
mdata2.mipLevels = levels; mdata2.mipLevels = levels;
unsigned long filter_select = (filter & TEX_FILTER_MODE_MASK); uint32_t filter_select = (filter & TEX_FILTER_MODE_MASK);
if (!filter_select) if (!filter_select)
{ {
// Default filter choice // Default filter choice
@ -3300,7 +3300,7 @@ HRESULT DirectX::GenerateMipMaps3D(
HRESULT hr = E_UNEXPECTED; HRESULT hr = E_UNEXPECTED;
unsigned long filter_select = (filter & TEX_FILTER_MODE_MASK); uint32_t filter_select = (filter & TEX_FILTER_MODE_MASK);
if (!filter_select) if (!filter_select)
{ {
// Default filter choice // Default filter choice
@ -3419,7 +3419,7 @@ HRESULT DirectX::GenerateMipMaps3D(
static_assert(TEX_FILTER_POINT == 0x100000, "TEX_FILTER_ flag values don't match TEX_FILTER_MODE_MASK"); static_assert(TEX_FILTER_POINT == 0x100000, "TEX_FILTER_ flag values don't match TEX_FILTER_MODE_MASK");
unsigned long filter_select = (filter & TEX_FILTER_MODE_MASK); uint32_t filter_select = (filter & TEX_FILTER_MODE_MASK);
if (!filter_select) if (!filter_select)
{ {
// Default filter choice // Default filter choice

View File

@ -811,7 +811,7 @@ namespace
static_assert(TEX_FILTER_POINT == 0x100000, "TEX_FILTER_ flag values don't match TEX_FILTER_MASK"); static_assert(TEX_FILTER_POINT == 0x100000, "TEX_FILTER_ flag values don't match TEX_FILTER_MASK");
unsigned long filter_select = filter & TEX_FILTER_MODE_MASK; uint32_t filter_select = filter & TEX_FILTER_MODE_MASK;
if (!filter_select) if (!filter_select)
{ {
// Default filter choice // Default filter choice

View File

@ -139,7 +139,7 @@ namespace
// Decodes TGA header // Decodes TGA header
//------------------------------------------------------------------------------------- //-------------------------------------------------------------------------------------
HRESULT DecodeTGAHeader( HRESULT DecodeTGAHeader(
_In_reads_bytes_(size) const void* pSource, _In_reads_bytes_(size) const uint8_t* pSource,
size_t size, size_t size,
TGA_FLAGS flags, TGA_FLAGS flags,
_Out_ TexMetadata& metadata, _Out_ TexMetadata& metadata,
@ -156,7 +156,7 @@ namespace
return HRESULT_E_INVALID_DATA; return HRESULT_E_INVALID_DATA;
} }
auto pHeader = static_cast<const TGA_HEADER*>(pSource); auto pHeader = reinterpret_cast<const TGA_HEADER*>(pSource);
if (pHeader->bDescriptor & (TGA_FLAGS_INTERLEAVED_2WAY | TGA_FLAGS_INTERLEAVED_4WAY)) if (pHeader->bDescriptor & (TGA_FLAGS_INTERLEAVED_2WAY | TGA_FLAGS_INTERLEAVED_4WAY))
{ {
@ -1447,7 +1447,7 @@ namespace
//------------------------------------------------------------------------------------- //-------------------------------------------------------------------------------------
_Use_decl_annotations_ _Use_decl_annotations_
HRESULT DirectX::GetMetadataFromTGAMemory( HRESULT DirectX::GetMetadataFromTGAMemory(
const void* pSource, const uint8_t* pSource,
size_t size, size_t size,
TGA_FLAGS flags, TGA_FLAGS flags,
TexMetadata& metadata) noexcept TexMetadata& metadata) noexcept
@ -1641,7 +1641,7 @@ HRESULT DirectX::GetMetadataFromTGAFile(const wchar_t* szFile, TGA_FLAGS flags,
//------------------------------------------------------------------------------------- //-------------------------------------------------------------------------------------
_Use_decl_annotations_ _Use_decl_annotations_
HRESULT DirectX::LoadFromTGAMemory( HRESULT DirectX::LoadFromTGAMemory(
const void* pSource, const uint8_t* pSource,
size_t size, size_t size,
TGA_FLAGS flags, TGA_FLAGS flags,
TexMetadata* metadata, TexMetadata* metadata,
@ -2279,7 +2279,7 @@ HRESULT DirectX::SaveToTGAMemory(
return hr; return hr;
// Copy header // Copy header
auto destPtr = static_cast<uint8_t*>(blob.GetBufferPointer()); auto destPtr = blob.GetBufferPointer();
assert(destPtr != nullptr); assert(destPtr != nullptr);
uint8_t* dPtr = destPtr; uint8_t* dPtr = destPtr;
@ -2396,7 +2396,7 @@ HRESULT DirectX::SaveToTGAFile(
#ifdef _WIN32 #ifdef _WIN32
const DWORD bytesToWrite = static_cast<DWORD>(blob.GetBufferSize()); const DWORD bytesToWrite = static_cast<DWORD>(blob.GetBufferSize());
DWORD bytesWritten; DWORD bytesWritten;
if (!WriteFile(hFile.get(), blob.GetBufferPointer(), bytesToWrite, &bytesWritten, nullptr)) if (!WriteFile(hFile.get(), blob.GetConstBufferPointer(), bytesToWrite, &bytesWritten, nullptr))
{ {
return HRESULT_FROM_WIN32(GetLastError()); return HRESULT_FROM_WIN32(GetLastError());
} }
@ -2406,7 +2406,7 @@ HRESULT DirectX::SaveToTGAFile(
return E_FAIL; return E_FAIL;
} }
#else #else
outFile.write(reinterpret_cast<char*>(blob.GetBufferPointer()), outFile.write(reinterpret_cast<const char*>(blob.GetConstBufferPointer()),
static_cast<std::streamsize>(blob.GetBufferSize())); static_cast<std::streamsize>(blob.GetBufferSize()));
if (!outFile) if (!outFile)

View File

@ -1688,7 +1688,7 @@ HRESULT Blob::Initialize(size_t size) noexcept
Release(); Release();
m_buffer = _aligned_malloc(size, 16); m_buffer = reinterpret_cast<uint8_t*>(_aligned_malloc(size, 16));
if (!m_buffer) if (!m_buffer)
{ {
Release(); Release();
@ -1724,7 +1724,7 @@ HRESULT Blob::Resize(size_t size) noexcept
if (!m_buffer || !m_size) if (!m_buffer || !m_size)
return E_UNEXPECTED; return E_UNEXPECTED;
void *tbuffer = _aligned_malloc(size, 16); auto tbuffer = reinterpret_cast<uint8_t*>(_aligned_malloc(size, 16));
if (!tbuffer) if (!tbuffer)
return E_OUTOFMEMORY; return E_OUTOFMEMORY;

View File

@ -208,7 +208,7 @@ namespace
m_streamEOF(0), m_streamEOF(0),
mRefCount(1) mRefCount(1)
{ {
assert(mBlob.GetBufferPointer() && mBlob.GetBufferSize() > 0); assert(mBlob.GetConstBufferPointer() && mBlob.GetBufferSize() > 0);
} }
public: public:
@ -254,7 +254,7 @@ namespace
HRESULT STDMETHODCALLTYPE Read(void* pv, ULONG cb, ULONG* pcbRead) override HRESULT STDMETHODCALLTYPE Read(void* pv, ULONG cb, ULONG* pcbRead) override
{ {
size_t maxRead = m_streamEOF - m_streamPosition; size_t maxRead = m_streamEOF - m_streamPosition;
auto ptr = static_cast<const uint8_t*>(mBlob.GetBufferPointer()); auto ptr = mBlob.GetBufferPointer();
if (cb > maxRead) if (cb > maxRead)
{ {
const uint64_t pos = uint64_t(m_streamPosition) + uint64_t(maxRead); const uint64_t pos = uint64_t(m_streamPosition) + uint64_t(maxRead);
@ -324,7 +324,7 @@ namespace
if (pos > UINT32_MAX) if (pos > UINT32_MAX)
return HRESULT_E_ARITHMETIC_OVERFLOW; return HRESULT_E_ARITHMETIC_OVERFLOW;
auto ptr = static_cast<uint8_t*>(mBlob.GetBufferPointer()); auto ptr = mBlob.GetBufferPointer();
memcpy(&ptr[m_streamPosition], pv, cb); memcpy(&ptr[m_streamPosition], pv, cb);
m_streamPosition = static_cast<size_t>(pos); m_streamPosition = static_cast<size_t>(pos);
@ -347,7 +347,7 @@ namespace
if (blobSize >= size.LowPart) if (blobSize >= size.LowPart)
{ {
auto ptr = static_cast<uint8_t*>(mBlob.GetBufferPointer()); auto ptr = mBlob.GetBufferPointer();
if (m_streamEOF < size.LowPart) if (m_streamEOF < size.LowPart)
{ {
memset(&ptr[m_streamEOF], 0, size.LowPart - m_streamEOF); memset(&ptr[m_streamEOF], 0, size.LowPart - m_streamEOF);
@ -367,7 +367,7 @@ namespace
if (FAILED(hr)) if (FAILED(hr))
return hr; return hr;
auto ptr = static_cast<uint8_t*>(mBlob.GetBufferPointer()); auto ptr = mBlob.GetBufferPointer();
if (m_streamEOF < size.LowPart) if (m_streamEOF < size.LowPart)
{ {
memset(&ptr[m_streamEOF], 0, size.LowPart - m_streamEOF); memset(&ptr[m_streamEOF], 0, size.LowPart - m_streamEOF);
@ -1221,7 +1221,7 @@ namespace
//------------------------------------------------------------------------------------- //-------------------------------------------------------------------------------------
_Use_decl_annotations_ _Use_decl_annotations_
HRESULT DirectX::GetMetadataFromWICMemory( HRESULT DirectX::GetMetadataFromWICMemory(
const void* pSource, const uint8_t* pSource,
size_t size, size_t size,
WIC_FLAGS flags, WIC_FLAGS flags,
TexMetadata& metadata, TexMetadata& metadata,
@ -1244,7 +1244,7 @@ HRESULT DirectX::GetMetadataFromWICMemory(
if (FAILED(hr)) if (FAILED(hr))
return hr; return hr;
hr = stream->InitializeFromMemory(static_cast<BYTE*>(const_cast<void*>(pSource)), hr = stream->InitializeFromMemory(static_cast<BYTE*>(const_cast<uint8_t*>(pSource)),
static_cast<UINT>(size)); static_cast<UINT>(size));
if (FAILED(hr)) if (FAILED(hr))
return hr; return hr;
@ -1312,7 +1312,7 @@ HRESULT DirectX::GetMetadataFromWICFile(
//------------------------------------------------------------------------------------- //-------------------------------------------------------------------------------------
_Use_decl_annotations_ _Use_decl_annotations_
HRESULT DirectX::LoadFromWICMemory( HRESULT DirectX::LoadFromWICMemory(
const void* pSource, const uint8_t* pSource,
size_t size, size_t size,
WIC_FLAGS flags, WIC_FLAGS flags,
TexMetadata* metadata, TexMetadata* metadata,
@ -1338,7 +1338,7 @@ HRESULT DirectX::LoadFromWICMemory(
if (FAILED(hr)) if (FAILED(hr))
return hr; return hr;
hr = stream->InitializeFromMemory(static_cast<uint8_t*>(const_cast<void*>(pSource)), static_cast<DWORD>(size)); hr = stream->InitializeFromMemory(static_cast<uint8_t*>(const_cast<uint8_t*>(pSource)), static_cast<DWORD>(size));
if (FAILED(hr)) if (FAILED(hr))
return hr; return hr;

View File

@ -51,7 +51,7 @@ namespace DirectX
#pragma clang diagnostic ignored "-Wdeprecated-dynamic-exception-spec" #pragma clang diagnostic ignored "-Wdeprecated-dynamic-exception-spec"
#endif #endif
DEFINE_ENUM_FLAG_OPERATORS(WIC_LOADER_FLAGS); DEFINE_ENUM_FLAG_OPERATORS(WIC_LOADER_FLAGS)
#ifdef __clang__ #ifdef __clang__
#pragma clang diagnostic pop #pragma clang diagnostic pop

View File

@ -65,7 +65,7 @@ namespace DirectX
#pragma clang diagnostic ignored "-Wdeprecated-dynamic-exception-spec" #pragma clang diagnostic ignored "-Wdeprecated-dynamic-exception-spec"
#endif #endif
DEFINE_ENUM_FLAG_OPERATORS(WIC_LOADER_FLAGS); DEFINE_ENUM_FLAG_OPERATORS(WIC_LOADER_FLAGS)
#ifdef __clang__ #ifdef __clang__
#pragma clang diagnostic pop #pragma clang diagnostic pop

View File

@ -47,7 +47,7 @@ namespace DirectX
#pragma clang diagnostic ignored "-Wdeprecated-dynamic-exception-spec" #pragma clang diagnostic ignored "-Wdeprecated-dynamic-exception-spec"
#endif #endif
DEFINE_ENUM_FLAG_OPERATORS(WIC_LOADER_FLAGS); DEFINE_ENUM_FLAG_OPERATORS(WIC_LOADER_FLAGS)
#ifdef __clang__ #ifdef __clang__
#pragma clang diagnostic pop #pragma clang diagnostic pop