Implement partial parallelisation of non-map mode viewport rendering

This commit is contained in:
Jonathan G Rennison
2022-11-09 22:24:31 +00:00
parent 07b752fe69
commit 7685c36f35
12 changed files with 479 additions and 269 deletions

View File

@@ -12,6 +12,7 @@
#include "gfx_type.h"
#include "spriteloader/spriteloader.hpp"
#include "3rdparty/cpp-btree/btree_map.h"
/** Data structure describing a sprite. */
struct Sprite {
@@ -72,4 +73,30 @@ void DupSprite(SpriteID old_spr, SpriteID new_spr);
uint32 GetSpriteMainColour(SpriteID sprite_id, PaletteID palette_id);
struct SpritePointerHolder {
private:
btree::btree_map<uint32, const void *> cache;
public:
inline const Sprite *GetSprite(SpriteID sprite, SpriteType type) const
{
return (const Sprite*)(this->cache.find(sprite | (type << 29))->second);
}
inline const byte *GetRecolourSprite(SpriteID sprite) const
{
return (const byte*)(this->cache.find(sprite | (ST_RECOLOUR << 29))->second);
}
void Clear()
{
this->cache.clear();
}
inline void CacheSprite(SpriteID sprite, SpriteType type)
{
this->cache[sprite | (type << 29)] = GetRawSprite(sprite, type);
}
};
#endif /* SPRITECACHE_H */