74 st = (e1->
version - e2->version);
88 for (
int i = 0; i <
DIC_MAX; i++) {
139 last->
Flags &= ~DIF_Last;
183 _MSG(
"Dicache_remove Imgbuf=%p Decoder=%p DecoderData=%p\n",
219 _MSG(
"a_Dicache_unref: RefCount=%d State=%d ImgbufLastRef=%d\n",
250 entry->
Flags &= ~DIF_Valid;
283 DicEntry->
TotalSize = width * height * 3;
284 DicEntry->
width = width;
285 DicEntry->
height = height;
286 DicEntry->
type = type;
298 int num_colors_max,
int bg_index)
302 _MSG(
"a_Dicache_set_cmap\n");
307 memcpy(DicEntry->
cmap, cmap, 3 * num_colors);
308 if (bg_index >= 0 && (
uint_t)bg_index < num_colors) {
309 DicEntry->
cmap[bg_index * 3] = (bg_color >> 16) & 0xff;
310 DicEntry->
cmap[bg_index * 3 + 1] = (bg_color >> 8) & 0xff;
311 DicEntry->
cmap[bg_index * 3 + 2] = (bg_color) & 0xff;
324 _MSG(
"a_Dicache_new_scan\n");
329 MSG(
"a_Dicache_new_scan before DIC_SetParms\n");
347 _MSG(
"a_Dicache_write\n");
371 _MSG(
"a_Dicache_close RefCount=%d\n", DicEntry->
RefCount - 1);
373 _MSG(
" a_Dicache_close imgbuf=%p Decoder=%p DecoderData=%p\n",
379 DicEntry->
cmap = NULL;
428 }
else if (ImgType ==
DIC_Gif) {
436 }
else if (ImgType ==
DIC_Png) {
440 }
else if (ImgType ==
DIC_Svg) {
543 for (i = 0; i < DicEntry->
height; ++i)
548 for (i = 0; i < DicEntry->
height; ++i) {
619 long bytesCached = 0L;
623 "<head><title>Decompressed Image Cache</title></head>\n"
627 dStr_sprintfa(s,
"<h1>Decompressed Image Cache (%d)</h1>\n", n);
631 dStr_append(s,
"<th><span title='Survival Counter'>S</span></th>\n");
632 dStr_append(s,
"<th><span title='Last Reference'>L</span></th>\n");
637 for (
int i = 0; i < n; i++) {
643 dStr_sprintfa(s,
"<td style='text-align:right'>%.2f KiB</td>\n",
652 float mb = (float) bytesCached / (1024.0f * 1024.0f);
void a_Bitvec_clear(bitvec_t *bvec)
Clear a bitvec.
bitvec_t * a_Bitvec_new(int num_bits)
Create a new bitvec with 'num_bits' size.
void a_Bitvec_set_bit(bitvec_t *bvec, int pos)
Set a bit.
void a_Bitvec_free(bitvec_t *bvec)
Free a bitvec.
int a_Bitvec_get_bit(bitvec_t *bvec, int pos)
Get a bit.
#define a_Bitvec_clear_bit(bvec, pos)
void a_Bw_close_client(BrowserWindow *bw, int ClientKey)
Close a cache-client upon successful retrieval.
void(* CA_Callback_t)(int Op, CacheClient_t *Client)
Callback type for cache clients.
void a_Dicache_set_parms(DilloUrl *url, int version, DilloImage *Image, uint_t width, uint_t height, DilloImgType type, double gamma)
Set image's width, height & type.
DICacheEntry * a_Dicache_get_entry(const DilloUrl *Url, int version)
Search a particular version of a URL in the Dicache.
void a_Dicache_cleanup(void)
Free the imgbuf (RGB data) of unused entries.
static Dlist * CachedIMGs
List of DICacheEntry.
static DICacheEntry * Dicache_entry_new(void)
Create, and initialize a new, empty, dicache entry.
void a_Dicache_invalidate_entry(const DilloUrl *Url)
Invalidate this entry.
static const char * format_name[DIC_MAX]
DICacheEntry * a_Dicache_ref(const DilloUrl *Url, int version)
Refs the counter of a dicache entry.
void a_Dicache_new_scan(const DilloUrl *url, int version)
Reset for a new scan from a multiple-scan image.
void a_Dicache_close(DilloUrl *url, int version, CacheClient_t *Client)
Implement the close method of the decoding process.
void * a_Dicache_svg_image(const char *Type, void *Ptr, CA_Callback_t *Call, void **Data)
SVG wrapper for Dicache_image()
void a_Dicache_init(void)
Initialize dicache data.
void a_Dicache_unref(const DilloUrl *Url, int version)
Unrefs the counter of a dicache entry (it counts cache clients).
void a_Dicache_callback(int Op, CacheClient_t *Client)
This function is a cache client; (but feeds its clients from dicache)
void a_Dicache_write(DilloUrl *url, int version, const uchar_t *buf, uint_t Y)
Implement the write method (Write a scan line into the Dicache entry) buf: row buffer Y : row number.
static int Dicache_entry_cmp(const void *v1, const void *v2)
Compare function for image entries.
static void * Dicache_image(int ImgType, const char *MimeType, void *Ptr, CA_Callback_t *Call, void **Data)
Generic MIME handler for GIF, JPEG, PNG and SVG.
void a_Dicache_freeall(void)
Deallocate memory used by dicache module (Call this one at exit time, with no cache clients queued)
static uint_t dicache_size_total
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)
Implement the set_cmap method for the Image.
static void Dicache_remove(const DilloUrl *Url, int version)
Actually free a dicache entry, given the URL and the version number.
void * a_Dicache_jpeg_image(const char *Type, void *Ptr, CA_Callback_t *Call, void **Data)
JPEG wrapper for Dicache_image()
static DICacheEntry * Dicache_add_entry(const DilloUrl *Url)
Add a new entry in the dicache (a single URL may have several entries)
static int Dicache_is_last_ref(DICacheEntry *entry)
Dstr * a_Dicache_stats(void)
void * a_Dicache_webp_image(const char *Type, void *Ptr, CA_Callback_t *Call, void **Data)
WEBP wrapper for Dicache_image()
void * a_Dicache_gif_image(const char *Type, void *Ptr, CA_Callback_t *Call, void **Data)
GIF wrapper for Dicache_image()
static int disabled_formats[DIC_MAX]
void * a_Dicache_png_image(const char *Type, void *Ptr, CA_Callback_t *Call, void **Data)
PNG wrapper for Dicache_image()
#define DIF_Last
Flags: Last version, Valid entry.
@ DIC_Close
Whole image got!
@ DIC_SetCmap
Color map set.
@ DIC_SetParms
Parameters set.
@ DIC_Write
Feeding the entry.
@ DIC_Empty
Just created the entry.
#define DIC_Last
Symbolic name to request the last version of an image.
void dList_insert_sorted(Dlist *lp, void *data, dCompareFunc func)
Insert an element into a sorted list.
void dStr_sprintfa(Dstr *ds, const char *format,...)
Printf-like function that appends.
void dStr_append(Dstr *ds, const char *s)
Append a C string to a Dstr.
Dlist * dList_new(int size)
Create a new empty list.
int dList_length(Dlist *lp)
For completing the ADT.
void dStr_shorten(Dstr *dst, const char *src, int n)
Shorten string so it fits in n characters.
void * dList_nth_data(Dlist *lp, int n0)
Return the nth data item, NULL when not found or 'n0' is out of range.
void dList_remove_fast(Dlist *lp, const void *data)
Remove a data item without preserving order.
char * dStriAsciiStr(const char *haystack, const char *needle)
Case insensitive strstr.
Dstr * dStr_new(const char *s)
Create a new string.
void * dList_find_sorted(Dlist *lp, const void *data, dCompareFunc func)
Search a sorted list.
void dList_free(Dlist *lp)
Free a list (not its elements)
void dList_remove(Dlist *lp, const void *data)
#define dReturn_if_fail(expr)
#define dNew0(type, count)
#define dReturn_val_if_fail(expr, val)
#define dNew(type, count)
void * a_Png_new(DilloImage *Image, DilloUrl *url, int version)
Create the image state data that must be kept between calls.
void a_Png_callback(int Op, CacheClient_t *Client)
void * a_Imgbuf_new(void *layout, int img_type, uint_t width, uint_t height, double gamma)
Create a new Imgbuf.
void a_Imgbuf_update(void *v_imgbuf, const uchar_t *buf, DilloImgType type, uchar_t *cmap, uint_t width, uint_t height, uint_t y)
Update the root buffer of an imgbuf.
int a_Imgbuf_last_reference(void *v_imgbuf)
Last reference for this Imgbuf?
void a_Imgbuf_unref(void *v_imgbuf)
Decrement reference count for an Imgbuf.
void a_Imgbuf_new_scan(void *v_imgbuf)
Reset for a new scan from a multiple-scan image.
DilloPrefs prefs
Global Data.
void a_Image_ref(DilloImage *Image)
Add a reference to an Image struct Do nothing if the argument is NULL.
DilloImage * a_Image_new_with_dw(void *layout, const char *alt_text, int32_t bg_color, int32_t fg_color)
Create and initialize a new image structure with an image widget.
void * a_Image_get_dw(DilloImage *Image)
Return the image renderer as a widget.
void a_Image_abort(DilloImage *Image)
Implement the abort method.
void a_Image_write(DilloImage *Image, uint_t y)
Implement the write method.
void a_Image_close(DilloImage *Image)
Implement the close method.
void a_Image_set_parms(DilloImage *Image, void *v_imgbuf, DilloUrl *url, int version, uint_t width, uint_t height, DilloImgType type)
Set initial parameters of the image.
The DilloImage data-structure and methods.
void * render_layout
All the rendering is done by this.
Data structure for cache clients.
int Key
Primary Key for this client.
int Version
Dicache version of this Url (0 if not used)
uint_t BufSize
Valid size of cache-data.
void * Web
Pointer to the Web structure of our client.
int RefCount
Reference Counter.
uint_t ScanNumber
Current decoding scan.
int version
Version number, used for different versions of the same URL image.
uint_t DecodedSize
Size of already decoded data.
short SurvCleanup
Cleanup-pass survival for unused images.
DilloImgType type
Image type.
DicEntryState State
Current status for this entry.
DilloUrl * url
Image URL for this entry.
CA_Callback_t Decoder
Client function.
uint_t TotalSize
Amount of memory the image takes up.
bitvec_t * BitVec
Bit vector for decoded rows.
uint_t height
As taken from image data.
void * DecoderData
Client function data.
void * v_imgbuf
Void pointer to an Imgbuf object.
char * ignore_image_formats
uint_t ScanNumber
Current decoding scan.
bitvec_t * BitVec
Bit vector for decoded rows.
DilloUrl * url
Requested URL.
BrowserWindow * bw
The requesting browser window [reference].
DilloImage * Image
For image urls [reference].
int32_t bgColor
for image backgrounds
int a_Url_cmp(const DilloUrl *A, const DilloUrl *B)
Compare two Url's to check if they're the same, or which one is bigger.
void a_Url_free(DilloUrl *url)
Free a DilloUrl.
DilloUrl * a_Url_dup(const DilloUrl *ori)
Duplicate a Url structure.