mirror of
https://github.com/microsoft/DirectXTex.git
synced 2025-07-13 21:50:13 +02:00
DirectXTex: added move operators for ScratchImage, Blob
This commit is contained in:
parent
858d473b81
commit
7ddd3762bb
@ -244,9 +244,14 @@ namespace DirectX
|
||||
class ScratchImage
|
||||
{
|
||||
public:
|
||||
ScratchImage() : _nimages(0), _size(0), _image(0), _memory(0) {}
|
||||
ScratchImage()
|
||||
: _nimages(0), _size(0), _image(nullptr), _memory(nullptr) {}
|
||||
ScratchImage(ScratchImage&& moveFrom)
|
||||
: _nimages(0), _size(0), _image(nullptr), _memory(nullptr) { *this = std::move(moveFrom); }
|
||||
~ScratchImage() { Release(); }
|
||||
|
||||
ScratchImage& operator= (ScratchImage&& moveFrom);
|
||||
|
||||
HRESULT Initialize( _In_ const TexMetadata& mdata );
|
||||
|
||||
HRESULT Initialize1D( _In_ DXGI_FORMAT fmt, _In_ size_t length, _In_ size_t arraySize, _In_ size_t mipLevels );
|
||||
@ -291,9 +296,12 @@ namespace DirectX
|
||||
class Blob
|
||||
{
|
||||
public:
|
||||
Blob() : _buffer(0), _size(0) {}
|
||||
Blob() : _buffer(nullptr), _size(0) {}
|
||||
Blob(Blob&& moveFrom) : _buffer(nullptr), _size(0) { *this = std::move(moveFrom); }
|
||||
~Blob() { Release(); }
|
||||
|
||||
Blob& operator= (Blob&& moveFrom);
|
||||
|
||||
HRESULT Initialize( _In_ size_t size );
|
||||
|
||||
void Release();
|
||||
|
@ -229,6 +229,27 @@ bool _SetupImageArray( uint8_t *pMemory, size_t pixelSize,
|
||||
// ScratchImage - Bitmap image container
|
||||
//=====================================================================================
|
||||
|
||||
ScratchImage& ScratchImage::operator= (ScratchImage&& moveFrom)
|
||||
{
|
||||
if ( this != &moveFrom )
|
||||
{
|
||||
Release();
|
||||
|
||||
_nimages = moveFrom._nimages;
|
||||
_size = moveFrom._size;
|
||||
_metadata = moveFrom._metadata;
|
||||
_image = moveFrom._image;
|
||||
_memory = moveFrom._memory;
|
||||
|
||||
moveFrom._nimages = 0;
|
||||
moveFrom._size = 0;
|
||||
moveFrom._image = nullptr;
|
||||
moveFrom._memory = nullptr;
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
//-------------------------------------------------------------------------------------
|
||||
// Methods
|
||||
//-------------------------------------------------------------------------------------
|
||||
|
@ -915,6 +915,21 @@ size_t TexMetadata::ComputeIndex( size_t mip, size_t item, size_t slice ) const
|
||||
// Blob - Bitmap image container
|
||||
//=====================================================================================
|
||||
|
||||
Blob& Blob::operator= (Blob&& moveFrom)
|
||||
{
|
||||
if ( this != &moveFrom )
|
||||
{
|
||||
Release();
|
||||
|
||||
_buffer = moveFrom._buffer;
|
||||
_size = moveFrom._size;
|
||||
|
||||
moveFrom._buffer = nullptr;
|
||||
moveFrom._size = 0;
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
|
||||
void Blob::Release()
|
||||
{
|
||||
if ( _buffer )
|
||||
|
Loading…
x
Reference in New Issue
Block a user