2017-04-22 22:44:34 -06:00
|
|
|
// Copyright 2017 Dolphin Emulator Project
|
|
|
|
// Licensed under GPLv2+
|
|
|
|
// Refer to the license.txt file included.
|
|
|
|
|
|
|
|
#include "VideoBackends/Software/SWTexture.h"
|
|
|
|
|
2017-08-23 20:46:23 -06:00
|
|
|
#include <cstring>
|
|
|
|
|
|
|
|
#include "VideoBackends/Software/CopyRegion.h"
|
|
|
|
|
2017-04-22 22:44:34 -06:00
|
|
|
namespace SW
|
|
|
|
{
|
|
|
|
SWTexture::SWTexture(const TextureConfig& tex_config) : AbstractTexture(tex_config)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
void SWTexture::Bind(unsigned int stage)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
void SWTexture::CopyRectangleFromTexture(const AbstractTexture* source,
|
|
|
|
const MathUtil::Rectangle<int>& srcrect,
|
|
|
|
const MathUtil::Rectangle<int>& dstrect)
|
|
|
|
{
|
2017-09-02 20:30:34 -06:00
|
|
|
const SWTexture* software_source_texture = static_cast<const SWTexture*>(source);
|
2017-08-23 20:46:23 -06:00
|
|
|
|
|
|
|
if (srcrect.GetWidth() == dstrect.GetWidth() && srcrect.GetHeight() == dstrect.GetHeight())
|
|
|
|
{
|
2017-09-02 20:30:34 -06:00
|
|
|
m_data.assign(software_source_texture->GetData(),
|
|
|
|
software_source_texture->GetData() + m_data.size());
|
2017-08-23 20:46:23 -06:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
copy_region(software_source_texture->GetData(), srcrect, GetData(), dstrect);
|
|
|
|
}
|
2017-04-22 22:44:34 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
void SWTexture::Load(u32 level, u32 width, u32 height, u32 row_length, const u8* buffer,
|
|
|
|
size_t buffer_size)
|
|
|
|
{
|
2017-08-23 20:46:23 -06:00
|
|
|
m_data.assign(buffer, buffer + buffer_size);
|
|
|
|
}
|
|
|
|
|
|
|
|
const u8* SWTexture::GetData() const
|
|
|
|
{
|
|
|
|
return m_data.data();
|
|
|
|
}
|
|
|
|
|
|
|
|
u8* SWTexture::GetData()
|
|
|
|
{
|
|
|
|
return m_data.data();
|
|
|
|
}
|
|
|
|
|
|
|
|
std::optional<AbstractTexture::RawTextureInfo> SWTexture::MapFullImpl()
|
|
|
|
{
|
2017-09-02 20:30:34 -06:00
|
|
|
return AbstractTexture::RawTextureInfo{GetData(), m_config.width * 4, m_config.width,
|
|
|
|
m_config.height};
|
2017-04-22 22:44:34 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
} // namespace SW
|