NetSurf
|
The image content handler intermediate image cache. More...
Go to the source code of this file.
Data Structures | |
struct | image_cache_parameters |
Typedefs | |
typedef struct bitmap *() | image_cache_convert_fn(struct content *content) |
Functions | |
nserror | image_cache_init (const struct image_cache_parameters *image_cache_parameters) |
Initialise the image cache. More... | |
nserror | image_cache_fini (void) |
nserror | image_cache_add (struct content *content, struct bitmap *bitmap, image_cache_convert_fn *convert) |
adds an image content to be cached. More... | |
nserror | image_cache_remove (struct content *content) |
struct bitmap * | image_cache_get_bitmap (const struct content *c) |
Obtain a bitmap from a content converting from source if neccessary. More... | |
struct bitmap * | image_cache_find_bitmap (struct content *c) |
Obtain a bitmap from a content with no conversion. More... | |
bool | image_cache_speculate (struct content *c) |
Decide if a content should be speculatively converted. More... | |
int | image_cache_snentryf (char *string, size_t size, unsigned int entryn, const char *fmt) |
Fill a buffer with information about a cache entry using a format. More... | |
int | image_cache_snsummaryf (char *string, size_t size, const char *fmt) |
Fill a buffer with information about the image cache using a format. More... | |
bool | image_cache_redraw (struct content *c, struct content_redraw_data *data, const struct rect *clip, const struct redraw_context *ctx) |
Generic content redraw callback. More... | |
void | image_cache_destroy (struct content *c) |
void * | image_cache_get_internal (const struct content *c, void *context) |
bool | image_cache_is_opaque (struct content *c) |
content_type | image_cache_content_type (void) |
The image content handler intermediate image cache.
This cache allows netsurf to use a generic intermediate bitmap format without keeping the intermediate representation in memory.
The bitmap structure is opaque to the rest of netsurf and is controlled by the platform-specific code (see image/bitmap.h for detials). All image content handlers convert into this format and pass it to the plot functions for display,
This cache maintains a link between the underlying original content and the intermediate representation. It is intended to be flexable and either manage the bitmap plotting completely or give the image content handler complete control.
Definition in file image_cache.h.
Definition at line 1 of file image_cache.h.
nserror image_cache_add | ( | struct content * | content, |
struct bitmap * | bitmap, | ||
image_cache_convert_fn * | convert | ||
) |
adds an image content to be cached.
content | The content handle used as a key |
bitmap | A bitmap representing the already converted content or NULL. |
convert | A function pointer to convert the content into a bitmap or NULL. |
Definition at line 510 of file image_cache.c.
References image_cache_entry_s::bitmap, netsurf_table::bitmap, bitmap(), image_cache_entry_s::bitmap_size, image_cache_entry_s::content, image_cache_entry_s::convert, image_cache_s::current_age, gui_bitmap_table::destroy, image_cache_s::fail_count, guit, content::height, image_cache, image_cache__find(), image_cache__link(), image_cache_speculate(), image_cache_stats_bitmap_add(), NSERROR_NOMEM, NSERROR_OK, NSLOG, and content::width.
Referenced by nsjpeg_convert(), nsjpegxl_convert(), nspng_convert(), rsvg_convert(), and webp_convert().
content_type image_cache_content_type | ( | void | ) |
Definition at line 873 of file image_cache.c.
References CONTENT_IMAGE.
void image_cache_destroy | ( | struct content * | c | ) |
Definition at line 841 of file image_cache.c.
References image_cache__find(), image_cache__free_entry(), and NSLOG.
Referenced by rsvg_destroy().
Obtain a bitmap from a content with no conversion.
Definition at line 402 of file image_cache.c.
References image_cache_entry_s::bitmap, and image_cache__find().
nserror image_cache_fini | ( | void | ) |
Definition at line 438 of file image_cache.c.
References image_cache_s::bitmap_count, image_cache_s::current_age, image_cache_s::entries, image_cache_s::fail_count, image_cache_s::fail_size, guit, image_cache_s::hit_count, image_cache_s::hit_size, image_cache, image_cache__background_update(), image_cache__free_entry(), image_cache_s::max_bitmap_count, image_cache_s::max_bitmap_count_size, image_cache_s::max_bitmap_size, image_cache_s::max_bitmap_size_count, netsurf_table::misc, image_cache_s::miss_count, image_cache_s::miss_size, NSERROR_OK, NSLOG, image_cache_s::peak_conversions, image_cache_s::peak_conversions_size, PRId64, PRIsizet, PRIu64, gui_misc_table::schedule, image_cache_s::specultive_miss_count, image_cache_s::total_bitmap_size, image_cache_s::total_extra_conversions, image_cache_s::total_extra_conversions_count, and image_cache_s::total_unrendered.
Referenced by netsurf_exit().
Obtain a bitmap from a content converting from source if neccessary.
Definition at line 346 of file image_cache.c.
References image_cache_entry_s::bitmap, image_cache_entry_s::bitmap_size, image_cache_entry_s::content, image_cache_entry_s::convert, image_cache_s::fail_count, image_cache_s::fail_size, image_cache_s::hit_count, image_cache_s::hit_size, image_cache, image_cache__find(), image_cache_stats_bitmap_add(), image_cache_s::miss_count, and image_cache_s::miss_size.
Referenced by image_cache_get_internal(), and image_cache_is_opaque().
void * image_cache_get_internal | ( | const struct content * | c, |
void * | context | ||
) |
Definition at line 856 of file image_cache.c.
References image_cache_get_bitmap().
nserror image_cache_init | ( | const struct image_cache_parameters * | image_cache_parameters | ) |
Initialise the image cache.
image_cache_parameters | The control parameters for the image cache |
Definition at line 416 of file image_cache.c.
References image_cache_parameters::bg_clean_time, guit, image_cache_parameters::hysteresis, image_cache, image_cache__background_update(), image_cache_parameters::limit, netsurf_table::misc, NSERROR_NOMEM, NSERROR_OK, NSLOG, image_cache_s::params, PRIsizet, and gui_misc_table::schedule.
Referenced by netsurf_init().
bool image_cache_is_opaque | ( | struct content * | c | ) |
Definition at line 862 of file image_cache.c.
References netsurf_table::bitmap, gui_bitmap_table::get_opaque, guit, and image_cache_get_bitmap().
bool image_cache_redraw | ( | struct content * | c, |
struct content_redraw_data * | data, | ||
const struct rect * | clip, | ||
const struct redraw_context * | ctx | ||
) |
Generic content redraw callback.
May be used by image content handlers as their redraw callback. Performs all neccissary cache lookups and conversions and calls the bitmap plot function in the redraw context.
Definition at line 798 of file image_cache.c.
References image_cache_entry_s::bitmap, image_cache_entry_s::bitmap_size, clip(), image_cache_entry_s::content, image_cache_entry_s::convert, image_cache_s::current_age, image_cache_s::fail_count, image_cache_s::fail_size, image_cache_s::hit_count, image_cache_s::hit_size, image_bitmap_plot(), image_cache, image_cache__find(), image_cache_stats_bitmap_add(), image_cache_s::miss_count, image_cache_s::miss_size, NSLOG, image_cache_entry_s::redraw_age, and image_cache_entry_s::redraw_count.
Definition at line 567 of file image_cache.c.
References image_cache__find(), image_cache__free_entry(), NSERROR_NOT_FOUND, NSERROR_OK, and NSLOG.
int image_cache_snentryf | ( | char * | string, |
size_t | size, | ||
unsigned int | entryn, | ||
const char * | fmt | ||
) |
Fill a buffer with information about a cache entry using a format.
The format string is copied into the output buffer with the following replaced: e - The entry number k - The content key r - The number of redraws of this bitmap c - The number of times this bitmap has been converted s - The size of the current bitmap allocation
string | The buffer in which to place the results. |
size | The size of the string buffer. |
entryn | The opaque entry number. |
fmt | The format string. |
Definition at line 692 of file image_cache.c.
References image_cache_entry_s::bitmap, image_cache_entry_s::bitmap_age, image_cache_entry_s::bitmap_size, image_cache_entry_s::content, image_cache_entry_s::conversion_count, image_cache_s::current_age, image_cache, image_cache__findn(), content::llcache, llcache, llcache_handle_get_url(), min, nsurl_access(), nsurl_get_component(), nsurl_has_component(), NSURL_HOST, PRIsizet, image_cache_entry_s::redraw_age, and image_cache_entry_s::redraw_count.
int image_cache_snsummaryf | ( | char * | string, |
size_t | size, | ||
const char * | fmt | ||
) |
Fill a buffer with information about the image cache using a format.
The format string is copied into the output buffer with the following replaced:
a Configured cache limit size b Configured cache hysteresis size c Current caches total consumed size d Number of images currently in the cache e The age of the cache f The largest amount of space the cache has occupied since initialisation g The number of objetcs when the cache was at its largest h The largest number of images in the cache since initialisation i The size of the cache when the largest number of objects occoured j The total number of read operations performed on the cache k The total number of read operations satisfied from the cache without conversion. l The total number of read operations satisfied from the cache which required a conversion. m The total number of read operations which could not be sucessfully returned. ie. not available in cache and conversion failed. n The total size of read operations performed on the cache o The total size of read operations satisfied from the cache without conversion. q The total size of read operations satisfied from the cache which required a conversion. r The total size of read operations which could not be sucessfully returned. ie. not available in cache and conversion failed. s The number of images which were placed in the cache but never read. t The number of images that were converted on insertion into the cache which were subsequently never used. u The number of times an image was converted after the first v The number of images that had extra conversions performed. w Size of the image that was converted (read missed cache) highest number of times. x The number of times the image that was converted (read missed cache) highest number of times.
format modifiers: A p before the value modifies the replacement to be a percentage.
string | The buffer in which to place the results. |
size | The size of the string buffer. |
fmt | The format string. |
Definition at line 585 of file image_cache.c.
References image_cache_s::fail_count, image_cache_s::fail_size, FMTCHR, FMTPCHR, image_cache_s::hit_count, image_cache_s::hit_size, image_cache, min, image_cache_s::miss_count, image_cache_s::miss_size, PRId64, and PRIsizet.
bool image_cache_speculate | ( | struct content * | c | ) |
Decide if a content should be speculatively converted.
This allows for image content handlers to ask the cache if a bitmap should be generated before it is added to the cache. This is the same decision logic used to decide to perform an immediate conversion when a content is initially added to the cache.
c | The content to be considered. |
Definition at line 377 of file image_cache.c.
References image_cache, image_cache_parameters::limit, NSLOG, image_cache_s::params, content::size, SPECULATE_SMALL, image_cache_parameters::speculative_small, and image_cache_s::total_bitmap_size.
Referenced by image_cache_add(), and info_callback().