summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVincent Sanders <vince@kyllikki.org>2016-11-20 23:52:45 (GMT)
committer Vincent Sanders <vince@kyllikki.org>2016-11-21 00:07:12 (GMT)
commitf679a9b1d6b652e06c24d543c7c5921753e3071b (patch)
tree28064b3991e895969f90f8064a5c46d5721bfe43
parentd436992eb2a28e2e056e96e42072b13d89b44a0b (diff)
downloadnetsurf-f679a9b1d6b652e06c24d543c7c5921753e3071b.tar.gz
netsurf-f679a9b1d6b652e06c24d543c7c5921753e3071b.tar.bz2
fix spelling and doxygen comments in image cache
-rw-r--r--content/handlers/image/image_cache.c96
1 files changed, 72 insertions, 24 deletions
diff --git a/content/handlers/image/image_cache.c b/content/handlers/image/image_cache.c
index 3eb27ac..9c7ce22 100644
--- a/content/handlers/image/image_cache.c
+++ b/content/handlers/image/image_cache.c
@@ -16,6 +16,11 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
+/**
+ * \file
+ * Cache implementation for bitmap images decoded into frontend format.
+ */
+
#include <assert.h>
#include <inttypes.h>
#include <stdint.h>
@@ -34,22 +39,26 @@
#include "image/image_cache.h"
#include "image/image.h"
-/** Age of an entry within the cache
+/**
+ * Age of an entry within the cache
*
* type deffed away so it can be readily changed later perhaps to a
* wallclock time structure.
*/
typedef unsigned int cache_age;
-/** Image cache entry
+/**
+ * Image cache entry
*/
struct image_cache_entry_s {
- struct image_cache_entry_s *next; /* next cache entry in list */
- struct image_cache_entry_s *prev; /* previous cache entry in list */
-
- struct content *content; /** content is used as a key */
- struct bitmap *bitmap; /** associated bitmap entry */
- /** Conversion routine */
+ struct image_cache_entry_s *next; /**< next cache entry in list */
+ struct image_cache_entry_s *prev; /**< previous cache entry in list */
+
+ /** content is used as a key */
+ struct content *content;
+ /** associated bitmap entry */
+ struct bitmap *bitmap;
+ /** routine to convert content into bitmap */
image_cache_convert_fn *convert;
/* Statistics for replacement algorithm */
@@ -62,7 +71,8 @@ struct image_cache_entry_s {
int conversion_count; /**< Number of times image has been converted */
};
-/** Current state of the cache.
+/**
+ * Current state of the cache.
*
* Global state of the cache. entries "age" is determined based on a
* monotonically incrementing operation count. This avoids issues with
@@ -90,12 +100,12 @@ struct image_cache_s {
/** Maximum size of bitmaps allocated at any one time */
size_t max_bitmap_size;
- /** The number of objects when maximum bitmap usage occoured */
+ /** The number of objects when maximum bitmap usage occurred */
int max_bitmap_size_count;
/** Maximum count of bitmaps allocated at any one time */
int max_bitmap_count;
- /** The size of the bitmaps when the max count occoured */
+ /** The size of the bitmaps when the max count occurred */
size_t max_bitmap_count_size;
/** Bitmap was not available at plot time required conversion */
@@ -130,7 +140,11 @@ struct image_cache_s {
static struct image_cache_s *image_cache = NULL;
-/** Find the nth cache entry
+/**
+ * Find a cache entry by index.
+ *
+ * \param entryn index of cache entry
+ * \return cache entry at index or NULL if not found.
*/
static struct image_cache_entry_s *image_cache__findn(int entryn)
{
@@ -144,7 +158,12 @@ static struct image_cache_entry_s *image_cache__findn(int entryn)
return found;
}
-/** Find the cache entry for a content
+
+/**
+ * Find the cache entry for a content
+ *
+ * \param c The content to get an entry for
+ * \return The image cache entry or NULL if not found.
*/
static struct image_cache_entry_s *image_cache__find(const struct content *c)
{
@@ -157,6 +176,11 @@ static struct image_cache_entry_s *image_cache__find(const struct content *c)
return found;
}
+/**
+ * Update the image cache statistics with an entry.
+ *
+ * \param centry The image cache entry to update the stats with.
+ */
static void image_cache_stats_bitmap_add(struct image_cache_entry_s *centry)
{
centry->bitmap_age = image_cache->current_age;
@@ -223,11 +247,20 @@ static void image_cache__unlink(struct image_cache_entry_s *centry)
}
}
+/**
+ * free bitmap from an image cache entry
+ *
+ * \param centry The image cache entry to free bitmap from.
+ */
static void image_cache__free_bitmap(struct image_cache_entry_s *centry)
{
if (centry->bitmap != NULL) {
#ifdef IMAGE_CACHE_VERBOSE
- LOG("Freeing bitmap %p size %d age %d redraw count %d", centry->bitmap, centry->bitmap_size, image_cache->current_age - centry->bitmap_age, centry->redraw_count);
+ LOG("Freeing bitmap %p size %d age %d redraw count %d",
+ centry->bitmap,
+ centry->bitmap_size,
+ image_cache->current_age - centry->bitmap_age,
+ centry->redraw_count);
#endif
guit->bitmap->destroy(centry->bitmap);
centry->bitmap = NULL;
@@ -240,7 +273,11 @@ static void image_cache__free_bitmap(struct image_cache_entry_s *centry)
}
-/* free cache entry */
+/**
+ * free image cache entry
+ *
+ * \param centry The image cache entry to free.
+ */
static void image_cache__free_entry(struct image_cache_entry_s *centry)
{
#ifdef IMAGE_CACHE_VERBOSE
@@ -258,7 +295,11 @@ static void image_cache__free_entry(struct image_cache_entry_s *centry)
free(centry);
}
-/** Cache cleaner */
+/**
+ * Image cache cleaner
+ *
+ * \param icache The image cache context.
+ */
static void image_cache__clean(struct image_cache_s *icache)
{
struct image_cache_entry_s *centry = icache->entries;
@@ -277,7 +318,11 @@ static void image_cache__clean(struct image_cache_s *icache)
}
}
-/** Cache background scheduled callback. */
+/**
+ * Cache background scheduled callback.
+ *
+ * \param p The image cache context.
+ */
static void image_cache__background_update(void *p)
{
struct image_cache_s *icache = p;
@@ -377,7 +422,7 @@ image_cache_init(const struct image_cache_parameters *image_cache_parameters)
image_cache__background_update,
image_cache);
- LOG("Image cache initilised with a limit of %" PRIsizet " hysteresis of %"PRIsizet,
+ LOG("Image cache initialised with a limit of %" PRIsizet " hysteresis of %"PRIsizet,
image_cache->params.limit, image_cache->params.hysteresis);
return NSERROR_OK;
@@ -678,7 +723,7 @@ int image_cache_snentryf(char *string, size_t size, unsigned int entryn,
case 'U':
slen += snprintf(string + slen, size - slen,
- "%s", nsurl_access(llcache_handle_get_url(centry->content->llcache)));
+ "%s", nsurl_access(llcache_handle_get_url(centry->content->llcache)));
break;
case 'o':
@@ -690,20 +735,20 @@ int image_cache_snentryf(char *string, size_t size, unsigned int entryn,
centry->content->
llcache),
NSURL_HOST);
-
+
slen += snprintf(string + slen,
size - slen, "%s",
- lwc_string_data(
- origin));
+ lwc_string_data(
+ origin));
lwc_string_unref(origin);
} else {
slen += snprintf(string + slen,
size - slen, "%s",
- "localhost");
+ "localhost");
}
break;
-
+
case 's':
if (centry->bitmap != NULL) {
slen += snprintf(string + slen,
@@ -774,6 +819,7 @@ bool image_cache_redraw(struct content *c,
return image_bitmap_plot(centry->bitmap, data, clip, ctx);
}
+/* exported interface documented in image_cache.h */
void image_cache_destroy(struct content *content)
{
struct image_cache_entry_s *centry;
@@ -787,11 +833,13 @@ void image_cache_destroy(struct content *content)
}
}
+/* exported interface documented in image_cache.h */
void *image_cache_get_internal(const struct content *c, void *context)
{
return image_cache_get_bitmap(c);
}
+/* exported interface documented in image_cache.h */
content_type image_cache_content_type(void)
{
return CONTENT_IMAGE;