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

Method Run

Source/Editor/Content/PreviewsCache.cpp:31–69  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

29#define ASSETS_ICONS_PER_ATLAS (ASSETS_ICONS_PER_ROW*ASSETS_ICONS_PER_ROW)
30
31bool PreviewsCache::FlushTask::Run()
32{
33 // Check if has valid data downloaded
34 if (_data.GetMipLevels() != 1)
35 {
36 LOG(Warning, "Failed to flush asset previews atlas \'{0}\'.", _cache->ToString());
37 return true;
38 }
39 auto mipData = _data.GetData(0, 0);
40 ASSERT(mipData->DepthPitch == RenderTools::CalculateTextureMemoryUsage(_cache->GetTexture()->Format(), _cache->Width(), _cache->Height(), 1));
41
42 ScopeLock lock(_cache->Locker);
43
44 // Link chunks (don't allocate additional memory)
45 auto mipChunk = _cache->GetOrCreateChunk(0);
46 auto dataChunk = _cache->GetOrCreateChunk(15);
47 mipChunk->Data.Link(mipData->Data);
48 dataChunk->Data.Link((byte*)_cache->_assets.Get(), sizeof(Guid) * _cache->_assets.Count());
49
50 // Prepare asset data
51 AssetInitData data;
52 data.SerializedVersion = 4;
53 data.CustomData.Copy(_cache->_texture.GetHeader());
54
55 // Save (use silent mode to prevent asset reloading)
56 bool saveResult = _cache->SaveAsset(data, true);
57 mipChunk->Data.Release();
58 dataChunk->Data.Release();
59 if (saveResult)
60 {
61 LOG(Warning, "Failed to save asset previews atlas \'{0}\'.", _cache->ToString());
62 return true;
63 }
64
65 // Clear flag
66 _cache->_isDirty = false;
67
68 return false;
69}
70
71void PreviewsCache::FlushTask::OnEnd()
72{

Callers 8

BuildAllMeshesSDFMethod · 0.45
OnCreateButtonClickedMethod · 0.45
OnRebuildSDFMethod · 0.45
SearchMethod · 0.45
AudioClipPreviewClass · 0.45
RefreshPreviewMethod · 0.45

Calls 12

GetMipLevelsMethod · 0.80
FormatMethod · 0.80
GetTextureMethod · 0.80
GetOrCreateChunkMethod · 0.80
ToStringMethod · 0.45
GetDataMethod · 0.45
LinkMethod · 0.45
GetMethod · 0.45
CountMethod · 0.45
CopyMethod · 0.45
SaveAssetMethod · 0.45
ReleaseMethod · 0.45

Tested by

no test coverage detected