# HG changeset patch # User Tero Marttila # Date 1264378169 -7200 # Node ID 98d934a9b3db944614454281b922248b7cfb7c4f # Parent 2aab5d906dc8337281484405d14e1d856b9bfc5e document pt_ctx as optional diff -r 2aab5d906dc8 -r 98d934a9b3db include/pngtile.h --- a/include/pngtile.h Mon Jan 25 02:04:35 2010 +0200 +++ b/include/pngtile.h Mon Jan 25 02:09:29 2010 +0200 @@ -122,8 +122,10 @@ /** * Open a new pt_image for use. * + * The pt_ctx is optional, but required for pt_image_tile_async. + * * @param img_ptr returned pt_image handle - * @param ctx global state to use + * @param ctx global state to use (optional) * @param path filesystem path to .png file * @param mode combination of PT_OPEN_* flags */ @@ -184,6 +186,8 @@ * * This function may return before the PNG has been rendered. * + * Fails with PT_ERR if not pt_ctx was given to pt_image_open. + * * @param image render from image's cache. The cache must have been opened previously! * @param info tile parameters * @param out IO stream to write PNG data to, and close once done @@ -199,7 +203,12 @@ * Error codes returned */ enum pt_error { + /** No error */ PT_SUCCESS = 0, + + /** Generic error */ + PT_ERR = 1, + PT_ERR_MEM, PT_ERR_PATH, diff -r 2aab5d906dc8 -r 98d934a9b3db src/lib/image.c --- a/src/lib/image.c Mon Jan 25 02:04:35 2010 +0200 +++ b/src/lib/image.c Mon Jan 25 02:09:29 2010 +0200 @@ -206,6 +206,9 @@ return err; } +/** + * Async work func for pt_image_tile_async + */ static void _pt_image_tile_async (void *arg) { struct pt_tile *tile = arg; @@ -228,6 +231,10 @@ struct pt_tile *tile; int err; + // need a ctx for this + if (!image->ctx) + return -1; + // alloc if ((err = pt_tile_new(&tile))) return err;