31#include <webp/decode.h>
54 lwc_string *imime_type,
57 const char *fallback_charset,
64 webp_c = calloc(1,
sizeof(
struct content));
92 const uint8_t *source_data;
94 VP8StatusCode webpres;
95 WebPBitstreamFeatures webpfeatures;
96 unsigned int bmap_flags;
97 uint8_t *pixels = NULL;
107 webpres = WebPGetFeatures(source_data, source_size, &webpfeatures);
109 if (webpres != VP8_STATUS_OK) {
113 if (webpfeatures.has_alpha == 0) {
133 if (pixels == NULL) {
141 switch (webp_fmt.
layout) {
147 decoded = WebPDecodeRGBAInto(source_data, source_size, pixels,
152 decoded = WebPDecodeBGRAInto(source_data, source_size, pixels,
157 decoded = WebPDecodeARGBInto(source_data, source_size, pixels,
161 if (decoded == NULL) {
193 res = WebPGetInfo(data, data_size, &
width, &
height);
195 NSLOG(netsurf, INFO,
"WebPGetInfo failed:%p", c);
219 webp_c = calloc(1,
sizeof(
struct content));
220 if (webp_c == NULL) {
void content_destroy(struct content *c)
Destroy and free a content.
void content_set_done(struct content *c)
Put a content in status CONTENT_STATUS_DONE.
nserror content__init(struct content *c, const content_handler *handler, lwc_string *imime_type, const struct http_parameter *params, llcache_handle *llcache, const char *fallback_charset, bool quirks)
const uint8_t * content__get_source_data(struct content *c, size_t *size)
Retrieve source of content.
nserror content__clone(const struct content *c, struct content *nc)
Clone a content's data members.
void content_set_ready(struct content *c)
Put a content in status CONTENT_STATUS_READY and unlock the content.
Protected interface to Content handling.
@ CONTENT_STATUS_READY
Some parts of content still being loaded, but can be displayed.
@ CONTENT_STATUS_DONE
Content has completed all processing.
Internal core bitmap interface.
static void bitmap_format_to_client(void *bitmap, const bitmap_fmt_t *current_fmt)
Convert a bitmap to the client bitmap format.
nserror
Enumeration of error codes.
@ NSERROR_NOMEM
Memory exhaustion.
@ NSERROR_CLONE_FAILED
Failed to clone handle.
struct netsurf_table * guit
The global interface table.
Interface to core interface table.
content_type image_cache_content_type(void)
void * image_cache_get_internal(const struct content *c, void *context)
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.
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.
bool image_cache_is_opaque(struct content *c)
The image content handler intermediate image cache.
Generic bitmap handling interface.
@ BITMAP_OPAQUE
image is opaque
@ BITMAP_LAYOUT_B8G8R8A8
Bite-wise BGRA: Byte order: 0xBB, 0xGG, 0xRR, 0xAA.
@ BITMAP_LAYOUT_R8G8B8A8
Bite-wise RGBA: Byte order: 0xRR, 0xGG, 0xBB, 0xAA.
@ BITMAP_LAYOUT_A8R8G8B8
Bite-wise ARGB: Byte order: 0xAA, 0xRR, 0xGG, 0xBB.
static struct llcache_s * llcache
low level cache state
Low-level resource cache (interface)
#define NSLOG(catname, level, logmsg, args...)
Localised message support (interface).
bool pma
Premultiplied alpha.
enum bitmap_layout layout
Colour component layout.
RISC OS wimp toolkit bitmap.
Content operation function table.
nserror(* create)(const struct content_handler *handler, lwc_string *imime_type, const struct http_parameter *params, struct llcache_handle *llcache, const char *fallback_charset, bool quirks, struct content **c)
Content which corresponds to a single URL.
bool quirks
Content is in quirks mode.
int height
Height dimension, if applicable.
char * fallback_charset
Fallback charset, or NULL.
int width
Width dimension, if applicable.
const struct content_handler * handler
Handler for content.
content_status status
Current status.
unsigned int size
Estimated size of all data associated with this content.
void(* destroy)(void *bitmap)
Destroy a bitmap.
void *(* create)(int width, int height, enum gui_bitmap_flags flags)
Create a new bitmap.
size_t(* get_rowstride)(void *bitmap)
Get the number of bytes per row of the image.
void(* modified)(void *bitmap)
Marks a bitmap as modified.
unsigned char *(* get_buffer)(void *bitmap)
Get the image buffer from a bitmap.
Representation of an HTTP parameter.
Handle to low-level cache object.
struct gui_bitmap_table * bitmap
Bitmap table.
Interface to a number of general purpose functionality.
#define fallthrough
switch fall through
static bool webp_convert(struct content *c)
Convert the webp source data content.
static const content_handler webp_content_handler
static struct bitmap * webp_cache_convert(struct content *c)
create a bitmap from webp content.
static nserror webp_clone(const struct content *old, struct content **new_c)
Clone content.
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.
static const char * webp_types[]
CONTENT_FACTORY_REGISTER_TYPES(nswebp, webp_types, webp_content_handler)
Interface to image/webp content handlers.
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.