UnrealVoxta 0.1.1
 
Loading...
Searching...
No Matches
TexturesCacheHandler.h
Go to the documentation of this file.
1// Copyright(c) 2024 grrimgrriefer & DZnnah, see LICENSE for details.
2
3#pragma once
4
5#include "CoreMinimal.h"
6#include "VoxtaDefines.h"
7
8class UTexture2DDynamic;
9class IImageWrapper;
10
18class TexturesCacheHandler : public TSharedFromThis<TexturesCacheHandler>
19{
20#pragma region helper classes
21private:
28 class TextureInfo
29 {
30 public:
31 TextureInfo(TWeakObjectPtr<const UTexture2DDynamic> texture, int width, int height) :
32 TEXTURE(texture), TEXTURE_SIZE(width, height)
33 {}
34 const TWeakObjectPtr<const UTexture2DDynamic> TEXTURE;
35 const FIntVector2 TEXTURE_SIZE;
36 };
37#pragma endregion
38
39#pragma region public API
40public:
43
49 void FetchTextureFromUrl(const FString& url, FDownloadedTextureDelegateNative onThumbnailFetched);
50#pragma endregion
51
52#pragma region data
53private:
54 FCriticalSection m_cacheLock;
55 TMap<FString, TArray<FDownloadedTextureDelegateNative>> m_pendingCallbacks;
56 TMap<FString, TextureInfo> m_texturesCache;
57
58 FCriticalSection m_wrapperLock;
59 TArray<TSharedPtr<IImageWrapper>> m_imageWrappers;
60#pragma endregion
61};
void FetchTextureFromUrl(const FString &url, FDownloadedTextureDelegateNative onThumbnailFetched)
Fetch a texture from a URL asynchronously and cache it.
Definition TexturesCacheHandler.cpp:29
TexturesCacheHandler()
Constructor.
Definition TexturesCacheHandler.cpp:18