Plugin

Plugin — The API for plugins to use.

Functions

Types and Values

Includes

#include <abydos-plugin.h>

Description

To create a image loading plugin for abydos you must implement a function called "Abydos0" which returns a pointer to an abydos_plugin_interface_t. Which in turn must be filled with points to some functions.

These functions are mandatory:

  • get_mime_types

  • new

  • free

And at least one way to load an image. More than one can be provided. But implementing one by calling another is pointless since abydos knows how to do that anyway. One of these are mandatory:

  • progressive_begin, progressive_feed and progressive_end

  • create_from_data

  • create_from_file

And at least one way to get an image. Both can be provided. But implementing one by calling the other is pointless since abydos knows how to do that anyway. One of these are mandatory:

  • render

  • get_image_surface

If the plugin supports variants it also needs to implement:

  • get_variant_size

If the plugin supports animation it also needs to implement:

  • get_duration

The rest of the functions are optional.

Functions

abydos_plugin_info_func_t ()

void
(*abydos_plugin_info_func_t) (void *Param1);

abydos_plugin_progress_func_t ()

void
(*abydos_plugin_progress_func_t) (void *Param1,
                                  cairo_rectangle_int_t *Param2);

ABYDOS_PLUGIN_INFO_HAS()

#define ABYDOS_PLUGIN_INFO_HAS(info,member) (offsetof(abydos_plugin_info_t,member)<(info)->version)

Macro to check if the version of the abydos_plugin_page_info_t info has member .


abydos_plugin_func_t ()

abydos_plugin_interface_t *
(*abydos_plugin_func_t) (void);

Types and Values

abydos_plugin_handle_t

typedef struct _abydos_plugin_handle_t abydos_plugin_handle_t;

A pointer to an object provided by a plugin.


abydos_size_t

typedef struct {
    int width;
    int height;
} abydos_size_t;

abydos_plugin_info_t

typedef struct {
    int version;
    const char *error;
    int width;
    int height;
    double pixel_ratio;
    /* multi page */
    int page_count;
    /* layers */
    int layer_count;
    /* variants */
    int variant_count;
    /* animation */
    int frame_count;
    /* flags */
    cairo_bool_t scalable_size;
    cairo_bool_t scalable_time;
    cairo_bool_t threadsafe;
    /* 0.2 */
    int default_page;
    int default_frame;
    cairo_bool_t threadsafe_render;
} abydos_plugin_info_t;

ABYDOS_PLUGIN_INFO_VERSION

#define ABYDOS_PLUGIN_INFO_VERSION sizeof(abydos_plugin_info_t)

The compile time version of abydos_plugin_info_t.


abydos_plugin_interface_t

typedef struct {
    int version;
    void(*done)(void);
    const char **(*get_mime_types)(void);

    abydos_plugin_handle_t *(*new)(const char *mime_type,abydos_plugin_info_t *);
    void(*free)(abydos_plugin_handle_t *);

    void(*progressive_begin)(abydos_plugin_handle_t *,abydos_plugin_info_func_t,abydos_plugin_progress_func_t,void *);
    int(*progressive_feed)(abydos_plugin_handle_t *,const char *data,size_t len);
    int(*progressive_end)(abydos_plugin_handle_t *);
    int (*create_from_data)(abydos_plugin_handle_t *,const char *data, size_t len);
    int (*create_from_file)(abydos_plugin_handle_t *,const char *filename);

    void(*render)(abydos_plugin_handle_t *, cairo_t *cr,int page,cairo_bool_t *visible_layers,int prefered_variant,double time,int frame);
    cairo_surface_t *(*get_image_surface)(abydos_plugin_handle_t *,int page,cairo_bool_t *visible_layers,int prefered_variant,double time,int frame);

    void(*get_layer_visibility_OLD)(abydos_plugin_handle_t *,cairo_bool_t *visibility);
    int(*get_variant_size_OLD)(abydos_plugin_handle_t *,abydos_size_t *size);
    void(*get_duration_OLD)(abydos_plugin_handle_t *,double *frame_duration);

    void(*get_page_info)(abydos_plugin_handle_t *, int page, abydos_plugin_page_info_t *);
    void(*get_layer_visibility)(abydos_plugin_handle_t *,int page, cairo_bool_t *visibility);
    void(*get_variant_size)(abydos_plugin_handle_t *,int page, abydos_size_t *size);
    void(*get_duration)(abydos_plugin_handle_t *,int page, double *frame_duration);
} abydos_plugin_interface_t;

Members

int version;

Version of this structure supported by the plugin. Must always be set to ABYDOS_PLUGIN_INTERFACE_VERSION.

 

done ()

Function to be called before the plugin is unloaded. (optional)

 

get_mime_types ()

Function to get supported mime types. If must return a NULL terminated array.

 

new ()

Function to create a new instance of mime_type .

 

free ()

Function to free all resources associated with the abydos_handle_t. May be called before or after the image has been loaded as well as in the middle of a progressive load.

 

progressive_begin ()

   

progressive_feed ()

   

progressive_end ()

   

create_from_data ()

   

create_from_file ()

   

render ()

Function to render the image using cairo. The arguments passed to the function has already been checked by abydos and are valid. The arguments frame and time two ways to express the same thing. Use the one that is most convinient.

 

get_image_surface ()

Function to get an image surface for the image (according to the supplied arguments). Usually just return a reference to an internal image surface created during the load stage.

 

get_layer_visibility_OLD ()

   

get_variant_size_OLD ()

   

get_duration_OLD ()

   

get_page_info ()

   

get_layer_visibility ()

   

get_variant_size ()

   

get_duration ()

   

ABYDOS_PLUGIN_INTERFACE_VERSION

#define ABYDOS_PLUGIN_INTERFACE_VERSION sizeof(abydos_plugin_interface_t)

The compile time version of abydos_plugin_interface_t.