25 #ifndef __GLTEXTCACHE_H__
26 #define __GLTEXTCACHE_H__
28 #include <wx/glcanvas.h>
33 #include "model/ocpn_types.h"
34 #include "color_types.h"
40 #define COMPRESSED_CACHE_MAGIC 0xf013
42 #define FACTORY_TIMER 10000
44 void HalfScaleChartBits(
int width,
int height,
unsigned char *source,
45 unsigned char *target);
55 uint32_t catalog_offset;
56 uint32_t chartfile_date;
57 uint32_t chartfile_size;
62 ColorScheme tcolorscheme;
69 uint32_t compressed_size;
72 #define CATALOG_ENTRY_SERIAL_SIZE 6 * sizeof(uint32_t)
78 CatalogEntry(
int level,
int x0,
int y0, ColorScheme colorscheme);
80 void Serialize(
unsigned char *);
81 void DeSerialize(
unsigned char *);
91 m_coords = m_texcoords = NULL;
104 float *m_coords, *m_texcoords;
107 #define MAX_TEX_LEVEL 10
117 bool PrepareTexture(
int base_level,
const wxRect &rect,
118 ColorScheme color_scheme,
int mem_used);
120 ColorScheme color_scheme);
121 bool UpdateCacheAllLevels(
const wxRect &rect, ColorScheme color_scheme,
122 unsigned char **compcomp_array,
int *compcomp_size);
123 bool IsLevelInCache(
int level,
const wxRect &rect, ColorScheme color_scheme);
124 wxString GetChartPath() {
return m_ChartPath; }
125 wxString GetHashKey() {
return m_HashKey; }
126 void SetHashKey(wxString key) { m_HashKey = key; }
128 void AccumulateMemStatistics(
int &map_size,
int &comp_size,
130 void DeleteTexture(
const wxRect &rect);
131 void DeleteAllTextures(
void);
132 void DeleteSomeTextures(
long target);
133 void DeleteAllDescriptors(
void);
134 bool BackgroundCompressionAsJob()
const;
135 void PurgeBackgroundCompressionPool();
136 void SetLRUTime(
int lru) { m_LRUtime = lru; }
137 int GetLRUTime() {
return m_LRUtime; }
138 void FreeSome(
long target);
148 void GetCenter(
double &lat,
double &lon) { lat = m_clat, lon = m_clon; }
151 bool LoadCatalog(
void);
152 bool LoadHeader(
void);
153 bool WriteCatalogAndHeader();
155 bool UpdateCachePrecomp(
unsigned char *data,
int data_size,
156 const wxRect &rect,
int level,
157 ColorScheme color_scheme,
bool write_catalog =
true);
158 bool UpdateCacheLevel(
const wxRect &rect,
int level, ColorScheme color_scheme,
159 unsigned char *data,
int size);
164 ColorScheme color_scheme);
166 int ArrayIndex(
int x,
int y)
const {
167 return ((y / m_tex_dim) * m_stride) + (x / m_tex_dim);
169 void ArrayXY(wxRect *r,
int index)
const;
171 int n_catalog_entries;
175 wxString m_ChartPath;
177 wxString m_CompressedCacheFilePath;
179 int m_catalog_offset;
184 bool m_catalogCorrupted;
187 uint32_t m_chart_date_binary;
188 uint32_t m_chartfile_date_binary;
189 uint32_t m_chartfile_size;
203 double m_clat, m_clon;
205 int m_prepared_projection_type;