MCPcopy Create free account
hub / github.com/crownengine/crown / imageAlloc

Function imageAlloc

3rdparty/bimg/src/image.cpp:3300–3343  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3298 }
3299
3300 ImageContainer* imageAlloc(bx::AllocatorI* _allocator, TextureFormat::Enum _format, uint16_t _width, uint16_t _height, uint16_t _depth, uint16_t _numLayers, bool _cubeMap, bool _hasMips, const void* _data)
3301 {
3302 const ImageBlockInfo& blockInfo = getBlockInfo(_format);
3303 const uint16_t blockWidth = blockInfo.blockWidth;
3304 const uint16_t blockHeight = blockInfo.blockHeight;
3305 const uint16_t minBlockX = blockInfo.minBlockX;
3306 const uint16_t minBlockY = blockInfo.minBlockY;
3307
3308 _width = bx::max<uint16_t>(blockWidth * minBlockX, ( (_width + blockWidth - 1) / blockWidth)*blockWidth);
3309 _height = bx::max<uint16_t>(blockHeight * minBlockY, ( (_height + blockHeight - 1) / blockHeight)*blockHeight);
3310 _depth = bx::max<uint16_t>(1, _depth);
3311 _numLayers = bx::max<uint16_t>(1, _numLayers);
3312
3313 const uint8_t numMips = _hasMips ? imageGetNumMips(_format, _width, _height, _depth) : 1;
3314 uint32_t size = imageGetSize(NULL, _width, _height, _depth, _cubeMap, _hasMips, _numLayers, _format);
3315
3316 ImageContainer* imageContainer = (ImageContainer*)bx::alignedAlloc(_allocator, size + bx::alignUp(sizeof(ImageContainer), 16), 16);
3317
3318 imageContainer->m_allocator = _allocator;
3319 imageContainer->m_data = bx::alignPtr(imageContainer + 1, 0, 16);
3320 imageContainer->m_format = _format;
3321 imageContainer->m_orientation = Orientation::R0;
3322 imageContainer->m_size = size;
3323 imageContainer->m_offset = 0;
3324 imageContainer->m_width = _width;
3325 imageContainer->m_height = _height;
3326 imageContainer->m_depth = _depth;
3327 imageContainer->m_numLayers = _numLayers;
3328 imageContainer->m_numMips = numMips;
3329 imageContainer->m_hasAlpha = false;
3330 imageContainer->m_cubeMap = _cubeMap;
3331 imageContainer->m_ktx = false;
3332 imageContainer->m_pvr3 = false;
3333 imageContainer->m_ktxLE = false;
3334 imageContainer->m_srgb = false;
3335
3336 if (NULL != _data)
3337 {
3338 bx::memCopy(imageContainer->m_data, _data, imageContainer->m_size);
3339 }
3340
3341 return imageContainer;
3342
3343 }
3344
3345 void imageFree(ImageContainer* _imageContainer)
3346 {

Callers 14

convertFunction · 0.85
imageEncodeFunction · 0.85
imageGenerateMipsFunction · 0.85
imageParseLodePngFunction · 0.85
imageParseTinyExrFunction · 0.85
imageParseStbImageFunction · 0.85
imageParseLibHeifFunction · 0.85
imageConvertFunction · 0.85

Calls 3

imageGetNumMipsFunction · 0.85
imageGetSizeFunction · 0.85
memCopyFunction · 0.85

Tested by

no test coverage detected