NetSurf
Data Structures | Typedefs | Functions | Variables
gif.c File Reference

Content for image/gif implementation. More...

#include <assert.h>
#include <string.h>
#include <stdbool.h>
#include <stdlib.h>
#include <nsutils/assert.h>
#include <nsgif.h>
#include "utils/log.h"
#include "utils/utils.h"
#include "utils/messages.h"
#include "utils/nsoption.h"
#include "netsurf/misc.h"
#include "netsurf/bitmap.h"
#include "netsurf/content.h"
#include "content/llcache.h"
#include "content/content.h"
#include "content/content_protected.h"
#include "content/content_factory.h"
#include "desktop/gui_internal.h"
#include "desktop/bitmap.h"
#include "image/image.h"
#include "image/gif.h"
Include dependency graph for gif.c:

Go to the source code of this file.

Data Structures

struct  gif_content
 

Typedefs

typedef struct gif_content gif_content
 

Functions

static nserror gif__nsgif_error_to_ns (nsgif_error gif_res)
 
static void * gif_bitmap_create (int width, int height)
 Callback for libnsgif; forwards the call to bitmap_create() More...
 
static nsgif_bitmap_fmt_t nsgif__get_bitmap_format (void)
 Convert client bitmap format to a LibNSGIF format specifier. More...
 
static nserror gif_create_gif_data (gif_content *c)
 
static nserror gif_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 void gif_animate_cb (void *p)
 Scheduler callback. More...
 
static nserror gif__animate (gif_content *gif, bool redraw)
 Performs any necessary animation. More...
 
static bool gif_convert (struct content *c)
 
static nsgif_error gif_get_frame (gif_content *gif, nsgif_bitmap_t **bitmap)
 Updates the GIF bitmap to display the current frame. More...
 
static bool gif_redraw (struct content *c, struct content_redraw_data *data, const struct rect *clip, const struct redraw_context *ctx)
 
static void gif_destroy (struct content *c)
 
static nserror gif_clone (const struct content *old, struct content **newc)
 
static void gif_add_user (struct content *c)
 
static void gif_remove_user (struct content *c)
 
static nsgif_bitmap_t * gif_get_bitmap (const struct content *c, void *context)
 
static content_type gif_content_type (void)
 
static bool gif_content_is_opaque (struct content *c)
 
 CONTENT_FACTORY_REGISTER_TYPES (nsgif, gif_types, gif_content_handler)
 

Variables

static const content_handler gif_content_handler
 
static const char * gif_types []
 

Detailed Description

Content for image/gif implementation.

All GIFs are dynamically decompressed using the routines that gifread.c provides. Whilst this allows support for progressive decoding, it is not implemented here as NetSurf currently does not provide such support.

[rjw] - Sun 4th April 2004

Definition in file gif.c.

Typedef Documentation

◆ gif_content

typedef struct gif_content gif_content

Function Documentation

◆ CONTENT_FACTORY_REGISTER_TYPES()

CONTENT_FACTORY_REGISTER_TYPES ( nsgif  ,
gif_types  ,
gif_content_handler   
)

◆ gif__animate()

static nserror gif__animate ( gif_content gif,
bool  redraw 
)
static

Performs any necessary animation.

Parameters
pThe content to animate

Definition at line 176 of file gif.c.

References gif_content::base, content_broadcast(), CONTENT_MSG_REDRAW, gif_content::current_frame, gif_content::gif, gif__nsgif_error_to_ns(), gif_animate_cb(), guit, content_msg_data::height, netsurf_table::misc, NSERROR_OK, nsoption_bool, content_msg_data::redraw, gui_misc_table::schedule, content_msg_data::width, content_msg_data::x, rect::x0, rect::x1, content_msg_data::y, rect::y0, and rect::y1.

Referenced by gif_add_user(), gif_animate_cb(), and gif_convert().

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

◆ gif__nsgif_error_to_ns()

static nserror gif__nsgif_error_to_ns ( nsgif_error  gif_res)
inlinestatic

Definition at line 66 of file gif.c.

References NSERROR_GIF_ERROR, and NSERROR_NOMEM.

Referenced by gif__animate(), gif_convert(), and gif_create_gif_data().

Here is the caller graph for this function:

◆ gif_add_user()

static void gif_add_user ( struct content c)
static

Definition at line 356 of file gif.c.

References content_count_users(), gif_content::gif, and gif__animate().

Here is the call graph for this function:

◆ gif_animate_cb()

static void gif_animate_cb ( void *  p)
static

Scheduler callback.

Performs any necessary animation.

Parameters
pThe content to animate

Definition at line 210 of file gif.c.

References gif__animate().

Referenced by gif__animate(), gif_destroy(), and gif_remove_user().

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

◆ gif_bitmap_create()

static void * gif_bitmap_create ( int  width,
int  height 
)
static

Callback for libnsgif; forwards the call to bitmap_create()

Parameters
widthwidth of image in pixels
heightwidth of image in pixels
Returns
an opaque struct bitmap, or NULL on memory exhaustion

Definition at line 89 of file gif.c.

References netsurf_table::bitmap, BITMAP_NONE, gui_bitmap_table::create, guit, height, and width.

Referenced by gif_create_gif_data().

Here is the caller graph for this function:

◆ gif_clone()

static nserror gif_clone ( const struct content old,
struct content **  newc 
)
static

Definition at line 321 of file gif.c.

References gif_content::base, content__clone(), content_destroy(), CONTENT_STATUS_DONE, CONTENT_STATUS_READY, gif_convert(), gif_create_gif_data(), NSERROR_CLONE_FAILED, NSERROR_NOMEM, NSERROR_OK, and content::status.

