Logo Search packages:      
Sourcecode: gaia version File versions  Download package

int WorldWindTileManager::Cleanup (  ) 

Removes unneeded objects from memory.

Currently removes one texture each call, until number of textures >= DEFAULT_MAX_TEXTURES

Todo:
implement tunable limits

Definition at line 73 of file WorldWindTileManager.cc.

References FindTextureToDrop(), m_nTextureTiles, and m_TextureRoot.

                                  {
      /*
       * How cache cleanup works:
       *
       * 0. Tiles with children are not dropped
       * 0. Tiles recently used (!IsOld) are not dropped
       * 0. Root is not dropped
       * 1. Tile with highest level is dropped first.
       * 2. Of same level, Tile with higher age is dropped first.
       *
       * This ensures:
       * - Minimal number of textures loaded
       * - All visible tiles are always in memory
       * - No reloading tiles on zoomout
       */

      if (m_nTextureTiles <= DEFAULT_MAX_TEXTURES)
            return 0;

      TextureTilePtr victim = FindTextureToDrop(m_TextureRoot, 0);

      if (victim == 0)
            return 0;

      for (int i = 0; i < 4; i++)
            if (victim->GetParent()->GetChild(i) == victim) {
                  victim->GetParent()->SetChild(i, 0);      /* after this, victim is doomed */
                  victim->Unload();             /* be sure no opengl will be touched in threads XXX: review this */
                  m_nTextureTiles--;
                  return 1;
            }

      return 0;
}


Generated by  Doxygen 1.6.0   Back to index