Dillo v3.1.1-119-g140d9ebd
|
#include <string.h>
#include <stdlib.h>
#include "msg.h"
#include "image.hh"
#include "imgbuf.hh"
#include "web.hh"
#include "dicache.h"
#include "dpng.h"
#include "dwebp.h"
#include "dgif.h"
#include "djpeg.h"
#include "dsvg.h"
Go to the source code of this file.
Macros | |
#define | I_RGB 0 |
Enumerations | |
enum | { DIC_Gif = 0 , DIC_Png , DIC_Webp , DIC_Jpeg , DIC_Svg , DIC_MAX } |
Functions | |
static int | Dicache_entry_cmp (const void *v1, const void *v2) |
Compare function for image entries. | |
void | a_Dicache_init (void) |
Initialize dicache data. | |
static DICacheEntry * | Dicache_entry_new (void) |
Create, and initialize a new, empty, dicache entry. | |
static DICacheEntry * | Dicache_add_entry (const DilloUrl *Url) |
Add a new entry in the dicache (a single URL may have several entries) | |
DICacheEntry * | a_Dicache_get_entry (const DilloUrl *Url, int version) |
Search a particular version of a URL in the Dicache. | |
static void | Dicache_remove (const DilloUrl *Url, int version) |
Actually free a dicache entry, given the URL and the version number. | |
void | a_Dicache_unref (const DilloUrl *Url, int version) |
Unrefs the counter of a dicache entry (it counts cache clients). | |
DICacheEntry * | a_Dicache_ref (const DilloUrl *Url, int version) |
Refs the counter of a dicache entry. | |
void | a_Dicache_invalidate_entry (const DilloUrl *Url) |
Invalidate this entry. | |
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. | |
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. | |
void | a_Dicache_new_scan (const DilloUrl *url, int version) |
Reset for a new scan from a multiple-scan image. | |
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. | |
void | a_Dicache_close (DilloUrl *url, int version, CacheClient_t *Client) |
Implement the close method of the decoding process. | |
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_png_image (const char *Type, void *Ptr, CA_Callback_t *Call, void **Data) |
PNG wrapper for Dicache_image() | |
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() | |
void * | a_Dicache_jpeg_image (const char *Type, void *Ptr, CA_Callback_t *Call, void **Data) |
JPEG wrapper for Dicache_image() | |
void * | a_Dicache_svg_image (const char *Type, void *Ptr, CA_Callback_t *Call, void **Data) |
SVG wrapper for Dicache_image() | |
void | a_Dicache_callback (int Op, CacheClient_t *Client) |
This function is a cache client; (but feeds its clients from dicache) | |
void | a_Dicache_cleanup (void) |
Free the imgbuf (RGB data) of unused entries. | |
void | a_Dicache_freeall (void) |
Deallocate memory used by dicache module (Call this one at exit time, with no cache clients queued) | |
Variables | |
static const char * | format_name [DIC_MAX] |
static int | disabled_formats [DIC_MAX] = { 0 } |
static Dlist * | CachedIMGs = NULL |
List of DICacheEntry. | |
static uint_t | dicache_size_total |
#define I_RGB 0 |
anonymous enum |
void a_Dicache_callback | ( | int | Op, |
CacheClient_t * | Client | ||
) |
This function is a cache client; (but feeds its clients from dicache)
Definition at line 492 of file dicache.c.
References a_Bitvec_clear_bit, a_Bitvec_get_bit(), a_Bw_close_client(), a_Dicache_close(), a_Dicache_get_entry(), a_Image_abort(), a_Image_close(), a_Image_set_parms(), a_Image_write(), DICacheEntry::BitVec, _DilloImage::BitVec, CacheClient::BufSize, _DilloWeb::bw, CA_Abort, CA_Close, CA_Send, DICacheEntry::DecodedSize, DICacheEntry::Decoder, DIC_Close, DIC_Last, DIC_SetParms, DIC_Write, dReturn_if_fail, DICacheEntry::height, _DilloImage::height, _DilloWeb::Image, CacheClient::Key, DICacheEntry::ScanNumber, _DilloImage::ScanNumber, DICacheEntry::State, DICacheEntry::type, DICacheEntry::url, _DilloWeb::url, DICacheEntry::v_imgbuf, CacheClient::Version, DICacheEntry::version, CacheClient::Web, and DICacheEntry::width.
Referenced by Dicache_image().
void a_Dicache_cleanup | ( | void | ) |
Free the imgbuf (RGB data) of unused entries.
Definition at line 560 of file dicache.c.
References _MSG, a_Imgbuf_last_reference(), CachedIMGs, Dicache_remove(), dList_length(), dList_nth_data(), DICacheEntry::RefCount, DICacheEntry::SurvCleanup, DICacheEntry::url, DICacheEntry::v_imgbuf, and DICacheEntry::version.
Referenced by Cache_process_queue().
void a_Dicache_close | ( | DilloUrl * | url, |
int | version, | ||
CacheClient_t * | Client | ||
) |
Implement the close method of the decoding process.
Definition at line 349 of file dicache.c.
References _MSG, a_Bw_close_client(), a_Dicache_get_entry(), a_Dicache_unref(), _DilloWeb::bw, DICacheEntry::cmap, DICacheEntry::Decoder, DICacheEntry::DecoderData, dFree(), DIC_Close, dReturn_if_fail, CacheClient::Key, DICacheEntry::RefCount, DICacheEntry::State, DICacheEntry::v_imgbuf, and CacheClient::Web.
Referenced by a_Dicache_callback(), and Png_close().
void a_Dicache_freeall | ( | void | ) |
Deallocate memory used by dicache module (Call this one at exit time, with no cache clients queued)
Definition at line 586 of file dicache.c.
References a_Bitvec_free(), a_Imgbuf_unref(), a_Url_free(), DICacheEntry::BitVec, CachedIMGs, DICacheEntry::cmap, dFree(), dicache_size_total, dList_free(), dList_length(), dList_nth_data(), dList_remove_fast(), DICacheEntry::TotalSize, DICacheEntry::url, and DICacheEntry::v_imgbuf.
Referenced by main().
DICacheEntry * a_Dicache_get_entry | ( | const DilloUrl * | Url, |
int | version | ||
) |
Search a particular version of a URL in the Dicache.
Notes: DIC_Last means last version of the image. version zero is not allowed.
Definition at line 150 of file dicache.c.
References CachedIMGs, DIC_Last, Dicache_entry_cmp(), DIF_Valid, dList_find_sorted(), dReturn_val_if_fail, DICacheEntry::Flags, DICacheEntry::url, and DICacheEntry::version.
Referenced by a_Cache_stop_client(), a_Dicache_callback(), a_Dicache_close(), a_Dicache_invalidate_entry(), a_Dicache_new_scan(), a_Dicache_ref(), a_Dicache_set_cmap(), a_Dicache_set_parms(), a_Dicache_unref(), a_Dicache_write(), and Dicache_image().
void * a_Dicache_gif_image | ( | const char * | Type, |
void * | Ptr, | ||
CA_Callback_t * | Call, | ||
void ** | Data | ||
) |
GIF wrapper for Dicache_image()
Definition at line 465 of file dicache.c.
References DIC_Gif, and Dicache_image().
Referenced by a_Mime_init().
void a_Dicache_init | ( | void | ) |
Initialize dicache data.
Definition at line 76 of file dicache.c.
References _MSG, CachedIMGs, DIC_MAX, dicache_size_total, disabled_formats, dList_new(), dStriAsciiStr(), format_name, DilloPrefs::ignore_image_formats, and prefs.
Referenced by main().
void a_Dicache_invalidate_entry | ( | const DilloUrl * | Url | ) |
Invalidate this entry.
This is used for the reloading mechanism. Can't erase current versions, but a_Dicache_get_entry(url, DIC_Last) must return NULL.
Definition at line 232 of file dicache.c.
References a_Dicache_get_entry(), DIC_Last, and DICacheEntry::Flags.
Referenced by Cache_entry_remove().
void * a_Dicache_jpeg_image | ( | const char * | Type, |
void * | Ptr, | ||
CA_Callback_t * | Call, | ||
void ** | Data | ||
) |
JPEG wrapper for Dicache_image()
Definition at line 474 of file dicache.c.
References DIC_Jpeg, and Dicache_image().
Referenced by a_Mime_init().
void a_Dicache_new_scan | ( | const DilloUrl * | url, |
int | version | ||
) |
Reset for a new scan from a multiple-scan image.
Definition at line 306 of file dicache.c.
References _MSG, a_Bitvec_clear(), a_Dicache_get_entry(), a_Imgbuf_new_scan(), DICacheEntry::BitVec, DIC_SetParms, dReturn_if_fail, MSG, DICacheEntry::ScanNumber, DICacheEntry::State, and DICacheEntry::v_imgbuf.
Referenced by Png_datarow_callback().
void * a_Dicache_png_image | ( | const char * | Type, |
void * | Ptr, | ||
CA_Callback_t * | Call, | ||
void ** | Data | ||
) |
PNG wrapper for Dicache_image()
Definition at line 447 of file dicache.c.
References DIC_Png, and Dicache_image().
Referenced by a_Mime_init().
DICacheEntry * a_Dicache_ref | ( | const DilloUrl * | Url, |
int | version | ||
) |
Refs the counter of a dicache entry.
Definition at line 217 of file dicache.c.
References a_Dicache_get_entry(), and DICacheEntry::RefCount.
Referenced by Dicache_image().
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.
Definition at line 282 of file dicache.c.
References _MSG, a_Dicache_get_entry(), DICacheEntry::cmap, dFree(), DIC_SetCmap, dNew0, dReturn_if_fail, and DICacheEntry::State.
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.
Definition at line 248 of file dicache.c.
References _MSG, a_Bitvec_new(), a_Dicache_get_entry(), a_Imgbuf_new(), DICacheEntry::BitVec, DIC_SetParms, dicache_size_total, dReturn_if_fail, DICacheEntry::height, I_RGB, _DilloImage::layout, DICacheEntry::RefCount, DICacheEntry::State, DICacheEntry::TotalSize, DICacheEntry::type, URL_STR, DICacheEntry::v_imgbuf, DICacheEntry::version, and DICacheEntry::width.
Referenced by Png_datainfo_callback().
void * a_Dicache_svg_image | ( | const char * | Type, |
void * | Ptr, | ||
CA_Callback_t * | Call, | ||
void ** | Data | ||
) |
SVG wrapper for Dicache_image()
Definition at line 483 of file dicache.c.
References DIC_Svg, and Dicache_image().
Referenced by a_Mime_init().
void a_Dicache_unref | ( | const DilloUrl * | Url, |
int | version | ||
) |
Unrefs the counter of a dicache entry (it counts cache clients).
If there're no clients and no imgbuf, remove the entry. Otherwise, let a_Dicache_cleanup() do the job later (keeping it cached meanwhile for e.g. reload, repush, back/fwd).
Definition at line 200 of file dicache.c.
References _MSG, a_Dicache_get_entry(), a_Imgbuf_last_reference(), Dicache_remove(), DICacheEntry::RefCount, DICacheEntry::State, and DICacheEntry::v_imgbuf.
Referenced by a_Cache_stop_client(), and a_Dicache_close().
void * a_Dicache_webp_image | ( | const char * | Type, |
void * | Ptr, | ||
CA_Callback_t * | Call, | ||
void ** | Data | ||
) |
WEBP wrapper for Dicache_image()
Definition at line 456 of file dicache.c.
References DIC_Webp, and Dicache_image().
Referenced by a_Mime_init().
Implement the write method (Write a scan line into the Dicache entry) buf: row buffer Y : row number.
Definition at line 329 of file dicache.c.
References _MSG, a_Bitvec_set_bit(), a_Dicache_get_entry(), a_Imgbuf_update(), DICacheEntry::BitVec, DICacheEntry::cmap, DIC_Write, dReturn_if_fail, DICacheEntry::height, DICacheEntry::State, DICacheEntry::type, DICacheEntry::v_imgbuf, and DICacheEntry::width.
Referenced by Png_datarow_callback().
|
static |
Add a new entry in the dicache (a single URL may have several entries)
Definition at line 123 of file dicache.c.
References a_Url_dup(), CachedIMGs, DIC_Last, Dicache_entry_cmp(), Dicache_entry_new(), DIF_Last, dList_find_sorted(), dList_insert_sorted(), DICacheEntry::Flags, DICacheEntry::url, and DICacheEntry::version.
Referenced by Dicache_image().
|
static |
Compare function for image entries.
Definition at line 59 of file dicache.c.
References a_Url_cmp(), DIC_Last, DIF_Last, DICacheEntry::Flags, DICacheEntry::url, and DICacheEntry::version.
Referenced by a_Dicache_get_entry(), Dicache_add_entry(), and Dicache_remove().
|
static |
Create, and initialize a new, empty, dicache entry.
Definition at line 94 of file dicache.c.
References DICacheEntry::BitVec, DICacheEntry::cmap, DICacheEntry::DecodedSize, DICacheEntry::Decoder, DICacheEntry::DecoderData, DIC_Empty, DIF_Valid, DILLO_IMG_TYPE_NOTSET, dNew, DICacheEntry::Flags, DICacheEntry::height, DICacheEntry::RefCount, DICacheEntry::ScanNumber, DICacheEntry::State, DICacheEntry::SurvCleanup, DICacheEntry::TotalSize, DICacheEntry::type, DICacheEntry::v_imgbuf, DICacheEntry::version, and DICacheEntry::width.
Referenced by Dicache_add_entry().
|
static |
Generic MIME handler for GIF, JPEG, PNG and SVG.
Sets a_Dicache_callback as the cache-client, and also sets the image decoder.
Type | MIME type |
Ptr | points to a DilloWeb structure |
Call | Dillo calls this with more data/eod |
Data | Decoding data structure |
Definition at line 386 of file dicache.c.
References _MSG, a_Dicache_callback(), a_Dicache_get_entry(), a_Dicache_ref(), a_Gif_callback(), a_Gif_new(), a_Image_get_dw(), a_Image_new_with_dw(), a_Image_ref(), a_Jpeg_callback(), a_Jpeg_new(), a_Png_callback(), a_Png_new(), a_Svg_callback(), a_Svg_new(), a_Webp_callback(), a_Webp_new(), _DilloWeb::bgColor, _DilloWeb::bw, DICacheEntry::Decoder, DICacheEntry::DecoderData, DIC_Gif, DIC_Jpeg, DIC_Last, DIC_MAX, DIC_Png, DIC_Svg, DIC_Webp, Dicache_add_entry(), disabled_formats, dReturn_val_if_fail, format_name, _DilloWeb::Image, BrowserWindow::render_layout, DICacheEntry::SurvCleanup, DICacheEntry::url, _DilloWeb::url, and DICacheEntry::version.
Referenced by a_Dicache_gif_image(), a_Dicache_jpeg_image(), a_Dicache_png_image(), a_Dicache_svg_image(), and a_Dicache_webp_image().
|
static |
Actually free a dicache entry, given the URL and the version number.
Definition at line 167 of file dicache.c.
References _MSG, a_Bitvec_free(), a_Imgbuf_unref(), a_Url_free(), DICacheEntry::BitVec, CA_Abort, CachedIMGs, DICacheEntry::cmap, DICacheEntry::Decoder, DICacheEntry::DecoderData, dFree(), Dicache_entry_cmp(), dicache_size_total, dList_find_sorted(), dList_remove(), dReturn_if, DICacheEntry::TotalSize, DICacheEntry::url, URL_STR, DICacheEntry::v_imgbuf, and DICacheEntry::version.
Referenced by a_Dicache_cleanup(), and a_Dicache_unref().
|
static |
List of DICacheEntry.
May hold several versions of the same image, although most of the time it holds just one.
Definition at line 50 of file dicache.c.
Referenced by a_Dicache_cleanup(), a_Dicache_freeall(), a_Dicache_get_entry(), a_Dicache_init(), Dicache_add_entry(), and Dicache_remove().
|
static |
Definition at line 52 of file dicache.c.
Referenced by a_Dicache_freeall(), a_Dicache_init(), a_Dicache_set_parms(), and Dicache_remove().
|
static |
Definition at line 44 of file dicache.c.
Referenced by a_Dicache_init(), and Dicache_image().
|
static |
Definition at line 36 of file dicache.c.
Referenced by a_Dicache_init(), and Dicache_image().