// Copyright (c) 2012-2023 Wojciech Figat. All rights reserved.
#pragma once
#include "Engine/Core/Types/DataContainer.h"
#include "Engine/Content/Storage/FlaxStorage.h"
class GPUTexture;
class Task;
///
/// Interface for objects that can manage streamable texture
///
class FLAXENGINE_API ITextureOwner
{
public:
///
/// Gets the texture owner mutex used to synchronize texture logic.
///
virtual CriticalSection& GetOwnerLocker() const = 0;
///
/// Get texture mip map data
///
/// Mip map index
/// Task that will get asset data (may be null if data already loaded).
virtual Task* RequestMipDataAsync(int32 mipIndex) = 0;
///
/// Prepares texture data. May lock data chunks to be keep in cache for a while.
///
virtual FlaxStorage::LockData LockData() = 0;
///
/// Gets texture mip map data. May fail if not data requested. See RequestMipDataAsync.
///
/// Mip map index
/// Result data
virtual void GetMipData(int32 mipIndex, BytesContainer& data) const = 0;
///
/// Gets texture mip map data. Performs loading if data is not in memory (may stall the callee thread).
///
/// Mip map index
/// Result data
virtual void GetMipDataWithLoading(int32 mipIndex, BytesContainer& data) const
{
GetMipData(mipIndex, data);
}
///
/// Gets texture mip map data row and slice pitch. Cna be used to override the default values.
///
/// Mip map index
/// Data row pitch (in bytes).
/// Data slice pitch (in bytes).
/// True if has a custom row/slice pitch values, otherwise false (to use default values).
virtual bool GetMipDataCustomPitch(int32 mipIndex, uint32& rowPitch, uint32& slicePitch) const
{
return false;
}
};