154 while ((found != NULL) && (entryn > 0)) {
173 while ((found != NULL) && (found->
content != c)) {
223 if (centry->
next != NULL) {
232 if (centry->
prev == NULL) {
234 if (centry->
next != NULL) {
244 if (centry->
next != NULL) {
257 if (centry->
bitmap != NULL) {
258#ifdef IMAGE_CACHE_VERBOSE
260 "Freeing bitmap %p size %d age %d redraw count %d",
284#ifdef IMAGE_CACHE_VERBOSE
285 NSLOG(netsurf, INFO,
"freeing %p ", centry);
308 while (centry != NULL) {
314 (rand() > (RAND_MAX / 2))) {
334#ifdef IMAGE_CACHE_VERBOSE
351 if (centry == NULL) {
355 if (centry->
bitmap == NULL) {
360 if (centry->
bitmap != NULL) {
379 bool decision =
false;
386#ifdef IMAGE_CACHE_VERBOSE
388 "content size (%d) is smaller than minimum (%d)",
395#ifdef IMAGE_CACHE_VERBOSE
396 NSLOG(netsurf, INFO,
"returning %d", decision);
407 if (centry == NULL) {
430 "Image cache initialised with a limit of %"PRIsizet" hysteresis of %"PRIsizet,
440 unsigned int op_count;
464 NSLOG(netsurf, INFO,
"Peak image count %d (size %"PRIsizet")",
468 if ((op_count > 0) && (op_size >0)) {
471 "Cache total/hit/miss/fail (counts) %d/%d/%d/%d (100%%/%d%%/%d%%/%d%%)",
491 "Total images never rendered: %d (includes %d that were converted)",
496 "Total number of excessive conversions: %d (from %d images converted more than once)",
500 NSLOG(netsurf, INFO,
"Bitmap of size %d had most (%d) conversions",
522 if (centry == NULL) {
525 if (centry == NULL) {
534 NSLOG(netsurf, INFO,
"centry %p, content %p, bitmap %p", centry,
541 if (centry->
bitmap != NULL) {
549 if ((centry->
convert != NULL) &&
553 if (centry->
bitmap != NULL) {
573 if (centry == NULL) {
575 "Could not find cache entry for content (%p)",
content);
590 unsigned int op_count;
601 while((slen < size) && (fmt[fmtc] != 0)) {
602 if (fmt[fmtc] ==
'%') {
606 if (fmt[fmtc] ==
'p') {
613#define FMTCHR(chr,fmt,var) case chr : \
614slen += snprintf(string + slen, size - slen, "%"fmt, image_cache->var); break
616#define FMTPCHR(chr,fmt,var,div) \
620 slen += snprintf(string + slen, size - slen, "%"PRId64, (uint64_t)((image_cache->var * 100) / div)); \
622 slen += snprintf(string + slen, size - slen, "100"); \
625 slen += snprintf(string + slen, size - slen, "%"fmt, image_cache->var); \
638 FMTCHR(
'd',
"d", bitmap_count);
639 FMTCHR(
'e',
"u", current_age / 1000);
641 FMTCHR(
'g',
"d", max_bitmap_size_count);
642 FMTCHR(
'h',
"d", max_bitmap_count);
647 slen += snprintf(
string + slen, size - slen,
648 "%u", pct?100:op_count);
651 FMTPCHR(
'k',
"d", hit_count, op_count);
652 FMTPCHR(
'l',
"d", miss_count, op_count);
653 FMTPCHR(
'm',
"d", fail_count, op_count);
656 slen += snprintf(
string + slen, size - slen,
657 "%"PRId64, pct?100:op_size);
664 FMTCHR(
's',
"d", total_unrendered);
665 FMTCHR(
't',
"d", specultive_miss_count);
666 FMTCHR(
'u',
"d", total_extra_conversions);
667 FMTCHR(
'v',
"d", total_extra_conversions_count);
668 FMTCHR(
'w',
"u", peak_conversions_size);
669 FMTCHR(
'x',
"d", peak_conversions);
678 string[slen] = fmt[fmtc];
685 string[
min(slen, size - 1)] =
'\0';
706 while((slen < size) && (fmt[fmtc] != 0)) {
707 if (fmt[fmtc] ==
'%') {
711 slen += snprintf(
string + slen, size - slen,
716 slen += snprintf(
string + slen, size - slen,
721 slen += snprintf(
string + slen, size - slen,
727 slen += snprintf(
string + slen, size - slen,
732 slen += snprintf(
string + slen, size - slen,
737 slen += snprintf(
string + slen, size - slen,
742 slen += snprintf(
string + slen, size - slen,
756 slen += snprintf(
string + slen,
761 lwc_string_unref(origin);
763 slen += snprintf(
string + slen,
770 if (centry->
bitmap != NULL) {
771 slen += snprintf(
string + slen,
776 slen += snprintf(
string + slen,
784 string[slen] = fmt[fmtc];
791 string[
min(slen, size - 1)] =
'\0';
807 if (centry == NULL) {
809 "Could not find cache entry for content (%p)", c);
813 if (centry->
bitmap == NULL) {
818 if (centry->
bitmap != NULL) {
847 if (centry == NULL) {
849 "Could not find cache entry for content (%p)",
content);
bool image_bitmap_plot(struct bitmap *bitmap, struct content_redraw_data *data, const struct rect *clip, const struct redraw_context *ctx)
Common image content handler bitmap plot call.
Initialisation/finalisation of image handlers.
Protected interface to Content handling.
content_type
The type of a content.
@ CONTENT_IMAGE
All images.
nserror
Enumeration of error codes.
@ NSERROR_NOT_FOUND
Requested item not found.
@ NSERROR_NOMEM
Memory exhaustion.
struct netsurf_table * guit
The global interface table.
Interface to core interface table.
static void image_cache__free_bitmap(struct image_cache_entry_s *centry)
free bitmap from an image cache entry
struct bitmap * image_cache_get_bitmap(const struct content *c)
Obtain a bitmap from a content converting from source if neccessary.
static void image_cache__background_update(void *p)
Cache background scheduled callback.
static void image_cache__clean(struct image_cache_s *icache)
Image cache cleaner.
content_type image_cache_content_type(void)
void * image_cache_get_internal(const struct content *c, void *context)
nserror image_cache_remove(struct content *content)
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.
bool image_cache_speculate(struct content *c)
Decide if a content should be speculatively converted.
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.
void image_cache_destroy(struct content *content)
nserror image_cache_add(struct content *content, struct bitmap *bitmap, image_cache_convert_fn *convert)
adds an image content to be cached.
static struct image_cache_s * image_cache
image cache state
struct bitmap * image_cache_find_bitmap(struct content *c)
Obtain a bitmap from a content with no conversion.
static struct image_cache_entry_s * image_cache__find(const struct content *c)
Find the cache entry for a content.
static struct image_cache_entry_s * image_cache__findn(int entryn)
Find a cache entry by index.
static void image_cache__unlink(struct image_cache_entry_s *centry)
static void image_cache__link(struct image_cache_entry_s *centry)
#define FMTPCHR(chr, fmt, var, div)
nserror image_cache_fini(void)
static void image_cache__free_entry(struct image_cache_entry_s *centry)
free image cache entry
#define FMTCHR(chr, fmt, var)
unsigned int cache_age
Age of an entry within the cache.
static void image_cache_stats_bitmap_add(struct image_cache_entry_s *centry)
Update the image cache statistics with an entry.
bool image_cache_is_opaque(struct content *c)
int image_cache_snsummaryf(char *string, size_t size, const char *fmt)
Fill a buffer with information about the image cache using a format.
nserror image_cache_init(const struct image_cache_parameters *image_cache_parameters)
Initialise the image cache.
The image content handler intermediate image cache.
struct bitmap *() image_cache_convert_fn(struct content *content)
Generic bitmap handling interface.
Interface to platform-specific miscellaneous browser operation table.
Netsurf additional integer type formatting macros.
#define PRIsizet
c99 standard printf formatting for size_t type
static struct llcache_s * llcache
low level cache state
nsurl * llcache_handle_get_url(const llcache_handle *handle)
Retrieve the post-redirect URL of a low-level cache object.
Low-level resource cache (interface)
#define NSLOG(catname, level, logmsg, args...)
#define SPECULATE_SMALL
speculative pre-conversion small image size
const char * nsurl_access(const nsurl *url)
Access a NetSurf URL object as a string.
bool nsurl_has_component(const nsurl *url, nsurl_component part)
Enquire about the existence of componenets in a given URL.
lwc_string * nsurl_get_component(const nsurl *url, nsurl_component part)
Get part of a URL as a lwc_string, from a NetSurf URL object.
Interface to utility string handling.
RISC OS wimp toolkit bitmap.
parameters to content redraw
Content which corresponds to a single URL.
int height
Height dimension, if applicable.
int width
Width dimension, if applicable.
struct llcache_handle * llcache
Low-level cache object.
unsigned int size
Estimated size of all data associated with this content.
void(* destroy)(void *bitmap)
Destroy a bitmap.
bool(* get_opaque)(void *bitmap)
Get the opacity of a bitmap.
nserror(* schedule)(int t, void(*callback)(void *p), void *p)
Schedule a callback.
struct content * content
content is used as a key
unsigned int redraw_count
number of times object has been drawn
int conversion_count
Number of times image has been converted.
cache_age redraw_age
Age of last redraw.
size_t bitmap_size
size if storage occupied by bitmap
image_cache_convert_fn * convert
routine to convert content into bitmap
struct image_cache_entry_s * prev
previous cache entry in list
struct bitmap * bitmap
associated bitmap entry
struct image_cache_entry_s * next
next cache entry in list
cache_age bitmap_age
Age of last conversion to a bitmap by cache.
size_t speculative_small
The speculative conversion "small" size.
unsigned int bg_clean_time
How frequently the background cache clean process is run (ms)
size_t limit
The target upper bound for the image cache size.
size_t hysteresis
The hysteresis allowed round the target size.
Current state of the cache.
int max_bitmap_count
Maximum count of bitmaps allocated at any one time.
cache_age current_age
The "age" of the current operation.
struct image_cache_parameters params
Cache parameters.
int total_extra_conversions_count
counts total number of images with more than one conversion
int hit_count
Bitmap was available at plot time required no conversion.
size_t max_bitmap_count_size
The size of the bitmaps when the max count occurred.
int fail_count
Bitmap was not available at plot time and required conversion which failed.
int specultive_miss_count
Bitmap was available but never required - wasted conversions.
size_t max_bitmap_size
Maximum size of bitmaps allocated at any one time.
size_t total_bitmap_size
total size of bitmaps currently allocated
int peak_conversions
Bitmap with most conversions was converted this many times.
int max_bitmap_size_count
The number of objects when maximum bitmap usage occurred.
int total_extra_conversions
Total number of additional (after the first) conversions.
int bitmap_count
Total count of bitmaps currently allocated.
struct image_cache_entry_s * entries
int miss_count
Bitmap was not available at plot time required conversion.
unsigned int peak_conversions_size
Size of bitmap with most conversions.
struct gui_misc_table * misc
Browser table.
struct gui_bitmap_table * bitmap
Bitmap table.
Interface to a number of general purpose functionality.
static nserror bitmap(const struct redraw_context *ctx, struct bitmap *bitmap, int x, int y, int width, int height, colour bg, bitmap_flags_t flags)
Plot a bitmap.
static nserror clip(const struct redraw_context *ctx, const struct rect *clip)
Sets a clip rectangle for subsequent plot operations.