-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathmap-tile-cache.h
54 lines (46 loc) · 1.54 KB
/
map-tile-cache.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
/*
* SPDX-FileCopyrightText: 2021 Samuel Cuella <[email protected]>
*
* This file is part of SoFIS - an open source EFIS
*
* SPDX-License-Identifier: GPL-2.0-only
*/
#ifndef MAP_TILE_CACHE_H
#define MAP_TILE_CACHE_H
#include <stdio.h>
#include <stdbool.h>
#include "generic-layer.h"
#include "misc.h"
typedef struct{
Uint32 atime; /*last access time in SDL_Ticks*/
/* MAP_GAUGE_MAX_LEVEL 23
* has 8388608 tiles from 0 to 8388607
* which needs 24 bits. Nearest type is int32
*/
int32_t x;
int32_t y;
uintf8_t level;
GenericLayer *layer;
}MapTileDescriptor;
typedef struct{
MapTileDescriptor *tile_cache;
size_t acache; /*allocated size*/
size_t ncached; /*currently holding*/
}MapTileCache;
MapTileCache *map_tile_cache_init(MapTileCache *self, size_t cache_size);
MapTileCache *map_tile_cache_dispose(MapTileCache *self);
bool map_tile_cache_set_size(MapTileCache *self, uintf8_t cache_size);
GenericLayer *map_tile_cache_get(MapTileCache *self,
uintf8_t level, int32_t x, int32_t y);
bool map_tile_cache_add(MapTileCache *self, GenericLayer *tile,
uintf8_t level, int32_t x, int32_t y);
void map_tile_cache_clear(MapTileCache *self);
static inline bool map_tile_descriptor_match(MapTileDescriptor *self,
uintf8_t level,
int32_t x, int32_t y)
{
return self->level == level
&& self->x == x
&& self->y == y;
}
#endif /* MAP_TILE_CACHE_H */