Common and VideoCommon: Change texture data from std::vector to Common::UniqueBuffer.

This commit is contained in:
Jordan Woyak
2025-05-03 17:36:22 -05:00
parent a736d2ed5f
commit 5a80105555
8 changed files with 36 additions and 33 deletions

View File

@ -13,7 +13,6 @@
#include "Common/IOFile.h"
#include "Common/Image.h"
#include "Common/Logging/Log.h"
#include "Common/Swap.h"
#include "VideoCommon/VideoConfig.h"
namespace
@ -235,7 +234,7 @@ static void ConvertTexture_X8R8G8B8(VideoCommon::CustomTextureData::ArraySlice::
static void ConvertTexture_R8G8B8(VideoCommon::CustomTextureData::ArraySlice::Level* level)
{
std::vector<u8> new_data(level->row_length * level->height * sizeof(u32));
Common::UniqueBuffer<u8> new_data(level->row_length * level->height * sizeof(u32));
const u8* rgb_data_ptr = level->data.data();
u8* data_ptr = new_data.data();
@ -479,7 +478,7 @@ static bool ReadMipLevel(VideoCommon::CustomTextureData::ArraySlice::Level* leve
level->height = height;
level->format = info.format;
level->row_length = row_length;
level->data.resize(size);
level->data.reset(size);
if (!file.ReadBytes(level->data.data(), level->data.size()))
return false;
@ -571,13 +570,13 @@ bool LoadPNGTexture(CustomTextureData::ArraySlice::Level* level, const std::stri
File::IOFile file;
file.Open(filename, "rb");
std::vector<u8> buffer(file.GetSize());
Common::UniqueBuffer<u8> buffer(file.GetSize());
file.ReadBytes(buffer.data(), file.GetSize());
return LoadPNGTexture(level, buffer);
}
bool LoadPNGTexture(CustomTextureData::ArraySlice::Level* level, const std::vector<u8>& buffer)
bool LoadPNGTexture(CustomTextureData::ArraySlice::Level* level, std::span<const u8> buffer)
{
if (!level) [[unlikely]]
return false;