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

Method GetTextureMipData

Source/Engine/Graphics/Textures/TextureBase.cpp:399–436  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

397}
398
399bool TextureBase::GetTextureMipData(TextureMipData& result, int32 mipIndex, int32 arrayIndex, bool copyData)
400{
401 PROFILE_CPU_NAMED("Texture.GetTextureMipData");
402 if (!IsVirtual() && WaitForLoaded())
403 {
404 LOG(Error, "Asset load failed.");
405 return true;
406 }
407 if (mipIndex < 0 || mipIndex > GetMipLevels() || arrayIndex < 0 || arrayIndex > GetArraySize())
408 {
409 Log::ArgumentOutOfRangeException();
410 return true;
411 }
412
413 // Get raw texture data
414 int32 rowPitch, slicePitch;
415 BytesContainer mipData = GetMipData(mipIndex, rowPitch, slicePitch);
416 if (mipData.IsInvalid())
417 {
418 LOG(Error, "Failed to get texture mip data.");
419 return true;
420 }
421 if (mipData.Length() != slicePitch * _texture.TotalArraySize())
422 {
423 LOG(Error, "Invalid custom texture data (slice pitch * array size is different than data bytes count).");
424 return true;
425 }
426
427 // Fill result
428 result.RowPitch = rowPitch;
429 result.DepthPitch = slicePitch;
430 result.Lines = Math::Max(1, Height() >> mipIndex);
431 if (copyData)
432 result.Data.Copy(mipData.Get() + (arrayIndex * slicePitch), slicePitch);
433 else
434 result.Data.Link(mipData.Get() + (arrayIndex * slicePitch), slicePitch);
435 return false;
436}
437
438bool TextureBase::GetPixels(Array<Color32>& pixels, int32 mipIndex, int32 arrayIndex)
439{

Callers

nothing calls this directly

Calls 9

IsVirtualFunction · 0.85
HeightFunction · 0.70
MaxFunction · 0.50
IsInvalidMethod · 0.45
LengthMethod · 0.45
CopyMethod · 0.45
GetMethod · 0.45
LinkMethod · 0.45

Tested by

no test coverage detected