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

Method create

Source/Editor/Content/PreviewsCache.cpp:245–277  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

243}
244
245CreateAssetResult PreviewsCache::create(CreateAssetContext& context)
246{
247 // Base
248 IMPORT_SETUP(PreviewsCache, 4);
249
250 // Create texture header (custom data)
251 TextureHeader textureHeader;
252 textureHeader.Width = ASSETS_ICONS_ATLAS_SIZE;
253 textureHeader.Height = ASSETS_ICONS_ATLAS_SIZE;
254 textureHeader.Format = ASSETS_ICONS_ATLAS_FORMAT;
255 textureHeader.MipLevels = 1;
256 textureHeader.NeverStream = true;
257 context.Data.CustomData.Copy(&textureHeader);
258
259 // Create blank image (chunk 0)
260 uint64 imageSize = RenderTools::CalculateTextureMemoryUsage(ASSETS_ICONS_ATLAS_FORMAT, ASSETS_ICONS_ATLAS_SIZE, ASSETS_ICONS_ATLAS_SIZE, 1);
261 ASSERT(imageSize <= MAX_int32);
262 if (context.AllocateChunk(0))
263 return CreateAssetResult::CannotAllocateChunk;
264 auto mipChunk = context.Data.Header.Chunks[0];
265 mipChunk->Data.Allocate((int32)imageSize);
266 Platform::MemoryClear(mipChunk->Get(), mipChunk->Size());
267
268 // Create IDs cache array (chunk 15)
269 int32 idsSize = sizeof(Guid) * ASSETS_ICONS_PER_ATLAS;
270 if (context.AllocateChunk(15))
271 return CreateAssetResult::CannotAllocateChunk;
272 auto dataChunk = context.Data.Header.Chunks[15];
273 dataChunk->Data.Allocate(idsSize);
274 Platform::MemoryClear(dataChunk->Get(), dataChunk->Size());
275
276 return CreateAssetResult::Ok;
277}
278
279#endif

Callers

nothing calls this directly

Calls 6

MemoryClearFunction · 0.85
CopyMethod · 0.45
AllocateChunkMethod · 0.45
AllocateMethod · 0.45
GetMethod · 0.45
SizeMethod · 0.45

Tested by

no test coverage detected