MCPcopy Create free account
hub / github.com/FlaxEngine/FlaxEngine / Transform

Method Transform

Source/Engine/Tools/TextureTool/TextureTool.cpp:714–740  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

712}
713
714bool TextureTool::Transform(TextureData& texture, const Function<void(Color&)>& transformation)
715{
716 PROFILE_CPU();
717 PROFILE_MEM(GraphicsTextures);
718 auto sampler = PixelFormatSampler::Get(texture.Format);
719 if (!sampler)
720 return true;
721 for (auto& slice : texture.Items)
722 {
723 for (int32 mipIndex = 0; mipIndex < slice.Mips.Count(); mipIndex++)
724 {
725 auto& mip = slice.Mips[mipIndex];
726 auto mipWidth = Math::Max(texture.Width >> mipIndex, 1);
727 auto mipHeight = Math::Max(texture.Height >> mipIndex, 1);
728 for (int32 y = 0; y < mipHeight; y++)
729 {
730 for (int32 x = 0; x < mipWidth; x++)
731 {
732 Color color = sampler->SamplePoint(mip.Data.Get(), x, y, mip.RowPitch);
733 transformation(color);
734 sampler->Store(mip.Data.Get(), x, y, mip.RowPitch, color);
735 }
736 }
737 }
738 }
739 return false;
740}
741
742#endif

Callers 3

TestLocalToWorldMethod · 0.45
TestWorldToLocalMethod · 0.45
UpdateBoundsMethod · 0.45

Calls 6

SamplePointMethod · 0.80
GetFunction · 0.50
MaxFunction · 0.50
CountMethod · 0.45
GetMethod · 0.45
StoreMethod · 0.45

Tested by 2

TestLocalToWorldMethod · 0.36
TestWorldToLocalMethod · 0.36