| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
#pragma once |
| 5 |
|
| 6 |
#include <cstddef> |
| 7 |
#include <string> |
| 8 |
|
| 9 |
#include "Common/CommonTypes.h" |
| 10 |
#include "Common/MathUtil.h" |
| 11 |
#include "VideoCommon/TextureConfig.h" |
| 12 |
|
| 13 |
struct ImTextureRef; |
| 14 |
|
| 15 |
class AbstractTexture |
| 16 |
{ |
| 17 |
public: |
| 18 |
explicit AbstractTexture(const TextureConfig& c); |
| 19 |
virtual ~AbstractTexture() = default; |
| 20 |
|
| 21 |
|
| 22 |
using imgui_texture_id = unsigned long long; |
| 23 |
operator imgui_texture_id() const { return reinterpret_cast<imgui_texture_id>(this); } |
| 24 |
operator ImTextureRef() const; |
| 25 |
|
| 26 |
virtual void CopyRectangleFromTexture(const AbstractTexture* src, |
| 27 |
const MathUtil::Rectangle<int>& src_rect, u32 src_layer, |
| 28 |
u32 src_level, const MathUtil::Rectangle<int>& dst_rect, |
| 29 |
u32 dst_layer, u32 dst_level) = 0; |
| 30 |
virtual void ResolveFromTexture(const AbstractTexture* src, const MathUtil::Rectangle<int>& rect, |
| 31 |
u32 layer, u32 level) = 0; |
| 32 |
virtual void Load(u32 level, u32 width, u32 height, u32 row_length, const u8* buffer, |
| 33 |
size_t buffer_size, u32 layer = 0) = 0; |
| 34 |
|
| 35 |
|
| 36 |
|
| 37 |
virtual void FinishedRendering(); |
| 38 |
|
| 39 |
u32 GetWidth() const { return m_config.width; } |
| 40 |
u32 GetHeight() const { return m_config.height; } |
| 41 |
u32 GetLevels() const { return m_config.levels; } |
| 42 |
u32 GetLayers() const { return m_config.layers; } |
| 43 |
u32 GetSamples() const { return m_config.samples; } |
| 44 |
AbstractTextureFormat GetFormat() const { return m_config.format; } |
| 45 |
MathUtil::Rectangle<int> GetRect() const { return m_config.GetRect(); } |
| 46 |
MathUtil::Rectangle<int> GetMipRect(u32 level) const { return m_config.GetMipRect(level); } |
| 47 |
bool IsMultisampled() const { return m_config.IsMultisampled(); } |
| 48 |
bool Save(const std::string& filename, unsigned int level, int compression = 6) const; |
| 49 |
|
| 50 |
static bool IsCompressedFormat(AbstractTextureFormat format); |
| 51 |
static bool IsDepthFormat(AbstractTextureFormat format); |
| 52 |
static bool IsStencilFormat(AbstractTextureFormat format); |
| 53 |
static bool IsCompatibleDepthAndColorFormats(AbstractTextureFormat depth_format, |
| 54 |
AbstractTextureFormat color_format); |
| 55 |
static u32 CalculateStrideForFormat(AbstractTextureFormat format, u32 row_length); |
| 56 |
static u32 GetTexelSizeForFormat(AbstractTextureFormat format); |
| 57 |
static u32 GetBlockSizeForFormat(AbstractTextureFormat format); |
| 58 |
|
| 59 |
const TextureConfig& GetConfig() const; |
| 60 |
|
| 61 |
protected: |
| 62 |
const TextureConfig m_config; |
| 63 |
}; |