Implement partial parallelisation of non-map mode viewport rendering
This commit is contained in:
@@ -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 */
|
||||
|
Reference in New Issue
Block a user