include/pngtile.h
changeset 56 d5e3089906da
parent 54 4a25113cb2a4
child 59 80135bdfd343
equal deleted inserted replaced
55:a3542e78ecd8 56:d5e3089906da
    43     /** Cache does not exist */
    43     /** Cache does not exist */
    44     PT_CACHE_NONE       = 1,
    44     PT_CACHE_NONE       = 1,
    45 
    45 
    46     /** Cache exists, but is stale */
    46     /** Cache exists, but is stale */
    47     PT_CACHE_STALE      = 2,
    47     PT_CACHE_STALE      = 2,
       
    48 
       
    49     /** Cache exists, but it was generated using an incompatible version of this library */
       
    50     PT_CACHE_INCOMPAT   = 3,
    48 };
    51 };
    49 
    52 
    50 /** Metadata info for image. Values will be set to zero if not available */
    53 /** Metadata info for image. Values will be set to zero if not available */
    51 struct pt_image_info {
    54 struct pt_image_info {
    52     /** Dimensions of image */
    55     /** Dimensions of image. Only available if the cache is open */
    53     size_t width, height;
    56     size_t img_width, img_height;
       
    57 
       
    58     /** Bits per pixel */
       
    59     size_t img_bpp;
    54 
    60 
    55     /** Last update of image file */
    61     /** Last update of image file */
    56     time_t image_mtime;
    62     time_t image_mtime;
    57 
    63 
    58     /** Size of image file in bytes */
    64     /** Size of image file in bytes */
    59     size_t image_bytes;
    65     size_t image_bytes;
       
    66     
       
    67     /** Cache format version or -err */
       
    68     int cache_version;
    60 
    69 
    61     /** Last update of cache file */
    70     /** Last update of cache file */
    62     time_t cache_mtime;
    71     time_t cache_mtime;
    63 
    72 
    64     /** Size of cache file in bytes */
    73     /** Size of cache file in bytes */
   119  * @param mode combination of PT_OPEN_* flags
   128  * @param mode combination of PT_OPEN_* flags
   120  */
   129  */
   121 int pt_image_open (struct pt_image **image_ptr, struct pt_ctx *ctx, const char *png_path, int cache_mode);
   130 int pt_image_open (struct pt_image **image_ptr, struct pt_ctx *ctx, const char *png_path, int cache_mode);
   122 
   131 
   123 /**
   132 /**
   124  * Get the image's metadata
   133  * Get the image's metadata.
       
   134  *
       
   135  * XXX: return void, this never fails, just returns partial info
   125  */
   136  */
   126 int pt_image_info (struct pt_image *image, const struct pt_image_info **info_ptr);
   137 int pt_image_info (struct pt_image *image, const struct pt_image_info **info_ptr);
   127 
   138 
   128 /**
   139 /**
   129  * Check the given image's cache is stale - in other words, if the image needs to be update()'d.
   140  * Check the given image's cache is stale - in other words, if the image needs to be update()'d.
   139  */
   150  */
   140 int pt_image_update (struct pt_image *image, const struct pt_image_params *params);
   151 int pt_image_update (struct pt_image *image, const struct pt_image_params *params);
   141 
   152 
   142 /**
   153 /**
   143  * Load the image's cache in read-only mode without trying to update it.
   154  * Load the image's cache in read-only mode without trying to update it.
       
   155  *
       
   156  * Fails if the cache doesn't exist.
   144  */
   157  */
   145 // XXX: rename to pt_image_open?
   158 // XXX: rename to pt_image_open?
   146 int pt_image_load (struct pt_image *image);
   159 int pt_image_load (struct pt_image *image);
   147 
   160 
   148 /**
   161 /**
   205     PT_ERR_CACHE_READ,
   218     PT_ERR_CACHE_READ,
   206     PT_ERR_CACHE_WRITE,
   219     PT_ERR_CACHE_WRITE,
   207     PT_ERR_CACHE_TRUNC,
   220     PT_ERR_CACHE_TRUNC,
   208     PT_ERR_CACHE_MMAP,
   221     PT_ERR_CACHE_MMAP,
   209     PT_ERR_CACHE_RENAME_TMP,
   222     PT_ERR_CACHE_RENAME_TMP,
       
   223     PT_ERR_CACHE_VERSION,
   210 
   224 
   211     PT_ERR_TILE_CLIP,
   225     PT_ERR_TILE_CLIP,
   212 
   226 
   213     PT_ERR_PTHREAD_CREATE,
   227     PT_ERR_PTHREAD_CREATE,
   214     PT_ERR_CTX_SHUTDOWN,
   228     PT_ERR_CTX_SHUTDOWN,