Added class AbstractImage, inherited by Image and Texture

Former-commit-id: 16e5db4937a145ac244d6c70e4c74662622f86d9
This commit is contained in:
Lynix
2015-01-05 15:08:29 +01:00
parent 304b4d13cc
commit e3f7644831
7 changed files with 178 additions and 82 deletions

View File

@@ -0,0 +1,42 @@
// Copyright (C) 2015 Jérôme Leclercq
// This file is part of the "Nazara Engine - Utility module"
// For conditions of distribution and use, see copyright notice in Config.hpp
#pragma once
#ifndef NAZARA_ABSTRACTIMAGE_HPP
#define NAZARA_ABSTRACTIMAGE_HPP
#include <Nazara/Prerequesites.hpp>
#include <Nazara/Math/Box.hpp>
#include <Nazara/Math/Rect.hpp>
#include <Nazara/Math/Vector3.hpp>
#include <Nazara/Utility/Enums.hpp>
class NAZARA_API NzAbstractImage
{
public:
NzAbstractImage() = default;
~NzAbstractImage();
nzUInt8 GetBytesPerPixel() const;
virtual unsigned int GetDepth(nzUInt8 level = 0) const = 0;
virtual nzPixelFormat GetFormat() const = 0;
virtual unsigned int GetHeight(nzUInt8 level = 0) const = 0;
virtual nzUInt8 GetLevelCount() const = 0;
virtual nzUInt8 GetMaxLevel() const = 0;
virtual unsigned int GetMemoryUsage() const = 0;
virtual unsigned int GetMemoryUsage(nzUInt8 level) const = 0;
virtual NzVector3ui GetSize(nzUInt8 level = 0) const = 0;
virtual nzImageType GetType() const = 0;
virtual unsigned int GetWidth(nzUInt8 level = 0) const = 0;
bool IsCompressed() const;
bool IsCubemap() const;
virtual bool Update(const nzUInt8* pixels, unsigned int srcWidth = 0, unsigned int srcHeight = 0, nzUInt8 level = 0) = 0;
virtual bool Update(const nzUInt8* pixels, const NzBoxui& box, unsigned int srcWidth = 0, unsigned int srcHeight = 0, nzUInt8 level = 0) = 0;
virtual bool Update(const nzUInt8* pixels, const NzRectui& rect, unsigned int z = 0, unsigned int srcWidth = 0, unsigned int srcHeight = 0, nzUInt8 level = 0) = 0;
};
#endif // NAZARA_IMAGE_HPP

View File

@@ -13,12 +13,8 @@
#include <Nazara/Core/Resource.hpp>
#include <Nazara/Core/ResourceLoader.hpp>
#include <Nazara/Core/ResourceRef.hpp>
#include <Nazara/Math/Box.hpp>
#include <Nazara/Math/Rect.hpp>
#include <Nazara/Math/Vector3.hpp>
#include <Nazara/Utility/AbstractImage.hpp>
#include <Nazara/Utility/CubemapParams.hpp>
#include <Nazara/Utility/Enums.hpp>
#include <Nazara/Utility/PixelFormat.hpp>
#include <atomic>
///TODO: Filtres
@@ -40,7 +36,7 @@ using NzImageConstRef = NzResourceRef<const NzImage>;
using NzImageLoader = NzResourceLoader<NzImage, NzImageParams>;
using NzImageRef = NzResourceRef<NzImage>;
class NAZARA_API NzImage : public NzResource
class NAZARA_API NzImage : public NzAbstractImage, public NzResource
{
friend NzImageLoader;
@@ -68,7 +64,6 @@ class NAZARA_API NzImage : public NzResource
bool FlipHorizontally();
bool FlipVertically();
nzUInt8 GetBytesPerPixel() const;
const nzUInt8* GetConstPixels(unsigned int x = 0, unsigned int y = 0, unsigned int z = 0, nzUInt8 level = 0) const;
unsigned int GetDepth(nzUInt8 level = 0) const;
nzPixelFormat GetFormat() const;
@@ -83,8 +78,6 @@ class NAZARA_API NzImage : public NzResource
nzImageType GetType() const;
unsigned int GetWidth(nzUInt8 level = 0) const;
bool IsCompressed() const;
bool IsCubemap() const;
bool IsValid() const;
// Load
@@ -107,9 +100,9 @@ class NAZARA_API NzImage : public NzResource
void SetLevelCount(nzUInt8 levelCount);
bool SetPixelColor(const NzColor& color, unsigned int x, unsigned int y = 0, unsigned int z = 0);
void Update(const nzUInt8* pixels, unsigned int srcWidth = 0, unsigned int srcHeight = 0, nzUInt8 level = 0);
void Update(const nzUInt8* pixels, const NzBoxui& box, unsigned int srcWidth = 0, unsigned int srcHeight = 0, nzUInt8 level = 0);
void Update(const nzUInt8* pixels, const NzRectui& rect, unsigned int z = 0, unsigned int srcWidth = 0, unsigned int srcHeight = 0, nzUInt8 level = 0);
bool Update(const nzUInt8* pixels, unsigned int srcWidth = 0, unsigned int srcHeight = 0, nzUInt8 level = 0);
bool Update(const nzUInt8* pixels, const NzBoxui& box, unsigned int srcWidth = 0, unsigned int srcHeight = 0, nzUInt8 level = 0);
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;