2017-04-23 04:44:34 +00:00
|
|
|
// Copyright 2017 Dolphin Emulator Project
|
|
|
|
// Licensed under GPLv2+
|
|
|
|
// Refer to the license.txt file included.
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
2017-06-19 03:28:28 +00:00
|
|
|
#include <cstddef>
|
|
|
|
#include <string>
|
|
|
|
|
2017-04-23 04:44:34 +00:00
|
|
|
#include "Common/CommonTypes.h"
|
|
|
|
#include "Common/MathUtil.h"
|
|
|
|
#include "VideoCommon/TextureConfig.h"
|
|
|
|
|
|
|
|
class AbstractTexture
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
explicit AbstractTexture(const TextureConfig& c);
|
2018-01-26 08:32:33 +00:00
|
|
|
virtual ~AbstractTexture() = default;
|
2017-10-30 12:00:15 +00:00
|
|
|
|
2017-10-30 11:51:42 +00:00
|
|
|
virtual void CopyRectangleFromTexture(const AbstractTexture* src,
|
|
|
|
const MathUtil::Rectangle<int>& src_rect, u32 src_layer,
|
|
|
|
u32 src_level, const MathUtil::Rectangle<int>& dst_rect,
|
|
|
|
u32 dst_layer, u32 dst_level) = 0;
|
|
|
|
virtual void ScaleRectangleFromTexture(const AbstractTexture* source,
|
|
|
|
const MathUtil::Rectangle<int>& srcrect,
|
|
|
|
const MathUtil::Rectangle<int>& dstrect) = 0;
|
2018-01-21 05:03:06 +00:00
|
|
|
virtual void ResolveFromTexture(const AbstractTexture* src, const MathUtil::Rectangle<int>& rect,
|
|
|
|
u32 layer, u32 level) = 0;
|
2017-04-23 04:44:34 +00:00
|
|
|
virtual void Load(u32 level, u32 width, u32 height, u32 row_length, const u8* buffer,
|
|
|
|
size_t buffer_size) = 0;
|
|
|
|
|
2018-01-21 14:28:34 +00:00
|
|
|
u32 GetWidth() const { return m_config.width; }
|
|
|
|
u32 GetHeight() const { return m_config.height; }
|
|
|
|
u32 GetLevels() const { return m_config.levels; }
|
|
|
|
u32 GetLayers() const { return m_config.layers; }
|
|
|
|
u32 GetSamples() const { return m_config.samples; }
|
|
|
|
AbstractTextureFormat GetFormat() const { return m_config.format; }
|
|
|
|
bool IsMultisampled() const { return m_config.IsMultisampled(); }
|
2017-10-30 12:00:15 +00:00
|
|
|
bool Save(const std::string& filename, unsigned int level);
|
|
|
|
|
2017-10-21 14:49:40 +00:00
|
|
|
static bool IsCompressedFormat(AbstractTextureFormat format);
|
2018-01-21 13:59:19 +00:00
|
|
|
static bool IsDepthFormat(AbstractTextureFormat format);
|
2018-01-21 10:22:45 +00:00
|
|
|
static bool IsStencilFormat(AbstractTextureFormat format);
|
2017-10-21 14:49:40 +00:00
|
|
|
static size_t CalculateStrideForFormat(AbstractTextureFormat format, u32 row_length);
|
|
|
|
static size_t GetTexelSizeForFormat(AbstractTextureFormat format);
|
2017-04-23 04:44:34 +00:00
|
|
|
|
2017-06-19 03:33:15 +00:00
|
|
|
const TextureConfig& GetConfig() const;
|
2017-04-23 04:44:34 +00:00
|
|
|
|
|
|
|
protected:
|
|
|
|
const TextureConfig m_config;
|
|
|
|
};
|