#ifndef _GF_SG_SVG_H_
#define _GF_SG_SVG_H_
#ifdef __cplusplus
extern "C" {
#endif
#include <gpac/scenegraph.h>
#include <gpac/svg_types.h>
enum
{
TAG_DOM_ATTRIBUTE_NULL,
TAG_DOM_ATT_any,
TAG_XML_ATT_RANGE_FIRST,
TAG_XML_ATT_id = TAG_XML_ATT_RANGE_FIRST,
TAG_XML_ATT_base,
TAG_XML_ATT_lang,
TAG_XML_ATT_space,
TAG_XML_ATT_RANGE_LAST,
TAG_XLINK_ATT_RANGE_FIRST,
TAG_XLINK_ATT_type = TAG_XLINK_ATT_RANGE_FIRST,
TAG_XLINK_ATT_role,
TAG_XLINK_ATT_arcrole,
TAG_XLINK_ATT_title,
TAG_XLINK_ATT_href,
TAG_XLINK_ATT_show,
TAG_XLINK_ATT_actuate,
TAG_XLINK_ATT_RANGE_LAST,
TAG_XMLEV_ATT_RANGE_FIRST,
TAG_XMLEV_ATT_event,
TAG_XMLEV_ATT_phase,
TAG_XMLEV_ATT_propagate,
TAG_XMLEV_ATT_defaultAction,
TAG_XMLEV_ATT_observer,
TAG_XMLEV_ATT_target,
TAG_XMLEV_ATT_handler,
TAG_XMLEV_ATT_RANGE_LAST,
TAG_LSR_ATT_RANGE_FIRST,
TAG_LSR_ATT_enabled,
TAG_LSR_ATT_RANGE_LAST,
TAG_LSR_ATT_children,
TAG_LSR_ATT_overflow,
TAG_LSR_ATT_rotation,
TAG_LSR_ATT_scale,
TAG_LSR_ATT_translation,
TAG_LSR_ATT_svg_width,
TAG_LSR_ATT_svg_height,
TAG_LSR_ATT_textContent,
TAG_LSR_ATT_text_display,
TAG_SVG_ATT_RANGE_FIRST,
TAG_XBL_ATT_RANGE_FIRST = TAG_SVG_ATT_RANGE_FIRST + 256,
TAG_XBL_ATT_id = TAG_XBL_ATT_RANGE_FIRST,
TAG_XBL_ATT_extends,
TAG_XBL_ATT_display,
TAG_XBL_ATT_inheritstyle,
TAG_XBL_ATT_includes,
TAG_XBL_ATT_name,
TAG_XBL_ATT_implements,
TAG_XBL_ATT_type,
TAG_XBL_ATT_readonly,
TAG_XBL_ATT_onget,
TAG_XBL_ATT_onset,
TAG_XBL_ATT_event,
TAG_XBL_ATT_action,
TAG_XBL_ATT_phase,
TAG_XBL_ATT_button,
TAG_XBL_ATT_modifiers,
TAG_XBL_ATT_keycode,
TAG_XBL_ATT_key,
TAG_XBL_ATT_charcode,
TAG_XBL_ATT_clickcount,
TAG_XBL_ATT_command,
TAG_XBL_ATT_preventdefault,
TAG_XBL_ATT_src,
TAG_GSVG_ATT_useAsPrimary,
TAG_GSVG_ATT_depthOffset,
TAG_GSVG_ATT_depthGain,
};
#define GF_DOM_BASE_ATTRIBUTE \
u16 tag; \
u16 data_type; \
void *data; \
struct __dom_base_attribute *next;
#define GF_DOM_FULL_ATTRIBUTE \
GF_DOM_ATTRIBUTE \
typedef struct __dom_base_attribute
{
GF_DOM_BASE_ATTRIBUTE
} GF_DOMAttribute;
typedef struct __dom_full_attribute
{
GF_DOM_BASE_ATTRIBUTE
u32 xmlns;
char *name;
} GF_DOMFullAttribute;
#define GF_DOM_BASE_NODE \
BASE_NODE \
CHILDREN \
GF_DOMAttribute *attributes;
typedef struct __dom_base_node
{
GF_DOM_BASE_NODE
} GF_DOMNode;
typedef struct __dom_full_node
{
GF_DOM_BASE_NODE
char *name;
u32 ns;
} GF_DOMFullNode;
typedef enum
{
GF_XMLNS_UNDEFINED = 0,
GF_XMLNS_XML,
GF_XMLNS_XLINK,
GF_XMLNS_XMLEV,
GF_XMLNS_LASER,
GF_XMLNS_SVG,
GF_XMLNS_XBL,
GF_XMLNS_SVG_GPAC_EXTENSION,
} GF_NamespaceType;
GF_NamespaceType gf_xml_get_namespace_id(char *name);
GF_Err gf_sg_add_namespace(GF_SceneGraph *sg, char *name, char *qname);
GF_Err gf_sg_remove_namespace(GF_SceneGraph *sg, char *name, char *qname);
u32 gf_sg_get_namespace_code(GF_SceneGraph *sg, char *qname);
u32 gf_sg_get_namespace_code_from_name(GF_SceneGraph *sg, char *name);
const char *gf_sg_get_namespace_qname(GF_SceneGraph *sg, GF_NamespaceType xmlns_id);
GF_NamespaceType gf_xml_get_element_namespace(GF_Node *n);
const char *gf_sg_get_namespace(GF_SceneGraph *sg, GF_NamespaceType xmlns_id);
void gf_xml_push_namespaces(GF_DOMNode *elt);
void gf_xml_pop_namespaces(GF_DOMNode *elt);
enum
{
GF_DOM_TEXT_REGULAR = 0,
GF_DOM_TEXT_CDATA,
GF_DOM_TEXT_INSERTED
};
typedef struct
{
BASE_NODE
CHILDREN
char *textContent;
u32 type;
} GF_DOMText;
GF_DOMText *gf_dom_add_text_node(GF_Node *parent, char *text_data);
void gf_dom_set_textContent(GF_Node *n, char *text);
char *gf_dom_flatten_textContent(GF_Node *n);
GF_DOMText *gf_dom_new_text_node(GF_SceneGraph *sg);
typedef struct
{
BASE_NODE
CHILDREN
char *data;
u32 data_size;
GF_List *updates;
} GF_DOMUpdates;
GF_DOMUpdates *gf_dom_add_updates_node(GF_Node *parent);
typedef enum
{
GF_DOM_EVENT_PHASE_CAPTURE = 1,
GF_DOM_EVENT_PHASE_AT_TARGET = 2,
GF_DOM_EVENT_PHASE_BUBBLE = 3,
GF_DOM_EVENT_CANCEL_MASK = 0xE0,
GF_DOM_EVENT_PHASE_CANCEL = 1<<5,
GF_DOM_EVENT_PHASE_CANCEL_ALL = 1<<6,
GF_DOM_EVENT_PHASE_PREVENT = 1<<7,
} GF_DOMEventPhase;
typedef enum
{
GF_DOM_EVENT_TARGET_NODE,
GF_DOM_EVENT_TARGET_DOCUMENT,
GF_DOM_EVENT_TARGET_MSE_MEDIASOURCE,
GF_DOM_EVENT_TARGET_MSE_SOURCEBUFFERLIST,
GF_DOM_EVENT_TARGET_MSE_SOURCEBUFFER,
GF_DOM_EVENT_TARGET_XHR,
} GF_DOMEventTargetType;
typedef struct
{
GF_List *listeners;
void *ptr;
GF_DOMEventTargetType ptr_type;
} GF_DOMEventTarget;
GF_DOMEventTarget *gf_dom_event_target_new(GF_DOMEventTargetType type, void *obj);
GF_Err gf_sg_listener_add(GF_Node *listener, GF_DOMEventTarget *evt_target);
typedef struct
{
Bool bufferValid;
u32 level;
Fixed remaining_time;
u16 status;
const char *session_name;
u64 loaded_size, total_size;
} GF_DOMMediaEvent;
typedef struct
{
GF_EventType type;
u8 event_phase;
u8 bubbles;
u8 cancelable;
u8 has_ui_events;
void *target;
GF_DOMEventTargetType target_type;
GF_DOMEventTarget *currentTarget;
Double timestamp;
u32 detail;
s32 screenX, screenY;
s32 clientX, clientY;
u32 button;
u32 key_flags;
u32 key_hw_code;
GF_Node *relatedTarget;
GF_Rect screen_rect;
GF_Point2D prev_translate, new_translate;
Fixed prev_scale, new_scale;
u32 cpu_percentage;
Bool onBattery;
u32 batteryState, batteryLevel;
Double smil_event_time;
GF_Node *relatedNode;
Bool is_vrml;
GF_DOMMediaEvent media_event;
u32 consumed;
GF_FieldInfo *attr;
GF_Err error_state;
const char *addon_url;
} GF_DOM_Event;
Bool gf_dom_event_fire(GF_Node *node, GF_DOM_Event *event);
Bool gf_sg_fire_dom_event(GF_DOMEventTarget *et, GF_DOM_Event *event, GF_SceneGraph *sg, GF_Node *n);
Bool gf_dom_event_fire_ex(GF_Node *node, GF_DOM_Event *event, GF_List *use_stack);
GF_EventType gf_dom_event_type_by_name(const char *name);
const char *gf_dom_event_get_name(GF_EventType type);
const char *gf_dom_get_key_name(GF_KeyCode key_identifier);
GF_KeyCode gf_dom_get_key_type(char *key_name);
#define GF_DOM_BASE_LISTENER \
\
void *js_context; \
\
void *evt_listen_obj; \
\
u64 js_fun_val;\
\
void *js_fun; \
\
char *callback;
typedef struct __xml_ev_handler
{
GF_DOM_BASE_NODE
void (*handle_event)(GF_Node *hdl, GF_DOM_Event *event, GF_Node *observer);
GF_DOM_BASE_LISTENER
} GF_DOMHandler;
typedef enum
{
GF_DOM_EVENT_UNKNOWN_CATEGORY,
GF_DOM_EVENT_DOM = 1,
GF_DOM_EVENT_MUTATION = 1<<1,
GF_DOM_EVENT_MOUSE = 1<<2,
GF_DOM_EVENT_FOCUS = 1<<3,
GF_DOM_EVENT_KEY = 1<<4,
GF_DOM_EVENT_UI = 1<<5,
GF_DOM_EVENT_TEXT = 1<<6,
GF_DOM_EVENT_SVG = 1<<7,
GF_DOM_EVENT_SMIL = 1<<8,
GF_DOM_EVENT_LASER = 1<<9,
GF_DOM_EVENT_MEDIA = 1<<10,
GF_DOM_EVENT_MEDIASOURCE = 1<<11,
GF_DOM_EVENT_GPAC = 1<<30,
GF_DOM_EVENT_FAKE = 1<<31,
} GF_DOMEventCategory;
GF_DOMEventCategory gf_dom_event_get_category(GF_EventType type);
u32 gf_sg_get_dom_event_filter(GF_SceneGraph *sg);
u32 gf_node_get_dom_event_filter(GF_Node *node);
void gf_sg_register_event_type(GF_SceneGraph *sg, GF_DOMEventCategory category);
void gf_sg_unregister_event_type(GF_SceneGraph *sg, GF_DOMEventCategory category);
GF_Err gf_node_dom_listener_add(GF_Node *node, GF_Node *listener);
u32 gf_dom_listener_count(GF_Node *node);
GF_Node *gf_dom_listener_get(GF_Node *node, u32 i);
GF_DOMHandler *gf_dom_listener_build(GF_Node *observer, GF_EventType event_type, u32 event_param);
void gf_node_register_iri(GF_SceneGraph *sg, XMLRI *iri);
void gf_node_unregister_iri(GF_SceneGraph *sg, XMLRI *iri);
u32 gf_node_animation_count(GF_Node *node);
GF_Err gf_node_store_embedded_data(XMLRI *iri, const char *cache_dir, const char *base_filename);
typedef struct {
SVG_Paint *color;
SVG_Paint *fill;
SVG_Paint *stroke;
SVG_Paint *solid_color;
SVG_Paint *stop_color;
SVG_Paint *viewport_fill;
SVG_Number *fill_opacity;
SVG_Number *solid_opacity;
SVG_Number *stop_opacity;
SVG_Number *stroke_opacity;
SVG_Number *viewport_fill_opacity;
SVG_Number *opacity;
SVG_Number *audio_level;
Fixed computed_audio_level;
SVG_RenderingHint *color_rendering;
SVG_RenderingHint *image_rendering;
SVG_RenderingHint *shape_rendering;
SVG_RenderingHint *text_rendering;
SVG_Display *display;
SVG_Visibility *visibility;
SVG_Overflow *overflow;
SVG_FontFamily *font_family;
SVG_FontSize *font_size;
SVG_FontStyle *font_style;
SVG_FontWeight *font_weight;
SVG_FontVariant *font_variant;
SVG_Number *line_increment;
SVG_TextAnchor *text_anchor;
SVG_DisplayAlign *display_align;
SVG_TextAlign *text_align;
SVG_PointerEvents *pointer_events;
SVG_FillRule *fill_rule;
SVG_StrokeDashArray *stroke_dasharray;
SVG_Length *stroke_dashoffset;
SVG_StrokeLineCap *stroke_linecap;
SVG_StrokeLineJoin *stroke_linejoin;
SVG_Number *stroke_miterlimit;
SVG_Length *stroke_width;
SVG_VectorEffect *vector_effect;
} SVGPropertiesPointers;
void gf_svg_properties_init_pointers(SVGPropertiesPointers *svg_props);
void gf_svg_properties_reset_pointers(SVGPropertiesPointers *svg_props);
void gf_svg_apply_animations(GF_Node *node, SVGPropertiesPointers *render_svg_props);
Bool gf_svg_has_appearance_flag_dirty(u32 flags);
Bool gf_svg_is_element_transformable(u32 tag);
void *gf_svg_create_attribute_value(u32 attribute_type);
void gf_svg_delete_attribute_value(u32 type, void *value, GF_SceneGraph *sg);
Bool gf_svg_attributes_equal(GF_FieldInfo *a, GF_FieldInfo *b);
GF_Err gf_svg_attributes_copy(GF_FieldInfo *a, GF_FieldInfo *b, Bool clamp);
GF_Err gf_svg_attributes_add(GF_FieldInfo *a, GF_FieldInfo *b, GF_FieldInfo *c, Bool clamp);
Bool gf_svg_attribute_is_interpolatable(u32 type) ;
GF_Err gf_svg_attributes_interpolate(GF_FieldInfo *a, GF_FieldInfo *b, GF_FieldInfo *c, Fixed coef, Bool clamp);
GF_Err gf_svg_attributes_muladd(Fixed alpha, GF_FieldInfo *a, Fixed beta, GF_FieldInfo *b, GF_FieldInfo *c, Bool clamp);
GF_Err gf_node_get_attribute_by_tag(GF_Node *node, u32 attribute_tag, Bool create_if_not_found, Bool set_default, GF_FieldInfo *field);
char *gf_svg_attribute_type_to_string(u32 att_type);
GF_Err gf_svg_parse_attribute(GF_Node *n, GF_FieldInfo *info, char *attribute_content, u8 anim_value_type);
void gf_svg_parse_style(GF_Node *n, char *style);
char *gf_svg_dump_attribute(GF_Node *elt, GF_FieldInfo *info);
char *gf_svg_dump_attribute_indexed(GF_Node *elt, GF_FieldInfo *info);
void gf_svg_path_build(GF_Path *path, GF_List *commands, GF_List *points);
GF_Err gf_svg_parse_element_id(GF_Node *n, const char *nodename, Bool warning_if_defined);
const char *gf_svg_get_system_paint_server_name(u32 paint_type);
u32 gf_svg_get_system_paint_server_type(const char *name);
Bool gf_smil_notify_timed_elements(GF_SceneGraph *sg);
void gf_smil_timing_insert_clock(GF_Node *elt, Bool is_end, Double clock);
Bool gf_svg_parse_transformlist(GF_Matrix2D *mat, char *attribute_content);
typedef struct _smil_timing_rti SMIL_Timing_RTI;
enum
{
SMIL_TIMING_EVAL_NONE = 0,
SMIL_TIMING_EVAL_UPDATE,
SMIL_TIMING_EVAL_FREEZE,
SMIL_TIMING_EVAL_REMOVE,
SMIL_TIMING_EVAL_REPEAT,
SMIL_TIMING_EVAL_FRACTION,
SMIL_TIMING_EVAL_DISCARD,
SMIL_TIMING_EVAL_ACTIVATE,
SMIL_TIMING_EVAL_DEACTIVATE,
};
void gf_smil_set_evaluation_callback(GF_Node *smil_time,
void (*smil_evaluate)(struct _smil_timing_rti *rti, Fixed normalized_simple_time, u32 state));
void gf_smil_set_media_duration(SMIL_Timing_RTI *rti, Double media_duration);
Double gf_smil_get_media_duration(SMIL_Timing_RTI *rti);
GF_Node *gf_smil_get_element(SMIL_Timing_RTI *rti);
Bool gf_smil_timing_is_active(GF_Node *node);
void gf_smil_timing_modified(GF_Node *node, GF_FieldInfo *field);
typedef struct __dom_base_attribute SVGAttribute;
typedef struct __dom_full_attribute SVGExtendedAttribute;
typedef struct __dom_base_node SVG_Element;
typedef struct __xml_ev_handler SVG_handlerElement;
typedef struct _all_atts SVGAllAttributes;
void gf_svg_flatten_attributes(SVG_Element *e, SVGAllAttributes *all_atts);
const char *gf_svg_get_attribute_name(GF_Node *elt, u32 tag);
u32 gf_svg_apply_inheritance(SVGAllAttributes *all_atts, SVGPropertiesPointers *render_svg_props) ;
GF_DOMAttribute *gf_xml_create_attribute(GF_Node *node, u32 tag);
u32 gf_xml_get_attribute_type(u32 tag);
u32 gf_xml_get_attribute_tag(GF_Node *node, char *attribute_name, u32 ns);
u32 gf_xml_get_element_tag(const char *element_name, u32 xmlns);
#ifdef __cplusplus
}
#endif
#endif