static void UpdateRadialGradient(GF_TextureHandler *txh) { u32 i; M_RadialGradient *rg = (M_RadialGradient*) txh->owner; GradientStack *st = (GradientStack *) gf_node_get_private(txh->owner); if (!txh->hwtx) txh->hwtx = txh->compositor->r2d->stencil_new(txh->compositor->r2d, GF_STENCIL_RADIAL_GRADIENT); if (!gf_node_dirty_get(txh->owner)) return; gf_node_dirty_clear(txh->owner, 0); txh->needs_refresh = 1; st->txh.transparent = 0; for (i=0; i<rg->opacity.count; i++) { if (rg->opacity.vals[i] != FIX_ONE) { st->txh.transparent = 1; break; } } }
static void movietexture_update_time(GF_TimeNode *st) { Double time; M_MovieTexture *mt = (M_MovieTexture *)st->udta; MovieTextureStack *stack = (MovieTextureStack *)gf_node_get_private(st->udta); /*not active, store start time and speed*/ if ( ! mt->isActive) { stack->start_time = mt->startTime; } time = gf_node_get_scene_time(st->udta); if (time < stack->start_time || /*special case if we're getting active AFTER stoptime */ (!mt->isActive && (mt->stopTime > stack->start_time) && (time>=mt->stopTime)) // || (!stack->start_time && !stack->is_x3d && !mt->loop) ) { /*opens stream only at first access to fetch first frame*/ if (stack->fetch_first_frame) { stack->fetch_first_frame = 0; if (!stack->txh.is_open) gf_sc_texture_play(&stack->txh, &mt->url); else gf_mo_resume(stack->txh.stream); } return; } if (movietexture_get_speed(stack, mt) && mt->isActive) { /*if stoptime is reached (>startTime) deactivate*/ if ((mt->stopTime > stack->start_time) && (time >= mt->stopTime) ) { movietexture_deactivate(stack, mt); return; } } /*we're (about to be) active: VRML: "A time-dependent node is inactive until its startTime is reached. When time now becomes greater than or equal to startTime, an isActive TRUE event is generated and the time-dependent node becomes active */ if (! mt->isActive) movietexture_activate(stack, mt, time); stack->txh.stream_finished = GF_FALSE; }
static void TraverseIndexedCurve2D(GF_Node *node, void *rs, Bool is_destroy) { DrawableContext *ctx; IndexedCurve2D ic2d; GF_TraverseState *tr_state = (GF_TraverseState *)rs; Drawable *stack = (Drawable *)gf_node_get_private(node); if (is_destroy) { drawable_node_del(node); return; } if (gf_node_dirty_get(node)) { if (!IndexedCurve2D_GetNode(node, &ic2d)) return; curve2d_check_changes((GF_Node*) &ic2d, stack, tr_state, &ic2d.index); } switch (tr_state->traversing_mode) { #ifndef GPAC_DISABLE_3D case TRAVERSE_DRAW_3D: if (!stack->mesh) { stack->mesh = new_mesh(); mesh_from_path(stack->mesh, stack->path); } visual_3d_draw_2d(stack, tr_state); return; #endif case TRAVERSE_PICK: vrml_drawable_pick(stack, tr_state); return; case TRAVERSE_GET_BOUNDS: gf_path_get_bounds(stack->path, &tr_state->bounds); return; case TRAVERSE_SORT: #ifndef GPAC_DISABLE_3D if (tr_state->visual->type_3d) return; #endif ctx = drawable_init_context_mpeg4(stack, tr_state); if (!ctx) return; drawable_finalize_sort(ctx, tr_state, NULL); return; } }
static Bool audiobuffer_get_config(GF_AudioInterface *aifc, Bool for_reconf) { AudioBufferStack *st = (AudioBufferStack *) gf_node_get_private( ((GF_AudioInput *) aifc->callback)->owner); if (gf_mixer_must_reconfig(st->am)) { if (gf_mixer_reconfig(st->am)) { if (st->buffer) gf_free(st->buffer); st->buffer = NULL; st->buffer_size = 0; } gf_mixer_get_config(st->am, &aifc->samplerate, &aifc->chan, &aifc->bps, &aifc->ch_cfg); st->is_init = (aifc->samplerate && aifc->chan && aifc->bps) ? 1 : 0; assert(st->is_init); if (!st->is_init) aifc->samplerate = aifc->chan = aifc->bps = aifc->ch_cfg = 0; /*this will force invalidation*/ return (for_reconf && st->is_init) ? 1 : 0; } return st->is_init; }
static void svg_traverse_filter(GF_Node *node, void *rs, Bool is_destroy) { GF_TraverseState *tr_state = (GF_TraverseState *)rs; GF_FilterStack *st = gf_node_get_private(node); if (is_destroy) { drawable_del(st->drawable); if (st->data) gf_free(st->data); st->txh.data = NULL; gf_sc_texture_release(&st->txh); gf_sc_texture_destroy(&st->txh); gf_free(st); return; } if (tr_state->traversing_mode==TRAVERSE_DRAW_2D) { if (! tr_state->visual->DrawBitmap(tr_state->visual, tr_state, tr_state->ctx, NULL)) { visual_2d_texture_path(tr_state->visual, st->drawable->path, tr_state->ctx, tr_state); } } }
static void svg2bifs_node_end(void *sax_cbck, const char *name, const char *name_space) { SVG2BIFS_Converter *converter = (SVG2BIFS_Converter *)sax_cbck; GF_Node *parent; SVGPropertiesPointers *backup_props = gf_node_get_private(converter->svg_parent); memcpy(&converter->svg_props, backup_props, sizeof(SVGPropertiesPointers)); // gf_free(backup_props); gf_node_set_private(converter->svg_parent, NULL); if (!(gf_node_get_tag(converter->svg_parent) == TAG_SVG_animateTransform)) converter->bifs_parent = gf_node_get_parent(converter->bifs_parent, 0); parent = gf_node_get_parent(converter->svg_parent, 0); gf_node_unregister(converter->svg_parent, parent); if (!parent) gf_sg_set_root_node(converter->svg_sg, NULL); converter->svg_parent = parent; converter->bifs_text_node = NULL; fprintf(stdout, "END:\t%s\t%s\n", converter->svg_parent ? gf_node_get_class_name(converter->svg_parent) : "none", converter->bifs_parent ? gf_node_get_class_name(converter->bifs_parent) : "none"); }
/*check only URL changes*/ void InputSensorModified(GF_Node *node) { GF_MediaObject *mo; ISStack *st = (ISStack *)gf_node_get_private(node); mo = gf_mo_register(node, &st->is->url, 0, 0); if ((mo!=st->mo) || !st->registered){ if (mo!=st->mo) { if (st->mo) IS_Unregister(node, st); st->mo = mo; } if (st->is->enabled) IS_Register(node); else return; } else if (!st->is->enabled) { IS_Unregister(node, st); return; } }
void compositor_movietexture_modified(GF_Node *node) { M_MovieTexture *mt = (M_MovieTexture *)node; MovieTextureStack *st = (MovieTextureStack *) gf_node_get_private(node); if (!st) return; /*if open and changed, stop and play*/ if (gf_sc_texture_check_url_change(&st->txh, &mt->url)) { if (st->txh.is_open) gf_sc_texture_stop(&st->txh); if (mt->isActive) gf_sc_texture_play(&st->txh, &mt->url); } /*update state if we're active*/ else if (mt->isActive) { movietexture_update_time(&st->time_handle); if (!mt->isActive) return; } /*reregister if needed*/ st->time_handle.needs_unregister = 0; if (!st->time_handle.is_registered) gf_sc_register_time_node(st->txh.compositor, &st->time_handle); }
static void svg_sani_render_polygon(GF_Node *node, void *rs, Bool is_destroy) { SVG_SANI_polygonElement *polygon = (SVG_SANI_polygonElement *)node; Drawable *cs = (Drawable *)gf_node_get_private(node); RenderEffect2D *eff = (RenderEffect2D *)rs; if (is_destroy) { DestroyDrawableNode(node); return; } if (eff->traversing_mode==TRAVERSE_DRAW) { drawable_draw(eff); return; } else if (eff->traversing_mode==TRAVERSE_PICK) { drawable_pick(eff); return; } svg_sani_render_base(node, (RenderEffect2D *)rs); if (gf_node_dirty_get(node) & GF_SG_SVG_GEOMETRY_DIRTY) { u32 i; u32 nbPoints = gf_list_count(polygon->points); drawable_reset_path(cs); if (nbPoints) { SVG_Point *p = (SVG_Point *)gf_list_get(polygon->points, 0); gf_path_add_move_to(cs->path, p->x, p->y); for (i = 1; i < nbPoints; i++) { p = (SVG_Point *)gf_list_get(polygon->points, i); gf_path_add_line_to(cs->path, p->x, p->y); } gf_path_close(cs->path); } else { gf_path_add_move_to(cs->path, 0, 0); } gf_node_dirty_clear(node, GF_SG_SVG_GEOMETRY_DIRTY); cs->flags |= DRAWABLE_HAS_CHANGED; } svg_sani_DrawablePostRender(cs, (SVG_SANI_TransformableElement *)polygon, (RenderEffect2D *)rs, 0, 0); }
/*this is ugly but we have no choice, we need to clone the conditional stack because of externProto*/ void BIFS_SetupConditionalClone(GF_Node *node, GF_Node *orig) { #ifndef GPAC_DISABLE_BIFS M_Conditional *ptr; ConditionalStack *priv_orig, *priv; priv_orig = (ConditionalStack*)gf_node_get_private(orig); /*looks we're not in BIFS*/ if (!priv_orig) { #else { #endif #ifndef GPAC_DISABLE_VRML u32 i; GF_Command *ori_com; M_Conditional *c_orig, *c_dest; c_orig = (M_Conditional *)orig; c_dest = (M_Conditional *)node; gf_node_init(node); /*and clone all commands*/ i=0; while ((ori_com = (GF_Command*)gf_list_enum(c_orig->buffer.commandList, &i))) { GF_Command *dest_com = gf_sg_vrml_command_clone(ori_com, gf_node_get_graph(node), 1); if (dest_com) gf_list_add(c_dest->buffer.commandList, dest_com); } #endif return; } #ifndef GPAC_DISABLE_BIFS priv = (ConditionalStack*)gf_malloc(sizeof(ConditionalStack)); priv->codec = priv_orig->codec; priv->info = priv_orig->info; gf_node_set_callback_function(node, Conditional_PreDestroy); gf_node_set_private(node, priv); ptr = (M_Conditional *)node; ptr->on_activate = Conditional_OnActivate; ptr->on_reverseActivate = Conditional_OnReverseActivate; #endif }
static void DestroyBackground2D(GF_Node *node) { Background2DStack *stack = (Background2DStack *) gf_node_get_private(node); PreDestroyBindable(node, stack->reg_stacks); gf_list_del(stack->reg_stacks); while (gf_list_count(stack->status_stack)) { BackgroundStatus *status = (BackgroundStatus *)gf_list_get(stack->status_stack, 0); gf_list_rem(stack->status_stack, 0); gf_free(status); } gf_list_del(stack->status_stack); drawable_del(stack->drawable); gf_sc_texture_destroy(&stack->txh); #ifndef GPAC_DISABLE_3D if (stack->mesh) mesh_free(stack->mesh); #endif gf_free(stack); }
void compositor_background2d_modified(GF_Node *node) { M_Background2D *bck = (M_Background2D *)node; Background2DStack *st = (Background2DStack *) gf_node_get_private(node); if (!st) return; /*dirty node and parents in order to trigger parent visual redraw*/ gf_node_dirty_set(node, 0, 1); /*if open and changed, stop and play*/ if (st->txh.is_open) { if (! gf_sc_texture_check_url_change(&st->txh, &bck->url)) return; gf_sc_texture_stop(&st->txh); gf_sc_texture_play(&st->txh, &bck->url); return; } /*if not open and changed play*/ if (bck->url.count) gf_sc_texture_play(&st->txh, &bck->url); gf_sc_invalidate(st->txh.compositor, NULL); }
static void audiosource_update_time(GF_TimeNode *tn) { Double time; M_AudioSource *as = (M_AudioSource *)tn->udta; AudioSourceStack *st = (AudioSourceStack *)gf_node_get_private(tn->udta); if (! st->is_active) { st->start_time = as->startTime; st->input.speed = as->speed; } time = gf_node_get_scene_time(tn->udta); if ((time<st->start_time) || (st->start_time<0)) return; if (st->input.input_ifce.GetSpeed(st->input.input_ifce.callback) && st->is_active) { if ( (as->stopTime > st->start_time) && (time>=as->stopTime)) { audiosource_deactivate(st, as); return; } } if (!st->is_active) audiosource_activate(st, as); }
static void TraverseDisk2D(GF_Node *node, void *rs, Bool is_destroy) { DrawableContext *ctx; Drawable *stack = (Drawable *)gf_node_get_private(node); GF_TraverseState *tr_state = (GF_TraverseState *)rs; if (is_destroy) { drawable_node_del(node); return; } disk2d_check_changes(node, stack, tr_state); switch (tr_state->traversing_mode) { #ifndef GPAC_DISABLE_3D case TRAVERSE_DRAW_3D: if (!stack->mesh) { stack->mesh = new_mesh(); /*FIXME - enable it with OpenGL-ES*/ mesh_from_path(stack->mesh, stack->path); } visual_3d_draw_2d(stack, tr_state); return; #endif case TRAVERSE_GET_BOUNDS: gf_path_get_bounds(stack->path, &tr_state->bounds); return; case TRAVERSE_PICK: vrml_drawable_pick(stack, tr_state); return; case TRAVERSE_SORT: #ifndef GPAC_DISABLE_3D if (tr_state->visual->type_3d) return; #endif ctx = drawable_init_context_mpeg4(stack, tr_state); if (!ctx) return; drawable_finalize_sort(ctx, tr_state, NULL); return; } }
static void TraverseCircle(GF_Node *node, void *rs, Bool is_destroy) { DrawableContext *ctx; Drawable *stack = (Drawable *)gf_node_get_private(node); GF_TraverseState *tr_state = (GF_TraverseState *)rs; if (is_destroy) { drawable_node_del(node); return; } circle_check_changes(node, stack, tr_state); switch (tr_state->traversing_mode) { #ifndef GPAC_DISABLE_3D case TRAVERSE_DRAW_3D: if (!stack->mesh) { Fixed a = ((M_Circle *) node)->radius * 2; stack->mesh = new_mesh(); mesh_new_ellipse(stack->mesh, a, a, tr_state->visual->compositor->high_speed); } visual_3d_draw_2d(stack, tr_state); return; #endif case TRAVERSE_GET_BOUNDS: gf_path_get_bounds(stack->path, &tr_state->bounds); return; case TRAVERSE_PICK: vrml_drawable_pick(stack, tr_state); return; case TRAVERSE_SORT: #ifndef GPAC_DISABLE_3D if (tr_state->visual->type_3d) return; #endif ctx = drawable_init_context_mpeg4(stack, tr_state); if (!ctx) return; drawable_finalize_sort(ctx, tr_state, NULL); return; } }
/*ColorTransform*/ static void RenderColorTransform(GF_Node *node, void *rs, Bool is_destroy) { Bool c_changed; M_ColorTransform *tr = (M_ColorTransform *)node; ColorTransformStack *ptr = (ColorTransformStack *)gf_node_get_private(node); RenderEffect2D *eff; eff = (RenderEffect2D *) rs; if (is_destroy) { DeleteGroupingNode2D((GroupingNode2D *)ptr); free(ptr); return; } c_changed = 0; if (gf_node_dirty_get(node) & GF_SG_NODE_DIRTY) { gf_cmx_set(&ptr->cmat, tr->mrr , tr->mrg, tr->mrb, tr->mra, tr->tr, tr->mgr , tr->mgg, tr->mgb, tr->mga, tr->tg, tr->mbr, tr->mbg, tr->mbb, tr->mba, tr->tb, tr->mar, tr->mag, tr->mab, tr->maa, tr->ta); c_changed = 1; } /*note we don't clear dirty flag, this is done in traversing*/ if (ptr->cmat.identity) { group2d_traverse((GroupingNode2D *) ptr, tr->children, eff); } else { GF_ColorMatrix gf_cmx_bck; Bool prev_inv = eff->invalidate_all; /*if modified redraw all nodes*/ if (c_changed) eff->invalidate_all = 1; gf_cmx_copy(&gf_cmx_bck, &eff->color_mat); gf_cmx_multiply(&eff->color_mat, &ptr->cmat); group2d_traverse((GroupingNode2D *) ptr, tr->children, eff); /*restore effects*/ gf_cmx_copy(&eff->color_mat, &gf_cmx_bck); eff->invalidate_all = prev_inv; } }
static void TraversePlaneClipper(GF_Node *node, void *rs, Bool is_destroy) { PlaneClipperStack *stack = (PlaneClipperStack *)gf_node_get_private(node); GF_TraverseState *tr_state = (GF_TraverseState *) rs; if (is_destroy) { group_3d_delete(node); return; } if (gf_node_dirty_get(node)) { PlaneClipper_GetNode(node, &stack->pc); } if (tr_state->num_clip_planes==MAX_USER_CLIP_PLANES) { group_3d_traverse((GF_Node*)&stack->pc, (GroupingNode*)stack, tr_state); return; } if (tr_state->traversing_mode == TRAVERSE_SORT) { GF_Matrix mx; gf_mx_copy(mx, tr_state->model_matrix); visual_3d_set_clip_plane(tr_state->visual, stack->pc.plane, &mx, 0); tr_state->num_clip_planes++; group_3d_traverse((GF_Node*)&stack->pc, (GroupingNode*)stack, tr_state); visual_3d_reset_clip_plane(tr_state->visual); tr_state->num_clip_planes--; } else { tr_state->clip_planes[tr_state->num_clip_planes] = stack->pc.plane; gf_mx_apply_plane(&tr_state->model_matrix, &tr_state->clip_planes[tr_state->num_clip_planes]); tr_state->num_clip_planes++; group_3d_traverse((GF_Node*)&stack->pc, (GroupingNode*)stack, tr_state); tr_state->num_clip_planes--; } }
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); } }
void compositor_svg_video_modified(GF_Compositor *compositor, GF_Node *node) { /*if href has been modified, stop the video (and associated audio if any) right away - we cannot wait for next traversal to process this as the video could be in a hidden subtree not traversed*/ if (gf_node_dirty_get(node) & GF_SG_SVG_XLINK_HREF_DIRTY) { SVG_video_stack *st = (SVG_video_stack *)gf_node_get_private(node); /*WARNING - stack may be NULL at this point when inserting the video from script*/ if (st && st->txh.is_open) { if (st->audio) { svg_audio_smil_evaluate_ex(NULL, 0, SMIL_TIMING_EVAL_REMOVE, st->audio, st->txh.owner); gf_node_unregister(st->audio, NULL); st->audio = NULL; } /*reset cached URL to avoid reopening the resource in the smil timing callback*/ gf_sg_vrml_mf_reset(&st->txurl, GF_SG_VRML_MFURL); gf_sc_texture_stop(&st->txh); } } gf_node_dirty_set(node, 0, GF_FALSE); /*and force a redraw of next frame*/ gf_sc_next_frame_state(compositor, GF_SC_DRAW_FRAME); }
static void IS_Register(GF_Node *n) { GF_ObjectManager *odm; ISPriv *is_dec; ISStack *st = (ISStack *)gf_node_get_private(n); odm = st->mo->odm; if (!odm) return; assert(odm->codec && (odm->codec->type == GF_STREAM_INTERACT)); /*get IS dec*/ is_dec = (ISPriv*)odm->codec->decio->privateStack; gf_list_add(is_dec->is_nodes, st); st->registered = 1; #if GPAC_HTK_DEMO StartHTK(is_dec); #endif /*start stream*/ gf_mo_play(st->mo, 0, -1, 0); gf_term_rem_render_node(odm->term, n); }
static void audioclip_update_time(GF_TimeNode *tn) { Double time; M_AudioClip *ac = (M_AudioClip *)tn->udta; AudioClipStack *st = (AudioClipStack *)gf_node_get_private(tn->udta); if (st->failure) return; if (! ac->isActive) { st->start_time = ac->startTime; st->input.speed = ac->pitch; } time = gf_node_get_scene_time(tn->udta); if ((time<st->start_time) || (st->start_time<0)) return; if (ac->isActive) { if ( (ac->stopTime > st->start_time) && (time>=ac->stopTime)) { audioclip_deactivate(st, ac); return; } } if (!ac->isActive) audioclip_activate(st, ac); }
/*only URL can be changed, so reset and get new URL*/ void MS_Modified(GF_Node *node) { MediaSensorStack *st = (MediaSensorStack *)gf_node_get_private(node); if (!st) return; while (gf_list_count(st->seg)) gf_list_rem(st->seg, 0); if (st->stream) { /*unlink from OD*/ if (st->stream->odm && st->stream->odm->ms_stack) gf_list_del_item(st->stream->odm->ms_stack, st); gf_mo_unregister(node, st->stream); if (st->sensor->isActive) { st->sensor->isActive = 0; gf_node_event_out((GF_Node *) st->sensor, 4/*"isActive"*/); } } st->stream = NULL; st->is_init = 0; gf_term_invalidate_compositor(st->parent->root_od->term); }
static void TraverseDirectionalLight(GF_Node *n, void *rs, Bool is_destroy) { Bool *stack = (Bool*)gf_node_get_private(n); M_DirectionalLight *dl = (M_DirectionalLight *)n; GF_TraverseState *tr_state = (GF_TraverseState *) rs; if (is_destroy) { gf_free(stack); return; } if (tr_state->switched_off || !dl->on) return; /*1- DL only lights the parent group, no need for culling it*/ /*DL is set dynamically while traversing, the only mode that interest us is draw*/ if (tr_state->traversing_mode) return; if (tr_state->local_light_on) { *stack = visual_3d_add_directional_light(tr_state->visual, dl->ambientIntensity, dl->color, dl->intensity, dl->direction); } else { if (*stack) visual_3d_remove_last_light(tr_state->visual); *stack = 0; } }
static void RenderAnchor(GF_Node *node, void *rs, Bool is_destroy) { AnchorStack *st = (AnchorStack *) gf_node_get_private(node); M_Anchor *an = (M_Anchor *) node; RenderEffect2D *eff = (RenderEffect2D *)rs; if (is_destroy) { R2D_UnregisterSensor(st->compositor, &st->hdl); if (st->compositor->interaction_sensors) st->compositor->interaction_sensors--; DeleteGroupingNode2D((GroupingNode2D *)st); free(st); return; } /*update enabled state*/ if (gf_node_dirty_get(node) & GF_SG_NODE_DIRTY) { st->enabled = 0; if (an->url.count && an->url.vals[0].url && strlen(an->url.vals[0].url) ) st->enabled = 1; } /*note we don't clear dirty flag, this is done in traversing*/ group2d_traverse((GroupingNode2D*)st, an->children, eff); }
static void audioclip_traverse(GF_Node *node, void *rs, Bool is_destroy) { GF_TraverseState *tr_state = (GF_TraverseState *)rs; M_AudioClip *ac = (M_AudioClip *)node; AudioClipStack *st = (AudioClipStack *)gf_node_get_private(node); if (is_destroy) { gf_sc_audio_predestroy(&st->input); if (st->time_handle.is_registered) { gf_sc_unregister_time_node(st->input.compositor, &st->time_handle); } gf_free(st); return; } if (st->failure) return; /*check end of stream*/ if (st->input.stream && st->input.stream_finished) { if (gf_mo_get_loop(st->input.stream, ac->loop)) { gf_sc_audio_restart(&st->input); } else if (ac->isActive && gf_mo_should_deactivate(st->input.stream)) { /*deactivate*/ audioclip_deactivate(st, ac); } } if (ac->isActive) { gf_sc_audio_register(&st->input, (GF_TraverseState*)rs); } if (st->set_duration && st->input.stream) { ac->duration_changed = gf_mo_get_duration(st->input.stream); gf_node_event_out_str(node, "duration_changed"); st->set_duration = 0; } /*store mute flag*/ st->input.is_muted = tr_state->switched_off; }
static Bool OnAnchor(GF_SensorHandler *sh, Bool is_over, Bool is_cancel, GF_Event *ev, GF_Compositor *compositor) { GF_Event evt; MFURL *url = NULL; AnchorStack *st = (AnchorStack *) gf_node_get_private(sh->sensor); if ((ev->type==GF_EVENT_MOUSEDOWN) && (ev->mouse.button==GF_MOUSE_LEFT)) st->active = 1; else if ((ev->type==GF_EVENT_KEYDOWN) && (ev->key.key_code==GF_KEY_ENTER)) st->active = 1; else if (st->active && ( /*mouse*/ ((ev->type==GF_EVENT_MOUSEUP) && (ev->mouse.button==GF_MOUSE_LEFT)) || /*mouse*/((ev->type==GF_EVENT_KEYUP) && (ev->key.key_code==GF_KEY_ENTER)) ) ) { if (!is_cancel) anchor_activation(sh->sensor, st, compositor); } else if (is_over && !st->over) { st->over = 1; if (compositor->user->EventProc) { evt.type = GF_EVENT_NAVIGATE_INFO; switch (gf_node_get_tag(sh->sensor)) { case TAG_MPEG4_Anchor: evt.navigate.to_url = ((M_Anchor *)sh->sensor)->description.buffer; url = & ((M_Anchor *)sh->sensor)->url; break; #ifndef GPAC_DISABLE_X3D case TAG_X3D_Anchor: evt.navigate.to_url = ((X_Anchor *)sh->sensor)->description.buffer; url = & ((X_Anchor *)sh->sensor)->url; break; #endif } if (url && (!evt.navigate.to_url || !strlen(evt.navigate.to_url))) evt.navigate.to_url = url->vals[0].url; gf_term_send_event(compositor->term, &evt); } } else if (!is_over) { st->over = 0; } return 0; }
static void TraverseAnchor(GF_Node *node, void *rs, Bool is_destroy) { AnchorStack *st = (AnchorStack *) gf_node_get_private(node); GF_TraverseState *tr_state = (GF_TraverseState *)rs; if (is_destroy) { mpeg4_sensor_deleted(node, &st->hdl); gf_sc_check_focus_upon_destroy(node); if (st->sensors) gf_list_del(st->sensors); gf_free(st); return; } if (gf_node_dirty_get(node) & GF_SG_NODE_DIRTY) { MFURL *url = NULL; switch (gf_node_get_tag(node)) { case TAG_MPEG4_Anchor: url = & ((M_Anchor *)node)->url; break; #ifndef GPAC_DISABLE_X3D case TAG_X3D_Anchor: url = & ((X_Anchor *)node)->url; break; #endif } st->enabled = 0; if (url && url->count && url->vals[0].url && strlen(url->vals[0].url) ) st->enabled = 1; if (!tr_state->visual->compositor->user->EventProc) { st->enabled = 0; } gf_node_dirty_clear(node, GF_SG_NODE_DIRTY); } group_2d_traverse(node, (GroupingNode2D*)st, tr_state); }
static void svg_traverse_glyph(GF_Node *node, void *rs, Bool is_destroy) { if (is_destroy) { GF_Font *font; GF_Glyph *prev_glyph, *a_glyph; SVG_GlyphStack *st = gf_node_get_private(node); if (st->unicode) gf_free(st->unicode); font = st->font; prev_glyph = NULL; a_glyph = font->glyph; while (a_glyph) { if (a_glyph == &st->glyph) break; prev_glyph = a_glyph; a_glyph = a_glyph->next; } if (prev_glyph) { prev_glyph->next = st->glyph.next; } else { font->glyph = st->glyph.next; } gf_free(st); } }
static void fog_set_bind(GF_Node *node, GF_Route *route) { ViewStack *st = (ViewStack *) gf_node_get_private(node); Bindable_OnSetBind(node, st->reg_stacks, NULL); gf_sc_invalidate(gf_sc_get_compositor(node), NULL); }
static void TraverseNavigationInfo(GF_Node *node, void *rs, Bool is_destroy) { u32 i; #ifndef GPAC_DISABLE_3D u32 nb_select_mode; SFVec3f start, end; Fixed scale; ViewStack *st = (ViewStack *) gf_node_get_private(node); #endif GF_TraverseState *tr_state = (GF_TraverseState *)rs; M_NavigationInfo *ni = (M_NavigationInfo *) node; if (is_destroy) { DestroyViewStack(node); return; } #ifdef GPAC_DISABLE_3D /*FIXME, we only deal with one node, no bind stack for the current time*/ for (i=0; i<ni->type.count; i++) { if (ni->type.vals[i] && !stricmp(ni->type.vals[i], "NONE")) { tr_state->visual->compositor->navigation_disabled = 1; } } #else if (!tr_state->navigations) return; /*first traverse, bound if needed*/ if (gf_list_find(tr_state->navigations, node) < 0) { gf_list_add(tr_state->navigations, node); if (gf_list_get(tr_state->navigations, 0) == ni) { if (!ni->isBound) Bindable_SetIsBound(node, 1); } assert(gf_list_find(st->reg_stacks, tr_state->navigations)==-1); gf_list_add(st->reg_stacks, tr_state->navigations); gf_mx_copy(st->world_view_mx, tr_state->model_matrix); /*in any case don't draw the first time*/ gf_sc_invalidate(tr_state->visual->compositor, NULL); return; } /*not bound*/ if (!ni->isBound) return; /*not evaluating, return*/ if (tr_state->traversing_mode != TRAVERSE_BINDABLE) { if ((tr_state->traversing_mode==TRAVERSE_SORT) || (tr_state->traversing_mode==TRAVERSE_GET_BOUNDS) ) { if (!gf_mx_equal(&st->world_view_mx, &tr_state->model_matrix)) { gf_mx_copy(st->world_view_mx, tr_state->model_matrix); gf_node_dirty_set(node, 0, 0); } } return; } if (!gf_node_dirty_get(node)) return; gf_node_dirty_clear(node, 0); nb_select_mode = 0; tr_state->camera->navigation_flags = 0; tr_state->camera->navigate_mode = 0; for (i=0; i<ni->type.count; i++) { if (ni->type.vals[i] && !stricmp(ni->type.vals[i], "ANY")) tr_state->camera->navigation_flags |= NAV_ANY; else { nb_select_mode++; } if (!tr_state->camera->navigate_mode) { if (ni->type.vals[i] && !stricmp(ni->type.vals[i], "NONE")) tr_state->camera->navigate_mode = GF_NAVIGATE_NONE; else if (ni->type.vals[i] && !stricmp(ni->type.vals[i], "WALK")) tr_state->camera->navigate_mode = GF_NAVIGATE_WALK; else if (ni->type.vals[i] && !stricmp(ni->type.vals[i], "EXAMINE")) tr_state->camera->navigate_mode = GF_NAVIGATE_EXAMINE; else if (ni->type.vals[i] && !stricmp(ni->type.vals[i], "FLY")) tr_state->camera->navigate_mode = GF_NAVIGATE_FLY; else if (ni->type.vals[i] && !stricmp(ni->type.vals[i], "VR")) tr_state->camera->navigate_mode = GF_NAVIGATE_VR; } } if (nb_select_mode>1) tr_state->camera->navigation_flags |= NAV_SELECTABLE; if (ni->headlight) tr_state->camera->navigation_flags |= NAV_HEADLIGHT; start.x = start.y = start.z = 0; end.x = end.y = 0; end.z = FIX_ONE; gf_mx_apply_vec(&st->world_view_mx, &start); gf_mx_apply_vec(&st->world_view_mx, &end); gf_vec_diff(end, end, start); scale = gf_vec_len(end); tr_state->camera->speed = gf_mulfix(scale, ni->speed); tr_state->camera->visibility = gf_mulfix(scale, ni->visibilityLimit); if (ni->avatarSize.count) tr_state->camera->avatar_size.x = gf_mulfix(scale, ni->avatarSize.vals[0]); if (ni->avatarSize.count>1) tr_state->camera->avatar_size.y = gf_mulfix(scale, ni->avatarSize.vals[1]); if (ni->avatarSize.count>2) tr_state->camera->avatar_size.z = gf_mulfix(scale, ni->avatarSize.vals[2]); if (0 && tr_state->pixel_metrics) { u32 s = MAX(tr_state->visual->width, tr_state->visual->height); s /= 2; // tr_state->camera->speed = ni->speed; tr_state->camera->visibility *= s; tr_state->camera->avatar_size.x *= s; tr_state->camera->avatar_size.y *= s; tr_state->camera->avatar_size.z *= s; } #endif }