aboutsummaryrefslogtreecommitdiff
path: root/src/dicache.h
blob: e0f49dfb43b36d6265063f0adf5018f7dafa3280 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
#ifndef __DICACHE_H__
#define __DICACHE_H__

#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */


#include "bitvec.h"
#include "image.hh"
#include "cache.h"

/** Symbolic name to request the last version of an image */
#define DIC_Last  -1
/** Flags: Last version, Valid entry */
#define DIF_Last  1
#define DIF_Valid 2


/* These will reflect the entry's "state" */
typedef enum {
   DIC_Empty,      /**< Just created the entry */
   DIC_SetParms,   /**< Parameters set */
   DIC_SetCmap,    /**< Color map set */
   DIC_Write,      /**< Feeding the entry */
   DIC_Close,      /**< Whole image got! */
   DIC_Abort       /**< Image transfer aborted */
} DicEntryState;

typedef struct DICacheEntry {
   DilloUrl *url;          /**< Image URL for this entry */
   DilloImgType type;      /**< Image type */
   uint_t width, height;   /**< As taken from image data */
   short Flags;            /**< See Flags */
   short SurvCleanup;      /**< Cleanup-pass survival for unused images */
   uchar_t *cmap;          /**< Color map */
   void *v_imgbuf;         /**< Void pointer to an Imgbuf object */
   uint_t TotalSize;       /**< Amount of memory the image takes up */
   uint_t ScanNumber;      /**< Current decoding scan */
   bitvec_t *BitVec;       /**< Bit vector for decoded rows */
   DicEntryState State;    /**< Current status for this entry */
   int RefCount;           /**< Reference Counter */
   int version;            /**< Version number, used for different
                              versions of the same URL image */

   uint_t DecodedSize;     /**< Size of already decoded data */
   CA_Callback_t Decoder;  /**< Client function */
   void *DecoderData;      /**< Client function data */
} DICacheEntry;


void a_Dicache_init (void);

DICacheEntry *a_Dicache_get_entry(const DilloUrl *Url, int version);

void *a_Dicache_png_image(const char *Type, void *Ptr, CA_Callback_t *Call,
                          void **Data);
void *a_Dicache_gif_image(const char *Type, void *Ptr, CA_Callback_t *Call,
                          void **Data);
void *a_Dicache_jpeg_image(const char *Type, void *Ptr, CA_Callback_t *Call,
                           void **Data);
void a_Dicache_callback(int Op, CacheClient_t *Client);

void a_Dicache_set_parms(DilloUrl *url, int version, DilloImage *Image,
                         uint_t width, uint_t height, DilloImgType type,
                         double gamma);
void a_Dicache_set_cmap(DilloUrl *url, int version, int bg_color,
                        const uchar_t *cmap, uint_t num_colors,
                        int num_colors_max, int bg_index);
void a_Dicache_new_scan(const DilloUrl *url, int version);
void a_Dicache_write(DilloUrl *url, int version, const uchar_t *buf, uint_t Y);
void a_Dicache_close(DilloUrl *url, int version, CacheClient_t *Client);

void a_Dicache_invalidate_entry(const DilloUrl *Url);
DICacheEntry* a_Dicache_ref(const DilloUrl *Url, int version);
void a_Dicache_unref(const DilloUrl *Url, int version);
void a_Dicache_cleanup(void);
void a_Dicache_freeall(void);


#ifdef __cplusplus
}
#endif /* __cplusplus */
#endif /* __DICACHE_H__ */