void svg_pause_animation(GF_Node *n, Bool pause) { SVGlinkStack *st = gf_node_get_private(n); if (!st) return; if (pause) gf_mo_pause(st->resource); else gf_mo_resume(st->resource); }
void svg_pause_audio(GF_Node *n, Bool pause) { SVG_audio_stack *st = (SVG_audio_stack *)gf_node_get_private(n); if (!st) return; if (pause) gf_mo_pause(st->input.stream); else gf_mo_resume(st->input.stream); }
static void movietexture_update(GF_TextureHandler *txh) { M_MovieTexture *txnode = (M_MovieTexture *) txh->owner; MovieTextureStack *st = (MovieTextureStack *) gf_node_get_private(txh->owner); /*setup texture if needed*/ if (!txh->is_open) return; if (!txnode->isActive && st->first_frame_fetched) return; /*when fetching the first frame disable resync*/ gf_sc_texture_update_frame(txh, 0); if (txh->stream_finished) { if (movietexture_get_loop(st, txnode)) { gf_sc_texture_restart(txh); } /*if active deactivate*/ else if (txnode->isActive && gf_mo_should_deactivate(st->txh.stream) ) { movietexture_deactivate(st, txnode); } } /*first frame is fetched*/ if (!st->first_frame_fetched && (txh->needs_refresh) ) { st->first_frame_fetched = 1; txnode->duration_changed = gf_mo_get_duration(txh->stream); gf_node_event_out(txh->owner, 7/*"duration_changed"*/); /*stop stream if needed*/ if (!txnode->isActive && txh->is_open) { gf_mo_pause(txh->stream); /*make sure the refresh flag is not cleared*/ txh->needs_refresh = 1; gf_sc_invalidate(txh->compositor, NULL); } } if (txh->needs_refresh) { /*mark all subtrees using this image as dirty*/ gf_node_dirty_parents(txh->owner); } }
static void svg_traverse_animation(GF_Node *node, void *rs, Bool is_destroy) { SVGAllAttributes all_atts; GF_Matrix2D backup_matrix; GF_Matrix backup_matrix3d; SVGPropertiesPointers backup_props; u32 backup_flags; SFVec2f prev_vp; GF_Rect rc; GF_IRect clip, prev_clip; SVGAllAttributes *prev_vp_atts; GF_TraverseState *tr_state = (GF_TraverseState*)rs; GF_Matrix2D translate; SVGPropertiesPointers *old_props; SVGlinkStack *stack = gf_node_get_private(node); if (is_destroy) { if (stack->resource) gf_mo_unload_xlink_resource(node, stack->resource); gf_free(stack); return; } gf_svg_flatten_attributes((SVG_Element *)node, &all_atts); if (!stack->inline_sg && !stack->resource) { if (!stack->init_vis_state) { if (all_atts.initialVisibility && (*all_atts.initialVisibility==SVG_INITIALVISIBILTY_ALWAYS)) { stack->init_vis_state = 2; svg_animation_smil_update(node, stack, 0); } else { stack->init_vis_state = 1; } } if (!stack->inline_sg && !stack->resource) return; } if (!all_atts.width || !all_atts.height) return; if (!all_atts.width->value || !all_atts.height->value) return; if (!compositor_svg_traverse_base(node, &all_atts, tr_state, &backup_props, &backup_flags)) return; if (compositor_svg_is_display_off(tr_state->svg_props) || *(tr_state->svg_props->visibility) == SVG_VISIBILITY_HIDDEN) { goto end; } compositor_svg_apply_local_transformation(tr_state, &all_atts, &backup_matrix, &backup_matrix3d); /*add x/y translation*/ gf_mx2d_init(translate); translate.m[2] = (all_atts.x ? all_atts.x->value : 0); translate.m[5] = (all_atts.y ? all_atts.y->value : 0); #ifndef GPAC_DISABLE_3D if (tr_state->visual->type_3d) { gf_mx_add_matrix_2d(&tr_state->model_matrix, &translate); if (tr_state->traversing_mode==TRAVERSE_SORT) { GF_Matrix tmp; gf_mx_from_mx2d(&tmp, &translate); visual_3d_matrix_add(tr_state->visual, tmp.m); } } else #endif gf_mx2d_pre_multiply(&tr_state->transform, &translate); /*reset SVG props to reload a new inheritance context*/ old_props = tr_state->svg_props; tr_state->svg_props = NULL; /*store this node's attribute to compute PAR/ViewBox of the child <svg>*/ prev_vp_atts = tr_state->parent_anim_atts; tr_state->parent_anim_atts = &all_atts; /*update VP size*/ prev_vp = tr_state->vp_size; tr_state->vp_size.x = gf_sc_svg_convert_length_to_display(tr_state->visual->compositor, all_atts.width); tr_state->vp_size.y = gf_sc_svg_convert_length_to_display(tr_state->visual->compositor, all_atts.height); /*setup new clipper*/ rc.width = tr_state->vp_size.x; rc.height = tr_state->vp_size.y; rc.x = 0; rc.y = tr_state->vp_size.y; gf_mx2d_apply_rect(&tr_state->transform, &rc); prev_clip = tr_state->visual->top_clipper; clip = gf_rect_pixelize(&rc); // gf_irect_intersect(&tr_state->visual->top_clipper, &clip); if (!stack->inline_sg && stack->resource) { stack->inline_sg = gf_mo_get_scenegraph(stack->resource); } if (stack->inline_sg) { gf_sc_traverse_subscene(tr_state->visual->compositor, node, stack->inline_sg, tr_state); } if (stack->init_vis_state == 2) { stack->init_vis_state = 3; gf_mo_pause(stack->resource); } tr_state->svg_props = old_props; tr_state->visual->top_clipper = prev_clip; tr_state->parent_anim_atts = prev_vp_atts; tr_state->vp_size = prev_vp; compositor_svg_restore_parent_transformation(tr_state, &backup_matrix, &backup_matrix3d); end: memcpy(tr_state->svg_props, &backup_props, sizeof(SVGPropertiesPointers)); tr_state->svg_flags = backup_flags; }