68
68
static ImageCache *create (bool shared=true);
70
70
/// Destroy a ImageCache that was created using ImageCache::create().
71
/// The variety that takes a 'teardown' parameter, when set to true,
72
/// will fully destroy even a "shared" ImageCache.
72
73
static void destroy (ImageCache * x);
74
static void destroy (ImageCache * x, bool teardown);
74
76
ImageCache (void) { }
75
77
virtual ~ImageCache () { }
211
213
/// pixel coordinates. An opaque pointer to the tile will be
212
214
/// returned, or NULL if no such file (or tile within the file)
213
215
/// exists or can be read. The tile will not be purged from the
214
/// cache until after release_tile() is called on the tile pointer.
216
/// cache until after release_tile() is called on the tile pointer
217
/// the same number of times that get_tile() was called (refcnt).
215
218
/// This is thread-safe!
216
219
virtual Tile * get_tile (ustring filename, int subimage, int miplevel,
217
220
int x, int y, int z) = 0;
226
229
/// the data type of the pixels in the disk file).
227
230
virtual const void * tile_pixels (Tile *tile, TypeDesc &format) const = 0;
232
/// This creates a file entry in the cache that, instead of reading
233
/// from disk, uses a custom ImageInput to generate the image (note
234
/// that it will have no effect if there's already an image by the
235
/// same name in the cache). The 'creator' is a factory that
236
/// creates the custom ImageInput and will be called like this:
237
/// ImageInput *in = creator(); Once created, the ImageCache owns
238
/// the ImageInput and is responsible for destroying it when done.
239
/// Custom ImageInputs allow "procedural" images, among other
240
/// things. Also, this is the method you use to set up a
241
/// "writeable" ImageCache images (perhaps with a type of ImageInput
242
/// that's just a stub that does as little as possible).
243
virtual bool add_file (ustring filename, ImageInput::Creator creator) = 0;
245
/// Preemptively add a tile corresponding to the named image, at the
246
/// given subimage and MIP level. The tile added is the one whose
247
/// corner is (x,y,z), and buffer points to the pixels (in the given
248
/// format, with supplied strides) which will be copied and inserted
249
/// into the cache and made available for future lookups.
250
virtual bool add_tile (ustring filename, int subimage, int miplevel,
251
int x, int y, int z, TypeDesc format, const void *buffer,
252
stride_t xstride=AutoStride, stride_t ystride=AutoStride,
253
stride_t zstride=AutoStride) = 0;
229
255
/// If any of the API routines returned false indicating an error,
230
256
/// this routine will return the error string (and clear any error
231
257
/// flags). If no error has occurred since the last time geterror()