11
11
#include "StdInc.h"
12
12
#include "CClientVectorGraphic.h"
13
13
14
- constexpr std::int64_t TEMPORARY_TEXTURES_CLEANUP_PERIOD = 5000ll;
15
- constexpr std::int64_t TEMPORARY_TEXTURES_CLEANUP_THRESHOLD = 10000ll;
16
- constexpr std::size_t TEMPORARY_TEXTURES_DELETE_THRESHOLD = 10u;
17
-
18
14
////////////////////////////////////////////////////////////////
19
15
//
20
16
// CClientRenderElementManager::CClientRenderElementManager
@@ -287,24 +283,20 @@ CClientVectorGraphic* CClientRenderElementManager::CreateVectorGraphic(uint widt
287
283
CClientTexture* CClientRenderElementManager::FindAutoTexture(const SString& strFullFilePath, const SString& strUniqueName)
288
284
{
289
285
// Check if we've already done this file
290
- SAutoTexture * ppTextureElement = MapFind(m_AutoTextureMap, strUniqueName);
286
+ CClientTexture* * ppTextureElement = MapFind(m_AutoTextureMap, strUniqueName);
291
287
if (!ppTextureElement)
292
288
{
293
289
// Try to create
294
290
CClientTexture* pNewTextureElement = CreateTexture(strFullFilePath);
295
291
if (!pNewTextureElement)
296
- return nullptr;
297
-
298
- pNewTextureElement->MakeSystemEntity();
292
+ return NULL;
299
293
300
294
// Add to automap if created
301
- MapSet(m_AutoTextureMap, strUniqueName, SAutoTexture{ pNewTextureElement} );
295
+ MapSet(m_AutoTextureMap, strUniqueName, pNewTextureElement);
302
296
ppTextureElement = MapFind(m_AutoTextureMap, strUniqueName);
303
297
}
304
298
305
- ppTextureElement->lastUse = CTickCount::Now();
306
-
307
- return ppTextureElement->texture;
299
+ return *ppTextureElement;
308
300
}
309
301
310
302
////////////////////////////////////////////////////////////////
@@ -326,9 +318,9 @@ void CClientRenderElementManager::Remove(CClientRenderElement* pElement)
326
318
// Remove from auto texture map
327
319
if (pElement->IsA(CClientTexture::GetClassId()))
328
320
{
329
- for (auto iter = m_AutoTextureMap.begin(); iter != m_AutoTextureMap.end(); ++iter)
321
+ for (std::map<SString, CClientTexture*>::iterator iter = m_AutoTextureMap.begin(); iter != m_AutoTextureMap.end(); ++iter)
330
322
{
331
- if (iter->second.texture == pElement)
323
+ if (iter->second == pElement)
332
324
{
333
325
m_AutoTextureMap.erase(iter);
334
326
break;
@@ -358,39 +350,3 @@ void CClientRenderElementManager::Remove(CClientRenderElement* pElement)
358
350
CRenderItem* pRenderItem = pElement->GetRenderItem();
359
351
SAFE_RELEASE(pRenderItem);
360
352
}
361
-
362
- void CClientRenderElementManager::DoPulse()
363
- {
364
- if (m_texturePulseTimer.Get() < TEMPORARY_TEXTURES_CLEANUP_PERIOD)
365
- return;
366
-
367
- m_texturePulseTimer.Reset();
368
-
369
- const CTickCount now = CTickCount::Now();
370
-
371
- std::vector<CClientTexture*> deleteCandidates;
372
- deleteCandidates.reserve(TEMPORARY_TEXTURES_DELETE_THRESHOLD);
373
-
374
- for (const auto& [texName, texInfo] : m_AutoTextureMap)
375
- {
376
- const std::int64_t timeElapsedMs = (now - texInfo.lastUse).ToLongLong();
377
- if (timeElapsedMs < TEMPORARY_TEXTURES_CLEANUP_THRESHOLD)
378
- continue;
379
-
380
- CTextureItem* textureItem = texInfo.texture->GetTextureItem();
381
- if (textureItem && textureItem->m_iRefCount > 1)
382
- continue;
383
-
384
- // CElementDeleter::Delete causes changes in m_AutoTextureMap
385
- // and we cannot delete a texture while iterating over it
386
- deleteCandidates.push_back(texInfo.texture);
387
-
388
- // The deletion procedure can be expensive
389
- // and we're interested in capping on the number of deleted texture at once
390
- if (deleteCandidates.size() == TEMPORARY_TEXTURES_DELETE_THRESHOLD)
391
- break;
392
- }
393
-
394
- for (CClientTexture* texture : deleteCandidates)
395
- g_pClientGame->GetElementDeleter()->Delete(texture);
396
- }
0 commit comments