Add PixelFormatSampler utility to quick read/write operations on various data formats
Moved from `TextureTool` to be used in runtime and with more generic use cases (including C# scripting).
This commit is contained in:
@@ -11,6 +11,7 @@
|
||||
#include "Engine/Debug/Exceptions/InvalidOperationException.h"
|
||||
#include "Engine/Profiler/ProfilerCPU.h"
|
||||
#include "Engine/Content/Factories/BinaryAssetFactory.h"
|
||||
#include "Engine/Graphics/PixelFormatSampler.h"
|
||||
#include "Engine/Scripting/Enums.h"
|
||||
#include "Engine/Tools/TextureTool/TextureTool.h"
|
||||
#include "Engine/Threading/Threading.h"
|
||||
@@ -100,14 +101,14 @@ bool TextureMipData::GetPixels(Array<Color32>& pixels, int32 width, int32 height
|
||||
default:
|
||||
{
|
||||
// Try to use texture sampler utility
|
||||
auto sampler = TextureTool::GetSampler(format);
|
||||
auto sampler = PixelFormatSampler::Get(format);
|
||||
if (sampler)
|
||||
{
|
||||
for (int32 y = 0; y < height; y++)
|
||||
{
|
||||
for (int32 x = 0; x < width; x++)
|
||||
{
|
||||
Color c = TextureTool::SamplePoint(sampler, x, y, src, RowPitch);
|
||||
Color c = sampler->SamplePoint(src, x, y, RowPitch);
|
||||
*(Color32*)(dst + dstRowSize * y + x * sizeof(Color32)) = Color32(c);
|
||||
}
|
||||
}
|
||||
@@ -149,14 +150,14 @@ bool TextureMipData::GetPixels(Array<Color>& pixels, int32 width, int32 height,
|
||||
default:
|
||||
{
|
||||
// Try to use texture sampler utility
|
||||
auto sampler = TextureTool::GetSampler(format);
|
||||
auto sampler = PixelFormatSampler::Get(format);
|
||||
if (sampler)
|
||||
{
|
||||
for (int32 y = 0; y < height; y++)
|
||||
{
|
||||
for (int32 x = 0; x < width; x++)
|
||||
{
|
||||
Color c = TextureTool::SamplePoint(sampler, x, y, src, RowPitch);
|
||||
Color c = sampler->SamplePoint(src, x, y, RowPitch);
|
||||
*(Color*)(dst + dstRowSize * y + x * sizeof(Color)) = c;
|
||||
}
|
||||
}
|
||||
@@ -475,7 +476,7 @@ bool TextureBase::SetPixels(const Span<Color32>& pixels, int32 mipIndex, int32 a
|
||||
if (error)
|
||||
{
|
||||
// Try to use texture sampler utility
|
||||
auto sampler = TextureTool::GetSampler(format);
|
||||
auto sampler = PixelFormatSampler::Get(format);
|
||||
if (sampler)
|
||||
{
|
||||
for (int32 y = 0; y < height; y++)
|
||||
@@ -483,7 +484,7 @@ bool TextureBase::SetPixels(const Span<Color32>& pixels, int32 mipIndex, int32 a
|
||||
for (int32 x = 0; x < width; x++)
|
||||
{
|
||||
Color c(pixels.Get()[x + y * width]);
|
||||
TextureTool::Store(sampler, x, y, dst, rowPitch, c);
|
||||
sampler->Store(dst, x, y, rowPitch, c);
|
||||
}
|
||||
}
|
||||
error = false;
|
||||
@@ -553,7 +554,7 @@ bool TextureBase::SetPixels(const Span<Color>& pixels, int32 mipIndex, int32 arr
|
||||
if (error)
|
||||
{
|
||||
// Try to use texture sampler utility
|
||||
auto sampler = TextureTool::GetSampler(format);
|
||||
auto sampler = PixelFormatSampler::Get(format);
|
||||
if (sampler)
|
||||
{
|
||||
for (int32 y = 0; y < height; y++)
|
||||
@@ -561,7 +562,7 @@ bool TextureBase::SetPixels(const Span<Color>& pixels, int32 mipIndex, int32 arr
|
||||
for (int32 x = 0; x < width; x++)
|
||||
{
|
||||
Color c(pixels.Get()[x + y * width]);
|
||||
TextureTool::Store(sampler, x, y, dst, rowPitch, c);
|
||||
sampler->Store(dst, x, y, rowPitch, c);
|
||||
}
|
||||
}
|
||||
error = false;
|
||||
|
||||
Reference in New Issue
Block a user