NetSurf
Functions | Variables
webp.c File Reference

implementation of content handling for image/webp More...

#include <stdbool.h>
#include <stdlib.h>
#include <setjmp.h>
#include <webp/decode.h>
#include "utils/utils.h"
#include "utils/log.h"
#include "utils/messages.h"
#include "netsurf/bitmap.h"
#include "content/llcache.h"
#include "content/content_protected.h"
#include "content/content_factory.h"
#include "desktop/gui_internal.h"
#include "desktop/bitmap.h"
#include "image/image_cache.h"
#include "webp.h"
Include dependency graph for webp.c:

Go to the source code of this file.

Functions

static nserror webp_create (const content_handler *handler, lwc_string *imime_type, const struct http_parameter *params, llcache_handle *llcache, const char *fallback_charset, bool quirks, struct content **c)
 Content create entry point. More...
 
static struct bitmapwebp_cache_convert (struct content *c)
 create a bitmap from webp content. More...
 
static bool webp_convert (struct content *c)
 Convert the webp source data content. More...
 
static nserror webp_clone (const struct content *old, struct content **new_c)
 Clone content. More...
 
 CONTENT_FACTORY_REGISTER_TYPES (nswebp, webp_types, webp_content_handler)
 

Variables

static const content_handler webp_content_handler
 
static const char * webp_types []
 

Detailed Description

implementation of content handling for image/webp

This implementation uses the google webp library. Image cache handling is performed by the generic NetSurf handler.

Definition in file webp.c.

Function Documentation

◆ CONTENT_FACTORY_REGISTER_TYPES()

CONTENT_FACTORY_REGISTER_TYPES ( nswebp  ,
webp_types  ,
webp_content_handler   
)

◆ webp_cache_convert()

static struct bitmap * webp_cache_convert ( struct content c)
static

create a bitmap from webp content.

Definition at line 90 of file webp.c.

References netsurf_table::bitmap, bitmap(), bitmap_format_to_client(), BITMAP_LAYOUT_A8R8G8B8, BITMAP_LAYOUT_B8G8R8A8, BITMAP_LAYOUT_R8G8B8A8, BITMAP_NONE, BITMAP_OPAQUE, content__get_source_data(), gui_bitmap_table::create, gui_bitmap_table::destroy, fallthrough, gui_bitmap_table::get_buffer, gui_bitmap_table::get_rowstride, guit, bitmap_fmt::layout, gui_bitmap_table::modified, bitmap_fmt::pma, and bitmap::rowstride.

Referenced by webp_convert().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ webp_clone()

static nserror webp_clone ( const struct content old,
struct content **  new_c 
)
static

Clone content.

Definition at line 214 of file webp.c.

References content__clone(), content_destroy(), CONTENT_STATUS_DONE, CONTENT_STATUS_READY, NSERROR_CLONE_FAILED, NSERROR_NOMEM, NSERROR_OK, content::status, and webp_convert().

Here is the call graph for this function:

◆ webp_convert()

static bool webp_convert ( struct content c)
static

Convert the webp source data content.

This ensures there is valid webp source data in the content object and then adds it to the image cache ready to be converted on demand.

Parameters
cThe webp content object
Returns
true on successful processing of teh webp content else false

Definition at line 183 of file webp.c.

References content__get_source_data(), content_set_done(), content_set_ready(), content::height, height, image_cache_add(), NSLOG, content::size, webp_cache_convert(), content::width, and width.

Referenced by webp_clone().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ webp_create()

static nserror webp_create ( const content_handler handler,
lwc_string *  imime_type,
const struct http_parameter params,
llcache_handle llcache,
const char *  fallback_charset,
bool  quirks,
struct content **  c 
)
static

Content create entry point.

create a content object for the webp

Definition at line 53 of file webp.c.

References content__init(), content::fallback_charset, content::handler, llcache, NSERROR_NOMEM, NSERROR_OK, and content::quirks.

Here is the call graph for this function:

Variable Documentation

◆ webp_content_handler

const content_handler webp_content_handler
static
Initial value:
= {
.create = webp_create,
.data_complete = webp_convert,
.destroy = image_cache_destroy,
.redraw = image_cache_redraw,
.clone = webp_clone,
.get_internal = image_cache_get_internal,
.is_opaque = image_cache_is_opaque,
.no_share = false,
}
content_type image_cache_content_type(void)
Definition: image_cache.c:873
void * image_cache_get_internal(const struct content *c, void *context)
Definition: image_cache.c:856
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.
Definition: image_cache.c:798
void image_cache_destroy(struct content *content)
Definition: image_cache.c:841
bool image_cache_is_opaque(struct content *c)
Definition: image_cache.c:862
static bool webp_convert(struct content *c)
Convert the webp source data content.
Definition: webp.c:183
static nserror webp_clone(const struct content *old, struct content **new_c)
Clone content.
Definition: webp.c:214
static nserror webp_create(const content_handler *handler, lwc_string *imime_type, const struct http_parameter *params, llcache_handle *llcache, const char *fallback_charset, bool quirks, struct content **c)
Content create entry point.
Definition: webp.c:53

Definition at line 244 of file webp.c.

◆ webp_types

const char* webp_types[]
static
Initial value:
= {
"image/webp"
}

Definition at line 256 of file webp.c.