3#include "RasterLevel.h"
6#include "Rendering/IGraphicsDevice.h"
12#include <unordered_set>
16 struct RasterTileIdentifier;
17 struct TileLoadRequest;
21 enum EInvalidationFlags
24 InvalidateParents = 1 << 0,
30 std::vector<uint8_t> data;
36 std::atomic<size_t> generation = 0;
39 typedef std::lock_guard<RasterSource> ReadLock;
40 typedef std::lock_guard<RasterSource> WriteLock;
51 std::vector<RasterLevel> & getLevels() {
return levels; }
52 const std::vector<RasterLevel> & getLevels()
const {
return levels; }
54 int getTileWidth()
const {
return tileLongitudePosts; }
55 int getTileHeight()
const {
return tileLatitudePosts; }
59 void lock() { readyMutex.lock(); }
60 void unlock() { readyMutex.unlock(); }
62 TextureHandle loadTexture(
const unsigned char * data,
const int width,
const int height,
const TextureFormat format,
const size_t size);
63 void releaseTexture(
TextureHandle texture,
const size_t size);
68 void loadTileData(
RasterTile * tile,
size_t requestGeneration, std::vector<uint8_t> & data,
TextureHandle textureHandle, TextureFormat format,
size_t size);
70 void invalidateTile(
const RasterTileIdentifier &
id, InvalidationFlags::EInvalidationFlags flags = InvalidationFlags::InvalidateParents);
94 void removeTileUsageData(
size_t code);
100 virtual void allocateTileStorage(
const size_t textureSize, std::vector<uint8_t> & buffer) = 0;
101 virtual void deallocateTileStorage(std::vector<uint8_t> & buffer) = 0;
106 bool hasProcessingRequests()
const {
return processing.getCount() > 0; }
110 void lock() { ++count; }
111 void unlock() { --count; }
112 size_t getCount()
const {
return count.load(); }
115 std::atomic<size_t> count = 0;
118 std::unordered_set<struct RasterSourceSubscription *> subscribers;
119 std::mutex subscriberMutex;
123 std::atomic<size_t> textureBufferSize = 0;
125 TextureFormat format = TextureFormat::Unknown;
127 bool isHeight =
false;
134 std::atomic<size_t> generation = 0;
137 std::vector<RasterLevel> levels;
139 int tileLongitudePosts = 0;
140 int tileLatitudePosts = 0;
145 std::map<size_t, RasterTile> activeTiles;
146 std::map<size_t, RasterTileData> residentTiles;
147 std::vector<RasterTileData> oldTileData;
149 std::list<size_t> lruList;
150 std::map<size_t, std::list<size_t>::iterator> lruMap;
152 std::mutex readyMutex;
Represents a graphics device used to manage graphics resources and issue drawing commands.
void releaseTileData(RasterTileData &tileData)
Release the given tile data.
void purgeOldData()
Purges orphaned tile data that has been replaced with new contents.
void purgeResidentCache()
Purge tile data resident in memory and on the GPU.
void purgeCache()
Purge all cache, including resident data.
void cancelActiveRequests()
Cancels all active requests.
Contains all Cogs related functionality.
static const Handle_t InvalidHandle
Represents an invalid handle.