From 2348b134924e8b24fba02f068a16c6fb308af88a Mon Sep 17 00:00:00 2001 From: Vincent Sanders Date: Wed, 31 Aug 2011 12:12:41 +0000 Subject: refactor bitmap out of generic content structure svn path=/trunk/netsurf/; revision=12686 --- content/content.c | 54 +++++++++++++++++++++++++++++++++++++++++---- content/content.h | 1 + content/content_protected.h | 10 +++++---- 3 files changed, 57 insertions(+), 8 deletions(-) (limited to 'content') diff --git a/content/content.c b/content/content.c index f792e794a..db186e8cc 100644 --- a/content/content.c +++ b/content/content.c @@ -103,7 +103,6 @@ nserror content__init(struct content *c, const content_handler *handler, c->available_width = 0; c->quirks = quirks; c->refresh = 0; - c->bitmap = NULL; c->time = wallclock(); c->size = 0; c->title = NULL; @@ -959,6 +958,7 @@ const char *content__get_refresh_url(struct content *c) return c->refresh; } + /** * Retrieve the bitmap contained in an image content * @@ -972,10 +972,56 @@ struct bitmap *content_get_bitmap(hlcache_handle *h) struct bitmap *content__get_bitmap(struct content *c) { - if (c == NULL) - return NULL; + struct bitmap *bitmap = NULL; + + if ((c != NULL) && + (c->handler != NULL) && + (c->handler->type != NULL) && + (c->handler->type(NULL) == CONTENT_IMAGE) && + (c->handler->get_internal != NULL) ) { + bitmap = c->handler->get_internal(c, NULL); + } + + return bitmap; +} + + +/** + * Determine if a content is opaque from handle + * + * \param h high level cache handle to retrieve opacity from. + * \return false if the content is not opaque or information is not + * known else true. + */ +bool content_get_opaque(hlcache_handle *h) +{ + return content__get_opaque(hlcache_handle_get_content(h)); +} + +/** + * Determine if a content is opaque + * + * \param c Content to retrieve opacity from + * \return false if the content is not opaque or information is not + * known else true. + */ +bool content__get_opaque(struct content *c) +{ + bool opaque = false; + + if ((c != NULL) && + (c->handler != NULL) && + (c->handler->type != NULL) && + (c->handler->type(NULL) == CONTENT_IMAGE) && + (c->handler->get_internal != NULL) ) { + struct bitmap *bitmap = NULL; + bitmap = c->handler->get_internal(c, NULL); + if (bitmap != NULL) { + opaque = bitmap_get_opaque(bitmap); + } + } - return c->bitmap; + return opaque; } diff --git a/content/content.h b/content/content.h index 40e7f2089..1b2a8d097 100644 --- a/content/content.h +++ b/content/content.h @@ -174,6 +174,7 @@ const char *content_get_source_data(struct hlcache_handle *c, void content_invalidate_reuse_data(struct hlcache_handle *c); const char *content_get_refresh_url(struct hlcache_handle *c); struct bitmap *content_get_bitmap(struct hlcache_handle *c); +bool content_get_opaque(struct hlcache_handle *h); bool content_get_quirks(struct hlcache_handle *c); bool content_is_locked(struct hlcache_handle *h); diff --git a/content/content_protected.h b/content/content_protected.h index d113508e4..fd854a0bc 100644 --- a/content/content_protected.h +++ b/content/content_protected.h @@ -68,6 +68,10 @@ struct content_handler { nserror (*clone)(const struct content *old, struct content **newc); bool (*matches_quirks)(const struct content *c, bool quirks); content_type (*type)(lwc_string *mime_type); + + /** handler dependant content sensitive internal data interface. */ + void * (*get_internal)(const struct content *c, void *context); + /** There must be one content per user for this type. */ bool no_share; }; @@ -98,12 +102,9 @@ struct content { bool quirks; /**< Content is in quirks mode */ char *fallback_charset; /**< Fallback charset, or NULL */ - /**< URL for refresh request, in standard form as from url_join. */ + /** URL for refresh request, in standard form as from url_join. */ char *refresh; - /** Bitmap, for various image contents. */ - struct bitmap *bitmap; - unsigned int time; /**< Creation time, if LOADING or READY, otherwise total time. */ @@ -174,6 +175,7 @@ const char *content__get_source_data(struct content *c, unsigned long *size); void content__invalidate_reuse_data(struct content *c); const char *content__get_refresh_url(struct content *c); struct bitmap *content__get_bitmap(struct content *c); +bool content__get_opaque(struct content *c); bool content__is_locked(struct content *c); -- cgit v1.2.3