Made Resource copying/moving impossible
It is still possible to copy some Resource-based classes though Former-commit-id: bbb6066f736c210015ff9fdfded7d95eb9695359
This commit is contained in:
parent
ff7cfa226e
commit
cd5399459d
|
|
@ -23,6 +23,8 @@ class NAZARA_API NzResource
|
|||
{
|
||||
public:
|
||||
NzResource(bool persistent = true);
|
||||
NzResource(const NzResource& resource) = delete;
|
||||
NzResource(NzResource&& resource) = delete;
|
||||
virtual ~NzResource();
|
||||
|
||||
void AddResourceListener(NzResourceListener* listener, int index = 0) const;
|
||||
|
|
@ -37,6 +39,9 @@ class NAZARA_API NzResource
|
|||
|
||||
bool SetPersistent(bool persistent = true, bool checkReferenceCount = false);
|
||||
|
||||
NzResource& operator=(const NzResource& resource) = delete;
|
||||
NzResource& operator=(NzResource&& resource) = delete;
|
||||
|
||||
protected:
|
||||
void NotifyCreated();
|
||||
void NotifyDestroy();
|
||||
|
|
|
|||
|
|
@ -46,7 +46,6 @@ class NAZARA_API NzMaterial : public NzResource
|
|||
public:
|
||||
NzMaterial();
|
||||
NzMaterial(const NzMaterial& material);
|
||||
NzMaterial(NzMaterial&& material);
|
||||
~NzMaterial();
|
||||
|
||||
const NzShader* Apply(nzUInt32 shaderFlags = 0, nzUInt8 textureUnit = 0, nzUInt8* lastUsedUnit = nullptr) const;
|
||||
|
|
@ -127,7 +126,6 @@ class NAZARA_API NzMaterial : public NzResource
|
|||
void SetSrcBlend(nzBlendFunc func);
|
||||
|
||||
NzMaterial& operator=(const NzMaterial& material);
|
||||
NzMaterial& operator=(NzMaterial&& material);
|
||||
|
||||
static NzMaterial* GetDefault();
|
||||
|
||||
|
|
|
|||
|
|
@ -31,7 +31,6 @@ class NAZARA_API NzTexture : public NzAbstractImage, public NzResource, NzNonCop
|
|||
NzTexture() = default;
|
||||
NzTexture(nzImageType type, nzPixelFormat format, unsigned int width, unsigned int height, unsigned int depth = 1, nzUInt8 levelCount = 1);
|
||||
explicit NzTexture(const NzImage& image);
|
||||
NzTexture(NzTexture&& texture);
|
||||
~NzTexture();
|
||||
|
||||
bool Create(nzImageType type, nzPixelFormat format, unsigned int width, unsigned int height, unsigned int depth = 1, nzUInt8 levelCount = 1);
|
||||
|
|
@ -94,8 +93,6 @@ class NAZARA_API NzTexture : public NzAbstractImage, public NzResource, NzNonCop
|
|||
// Fonctions OpenGL
|
||||
unsigned int GetOpenGLID() const;
|
||||
|
||||
NzTexture& operator=(NzTexture&& texture);
|
||||
|
||||
static unsigned int GetValidSize(unsigned int size);
|
||||
static bool IsFormatSupported(nzPixelFormat format);
|
||||
static bool IsMipmappingSupported();
|
||||
|
|
|
|||
|
|
@ -46,7 +46,6 @@ class NAZARA_API NzImage : public NzAbstractImage, public NzResource
|
|||
NzImage();
|
||||
NzImage(nzImageType type, nzPixelFormat format, unsigned int width, unsigned int height, unsigned int depth = 1, nzUInt8 levelCount = 1);
|
||||
NzImage(const NzImage& image);
|
||||
NzImage(NzImage&& image) noexcept;
|
||||
NzImage(SharedImage* sharedImage);
|
||||
~NzImage();
|
||||
|
||||
|
|
@ -105,7 +104,6 @@ class NAZARA_API NzImage : public NzAbstractImage, public NzResource
|
|||
bool Update(const nzUInt8* pixels, const NzRectui& rect, unsigned int z = 0, unsigned int srcWidth = 0, unsigned int srcHeight = 0, nzUInt8 level = 0);
|
||||
|
||||
NzImage& operator=(const NzImage& image);
|
||||
NzImage& operator=(NzImage&& image) noexcept;
|
||||
|
||||
static void Copy(nzUInt8* destination, const nzUInt8* source, nzUInt8 bpp, unsigned int width, unsigned int height, unsigned int depth = 1, unsigned int dstWidth = 0, unsigned int dstHeight = 0, unsigned int srcWidth = 0, unsigned int srcHeight = 0);
|
||||
static nzUInt8 GetMaxLevel(unsigned int width, unsigned int height, unsigned int depth = 1);
|
||||
|
|
|
|||
|
|
@ -34,11 +34,6 @@ NzResource()
|
|||
Copy(material);
|
||||
}
|
||||
|
||||
NzMaterial::NzMaterial(NzMaterial&& material)
|
||||
{
|
||||
Move(material);
|
||||
}
|
||||
|
||||
NzMaterial::~NzMaterial()
|
||||
{
|
||||
NotifyDestroy();
|
||||
|
|
@ -613,13 +608,6 @@ NzMaterial& NzMaterial::operator=(const NzMaterial& material)
|
|||
return *this;
|
||||
}
|
||||
|
||||
NzMaterial& NzMaterial::operator=(NzMaterial&& material)
|
||||
{
|
||||
Move(material);
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
NzMaterial* NzMaterial::GetDefault()
|
||||
{
|
||||
return s_defaultMaterial;
|
||||
|
|
@ -655,36 +643,6 @@ void NzMaterial::Copy(const NzMaterial& material)
|
|||
std::memcpy(&m_shaders[0], &material.m_shaders[0], (nzShaderFlags_Max+1)*sizeof(ShaderInstance));
|
||||
}
|
||||
|
||||
void NzMaterial::Move(NzMaterial&& material)
|
||||
{
|
||||
// Copie des états de base
|
||||
m_alphaTestEnabled = material.m_alphaTestEnabled;
|
||||
m_alphaThreshold = material.m_alphaThreshold;
|
||||
m_ambientColor = material.m_ambientColor;
|
||||
m_diffuseColor = material.m_diffuseColor;
|
||||
m_diffuseSampler = material.m_diffuseSampler;
|
||||
m_lightingEnabled = material.m_lightingEnabled;
|
||||
m_shininess = material.m_shininess;
|
||||
m_specularColor = material.m_specularColor;
|
||||
m_specularSampler = material.m_specularSampler;
|
||||
m_states = material.m_states;
|
||||
m_transformEnabled = material.m_transformEnabled;
|
||||
|
||||
// Vol des références de texture
|
||||
m_alphaMap = std::move(material.m_alphaMap);
|
||||
m_diffuseMap = std::move(material.m_diffuseMap);
|
||||
m_emissiveMap = std::move(material.m_emissiveMap);
|
||||
m_heightMap = std::move(material.m_heightMap);
|
||||
m_normalMap = std::move(material.m_normalMap);
|
||||
m_specularMap = std::move(material.m_specularMap);
|
||||
|
||||
// Vol de la référence vers l'Über-Shader
|
||||
m_uberShader = std::move(material.m_uberShader);
|
||||
|
||||
// On copie les instances de shader par la même occasion
|
||||
std::memcpy(&m_shaders[0], &material.m_shaders[0], (nzShaderFlags_Max+1)*sizeof(ShaderInstance));
|
||||
}
|
||||
|
||||
void NzMaterial::GenerateShader(nzUInt32 flags) const
|
||||
{
|
||||
NzParameterList list;
|
||||
|
|
|
|||
|
|
@ -60,12 +60,6 @@ NzTexture::NzTexture(const NzImage& image)
|
|||
LoadFromImage(image);
|
||||
}
|
||||
|
||||
NzTexture::NzTexture(NzTexture&& texture) :
|
||||
m_impl(texture.m_impl)
|
||||
{
|
||||
texture.m_impl = nullptr;
|
||||
}
|
||||
|
||||
NzTexture::~NzTexture()
|
||||
{
|
||||
Destroy();
|
||||
|
|
@ -477,6 +471,19 @@ bool NzTexture::HasMipmaps() const
|
|||
return m_impl->levelCount > 1;
|
||||
}
|
||||
|
||||
void NzTexture::InvalidateMipmaps()
|
||||
{
|
||||
#if NAZARA_RENDERER_SAFE
|
||||
if (!m_impl)
|
||||
{
|
||||
NazaraInternalError("Texture must be valid");
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
|
||||
m_impl->mipmapsUpdated = false;
|
||||
}
|
||||
|
||||
bool NzTexture::IsValid() const
|
||||
{
|
||||
return m_impl != nullptr;
|
||||
|
|
@ -1031,16 +1038,6 @@ unsigned int NzTexture::GetOpenGLID() const
|
|||
return m_impl->id;
|
||||
}
|
||||
|
||||
NzTexture& NzTexture::operator=(NzTexture&& texture)
|
||||
{
|
||||
Destroy();
|
||||
|
||||
m_impl = texture.m_impl;
|
||||
texture.m_impl = nullptr;
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
unsigned int NzTexture::GetValidSize(unsigned int size)
|
||||
{
|
||||
if (NzRenderer::HasCapability(nzRendererCap_TextureNPOT))
|
||||
|
|
@ -1277,16 +1274,3 @@ bool NzTexture::CreateTexture(bool proxy)
|
|||
|
||||
return true;
|
||||
}
|
||||
|
||||
void NzTexture::InvalidateMipmaps()
|
||||
{
|
||||
#if NAZARA_RENDERER_SAFE
|
||||
if (!m_impl)
|
||||
{
|
||||
NazaraInternalError("Texture must be valid");
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
|
||||
m_impl->mipmapsUpdated = false;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -57,12 +57,6 @@ m_sharedImage(image.m_sharedImage)
|
|||
m_sharedImage->refCount++;
|
||||
}
|
||||
|
||||
NzImage::NzImage(NzImage&& image) noexcept :
|
||||
m_sharedImage(image.m_sharedImage)
|
||||
{
|
||||
image.m_sharedImage = &emptyImage;
|
||||
}
|
||||
|
||||
NzImage::NzImage(SharedImage* sharedImage) :
|
||||
m_sharedImage(sharedImage)
|
||||
{
|
||||
|
|
@ -1283,13 +1277,6 @@ NzImage& NzImage::operator=(const NzImage& image)
|
|||
return *this;
|
||||
}
|
||||
|
||||
NzImage& NzImage::operator=(NzImage&& image) noexcept
|
||||
{
|
||||
std::swap(m_sharedImage, image.m_sharedImage);
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
void NzImage::Copy(nzUInt8* destination, const nzUInt8* source, nzUInt8 bpp, unsigned int width, unsigned int height, unsigned int depth, unsigned int dstWidth, unsigned int dstHeight, unsigned int srcWidth, unsigned int srcHeight)
|
||||
{
|
||||
if (dstWidth == 0)
|
||||
|
|
|
|||
Loading…
Reference in New Issue