MCPcopy Create free account
hub / github.com/axmolengine/axmol / updateWithMipmaps

Method updateWithMipmaps

core/renderer/Texture2D.cpp:299–437  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

297}
298
299bool Texture2D::updateWithMipmaps(MipmapInfo* mipmaps,
300 int mipmapsNum,
301 backend::PixelFormat pixelFormat,
302 backend::PixelFormat renderFormat,
303 int pixelsWide,
304 int pixelsHigh,
305 bool preMultipliedAlpha,
306 int index)
307{
308 // the pixelFormat must be a certain value
309 AXASSERT(pixelFormat != PixelFormat::NONE, "the \"pixelFormat\" param must be a certain value!");
310 AXASSERT(pixelsWide > 0 && pixelsHigh > 0, "Invalid size");
311
312 if (mipmapsNum <= 0)
313 {
314 AXLOGW("WARNING: mipmap number is less than 1");
315 return false;
316 }
317
318 auto& pfd = backend::PixelFormatUtils::getFormatDescriptor(pixelFormat);
319 if (!pfd.bpp)
320 {
321 AXLOGW("WARNING: unsupported pixelformat: {:x}", (uint32_t)pixelFormat);
322#ifdef AX_USE_METAL
323 AXASSERT(false, "pixeformat not found in _pixelFormatInfoTables, register required!");
324#endif
325 return false;
326 }
327
328 bool compressed = backend::PixelFormatUtils::isCompressed(pixelFormat);
329
330 if (compressed && !Configuration::getInstance()->supportsPVRTC() && !Configuration::getInstance()->supportsETC1() &&
331 !Configuration::getInstance()->supportsETC2() && !Configuration::getInstance()->supportsS3TC() &&
332 !Configuration::getInstance()->supportsASTC() && !Configuration::getInstance()->supportsATITC())
333 {
334 AXLOGW("WARNING: PVRTC/ETC images are not supported");
335 return false;
336 }
337
338#if AX_ENABLE_CACHE_TEXTURE_DATA
339 VolatileTextureMgr::getOrAddVolatileTexture(this);
340#endif
341
342 backend::TextureDescriptor textureDescriptor;
343 textureDescriptor.width = pixelsWide;
344 textureDescriptor.height = pixelsHigh;
345
346 textureDescriptor.samplerDescriptor.magFilter =
347 (_flags & TextureFlag::ANTIALIAS_ENABLED) ? backend::SamplerFilter::LINEAR : backend::SamplerFilter::NEAREST;
348 if (mipmapsNum == 1)
349 {
350 textureDescriptor.samplerDescriptor.minFilter = (_flags & TextureFlag::ANTIALIAS_ENABLED)
351 ? backend::SamplerFilter::LINEAR
352 : backend::SamplerFilter::NEAREST;
353 }
354 else
355 {
356 textureDescriptor.samplerDescriptor.minFilter = (_flags & TextureFlag::ANTIALIAS_ENABLED)

Callers

nothing calls this directly

Calls 15

isCompressedFunction · 0.85
getInstanceFunction · 0.85
convertDataToFormatFunction · 0.85
nextPOTFunction · 0.85
supportsPVRTCMethod · 0.80
supportsETC1Method · 0.80
supportsETC2Method · 0.80
supportsS3TCMethod · 0.80
supportsASTCMethod · 0.80
supportsATITCMethod · 0.80
getTextureFormatMethod · 0.80
updateCompressedDataMethod · 0.80

Tested by

no test coverage detected