author | Tero Marttila <terom@fixme.fi> |
Tue, 26 Jan 2010 21:22:43 +0200 | |
changeset 123 | 81d1cad8b588 |
parent 56 | d5e3089906da |
permissions | -rw-r--r-- |
18 | 1 |
#ifndef PNGTILE_TILE_H |
2 |
#define PNGTILE_TILE_H |
|
3 |
||
4 |
/** |
|
56
d5e3089906da
major refactoring of pt_cache, split off all PNG processing into pt_png
Tero Marttila <terom@fixme.fi>
parents:
19
diff
changeset
|
5 |
* @file |
18 | 6 |
* Generating PNG tiles from a cache |
7 |
*/ |
|
56
d5e3089906da
major refactoring of pt_cache, split off all PNG processing into pt_png
Tero Marttila <terom@fixme.fi>
parents:
19
diff
changeset
|
8 |
|
d5e3089906da
major refactoring of pt_cache, split off all PNG processing into pt_png
Tero Marttila <terom@fixme.fi>
parents:
19
diff
changeset
|
9 |
struct pt_tile; |
d5e3089906da
major refactoring of pt_cache, split off all PNG processing into pt_png
Tero Marttila <terom@fixme.fi>
parents:
19
diff
changeset
|
10 |
|
18 | 11 |
#include "pngtile.h" |
12 |
#include "cache.h" |
|
13 |
||
14 |
/** Types of tile output */ |
|
15 |
enum pt_tile_output { |
|
16 |
PT_TILE_OUT_FILE, |
|
17 |
PT_TILE_OUT_MEM, |
|
18 |
}; |
|
19 |
||
20 |
/** Initial size of out.mem.base, 16k */ |
|
21 |
#define PT_TILE_BUF_SIZE (16 * 1024) |
|
22 |
||
23 |
||
24 |
||
25 |
/** Per-tile-render state */ |
|
26 |
struct pt_tile { |
|
19
ebcc49de97d0
implement pt_ctx threadpool and pt_image_tile_async
Tero Marttila <terom@fixme.fi>
parents:
18
diff
changeset
|
27 |
/** Cache to render from */ |
ebcc49de97d0
implement pt_ctx threadpool and pt_image_tile_async
Tero Marttila <terom@fixme.fi>
parents:
18
diff
changeset
|
28 |
struct pt_cache *cache; |
ebcc49de97d0
implement pt_ctx threadpool and pt_image_tile_async
Tero Marttila <terom@fixme.fi>
parents:
18
diff
changeset
|
29 |
|
18 | 30 |
/** Render spec */ |
31 |
struct pt_tile_info info; |
|
32 |
||
33 |
/** Output type */ |
|
34 |
enum pt_tile_output out_type; |
|
35 |
||
36 |
union { |
|
37 |
/** Output file */ |
|
38 |
FILE *file; |
|
39 |
||
40 |
/** Output buffer */ |
|
41 |
struct pt_tile_mem { |
|
42 |
char *base; |
|
43 |
size_t off, len; |
|
44 |
} mem; |
|
45 |
} out; |
|
46 |
}; |
|
47 |
||
48 |
/** |
|
56
d5e3089906da
major refactoring of pt_cache, split off all PNG processing into pt_png
Tero Marttila <terom@fixme.fi>
parents:
19
diff
changeset
|
49 |
* Write to the tile's output buffer |
d5e3089906da
major refactoring of pt_cache, split off all PNG processing into pt_png
Tero Marttila <terom@fixme.fi>
parents:
19
diff
changeset
|
50 |
*/ |
d5e3089906da
major refactoring of pt_cache, split off all PNG processing into pt_png
Tero Marttila <terom@fixme.fi>
parents:
19
diff
changeset
|
51 |
int pt_tile_mem_write (struct pt_tile_mem *buf, void *data, size_t len); |
d5e3089906da
major refactoring of pt_cache, split off all PNG processing into pt_png
Tero Marttila <terom@fixme.fi>
parents:
19
diff
changeset
|
52 |
|
d5e3089906da
major refactoring of pt_cache, split off all PNG processing into pt_png
Tero Marttila <terom@fixme.fi>
parents:
19
diff
changeset
|
53 |
|
d5e3089906da
major refactoring of pt_cache, split off all PNG processing into pt_png
Tero Marttila <terom@fixme.fi>
parents:
19
diff
changeset
|
54 |
/** |
19
ebcc49de97d0
implement pt_ctx threadpool and pt_image_tile_async
Tero Marttila <terom@fixme.fi>
parents:
18
diff
changeset
|
55 |
* Alloc a new pt_tile, which must be initialized using pt_tile_init_* |
ebcc49de97d0
implement pt_ctx threadpool and pt_image_tile_async
Tero Marttila <terom@fixme.fi>
parents:
18
diff
changeset
|
56 |
*/ |
ebcc49de97d0
implement pt_ctx threadpool and pt_image_tile_async
Tero Marttila <terom@fixme.fi>
parents:
18
diff
changeset
|
57 |
int pt_tile_new (struct pt_tile **tile_ptr); |
ebcc49de97d0
implement pt_ctx threadpool and pt_image_tile_async
Tero Marttila <terom@fixme.fi>
parents:
18
diff
changeset
|
58 |
|
ebcc49de97d0
implement pt_ctx threadpool and pt_image_tile_async
Tero Marttila <terom@fixme.fi>
parents:
18
diff
changeset
|
59 |
/** |
18 | 60 |
* Initialize to render with given params, writing output to given FILE* |
61 |
*/ |
|
19
ebcc49de97d0
implement pt_ctx threadpool and pt_image_tile_async
Tero Marttila <terom@fixme.fi>
parents:
18
diff
changeset
|
62 |
int pt_tile_init_file (struct pt_tile *tile, struct pt_cache *cache, const struct pt_tile_info *info, FILE *out); |
18 | 63 |
|
64 |
/** |
|
65 |
* Initialize to render with given params, writing output to a memory buffer |
|
66 |
*/ |
|
19
ebcc49de97d0
implement pt_ctx threadpool and pt_image_tile_async
Tero Marttila <terom@fixme.fi>
parents:
18
diff
changeset
|
67 |
int pt_tile_init_mem (struct pt_tile *tile, struct pt_cache *cache, const struct pt_tile_info *info); |
18 | 68 |
|
69 |
/** |
|
70 |
* Render PNG data from given cache according to parameters given to pt_tile_init_* |
|
71 |
*/ |
|
19
ebcc49de97d0
implement pt_ctx threadpool and pt_image_tile_async
Tero Marttila <terom@fixme.fi>
parents:
18
diff
changeset
|
72 |
int pt_tile_render (struct pt_tile *tile); |
18 | 73 |
|
74 |
/** |
|
75 |
* Abort any failed render process, cleaning up. |
|
76 |
*/ |
|
77 |
void pt_tile_abort (struct pt_tile *tile); |
|
78 |
||
19
ebcc49de97d0
implement pt_ctx threadpool and pt_image_tile_async
Tero Marttila <terom@fixme.fi>
parents:
18
diff
changeset
|
79 |
/** |
ebcc49de97d0
implement pt_ctx threadpool and pt_image_tile_async
Tero Marttila <terom@fixme.fi>
parents:
18
diff
changeset
|
80 |
* Destroy given pt_tile, aborting it and freeing it |
ebcc49de97d0
implement pt_ctx threadpool and pt_image_tile_async
Tero Marttila <terom@fixme.fi>
parents:
18
diff
changeset
|
81 |
*/ |
ebcc49de97d0
implement pt_ctx threadpool and pt_image_tile_async
Tero Marttila <terom@fixme.fi>
parents:
18
diff
changeset
|
82 |
void pt_tile_destroy (struct pt_tile *tile); |
ebcc49de97d0
implement pt_ctx threadpool and pt_image_tile_async
Tero Marttila <terom@fixme.fi>
parents:
18
diff
changeset
|
83 |
|
18 | 84 |
#endif |