author | Tero Marttila <terom@fixme.fi> |
Tue, 26 Jan 2010 01:37:30 +0200 | |
changeset 106 | 26f10ed59c8e |
parent 91 | 0bf7878bdf5c |
permissions | -rw-r--r-- |
0 | 1 |
#ifndef PNGTILE_H |
2 |
#define PNGTILE_H |
|
3 |
||
4 |
/** |
|
5 |
* @file |
|
6 |
* |
|
7 |
* Tile-based access to large PNG images. |
|
8 |
*/ |
|
6
766df7c9b90d
--force-update and store palette
Tero Marttila <terom@fixme.fi>
parents:
5
diff
changeset
|
9 |
#include <stddef.h> |
9 | 10 |
#include <stdio.h> // for FILE* |
52
148a120ea7d5
skip contiguous regions of some background color
Tero Marttila <terom@fixme.fi>
parents:
34
diff
changeset
|
11 |
#include <stdint.h> |
54
4a25113cb2a4
add some additional pt_image_info fields for stat
Tero Marttila <terom@fixme.fi>
parents:
53
diff
changeset
|
12 |
#include <sys/types.h> // for time_t |
0 | 13 |
|
14 |
/** |
|
15 |
* "Global" context shared between images |
|
16 |
*/ |
|
17 |
struct pt_ctx; |
|
18 |
||
19 |
/** |
|
20 |
* Per-image state |
|
21 |
*/ |
|
22 |
struct pt_image; |
|
23 |
||
6
766df7c9b90d
--force-update and store palette
Tero Marttila <terom@fixme.fi>
parents:
5
diff
changeset
|
24 |
/** Bitmask for pt_image_open modes */ |
15 | 25 |
enum pt_open_mode { |
80 | 26 |
/** Open cache for read*/ |
27 |
PT_OPEN_READ = 0x00, |
|
28 |
||
29 |
/** Open cache for update */ |
|
11 | 30 |
PT_OPEN_UPDATE = 0x01, |
6
766df7c9b90d
--force-update and store palette
Tero Marttila <terom@fixme.fi>
parents:
5
diff
changeset
|
31 |
|
766df7c9b90d
--force-update and store palette
Tero Marttila <terom@fixme.fi>
parents:
5
diff
changeset
|
32 |
/** Accept stale cache */ |
15 | 33 |
// TODO: PT_OPEN_STALE = 0x02, |
6
766df7c9b90d
--force-update and store palette
Tero Marttila <terom@fixme.fi>
parents:
5
diff
changeset
|
34 |
}; |
766df7c9b90d
--force-update and store palette
Tero Marttila <terom@fixme.fi>
parents:
5
diff
changeset
|
35 |
|
8 | 36 |
/** |
37 |
* Values for pt_image_cached |
|
38 |
*/ |
|
39 |
enum pt_cache_status { |
|
40 |
/** Cache status could not be determined */ |
|
41 |
PT_CACHE_ERROR = -1, |
|
42 |
||
43 |
/** Cache is fresh */ |
|
44 |
PT_CACHE_FRESH = 0, |
|
45 |
||
46 |
/** Cache does not exist */ |
|
47 |
PT_CACHE_NONE = 1, |
|
48 |
||
49 |
/** Cache exists, but is stale */ |
|
50 |
PT_CACHE_STALE = 2, |
|
56
d5e3089906da
major refactoring of pt_cache, split off all PNG processing into pt_png
Tero Marttila <terom@fixme.fi>
parents:
54
diff
changeset
|
51 |
|
d5e3089906da
major refactoring of pt_cache, split off all PNG processing into pt_png
Tero Marttila <terom@fixme.fi>
parents:
54
diff
changeset
|
52 |
/** Cache exists, but it was generated using an incompatible version of this library */ |
d5e3089906da
major refactoring of pt_cache, split off all PNG processing into pt_png
Tero Marttila <terom@fixme.fi>
parents:
54
diff
changeset
|
53 |
PT_CACHE_INCOMPAT = 3, |
8 | 54 |
}; |
55 |
||
54
4a25113cb2a4
add some additional pt_image_info fields for stat
Tero Marttila <terom@fixme.fi>
parents:
53
diff
changeset
|
56 |
/** Metadata info for image. Values will be set to zero if not available */ |
6
766df7c9b90d
--force-update and store palette
Tero Marttila <terom@fixme.fi>
parents:
5
diff
changeset
|
57 |
struct pt_image_info { |
56
d5e3089906da
major refactoring of pt_cache, split off all PNG processing into pt_png
Tero Marttila <terom@fixme.fi>
parents:
54
diff
changeset
|
58 |
/** Dimensions of image. Only available if the cache is open */ |
d5e3089906da
major refactoring of pt_cache, split off all PNG processing into pt_png
Tero Marttila <terom@fixme.fi>
parents:
54
diff
changeset
|
59 |
size_t img_width, img_height; |
d5e3089906da
major refactoring of pt_cache, split off all PNG processing into pt_png
Tero Marttila <terom@fixme.fi>
parents:
54
diff
changeset
|
60 |
|
d5e3089906da
major refactoring of pt_cache, split off all PNG processing into pt_png
Tero Marttila <terom@fixme.fi>
parents:
54
diff
changeset
|
61 |
/** Bits per pixel */ |
d5e3089906da
major refactoring of pt_cache, split off all PNG processing into pt_png
Tero Marttila <terom@fixme.fi>
parents:
54
diff
changeset
|
62 |
size_t img_bpp; |
53
8a3165c604f8
fix cache->size calculation to not include the header
Tero Marttila <terom@fixme.fi>
parents:
52
diff
changeset
|
63 |
|
54
4a25113cb2a4
add some additional pt_image_info fields for stat
Tero Marttila <terom@fixme.fi>
parents:
53
diff
changeset
|
64 |
/** Last update of image file */ |
4a25113cb2a4
add some additional pt_image_info fields for stat
Tero Marttila <terom@fixme.fi>
parents:
53
diff
changeset
|
65 |
time_t image_mtime; |
4a25113cb2a4
add some additional pt_image_info fields for stat
Tero Marttila <terom@fixme.fi>
parents:
53
diff
changeset
|
66 |
|
53
8a3165c604f8
fix cache->size calculation to not include the header
Tero Marttila <terom@fixme.fi>
parents:
52
diff
changeset
|
67 |
/** Size of image file in bytes */ |
8a3165c604f8
fix cache->size calculation to not include the header
Tero Marttila <terom@fixme.fi>
parents:
52
diff
changeset
|
68 |
size_t image_bytes; |
56
d5e3089906da
major refactoring of pt_cache, split off all PNG processing into pt_png
Tero Marttila <terom@fixme.fi>
parents:
54
diff
changeset
|
69 |
|
d5e3089906da
major refactoring of pt_cache, split off all PNG processing into pt_png
Tero Marttila <terom@fixme.fi>
parents:
54
diff
changeset
|
70 |
/** Cache format version or -err */ |
d5e3089906da
major refactoring of pt_cache, split off all PNG processing into pt_png
Tero Marttila <terom@fixme.fi>
parents:
54
diff
changeset
|
71 |
int cache_version; |
53
8a3165c604f8
fix cache->size calculation to not include the header
Tero Marttila <terom@fixme.fi>
parents:
52
diff
changeset
|
72 |
|
54
4a25113cb2a4
add some additional pt_image_info fields for stat
Tero Marttila <terom@fixme.fi>
parents:
53
diff
changeset
|
73 |
/** Last update of cache file */ |
4a25113cb2a4
add some additional pt_image_info fields for stat
Tero Marttila <terom@fixme.fi>
parents:
53
diff
changeset
|
74 |
time_t cache_mtime; |
4a25113cb2a4
add some additional pt_image_info fields for stat
Tero Marttila <terom@fixme.fi>
parents:
53
diff
changeset
|
75 |
|
53
8a3165c604f8
fix cache->size calculation to not include the header
Tero Marttila <terom@fixme.fi>
parents:
52
diff
changeset
|
76 |
/** Size of cache file in bytes */ |
8a3165c604f8
fix cache->size calculation to not include the header
Tero Marttila <terom@fixme.fi>
parents:
52
diff
changeset
|
77 |
size_t cache_bytes; |
8a3165c604f8
fix cache->size calculation to not include the header
Tero Marttila <terom@fixme.fi>
parents:
52
diff
changeset
|
78 |
|
54
4a25113cb2a4
add some additional pt_image_info fields for stat
Tero Marttila <terom@fixme.fi>
parents:
53
diff
changeset
|
79 |
/** Size of cache file in blocks (for sparse cache files) - 512 bytes / block? */ |
53
8a3165c604f8
fix cache->size calculation to not include the header
Tero Marttila <terom@fixme.fi>
parents:
52
diff
changeset
|
80 |
size_t cache_blocks; |
0 | 81 |
}; |
82 |
||
13
294201975f8c
fix clip_x bug, and reject images that are completely out of bounds
Tero Marttila <terom@fixme.fi>
parents:
11
diff
changeset
|
83 |
/** |
52
148a120ea7d5
skip contiguous regions of some background color
Tero Marttila <terom@fixme.fi>
parents:
34
diff
changeset
|
84 |
* Modifyable params for update |
148a120ea7d5
skip contiguous regions of some background color
Tero Marttila <terom@fixme.fi>
parents:
34
diff
changeset
|
85 |
*/ |
148a120ea7d5
skip contiguous regions of some background color
Tero Marttila <terom@fixme.fi>
parents:
34
diff
changeset
|
86 |
struct pt_image_params { |
148a120ea7d5
skip contiguous regions of some background color
Tero Marttila <terom@fixme.fi>
parents:
34
diff
changeset
|
87 |
/** Don't write out any contiguous regions of this color. Left-aligned in whatever format the source image is in */ |
148a120ea7d5
skip contiguous regions of some background color
Tero Marttila <terom@fixme.fi>
parents:
34
diff
changeset
|
88 |
uint8_t background_color[4]; |
148a120ea7d5
skip contiguous regions of some background color
Tero Marttila <terom@fixme.fi>
parents:
34
diff
changeset
|
89 |
}; |
148a120ea7d5
skip contiguous regions of some background color
Tero Marttila <terom@fixme.fi>
parents:
34
diff
changeset
|
90 |
|
148a120ea7d5
skip contiguous regions of some background color
Tero Marttila <terom@fixme.fi>
parents:
34
diff
changeset
|
91 |
/** |
13
294201975f8c
fix clip_x bug, and reject images that are completely out of bounds
Tero Marttila <terom@fixme.fi>
parents:
11
diff
changeset
|
92 |
* Info for image tile |
294201975f8c
fix clip_x bug, and reject images that are completely out of bounds
Tero Marttila <terom@fixme.fi>
parents:
11
diff
changeset
|
93 |
* |
294201975f8c
fix clip_x bug, and reject images that are completely out of bounds
Tero Marttila <terom@fixme.fi>
parents:
11
diff
changeset
|
94 |
* The tile may safely overlap with the edge of the image, but it should not be entirely outside of the image |
294201975f8c
fix clip_x bug, and reject images that are completely out of bounds
Tero Marttila <terom@fixme.fi>
parents:
11
diff
changeset
|
95 |
*/ |
9 | 96 |
struct pt_tile_info { |
97 |
/** Dimensions of output image */ |
|
98 |
size_t width, height; |
|
99 |
||
100 |
/** Pixel coordinates of top-left corner */ |
|
101 |
size_t x, y; |
|
102 |
||
34 | 103 |
/** Zoom factor of 2^z (out < zero < in) */ |
104 |
int zoom; |
|
9 | 105 |
}; |
106 |
||
11 | 107 |
/** |
19
ebcc49de97d0
implement pt_ctx threadpool and pt_image_tile_async
Tero Marttila <terom@fixme.fi>
parents:
18
diff
changeset
|
108 |
* Construct a new pt_ctx for use with further pt_image's. |
ebcc49de97d0
implement pt_ctx threadpool and pt_image_tile_async
Tero Marttila <terom@fixme.fi>
parents:
18
diff
changeset
|
109 |
* |
ebcc49de97d0
implement pt_ctx threadpool and pt_image_tile_async
Tero Marttila <terom@fixme.fi>
parents:
18
diff
changeset
|
110 |
* @param ctx_ptr returned pt_ctx handle |
ebcc49de97d0
implement pt_ctx threadpool and pt_image_tile_async
Tero Marttila <terom@fixme.fi>
parents:
18
diff
changeset
|
111 |
* @param threads number of worker threads to use for parralel operations, or zero to disable |
11 | 112 |
*/ |
19
ebcc49de97d0
implement pt_ctx threadpool and pt_image_tile_async
Tero Marttila <terom@fixme.fi>
parents:
18
diff
changeset
|
113 |
int pt_ctx_new (struct pt_ctx **ctx_ptr, int threads); |
ebcc49de97d0
implement pt_ctx threadpool and pt_image_tile_async
Tero Marttila <terom@fixme.fi>
parents:
18
diff
changeset
|
114 |
|
ebcc49de97d0
implement pt_ctx threadpool and pt_image_tile_async
Tero Marttila <terom@fixme.fi>
parents:
18
diff
changeset
|
115 |
/** |
ebcc49de97d0
implement pt_ctx threadpool and pt_image_tile_async
Tero Marttila <terom@fixme.fi>
parents:
18
diff
changeset
|
116 |
* Shut down the given pt_ctx, waiting for any ongoing/pending operations to finish. |
ebcc49de97d0
implement pt_ctx threadpool and pt_image_tile_async
Tero Marttila <terom@fixme.fi>
parents:
18
diff
changeset
|
117 |
*/ |
ebcc49de97d0
implement pt_ctx threadpool and pt_image_tile_async
Tero Marttila <terom@fixme.fi>
parents:
18
diff
changeset
|
118 |
int pt_ctx_shutdown (struct pt_ctx *ctx); |
ebcc49de97d0
implement pt_ctx threadpool and pt_image_tile_async
Tero Marttila <terom@fixme.fi>
parents:
18
diff
changeset
|
119 |
|
ebcc49de97d0
implement pt_ctx threadpool and pt_image_tile_async
Tero Marttila <terom@fixme.fi>
parents:
18
diff
changeset
|
120 |
/** |
ebcc49de97d0
implement pt_ctx threadpool and pt_image_tile_async
Tero Marttila <terom@fixme.fi>
parents:
18
diff
changeset
|
121 |
* Release the given pt_ctx without waiting for any ongoing operations to finish. |
ebcc49de97d0
implement pt_ctx threadpool and pt_image_tile_async
Tero Marttila <terom@fixme.fi>
parents:
18
diff
changeset
|
122 |
*/ |
ebcc49de97d0
implement pt_ctx threadpool and pt_image_tile_async
Tero Marttila <terom@fixme.fi>
parents:
18
diff
changeset
|
123 |
void pt_ctx_destroy (struct pt_ctx *ctx); |
0 | 124 |
|
125 |
/** |
|
126 |
* Open a new pt_image for use. |
|
127 |
* |
|
64 | 128 |
* The pt_ctx is optional, but required for pt_image_tile_async. |
129 |
* |
|
0 | 130 |
* @param img_ptr returned pt_image handle |
64 | 131 |
* @param ctx global state to use (optional) |
0 | 132 |
* @param path filesystem path to .png file |
11 | 133 |
* @param mode combination of PT_OPEN_* flags |
0 | 134 |
*/ |
5
4b440fa03183
move stale-update logic to main
Tero Marttila <terom@fixme.fi>
parents:
0
diff
changeset
|
135 |
int pt_image_open (struct pt_image **image_ptr, struct pt_ctx *ctx, const char *png_path, int cache_mode); |
0 | 136 |
|
5
4b440fa03183
move stale-update logic to main
Tero Marttila <terom@fixme.fi>
parents:
0
diff
changeset
|
137 |
/** |
56
d5e3089906da
major refactoring of pt_cache, split off all PNG processing into pt_png
Tero Marttila <terom@fixme.fi>
parents:
54
diff
changeset
|
138 |
* Get the image's metadata. |
d5e3089906da
major refactoring of pt_cache, split off all PNG processing into pt_png
Tero Marttila <terom@fixme.fi>
parents:
54
diff
changeset
|
139 |
* |
d5e3089906da
major refactoring of pt_cache, split off all PNG processing into pt_png
Tero Marttila <terom@fixme.fi>
parents:
54
diff
changeset
|
140 |
* XXX: return void, this never fails, just returns partial info |
6
766df7c9b90d
--force-update and store palette
Tero Marttila <terom@fixme.fi>
parents:
5
diff
changeset
|
141 |
*/ |
7
997906f5fd2d
mmap header, implement pt_image_info (post-update)
Tero Marttila <terom@fixme.fi>
parents:
6
diff
changeset
|
142 |
int pt_image_info (struct pt_image *image, const struct pt_image_info **info_ptr); |
6
766df7c9b90d
--force-update and store palette
Tero Marttila <terom@fixme.fi>
parents:
5
diff
changeset
|
143 |
|
766df7c9b90d
--force-update and store palette
Tero Marttila <terom@fixme.fi>
parents:
5
diff
changeset
|
144 |
/** |
8 | 145 |
* Check the given image's cache is stale - in other words, if the image needs to be update()'d. |
146 |
* |
|
147 |
* @return one of pt_cache_status |
|
5
4b440fa03183
move stale-update logic to main
Tero Marttila <terom@fixme.fi>
parents:
0
diff
changeset
|
148 |
*/ |
8 | 149 |
int pt_image_status (struct pt_image *image); |
0 | 150 |
|
5
4b440fa03183
move stale-update logic to main
Tero Marttila <terom@fixme.fi>
parents:
0
diff
changeset
|
151 |
/** |
4b440fa03183
move stale-update logic to main
Tero Marttila <terom@fixme.fi>
parents:
0
diff
changeset
|
152 |
* Update the given image's cache. |
52
148a120ea7d5
skip contiguous regions of some background color
Tero Marttila <terom@fixme.fi>
parents:
34
diff
changeset
|
153 |
* |
148a120ea7d5
skip contiguous regions of some background color
Tero Marttila <terom@fixme.fi>
parents:
34
diff
changeset
|
154 |
* @param params optional parameters to use for the update process |
5
4b440fa03183
move stale-update logic to main
Tero Marttila <terom@fixme.fi>
parents:
0
diff
changeset
|
155 |
*/ |
52
148a120ea7d5
skip contiguous regions of some background color
Tero Marttila <terom@fixme.fi>
parents:
34
diff
changeset
|
156 |
int pt_image_update (struct pt_image *image, const struct pt_image_params *params); |
0 | 157 |
|
6
766df7c9b90d
--force-update and store palette
Tero Marttila <terom@fixme.fi>
parents:
5
diff
changeset
|
158 |
/** |
19
ebcc49de97d0
implement pt_ctx threadpool and pt_image_tile_async
Tero Marttila <terom@fixme.fi>
parents:
18
diff
changeset
|
159 |
* Load the image's cache in read-only mode without trying to update it. |
56
d5e3089906da
major refactoring of pt_cache, split off all PNG processing into pt_png
Tero Marttila <terom@fixme.fi>
parents:
54
diff
changeset
|
160 |
* |
d5e3089906da
major refactoring of pt_cache, split off all PNG processing into pt_png
Tero Marttila <terom@fixme.fi>
parents:
54
diff
changeset
|
161 |
* Fails if the cache doesn't exist. |
19
ebcc49de97d0
implement pt_ctx threadpool and pt_image_tile_async
Tero Marttila <terom@fixme.fi>
parents:
18
diff
changeset
|
162 |
*/ |
ebcc49de97d0
implement pt_ctx threadpool and pt_image_tile_async
Tero Marttila <terom@fixme.fi>
parents:
18
diff
changeset
|
163 |
// XXX: rename to pt_image_open? |
25 | 164 |
int pt_image_load (struct pt_image *image); |
19
ebcc49de97d0
implement pt_ctx threadpool and pt_image_tile_async
Tero Marttila <terom@fixme.fi>
parents:
18
diff
changeset
|
165 |
|
ebcc49de97d0
implement pt_ctx threadpool and pt_image_tile_async
Tero Marttila <terom@fixme.fi>
parents:
18
diff
changeset
|
166 |
/** |
18 | 167 |
* Render a PNG tile to a FILE*. |
9 | 168 |
* |
169 |
* The PNG data will be written to the given stream, which will be flushed, but not closed. |
|
91
0bf7878bdf5c
document pt_image_tile_* as semi-threadsafe, and nogil pypngtile.pyx (and get rid of trap_err, ugh). Also fix constness warning
Tero Marttila <terom@fixme.fi>
parents:
86
diff
changeset
|
170 |
* |
0bf7878bdf5c
document pt_image_tile_* as semi-threadsafe, and nogil pypngtile.pyx (and get rid of trap_err, ugh). Also fix constness warning
Tero Marttila <terom@fixme.fi>
parents:
86
diff
changeset
|
171 |
* Tile render operations are threadsafe as long as the pt_image is not modified during execution. |
9 | 172 |
*/ |
18 | 173 |
int pt_image_tile_file (struct pt_image *image, const struct pt_tile_info *info, FILE *out); |
174 |
||
175 |
/** |
|
176 |
* Render a PNG tile to memory. |
|
177 |
* |
|
178 |
* The PNG data will be written to a malloc'd buffer. |
|
179 |
* |
|
91
0bf7878bdf5c
document pt_image_tile_* as semi-threadsafe, and nogil pypngtile.pyx (and get rid of trap_err, ugh). Also fix constness warning
Tero Marttila <terom@fixme.fi>
parents:
86
diff
changeset
|
180 |
* Tile render operations are threadsafe as long as the pt_image is not modified during execution. |
0bf7878bdf5c
document pt_image_tile_* as semi-threadsafe, and nogil pypngtile.pyx (and get rid of trap_err, ugh). Also fix constness warning
Tero Marttila <terom@fixme.fi>
parents:
86
diff
changeset
|
181 |
* |
18 | 182 |
* @param image render from image's cache |
183 |
* @param info tile parameters |
|
184 |
* @param buf_ptr returned heap buffer |
|
185 |
* @param len_ptr returned buffer length |
|
186 |
*/ |
|
187 |
int pt_image_tile_mem (struct pt_image *image, const struct pt_tile_info *info, char **buf_ptr, size_t *len_ptr); |
|
9 | 188 |
|
189 |
/** |
|
19
ebcc49de97d0
implement pt_ctx threadpool and pt_image_tile_async
Tero Marttila <terom@fixme.fi>
parents:
18
diff
changeset
|
190 |
* Render a PNG tile to FILE* in a parralel manner. |
ebcc49de97d0
implement pt_ctx threadpool and pt_image_tile_async
Tero Marttila <terom@fixme.fi>
parents:
18
diff
changeset
|
191 |
* |
ebcc49de97d0
implement pt_ctx threadpool and pt_image_tile_async
Tero Marttila <terom@fixme.fi>
parents:
18
diff
changeset
|
192 |
* The PNG data will be written to \a out, which will be fclose()'d once done. |
ebcc49de97d0
implement pt_ctx threadpool and pt_image_tile_async
Tero Marttila <terom@fixme.fi>
parents:
18
diff
changeset
|
193 |
* |
ebcc49de97d0
implement pt_ctx threadpool and pt_image_tile_async
Tero Marttila <terom@fixme.fi>
parents:
18
diff
changeset
|
194 |
* This function may return before the PNG has been rendered. |
ebcc49de97d0
implement pt_ctx threadpool and pt_image_tile_async
Tero Marttila <terom@fixme.fi>
parents:
18
diff
changeset
|
195 |
* |
64 | 196 |
* Fails with PT_ERR if not pt_ctx was given to pt_image_open. |
197 |
* |
|
19
ebcc49de97d0
implement pt_ctx threadpool and pt_image_tile_async
Tero Marttila <terom@fixme.fi>
parents:
18
diff
changeset
|
198 |
* @param image render from image's cache. The cache must have been opened previously! |
ebcc49de97d0
implement pt_ctx threadpool and pt_image_tile_async
Tero Marttila <terom@fixme.fi>
parents:
18
diff
changeset
|
199 |
* @param info tile parameters |
ebcc49de97d0
implement pt_ctx threadpool and pt_image_tile_async
Tero Marttila <terom@fixme.fi>
parents:
18
diff
changeset
|
200 |
* @param out IO stream to write PNG data to, and close once done |
ebcc49de97d0
implement pt_ctx threadpool and pt_image_tile_async
Tero Marttila <terom@fixme.fi>
parents:
18
diff
changeset
|
201 |
*/ |
ebcc49de97d0
implement pt_ctx threadpool and pt_image_tile_async
Tero Marttila <terom@fixme.fi>
parents:
18
diff
changeset
|
202 |
int pt_image_tile_async (struct pt_image *image, const struct pt_tile_info *info, FILE *out); |
ebcc49de97d0
implement pt_ctx threadpool and pt_image_tile_async
Tero Marttila <terom@fixme.fi>
parents:
18
diff
changeset
|
203 |
|
ebcc49de97d0
implement pt_ctx threadpool and pt_image_tile_async
Tero Marttila <terom@fixme.fi>
parents:
18
diff
changeset
|
204 |
/** |
6
766df7c9b90d
--force-update and store palette
Tero Marttila <terom@fixme.fi>
parents:
5
diff
changeset
|
205 |
* Release the given pt_image without any clean shutdown |
766df7c9b90d
--force-update and store palette
Tero Marttila <terom@fixme.fi>
parents:
5
diff
changeset
|
206 |
*/ |
766df7c9b90d
--force-update and store palette
Tero Marttila <terom@fixme.fi>
parents:
5
diff
changeset
|
207 |
void pt_image_destroy (struct pt_image *image); |
766df7c9b90d
--force-update and store palette
Tero Marttila <terom@fixme.fi>
parents:
5
diff
changeset
|
208 |
|
17
baf3fe7c6354
add library error codes, and fix image fopen error handling
Tero Marttila <terom@fixme.fi>
parents:
16
diff
changeset
|
209 |
/** |
baf3fe7c6354
add library error codes, and fix image fopen error handling
Tero Marttila <terom@fixme.fi>
parents:
16
diff
changeset
|
210 |
* Error codes returned |
baf3fe7c6354
add library error codes, and fix image fopen error handling
Tero Marttila <terom@fixme.fi>
parents:
16
diff
changeset
|
211 |
*/ |
baf3fe7c6354
add library error codes, and fix image fopen error handling
Tero Marttila <terom@fixme.fi>
parents:
16
diff
changeset
|
212 |
enum pt_error { |
64 | 213 |
/** No error */ |
17
baf3fe7c6354
add library error codes, and fix image fopen error handling
Tero Marttila <terom@fixme.fi>
parents:
16
diff
changeset
|
214 |
PT_SUCCESS = 0, |
64 | 215 |
|
216 |
/** Generic error */ |
|
217 |
PT_ERR = 1, |
|
218 |
||
17
baf3fe7c6354
add library error codes, and fix image fopen error handling
Tero Marttila <terom@fixme.fi>
parents:
16
diff
changeset
|
219 |
PT_ERR_MEM, |
baf3fe7c6354
add library error codes, and fix image fopen error handling
Tero Marttila <terom@fixme.fi>
parents:
16
diff
changeset
|
220 |
|
baf3fe7c6354
add library error codes, and fix image fopen error handling
Tero Marttila <terom@fixme.fi>
parents:
16
diff
changeset
|
221 |
PT_ERR_PATH, |
baf3fe7c6354
add library error codes, and fix image fopen error handling
Tero Marttila <terom@fixme.fi>
parents:
16
diff
changeset
|
222 |
PT_ERR_OPEN_MODE, |
baf3fe7c6354
add library error codes, and fix image fopen error handling
Tero Marttila <terom@fixme.fi>
parents:
16
diff
changeset
|
223 |
|
baf3fe7c6354
add library error codes, and fix image fopen error handling
Tero Marttila <terom@fixme.fi>
parents:
16
diff
changeset
|
224 |
PT_ERR_IMG_STAT, |
69
1d188aa94aee
pt_png_check, and fclose() pt_image_open_file
Tero Marttila <terom@fixme.fi>
parents:
64
diff
changeset
|
225 |
PT_ERR_IMG_OPEN, |
1d188aa94aee
pt_png_check, and fclose() pt_image_open_file
Tero Marttila <terom@fixme.fi>
parents:
64
diff
changeset
|
226 |
PT_ERR_IMG_FORMAT, |
17
baf3fe7c6354
add library error codes, and fix image fopen error handling
Tero Marttila <terom@fixme.fi>
parents:
16
diff
changeset
|
227 |
|
baf3fe7c6354
add library error codes, and fix image fopen error handling
Tero Marttila <terom@fixme.fi>
parents:
16
diff
changeset
|
228 |
PT_ERR_PNG_CREATE, |
baf3fe7c6354
add library error codes, and fix image fopen error handling
Tero Marttila <terom@fixme.fi>
parents:
16
diff
changeset
|
229 |
PT_ERR_PNG, |
baf3fe7c6354
add library error codes, and fix image fopen error handling
Tero Marttila <terom@fixme.fi>
parents:
16
diff
changeset
|
230 |
|
baf3fe7c6354
add library error codes, and fix image fopen error handling
Tero Marttila <terom@fixme.fi>
parents:
16
diff
changeset
|
231 |
PT_ERR_CACHE_STAT, |
baf3fe7c6354
add library error codes, and fix image fopen error handling
Tero Marttila <terom@fixme.fi>
parents:
16
diff
changeset
|
232 |
PT_ERR_CACHE_OPEN_READ, |
baf3fe7c6354
add library error codes, and fix image fopen error handling
Tero Marttila <terom@fixme.fi>
parents:
16
diff
changeset
|
233 |
PT_ERR_CACHE_OPEN_TMP, |
baf3fe7c6354
add library error codes, and fix image fopen error handling
Tero Marttila <terom@fixme.fi>
parents:
16
diff
changeset
|
234 |
PT_ERR_CACHE_SEEK, |
baf3fe7c6354
add library error codes, and fix image fopen error handling
Tero Marttila <terom@fixme.fi>
parents:
16
diff
changeset
|
235 |
PT_ERR_CACHE_READ, |
baf3fe7c6354
add library error codes, and fix image fopen error handling
Tero Marttila <terom@fixme.fi>
parents:
16
diff
changeset
|
236 |
PT_ERR_CACHE_WRITE, |
baf3fe7c6354
add library error codes, and fix image fopen error handling
Tero Marttila <terom@fixme.fi>
parents:
16
diff
changeset
|
237 |
PT_ERR_CACHE_TRUNC, |
baf3fe7c6354
add library error codes, and fix image fopen error handling
Tero Marttila <terom@fixme.fi>
parents:
16
diff
changeset
|
238 |
PT_ERR_CACHE_MMAP, |
baf3fe7c6354
add library error codes, and fix image fopen error handling
Tero Marttila <terom@fixme.fi>
parents:
16
diff
changeset
|
239 |
PT_ERR_CACHE_RENAME_TMP, |
56
d5e3089906da
major refactoring of pt_cache, split off all PNG processing into pt_png
Tero Marttila <terom@fixme.fi>
parents:
54
diff
changeset
|
240 |
PT_ERR_CACHE_VERSION, |
59 | 241 |
PT_ERR_CACHE_MUNMAP, |
242 |
PT_ERR_CACHE_CLOSE, |
|
86
d4a62899587f
PT_ERR_TILE_DIM and PT_ERR_TILE_ZOOM
Tero Marttila <terom@fixme.fi>
parents:
80
diff
changeset
|
243 |
|
d4a62899587f
PT_ERR_TILE_DIM and PT_ERR_TILE_ZOOM
Tero Marttila <terom@fixme.fi>
parents:
80
diff
changeset
|
244 |
PT_ERR_TILE_DIM, |
17
baf3fe7c6354
add library error codes, and fix image fopen error handling
Tero Marttila <terom@fixme.fi>
parents:
16
diff
changeset
|
245 |
PT_ERR_TILE_CLIP, |
86
d4a62899587f
PT_ERR_TILE_DIM and PT_ERR_TILE_ZOOM
Tero Marttila <terom@fixme.fi>
parents:
80
diff
changeset
|
246 |
PT_ERR_TILE_ZOOM, |
17
baf3fe7c6354
add library error codes, and fix image fopen error handling
Tero Marttila <terom@fixme.fi>
parents:
16
diff
changeset
|
247 |
|
19
ebcc49de97d0
implement pt_ctx threadpool and pt_image_tile_async
Tero Marttila <terom@fixme.fi>
parents:
18
diff
changeset
|
248 |
PT_ERR_PTHREAD_CREATE, |
ebcc49de97d0
implement pt_ctx threadpool and pt_image_tile_async
Tero Marttila <terom@fixme.fi>
parents:
18
diff
changeset
|
249 |
PT_ERR_CTX_SHUTDOWN, |
ebcc49de97d0
implement pt_ctx threadpool and pt_image_tile_async
Tero Marttila <terom@fixme.fi>
parents:
18
diff
changeset
|
250 |
|
34 | 251 |
|
17
baf3fe7c6354
add library error codes, and fix image fopen error handling
Tero Marttila <terom@fixme.fi>
parents:
16
diff
changeset
|
252 |
PT_ERR_MAX, |
baf3fe7c6354
add library error codes, and fix image fopen error handling
Tero Marttila <terom@fixme.fi>
parents:
16
diff
changeset
|
253 |
}; |
baf3fe7c6354
add library error codes, and fix image fopen error handling
Tero Marttila <terom@fixme.fi>
parents:
16
diff
changeset
|
254 |
|
baf3fe7c6354
add library error codes, and fix image fopen error handling
Tero Marttila <terom@fixme.fi>
parents:
16
diff
changeset
|
255 |
/** |
baf3fe7c6354
add library error codes, and fix image fopen error handling
Tero Marttila <terom@fixme.fi>
parents:
16
diff
changeset
|
256 |
* Translate error code to short description |
baf3fe7c6354
add library error codes, and fix image fopen error handling
Tero Marttila <terom@fixme.fi>
parents:
16
diff
changeset
|
257 |
*/ |
baf3fe7c6354
add library error codes, and fix image fopen error handling
Tero Marttila <terom@fixme.fi>
parents:
16
diff
changeset
|
258 |
const char *pt_strerror (int err); |
baf3fe7c6354
add library error codes, and fix image fopen error handling
Tero Marttila <terom@fixme.fi>
parents:
16
diff
changeset
|
259 |
|
0 | 260 |
#endif |