MCPcopy Create free account
hub / github.com/defold/defold / NullSetTexture

Function NullSetTexture

engine/graphics/src/null/graphics_null.cpp:1633–1668  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1631 }
1632
1633 static void NullSetTexture(HContext context, HTexture texture, const TextureParams& params)
1634 {
1635 DM_MUTEX_OPTIONAL_SCOPED_LOCK(g_NullContext->m_BaseContext.m_AssetHandleContainerMutex);
1636 NullTexture* tex = GetAssetFromContainer<NullTexture>(g_NullContext->m_BaseContext.m_AssetHandleContainer, texture);
1637 assert(tex);
1638 assert(!params.m_SubUpdate || (params.m_X + params.m_Width <= tex->m_Base.m_Width));
1639 assert(!params.m_SubUpdate || (params.m_Y + params.m_Height <= tex->m_Base.m_Height));
1640
1641 if (tex->m_Data != 0x0)
1642 {
1643 delete [] (char*)tex->m_Data;
1644 }
1645
1646 tex->m_Base.m_Format = params.m_Format;
1647 // Allocate even for 0x0 size so that the rendertarget dummies will work.
1648 tex->m_Data = new char[params.m_DataSize];
1649 if (params.m_Data != 0x0)
1650 {
1651 memcpy(tex->m_Data, params.m_Data, params.m_DataSize);
1652 }
1653
1654 // The width/height of the texture can change from this function as well
1655 if (!params.m_SubUpdate && params.m_MipMap == 0)
1656 {
1657 tex->m_Base.m_Width = params.m_Width;
1658 tex->m_Base.m_Height = params.m_Height;
1659 }
1660
1661 tex->m_Base.m_Depth = dmMath::Max(1u, (uint32_t)params.m_Depth);
1662 tex->m_Base.m_MipMapCount = dmMath::Max(tex->m_Base.m_MipMapCount, (uint8_t) (params.m_MipMap+1));
1663 tex->m_Base.m_MipMapCount = dmMath::Clamp(tex->m_Base.m_MipMapCount, (uint8_t) 0, GetMipmapCount(dmMath::Max(tex->m_Base.m_Width, tex->m_Base.m_Height)));
1664 tex->m_Sampler.m_MinFilter = params.m_MinFilter;
1665 tex->m_Sampler.m_MagFilter = params.m_MagFilter;
1666 tex->m_Sampler.m_UWrap = params.m_UWrap;
1667 tex->m_Sampler.m_VWrap = params.m_VWrap;
1668 }
1669
1670 static uint32_t NullGetTextureResourceSize(HContext context, HTexture texture)
1671 {

Callers

nothing calls this directly

Calls 4

GetMipmapCountFunction · 0.85
assertFunction · 0.50
MaxFunction · 0.50
ClampFunction · 0.50

Tested by

no test coverage detected