#ifndef _COMPOSITOR_DEV_H_
#define _COMPOSITOR_DEV_H_
#ifdef __cplusplus
extern "C" {
#endif
#include <gpac/compositor.h>
#include <gpac/thread.h>
#include <gpac/mediaobject.h>
#include <gpac/modules/raster2d.h>
#include <gpac/modules/font.h>
#include <gpac/modules/video_out.h>
#include <gpac/modules/audio_out.h>
#ifndef GPAC_DISABLE_SVG
#include <gpac/scenegraph_svg.h>
#endif
#define GF_SR_USE_DEPTH
#define GF_SR_FPS_COMPUTE_SIZE 60
enum
{
GF_SR_CFG_OVERRIDE_SIZE = 1,
GF_SR_CFG_SET_SIZE = 1<<1,
GF_SR_CFG_AR = 1<<2,
GF_SR_CFG_FULLSCREEN = 1<<3,
GF_SR_IN_RECONFIG = 1<<4,
GF_SR_CFG_WINDOWSIZE_NOTIF = 1<<5,
GF_SR_CFG_INITIAL_RESIZE = 1<<6,
};
enum
{
GF_3D_STEREO_NONE = 0,
GF_3D_STEREO_TOP,
GF_3D_STEREO_SIDE,
GF_3D_STEREO_HEADSET,
GF_3D_STEREO_LAST_SINGLE_BUFFER = GF_3D_STEREO_HEADSET,
GF_3D_STEREO_CUSTOM,
GF_3D_STEREO_COLUMNS,
GF_3D_STEREO_ROWS,
GF_3D_STEREO_ANAGLYPH,
GF_3D_STEREO_5VSP19,
GF_3D_STEREO_8VALIO
};
typedef struct _visual_manager GF_VisualManager;
typedef struct _draw_aspect_2d DrawAspect2D;
typedef struct _traversing_state GF_TraverseState;
typedef struct _gf_ft_mgr GF_FontManager;
#ifndef GPAC_DISABLE_3D
#include <gpac/internal/camera.h>
#include <gpac/internal/mesh.h>
typedef struct
{
Bool multisample;
Bool bgra_texture;
Bool abgr_texture;
Bool npot_texture;
Bool rect_texture;
Bool point_sprite;
Bool vbo, pbo;
Bool gles2_unpack;
u32 yuv_texture;
Bool has_shaders;
s32 max_texture_size;
} GLCaps;
#endif
#if !defined(GPAC_DISABLE_3D) && !defined(GPAC_USE_TINYGL) && !defined(GPAC_USE_GLES2)
# define OPENGL_RASTER
#else
# ifdef OPENGL_RASTER
# undef OPENGL_RASTER
# endif
#endif
#define DOUBLECLICK_TIME_MS 250
enum
{
GF_SC_TSEL_NONE = 0,
GF_SC_TSEL_ACTIVE,
GF_SC_TSEL_FROZEN,
GF_SC_TSEL_RELEASED,
};
enum
{
GF_SC_DRAW_NONE,
GF_SC_DRAW_FRAME,
GF_SC_DRAW_FLUSH,
};
enum
{
GF_SC_DEPTH_GL_NONE=0,
GF_SC_DEPTH_GL_POINTS,
GF_SC_DEPTH_GL_STRIPS,
GF_SC_DEPTH_GL_VBO,
};
struct __tag_compositor
{
GF_User *user;
GF_Terminal *term;
struct _audio_render *audio_renderer;
GF_VideoOutput *video_out;
GF_Raster2D *rasterizer;
GF_List *video_listeners;
GF_Thread *VisualThread;
u32 video_th_state;
u32 video_th_id;
GF_Mutex *mx;
GF_List *proto_modules;
GF_SceneGraph *scene;
GF_List *extra_scenes;
u32 inherit_type_3d;
GF_List *time_nodes;
GF_List *textures;
Bool texture_inserted;
GF_List *textures_gc;
GF_List *event_queue, *event_queue_back;
GF_Mutex *evq_mx;
Bool video_setup_failed;
Double frame_rate;
Bool bench_mode;
u32 force_bench_frame;
Bool no_regulation;
u32 frame_duration;
u32 frame_time[GF_SR_FPS_COMPUTE_SIZE];
u32 frame_dur[GF_SR_FPS_COMPUTE_SIZE];
u32 current_frame;
u32 last_frame_time, caret_next_draw_time;
Bool show_caret;
Bool text_edit_changed;
u32 scene_sampled_clock;
u32 last_click_time;
s32 ms_until_next_frame;
s32 frame_delay;
Bool video_frame_pending;
Bool fullscreen_postponed;
u32 display_width, display_height;
u32 vp_x, vp_y, vp_width, vp_height;
u32 output_width, output_height;
Bool output_as_8bit;
u8 multiview_mode;
u32 scene_width, scene_height;
Bool has_size_info;
Bool fullscreen;
Bool paused, step_mode;
u32 frame_draw_type;
u32 force_next_frame_redraw;
Bool is_hidden, freeze_display;
Bool debug_defer;
Bool disable_composite_blit, disable_hardware_blit, rebuild_offscreen_textures;
u32 frame_number;
u32 interaction_sensors;
u32 reset_graphics;
GF_FontManager *font_manager;
Bool reset_fonts;
s32 fonts_pending;
u32 aspect_ratio, antiAlias, texture_text_mode;
Bool high_speed, stress_mode;
Bool is_opengl;
Bool autoconfig_opengl;
u32 force_opengl_2d;
#ifdef OPENGL_RASTER
Bool opengl_raster;
#endif
Bool hybrid_opengl;
u32 key_states;
u32 interaction_level;
u32 override_size_flags;
u32 msg_type;
u32 new_width, new_height;
u32 back_color, default_back_color;
u32 draw_bvol;
u32 sys_colors[28];
GF_List *visuals;
GF_List *strike_bank;
GF_VisualManager *visual;
Bool root_visual_setup;
u32 recompute_ar;
Bool zoom_changed;
struct _traversing_state *traverse_state;
GF_Node *grab_node;
GF_Node *grab_use;
GF_Node *focus_node;
GF_Node *focus_used;
GF_List *focus_ancestors;
GF_List *focus_use_stack;
Bool focus_uses_dom_events;
u32 sensor_type;
GF_List *previous_sensors;
GF_List *sensors;
u32 grabbed_sensor;
GF_Node *keynav_node;
GF_List *env_tests;
void *hw_context;
Bool hw_locked;
GF_VideoSurface hw_surface;
u32 video_memory;
Bool request_video_memory, was_system_memory;
Bool last_had_overlays;
GF_RasterCallback raster_callbacks;
Bool scalable_zoom;
Bool enable_yuv_hw;
Bool disable_partial_hw_blit;
u32 navigate_mode;
Bool navigation_disabled;
u32 rotate_mode;
u32 navigation_state;
Fixed grab_x, grab_y;
Fixed scale_x, scale_y;
Fixed zoom;
Fixed trans_x, trans_y;
Fixed rotation;
u32 skip_flush;
#ifndef GPAC_DISABLE_SVG
u32 num_clicks;
#endif
struct _drawable *focus_highlight;
u32 highlight_fill, highlight_stroke;
Fixed highlight_stroke_width;
Bool disable_focus_highlight;
GF_Node *hit_node;
GF_Node *hit_appear, *prev_hit_appear;
GF_List *hit_use_stack, *prev_hit_use_stack;
Bool hit_use_dom_events;
GF_Matrix hit_world_to_local, hit_local_to_world;
SFVec3f hit_local_point, hit_world_point;
SFVec2f hit_texcoords;
GF_Ray hit_world_ray;
SFVec3f hit_normal;
Fixed hit_square_dist;
GF_Node *text_selection;
SFVec2f start_sel, end_sel;
u32 store_text_state;
GF_Node *hit_text;
u32 sel_buffer_len, sel_buffer_alloc;
u16 *sel_buffer;
u8 *selected_text;
u32 text_sel_color;
s32 picked_glyph_idx, picked_span_idx;
u32 focus_text_type;
Bool edit_is_tspan;
char **edited_text;
u32 caret_pos, dom_text_pos;
#ifndef GPAC_DISABLE_3D
Bool emul_pow2;
Bool raster_outlines;
Bool disable_rect_ext;
u32 draw_normals;
u32 backcull;
Bool poly_aa;
Bool disable_glu_scale;
u32 wiremode;
u32 collide_mode;
Bool gravity_on;
Bool disable_gl_cull;
Bool disable_yuvgl;
Bool enable_pbo;
u32 default_navigation_mode;
GF_Mesh *unit_bbox;
GF_Node *active_layer;
GLCaps gl_caps;
u32 offscreen_width, offscreen_height;
#if !defined(GPAC_USE_TINYGL) && !defined(GPAC_USE_GLES1X)
Bool shader_only_mode;
#endif
u32 frame_packing;
#ifdef GPAC_USE_TINYGL
void *tgl_ctx;
#endif
Fixed depth_gl_scale, depth_gl_strips_filter;
u32 depth_gl_type;
Fixed interoccular_distance;
Fixed interoccular_offset;
Fixed focus_distance;
struct _gf_sc_texture_handler *hybgl_txh;
GF_Mesh *hybgl_mesh;
GF_Mesh *hybgl_mesh_background;
Bool force_type_3d;
char *screen_buffer;
u32 screen_buffer_alloc_size;
#endif
Bool texture_from_decoder_memory;
u32 networks_time;
u32 decoders_time;
u32 visual_config_time;
u32 traverse_setup_time;
u32 traverse_and_direct_draw_time;
u32 indirect_draw_time;
#ifdef GF_SR_USE_VIDEO_CACHE
u32 video_cache_current_size, video_cache_max_size;
u32 cache_scale, cache_tolerance;
GF_List *cached_groups;
GF_List *cached_groups_queue;
#endif
#ifdef GF_SR_USE_DEPTH
Bool auto_calibration;
s32 display_depth;
#endif
};
typedef struct
{
GF_Event evt;
GF_DOM_Event dom_evt;
GF_Node *node;
GF_DOMEventTarget *target;
GF_SceneGraph *sg;
} GF_QueuedEvent;
void gf_sc_queue_dom_event(GF_Compositor *compositor, GF_Node *node, GF_DOM_Event *evt);
void gf_sc_queue_dom_event_on_target(GF_Compositor *compositor, GF_DOM_Event *evt, GF_DOMEventTarget *target, GF_SceneGraph *sg);
void gf_sc_queue_event(GF_Compositor *compositor, GF_Event *evt);
typedef struct _time_node
{
void (*UpdateTimeNode)(struct _time_node *);
Bool is_registered, needs_unregister;
void *udta;
} GF_TimeNode;
void gf_sc_register_time_node(GF_Compositor *sr, GF_TimeNode *tn);
void gf_sc_unregister_time_node(GF_Compositor *sr, GF_TimeNode *tn);
enum
{
GF_SR_TEXTURE_REPEAT_S = (1<<0),
GF_SR_TEXTURE_REPEAT_T = (1<<1),
GF_SR_TEXTURE_MATTE = (1<<2),
GF_SR_TEXTURE_NO_GL_FLIP = (1<<3),
GF_SR_TEXTURE_USED = (1<<4),
GF_SR_TEXTURE_SVG = (1<<5),
GF_SR_TEXTURE_PRIVATE_MEDIA = (1<<6),
};
typedef struct _gf_sc_texture_handler
{
GF_Node *owner;
GF_Compositor *compositor;
struct __texture_wrapper *tx_io;
GF_MediaObject *stream;
Bool is_open;
void (*update_texture_fcnt)(struct _gf_sc_texture_handler *txh);
Bool needs_release;
Bool stream_finished;
Bool needs_refresh;
u32 last_frame_time;
Bool transparent;
u32 flags;
void (*compute_gradient_matrix)(struct _gf_sc_texture_handler *txh, GF_Rect *bounds, GF_Matrix2D *mat, Bool for_3d);
char *data;
u32 size, width, height, pixelformat, pixel_ar, stride, stride_chroma;
Bool is_flipped;
Bool raw_memory;
u8 *pU, *pV;
u32 nb_frames, upload_time;
GF_MediaDecoderFrame *frame;
#ifndef GPAC_DISABLE_VRML
Bool has_cmat;
GF_Node *matteTexture;
#endif
void *vout_udta;
} GF_TextureHandler;
void gf_sc_texture_setup(GF_TextureHandler *hdl, GF_Compositor *sr, GF_Node *owner);
void gf_sc_texture_destroy(GF_TextureHandler *txh);
GF_TextureHandler *gf_sc_texture_get_handler(GF_Node *n);
Bool gf_sc_texture_check_url_change(GF_TextureHandler *txh, MFURL *url);
GF_Err gf_sc_texture_open(GF_TextureHandler *txh, MFURL *url, Bool lock_scene_timeline);
GF_Err gf_sc_texture_play(GF_TextureHandler *txh, MFURL *url);
GF_Err gf_sc_texture_play_from_to(GF_TextureHandler *txh, MFURL *url, Double start_offset, Double end_offset, Bool can_loop, Bool lock_scene_timeline);
void gf_sc_texture_stop(GF_TextureHandler *txh);
void gf_sc_texture_restart(GF_TextureHandler *txh);
void gf_sc_texture_update_frame(GF_TextureHandler *txh, Bool disable_resync);
void gf_sc_texture_release_stream(GF_TextureHandler *txh);
void gf_sc_texture_cleanup_hw(GF_Compositor *compositor);
typedef struct _sensor_handler
{
Bool (*IsEnabled)(GF_Node *node);
Bool (*OnUserEvent)(struct _sensor_handler *sh, Bool is_over, Bool is_cancel, GF_Event *ev, GF_Compositor *compositor);
Bool grabbed;
GF_Node *sensor;
} GF_SensorHandler;
Bool compositor_mpeg4_is_sensor_node(GF_Node *node);
GF_SensorHandler *compositor_mpeg4_get_sensor_handler(GF_Node *n);
GF_SensorHandler *compositor_mpeg4_get_sensor_handler_ex(GF_Node *n, Bool skip_anchors);
enum
{
TRAVERSE_SORT = 0,
TRAVERSE_DRAW_2D,
TRAVERSE_PICK,
TRAVERSE_GET_BOUNDS,
TRAVERSE_BINDABLE,
TRAVERSE_GET_TEXT,
#ifndef GPAC_DISABLE_3D
TRAVERSE_DRAW_3D,
TRAVERSE_LIGHTING,
TRAVERSE_COLLIDE,
#endif
};
typedef struct _group_cache_candidate GF_CacheCandidate;
#define MAX_USER_CLIP_PLANES 4
struct _traversing_state
{
struct _audio_group *audio_parent;
struct _soundinterface *sound_holder;
#ifndef GPAC_DISABLE_SVG
SVGPropertiesPointers *svg_props;
u32 svg_flags;
#endif
u32 traversing_mode;
Bool immediate_draw;
Bool immediate_for_defer;
Bool switched_off;
Bool disable_cull;
Bool is_layer;
Bool pixel_metrics;
Fixed min_hsize;
Bool fliped_coords;
SFVec2f vp_size;
GF_VisualManager *visual;
#ifndef GPAC_DISABLE_VRML
GF_List *backgrounds;
GF_List *viewpoints;
#endif
GF_Matrix2D transform;
GF_ColorMatrix color_mat;
GF_Matrix2D vb_transform;
GF_ColorKey *col_key;
Bool invalidate_all;
u32 text_split_mode;
u32 text_split_idx;
GF_List *vrml_sensors;
GF_Node *appear;
struct _parent_node_2d *parent;
GF_Node *override_appearance;
GF_Rect bounds;
GF_Node *for_node;
Bool abort_bounds_traverse;
GF_Matrix2D mx_at_node;
Bool ignore_strike;
GF_List *use_stack;
#ifndef GPAC_DISABLE_SVG
SVG_Number *parent_use_opacity;
SVGAllAttributes *parent_anim_atts;
Bool parent_is_use;
Bool in_svg_text;
Bool in_svg_text_area;
u32 chunk_index;
Fixed text_end_x, text_end_y;
GF_List *x_anchors;
SVG_Coordinates *text_x, *text_y, *text_rotate;
u32 count_x, count_y, count_rotate, idx_rotate;
Fixed max_length, max_height;
Fixed base_x, base_y;
Fixed line_spacing;
Fixed base_shift;
u32 last_char_type;
u32 refresh_children_bounds;
#endif
GF_Node *text_parent;
struct _drawable_context *ctx;
GF_Ray ray;
s32 pick_x, pick_y;
Bool has_clip, has_layer_clip;
GF_Rect clipper, layer_clipper;
GF_Matrix layer_matrix;
Bool in_group_cache;
Bool in_svg_filter;
u32 subscene_not_over;
#ifndef GPAC_DISABLE_3D
GF_Camera *camera;
GF_Matrix model_matrix;
#ifndef GPAC_DISABLE_VRML
GF_List *fogs;
GF_List *navigations;
#endif
Bool mesh_is_transparent;
u32 mesh_num_textures;
GF_BBox bbox;
u32 cull_flag;
Bool local_light_on;
GF_List *local_lights;
GF_Plane clip_planes[MAX_USER_CLIP_PLANES];
u32 num_clip_planes;
GF_Node *layer3d;
#endif
#ifdef GF_SR_USE_DEPTH
Fixed depth_gain, depth_offset;
#endif
#ifdef GF_SR_USE_VIDEO_CACHE
Bool cache_too_small;
#endif
};
typedef struct _audiointerface
{
char *(*FetchFrame) (void *callback, u32 *size, u32 audio_delay_ms);
void (*ReleaseFrame) (void *callback, u32 nb_bytes);
Fixed (*GetSpeed)(void *callback);
Bool (*GetChannelVolume)(void *callback, Fixed *vol);
Bool (*IsMuted)(void *callback);
void *callback;
Bool (*GetConfig)(struct _audiointerface *ai, Bool for_reconf);
u32 chan, bps, samplerate, ch_cfg;
} GF_AudioInterface;
typedef struct __audiomix GF_AudioMixer;
GF_AudioMixer *gf_mixer_new(struct _audio_render *ar);
void gf_mixer_del(GF_AudioMixer *am);
void gf_mixer_remove_all(GF_AudioMixer *am);
void gf_mixer_add_input(GF_AudioMixer *am, GF_AudioInterface *src);
void gf_mixer_remove_input(GF_AudioMixer *am, GF_AudioInterface *src);
void gf_mixer_lock(GF_AudioMixer *am, Bool lockIt);
u32 gf_mixer_get_output(GF_AudioMixer *am, void *buffer, u32 buffer_size, u32 delay_ms);
Bool gf_mixer_reconfig(GF_AudioMixer *am);
void gf_mixer_get_config(GF_AudioMixer *am, u32 *outSR, u32 *outCH, u32 *outBPS, u32 *outChCfg);
void gf_mixer_set_config(GF_AudioMixer *am, u32 outSR, u32 outCH, u32 outBPS, u32 ch_cfg);
Bool gf_mixer_is_src_present(GF_AudioMixer *am, GF_AudioInterface *ifce);
u32 gf_mixer_get_src_count(GF_AudioMixer *am);
void gf_mixer_force_chanel_out(GF_AudioMixer *am, u32 num_channels);
u32 gf_mixer_get_block_align(GF_AudioMixer *am);
Bool gf_mixer_must_reconfig(GF_AudioMixer *am);
Bool gf_mixer_empty(GF_AudioMixer *am);
struct _audiofilterentry
{
struct _audiofilterentry *next;
u32 in_block_size;
char *in_block;
u32 nb_bytes;
u32 delay_ms;
Bool enable, in_place;
GF_AudioFilter *filter;
};
typedef struct
{
Bool enable_filters;
struct _audiofilterentry *filters;
char *tmp_block1, *tmp_block2;
u32 min_block_size, max_block_size, delay_ms;
} GF_AudioFilterChain;
GF_Err gf_afc_load(GF_AudioFilterChain *afc, GF_User *user, char *filterstring);
GF_Err gf_afc_setup(GF_AudioFilterChain *afc, u32 bps, u32 sr, u32 chan, u32 ch_cfg, u32 *ch_out, u32 *ch_cfg_out);
u32 gf_afc_process(GF_AudioFilterChain *afc, u32 nb_bytes);
void gf_afc_unload(GF_AudioFilterChain *afc);
void gf_afc_reset(GF_AudioFilterChain *afc);
typedef struct _audio_render
{
GF_AudioOutput *audio_out;
Bool disable_resync;
Bool disable_multichannel;
Bool clock_use_audio_out;
Bool Frozen;
u64 start_time;
u64 freeze_time;
u32 current_time, bytes_per_second, time_at_last_config;
u64 bytes_requested;
GF_AudioMixer *mixer;
Bool need_reconfig;
GF_User *user;
u32 config_forced;
GF_List *audio_listeners;
GF_Thread *th;
u32 audio_th_state;
u32 audio_delay, volume, pan, mute;
GF_AudioFilterChain filter_chain;
u32 nb_filled, nb_used;
Bool step_mode;
} GF_AudioRenderer;
GF_AudioRenderer *gf_sc_ar_load(GF_User *user);
void gf_sc_ar_del(GF_AudioRenderer *ar);
enum
{
GF_SC_AR_PAUSE=0,
GF_SC_AR_RESUME,
GF_SC_AR_RESET_HW_AND_PLAY,
};
void gf_sc_ar_control(GF_AudioRenderer *ar, u32 CtrlType);
void gf_sc_ar_set_volume(GF_AudioRenderer *ar, u32 Volume);
void gf_sc_ar_set_pan(GF_AudioRenderer *ar, u32 Balance);
void gf_sc_ar_mute(GF_AudioRenderer *ar, Bool mute);
void gf_sc_ar_set_priority(GF_AudioRenderer *ar, u32 priority);
u32 gf_sc_ar_get_clock(GF_AudioRenderer *ar);
void gf_sc_ar_reset(GF_AudioRenderer *ar);
void gf_sc_ar_add_src(GF_AudioRenderer *ar, GF_AudioInterface *source);
void gf_sc_ar_remove_src(GF_AudioRenderer *ar, GF_AudioInterface *source);
void gf_sc_ar_reconfig(GF_AudioRenderer *ar);
u32 gf_sc_ar_get_delay(GF_AudioRenderer *ar);
void gf_sc_flush_next_audio(GF_Compositor *compositor);
Bool gf_sc_check_audio_pending(GF_Compositor *compositor);
typedef struct _soundinterface
{
Bool (*GetChannelVolume)(GF_Node *owner, Fixed *vol);
u8 (*GetPriority) (GF_Node *owner);
GF_Node *owner;
} GF_SoundInterface;
typedef struct __audiofilteritem GF_AudioFilterItem;
typedef struct
{
GF_Node *owner;
GF_Compositor *compositor;
GF_AudioInterface input_ifce;
GF_MediaObject *stream;
Fixed speed, intensity;
Bool stream_finished;
Bool need_release;
u32 is_open;
Bool is_muted;
Bool register_with_renderer, register_with_parent;
GF_SoundInterface *snd;
GF_AudioFilterItem *filter;
} GF_AudioInput;
void gf_sc_audio_setup(GF_AudioInput *ai, GF_Compositor *sr, GF_Node *node);
void gf_sc_audio_predestroy(GF_AudioInput *ai);
GF_Err gf_sc_audio_open(GF_AudioInput *ai, MFURL *url, Double clipBegin, Double clipEnd, Bool lock_timeline);
void gf_sc_audio_stop(GF_AudioInput *ai);
void gf_sc_audio_restart(GF_AudioInput *ai);
Bool gf_sc_audio_check_url(GF_AudioInput *ai, MFURL *url);
#define AUDIO_GROUP_NODE \
GF_AudioInput output; \
void (*add_source)(struct _audio_group *_this, GF_AudioInput *src); \
typedef struct _audio_group
{
AUDIO_GROUP_NODE
} GF_AudioGroup;
void gf_sc_audio_register(GF_AudioInput *ai, GF_TraverseState *tr_state);
void gf_sc_audio_unregister(GF_AudioInput *ai);
#ifndef GPAC_DISABLE_SVG
GF_Err gf_term_get_mfurl_from_xlink(GF_Node *node, MFURL *mfurl);
Fixed gf_sc_svg_convert_length_to_display(GF_Compositor *sr, SVG_Length *length);
char *gf_term_resolve_xlink(GF_Node *node, char *the_url);
#endif
GF_Err compositor_2d_set_aspect_ratio(GF_Compositor *sr);
void compositor_2d_set_user_transform(GF_Compositor *sr, Fixed zoom, Fixed tx, Fixed ty, Bool is_resize) ;
GF_Err compositor_2d_get_video_access(GF_VisualManager *surf);
void compositor_2d_release_video_access(GF_VisualManager *surf);
void compositor_2d_init_callbacks(GF_Compositor *compositor);
GF_Rect compositor_2d_update_clipper(GF_TraverseState *tr_state, GF_Rect this_clip, Bool *need_restore, GF_Rect *original, Bool for_layer);
Bool compositor_2d_check_attached(GF_VisualManager *visual);
void compositor_2d_clear_surface(GF_VisualManager *visual, GF_IRect *rc, u32 BackColor, u32 is_offscreen);
#ifndef GPAC_DISABLE_3D
void compositor_2d_reset_gl_auto(GF_Compositor *compositor);
void compositor_2d_hybgl_flush_video(GF_Compositor *compositor, GF_IRect *area);
void compositor_2d_hybgl_clear_surface(GF_VisualManager *visual, GF_IRect *rc, u32 BackColor, u32 is_offscreen_clear);
#endif
Bool compositor_texture_rectangles(GF_VisualManager *visual, GF_TextureHandler *txh, GF_IRect *clip, GF_Rect *unclip, GF_Window *src, GF_Window *dst, Bool *disable_blit, Bool *has_scale);
Bool compositor_get_2d_plane_intersection(GF_Ray *ray, SFVec3f *res);
void compositor_send_resize_event(GF_Compositor *compositor, GF_SceneGraph *subscene, Fixed old_z, Fixed old_tx, Fixed old_ty, Bool is_resize);
void compositor_set_cache_memory(GF_Compositor *compositor, u32 memory);
Bool compositor_background_transparent(GF_Node *node);
#ifndef GPAC_DISABLE_3D
GF_Err compositor_3d_set_aspect_ratio(GF_Compositor *sr);
GF_Camera *compositor_3d_get_camera(GF_Compositor *sr);
void compositor_3d_reset_camera(GF_Compositor *sr);
GF_Camera *compositor_layer3d_get_camera(GF_Node *node);
void compositor_layer3d_bind_camera(GF_Node *node, Bool do_bind, u32 nav_value);
void compositor_3d_draw_bitmap(struct _drawable *stack, DrawAspect2D *asp, GF_TraverseState *tr_state, Fixed width, Fixed height, Fixed bmp_scale_x, Fixed bmp_scale_y);
GF_Err compositor_3d_get_screen_buffer(GF_Compositor *sr, GF_VideoSurface *fb, u32 depth_buffer_mode);
GF_Err compositor_3d_get_offscreen_buffer(GF_Compositor *sr, GF_VideoSurface *fb, u32 view_idx, u32 depth_buffer_mode);
GF_Err compositor_3d_release_screen_buffer(GF_Compositor *sr, GF_VideoSurface *framebuffer);
void gf_sc_load_opengl_extensions(GF_Compositor *sr, Bool has_gl_context);
Bool gf_sc_fit_world_to_screen(GF_Compositor *compositor);
#endif
Bool gf_sc_exec_event(GF_Compositor *sr, GF_Event *evt);
void gf_sc_get_nodes_bounds(GF_Node *self, GF_ChildNodeItem *children, GF_TraverseState *tr_state, s32 *child_idx);
Bool gf_sc_exec_event_vrml(GF_Compositor *compositor, GF_Event *ev);
void gf_sc_visual_register(GF_Compositor *sr, GF_VisualManager *surf);
void gf_sc_visual_unregister(GF_Compositor *sr, GF_VisualManager *surf);
Bool gf_sc_visual_is_registered(GF_Compositor *sr, GF_VisualManager *surf);
Bool gf_sc_pick_in_clipper(GF_TraverseState *tr_state, GF_Rect *clip);
void compositor_gradient_update(GF_TextureHandler *txh);
void compositor_set_ar_scale(GF_Compositor *sr, Fixed scaleX, Fixed scaleY);
void gf_sc_check_focus_upon_destroy(GF_Node *n);
void gf_sc_key_navigator_del(GF_Compositor *sr, GF_Node *n);
void gf_sc_change_key_navigator(GF_Compositor *sr, GF_Node *n);
GF_Node *gf_scene_get_keynav(GF_SceneGraph *sg, GF_Node *sensor);
const char *gf_scene_get_service_url(GF_SceneGraph *sg);
Bool gf_scene_is_over(GF_SceneGraph *sg);
GF_SceneGraph *gf_scene_enum_extra_scene(GF_SceneGraph *sg, u32 *i);
Bool gf_scene_is_dynamic_scene(GF_SceneGraph *sg);
#ifndef GPAC_DISABLE_SVG
void compositor_svg_build_gradient_texture(GF_TextureHandler *txh);
Bool compositor_svg_traverse_base(GF_Node *node, SVGAllAttributes *all_atts, GF_TraverseState *tr_state, SVGPropertiesPointers *backup_props, u32 *backup_flags);
Bool compositor_svg_is_display_off(SVGPropertiesPointers *props);
void compositor_svg_apply_local_transformation(GF_TraverseState *tr_state, SVGAllAttributes *atts, GF_Matrix2D *backup_matrix_2d, GF_Matrix *backup_matrix);
void compositor_svg_restore_parent_transformation(GF_TraverseState *tr_state, GF_Matrix2D *backup_matrix_2d, GF_Matrix *backup_matrix);
void compositor_svg_traverse_children(GF_ChildNodeItem *children, GF_TraverseState *tr_state);
Bool compositor_svg_evaluate_conditional(GF_Compositor *compositor, SVGAllAttributes *all_atts);
GF_Node *compositor_svg_get_xlink_resource_node(GF_Node *node, XMLRI *xlink);
GF_SceneGraph *gf_sc_animation_get_scenegraph(GF_Node *node);
#endif
#define GF_CARET_CHAR 0x1
typedef struct _gf_font GF_Font;
struct _gf_font
{
GF_Font *next;
GF_Glyph *glyph;
char *name;
u32 em_size;
u32 styles;
s32 ascent, descent, underline, line_spacing, max_advance_h, max_advance_v;
s32 baseline;
GF_Font *(*get_alias)(void *udta);
GF_Err (*get_glyphs)(void *udta, const char *utf_string, u32 *glyph_ids_buffer, u32 *io_glyph_ids_buffer_size, const char *xml_lang, Bool *is_rtl);
GF_Glyph *(*load_glyph)(void *udta, u32 glyph_name);
void *udta;
Bool not_loaded;
struct _gf_ft_mgr *ft_mgr;
GF_List *spans;
};
enum
{
GF_TEXT_SPAN_HORIZONTAL = 1,
GF_TEXT_SPAN_UNDERLINE = 1<<1,
GF_TEXT_SPAN_FLIP = 1<<2,
GF_TEXT_SPAN_RIGHT_TO_LEFT = 1<<3,
GF_TEXT_SPAN_SELECTED = 1<<4
};
typedef struct __text_span
{
GF_Font *font;
GF_Glyph **glyphs;
u32 nb_glyphs;
u32 flags;
Fixed font_size;
Fixed font_scale;
GF_Rect bounds;
Fixed x_scale, y_scale;
Fixed off_x, off_y;
Fixed *dx, *dy, *rot;
struct _span_internal *ext;
GF_Node *anchor;
GF_Node *user;
} GF_TextSpan;
GF_FontManager *gf_font_manager_new(GF_User *user);
void gf_font_manager_del(GF_FontManager *fm);
GF_Font *gf_font_manager_set_font(GF_FontManager *fm, char **alt_fonts, u32 nb_fonts, u32 styles);
GF_Font *gf_font_manager_set_font_ex(GF_FontManager *fm, char **alt_fonts, u32 nb_fonts, u32 styles, Bool check_only);
GF_TextSpan *gf_font_manager_create_span(GF_FontManager *fm, GF_Font *font, char *span, Fixed font_size, Bool needs_x_offset, Bool needs_y_offset, Bool needs_rotate, const char *lang, Bool fliped_text, u32 styles, GF_Node *user);
void gf_font_manager_delete_span(GF_FontManager *fm, GF_TextSpan *tspan);
GF_Err gf_font_manager_register_font(GF_FontManager *fm, GF_Font *font);
GF_Err gf_font_manager_unregister_font(GF_FontManager *fm, GF_Font *font);
void gf_font_manager_refresh_span_bounds(GF_TextSpan *span);
GF_Path *gf_font_span_create_path(GF_TextSpan *span);
void gf_font_spans_draw_2d(GF_List *spans, GF_TraverseState *tr_state, u32 hl_color, Bool force_texture_text, GF_Rect *bounds);
void gf_font_spans_draw_3d(GF_List *spans, GF_TraverseState *tr_state, DrawAspect2D *asp, u32 text_hl, Bool force_texturing);
void gf_font_spans_pick(GF_Node *node, GF_List *spans, GF_TraverseState *tr_state, GF_Rect *node_bounds, Bool use_dom_events, struct _drawable *drawable);
void gf_font_spans_get_selection(GF_Node *node, GF_List *spans, GF_TraverseState *tr_state);
GF_Font *gf_compositor_svg_set_font(GF_FontManager *fm, char *a_font, u32 styles, Bool check_only);
u32 gf_sc_focus_switch_ring(GF_Compositor *compositor, Bool move_prev, GF_Node *focus, u32 force_focus_type);
Bool compositor_handle_navigation(GF_Compositor *compositor, GF_Event *ev);
void gf_sc_next_frame_state(GF_Compositor *compositor, u32 state);
#ifdef GPAC_USE_TINYGL
void gf_get_tinygl_depth(GF_TextureHandler *txh);
#endif
typedef struct
{
void *udta;
void (*on_video_frame)(void *udta, u32 time);
void (*on_video_reconfig)(void *udta, u32 width, u32 height, u8 bpp);
} GF_VideoListener;
GF_Err gf_sc_add_video_listener(GF_Compositor *compositor, GF_VideoListener *vl);
GF_Err gf_sc_remove_video_listener(GF_Compositor *compositor, GF_VideoListener *vl);
typedef struct
{
void *udta;
void (*on_audio_frame)(void *udta, char *buffer, u32 buffer_size, u32 time, u32 delay);
void (*on_audio_reconfig)(void *udta, u32 samplerate, u32 bits_per_sample, u32 nb_channel, u32 channel_cfg);
} GF_AudioListener;
GF_Err gf_sc_add_audio_listener(GF_Compositor *compositor, GF_AudioListener *al);
GF_Err gf_sc_remove_audio_listener(GF_Compositor *compositor, GF_AudioListener *al);
GF_Err gf_sc_set_scene_size(GF_Compositor *compositor, u32 Width, u32 Height, Bool force_size);
Bool gf_sc_use_raw_texture(GF_Compositor *compositor);
void gf_sc_get_av_caps(GF_Compositor *compositor, u32 *width, u32 *height, u32 *display_bit_depth, u32 *audio_bpp, u32 *channels, u32 *sample_rate);
void gf_sc_set_system_pending_frame(GF_Compositor *compositor, Bool frame_pending);
void gf_sc_set_video_pending_frame(GF_Compositor *compositor);
Bool gf_sc_is_over(GF_Compositor *compositor, GF_SceneGraph *scene_graph);
Bool gf_sc_navigation_supported(GF_Compositor *compositor, u32 type);
Bool gf_sc_use_3d(GF_Compositor *compositor);
#ifdef __cplusplus
}
#endif
#endif