| 243 | } |
| 244 | |
| 245 | CreateAssetResult 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 |
nothing calls this directly
no test coverage detected