Here is the call graph for this function:

◆ gif_content_is_opaque()

static bool gif_content_is_opaque ( struct content c)
static

Definition at line 398 of file gif.c.

References netsurf_table::bitmap, bitmap(), gui_bitmap_table::get_opaque, gif_get_frame(), and guit.

Here is the call graph for this function:

◆ gif_content_type()

static content_type gif_content_type ( void  )
static

Definition at line 393 of file gif.c.

References CONTENT_IMAGE.

◆ gif_convert()

static bool gif_convert ( struct content c)
static

Definition at line 217 of file gif.c.

References content__get_source_data(), content__set_title(), content_broadcast_error(), content_set_done(), content_set_ready(), content_set_status(), gif_content::gif, gif__animate(), gif__nsgif_error_to_ns(), content::height, content::llcache, llcache_handle_get_url(), messages_get_buff(), NSERROR_GIF_ERROR, NSERROR_OK, NSLOG, nsurl_access_leaf(), content::size, content_msg_data::title, and content::width.

Referenced by gif_clone().

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

◆ gif_create()

static nserror gif_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

Definition at line 134 of file gif.c.

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

Here is the call graph for this function:

◆ gif_create_gif_data()

static nserror gif_create_gif_data ( gif_content c)
static

Definition at line 111 of file gif.c.

References gif_content::base, netsurf_table::bitmap, bitmap_test_opaque(), content_broadcast_error(), gui_bitmap_table::destroy, gui_bitmap_table::get_buffer, gif_content::gif, gif__nsgif_error_to_ns(), gif_bitmap_create(), guit, gui_bitmap_table::modified, NSERROR_OK, nsgif__get_bitmap_format(), and gui_bitmap_table::set_opaque.

Referenced by gif_clone(), and gif_create().

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

◆ gif_destroy()

static void gif_destroy ( struct content c)
static

Definition at line 312 of file gif.c.

References gif_content::gif, gif_animate_cb(), guit, netsurf_table::misc, and gui_misc_table::schedule.

Here is the call graph for this function:

◆ gif_get_bitmap()

static nsgif_bitmap_t * gif_get_bitmap ( const struct content c,
void *  context 
)
static

Definition at line 380 of file gif.c.

References bitmap(), and gif_get_frame().

Here is the call graph for this function:

◆ gif_get_frame()

static nsgif_error gif_get_frame ( gif_content gif,
nsgif_bitmap_t **  bitmap 
)
static

Updates the GIF bitmap to display the current frame.

Parameters
gifThe gif context to update.
Returns
NSGIF_OK on success else apropriate error code.

Definition at line 288 of file gif.c.

References gif_content::current_frame, gif_content::gif, and nsoption_bool.

Referenced by gif_content_is_opaque(), gif_get_bitmap(), and gif_redraw().

Here is the caller graph for this function:

◆ gif_redraw()

static bool gif_redraw ( struct content c,
struct content_redraw_data data,
const struct rect clip,
const struct redraw_context ctx 
)
static

Definition at line 299 of file gif.c.

References bitmap(), clip(), content_msg_data::ctx, gif_get_frame(), and image_bitmap_plot().

Here is the call graph for this function:

◆ gif_remove_user()

static void gif_remove_user ( struct content c)
static

Definition at line 372 of file gif.c.

References content_count_users(), gif_animate_cb(), guit, netsurf_table::misc, and gui_misc_table::schedule.

Here is the call graph for this function:

◆ nsgif__get_bitmap_format()

static nsgif_bitmap_fmt_t nsgif__get_bitmap_format ( void  )
static

Convert client bitmap format to a LibNSGIF format specifier.

Definition at line 97 of file gif.c.

References BITMAP_LAYOUT_A8B8G8R8, BITMAP_LAYOUT_A8R8G8B8, BITMAP_LAYOUT_ABGR8888, BITMAP_LAYOUT_ARGB8888, BITMAP_LAYOUT_B8G8R8A8, BITMAP_LAYOUT_BGRA8888, BITMAP_LAYOUT_R8G8B8A8, BITMAP_LAYOUT_RGBA8888, and bitmap_fmt::layout.

Referenced by gif_create_gif_data().

Here is the caller graph for this function:

Variable Documentation

◆ gif_content_handler

const content_handler gif_content_handler
static
Initial value:
= {
.create = gif_create,
.data_complete = gif_convert,
.destroy = gif_destroy,
.redraw = gif_redraw,
.clone = gif_clone,
.add_user = gif_add_user,
.remove_user = gif_remove_user,
.get_internal = gif_get_bitmap,
.is_opaque = gif_content_is_opaque,
.no_share = false,
}
static void gif_remove_user(struct content *c)
Definition: gif.c:372
static bool gif_convert(struct content *c)
Definition: gif.c:217
static content_type gif_content_type(void)
Definition: gif.c:393
static nserror gif_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)
Definition: gif.c:134
static void gif_destroy(struct content *c)
Definition: gif.c:312
static nsgif_bitmap_t * gif_get_bitmap(const struct content *c, void *context)
Definition: gif.c:380
static void gif_add_user(struct content *c)
Definition: gif.c:356
static bool gif_redraw(struct content *c, struct content_redraw_data *data, const struct rect *clip, const struct redraw_context *ctx)
Definition: gif.c:299
static bool gif_content_is_opaque(struct content *c)
Definition: gif.c:398
static nserror gif_clone(const struct content *old, struct content **newc)
Definition: gif.c:321

Definition at line 410 of file gif.c.

◆ gif_types

const char* gif_types[]
static
Initial value:
= {
"image/gif"
}

Definition at line 424 of file gif.c.