void compositor_init_compositetexture2d(GF_Compositor *compositor, GF_Node *node) { M_CompositeTexture2D *c2d = (M_CompositeTexture2D *)node; CompositeTextureStack *st; GF_SAFEALLOC(st, CompositeTextureStack); st->sensors = gf_list_new(); st->previous_sensors = gf_list_new(); gf_sc_texture_setup(&st->txh, compositor, node); /*remove texture from compositor and add it at the end, so that any sub-textures are handled before*/ gf_list_del_item(compositor->textures, &st->txh); gf_list_add(compositor->textures, &st->txh); st->txh.update_texture_fcnt = composite_update; if ((c2d->repeatSandT==1) || (c2d->repeatSandT==3) ) st->txh.flags |= GF_SR_TEXTURE_REPEAT_S; if (c2d->repeatSandT>1) st->txh.flags |= GF_SR_TEXTURE_REPEAT_T; /*create composite visual*/ st->visual = visual_new(compositor); st->visual->offscreen = node; st->visual->GetSurfaceAccess = composite_get_video_access; st->visual->ReleaseSurfaceAccess = composite_release_video_access; st->visual->raster_surface = compositor->rasterizer->surface_new(compositor->rasterizer, 1); st->visual->DrawBitmap = composite2d_draw_bitmap; st->first = 1; st->visual->compositor = compositor; gf_node_set_private(node, st); gf_node_set_callback_function(node, composite_traverse); gf_sc_visual_register(compositor, st->visual); }
void compositor_init_mattetexture(GF_Compositor *compositor, GF_Node *node) { GF_TextureHandler *txh; GF_SAFEALLOC(txh, GF_TextureHandler); gf_sc_texture_setup(txh, compositor, node); txh->flags = GF_SR_TEXTURE_MATTE; txh->update_texture_fcnt = matte_update; gf_node_set_private(node, txh); gf_node_set_callback_function(node, imagetexture_destroy); }
GroupCache *group_cache_new(GF_Compositor *compositor, GF_Node *node) { GroupCache *cache; GF_SAFEALLOC(cache, GroupCache); gf_sc_texture_setup(&cache->txh, compositor, node); cache->drawable = drawable_new(); /*draw the cache through traverse callback*/ cache->drawable->flags |= DRAWABLE_USE_TRAVERSE_DRAW; cache->drawable->node = node; cache->opacity = FIX_ONE; gf_sc_texture_allocate(&cache->txh); return cache; }
void compositor_init_pixeltexture(GF_Compositor *compositor, GF_Node *node) { PixelTextureStack *st; GF_SAFEALLOC(st, PixelTextureStack); gf_sc_texture_setup(&st->txh, compositor, node); st->pixels = NULL; st->txh.update_texture_fcnt = pixeltexture_update; gf_node_set_private(node, st); gf_node_set_callback_function(node, pixeltexture_destroy); st->txh.flags = 0; if (((M_PixelTexture*)node)->repeatS) st->txh.flags |= GF_SR_TEXTURE_REPEAT_S; if (((M_PixelTexture*)node)->repeatT) st->txh.flags |= GF_SR_TEXTURE_REPEAT_T; }
void compositor_init_svg_filter(GF_Compositor *compositor, GF_Node *node) { GF_FilterStack *stack; GF_SAFEALLOC(stack, GF_FilterStack); gf_node_set_private(node, stack); gf_node_set_callback_function(node, svg_traverse_filter); gf_sc_texture_setup(&stack->txh, compositor, node); stack->drawable = drawable_new(); /*draw the cache through traverse callback*/ stack->drawable->flags |= DRAWABLE_USE_TRAVERSE_DRAW; stack->drawable->node = node; gf_sc_texture_allocate(&stack->txh); }
void compositor_init_svg_image(GF_Compositor *compositor, GF_Node *node) { SVG_video_stack *stack; GF_SAFEALLOC(stack, SVG_video_stack) stack->graph = drawable_new(); stack->graph->flags = DRAWABLE_USE_TRAVERSE_DRAW; stack->graph->node = node; gf_sc_texture_setup(&stack->txh, compositor, node); stack->txh.update_texture_fcnt = SVG_Update_image; stack->txh.flags = GF_SR_TEXTURE_SVG; /*force first processing of xlink-href*/ gf_node_dirty_set(node, GF_SG_SVG_XLINK_HREF_DIRTY, GF_FALSE); gf_node_set_private(node, stack); gf_node_set_callback_function(node, svg_traverse_image); }
void compositor_init_compositetexture3d(GF_Compositor *compositor, GF_Node *node) { M_CompositeTexture3D *c3d = (M_CompositeTexture3D *)node; CompositeTextureStack *st; GF_SAFEALLOC(st, CompositeTextureStack); st->sensors = gf_list_new(); st->previous_sensors = gf_list_new(); gf_sc_texture_setup(&st->txh, compositor, node); /*remove texture from compositor and add it at the end, so that any sub-textures are handled before*/ gf_list_del_item(compositor->textures, &st->txh); gf_list_add(compositor->textures, &st->txh); st->txh.update_texture_fcnt = composite_update; if (c3d->repeatS) st->txh.flags |= GF_SR_TEXTURE_REPEAT_S; if (c3d->repeatT) st->txh.flags |= GF_SR_TEXTURE_REPEAT_T; /*create composite visual*/ st->visual = visual_new(compositor); st->visual->offscreen = node; st->visual->GetSurfaceAccess = composite_get_video_access; st->visual->ReleaseSurfaceAccess = composite_release_video_access; st->first = 1; st->visual->compositor = compositor; gf_node_set_private(node, st); gf_node_set_callback_function(node, composite_traverse); gf_sc_visual_register(compositor, st->visual); #ifdef GPAC_USE_TINYGL st->visual->type_3d = 2; st->visual->camera.is_3D = 1; #else if (! (compositor->video_out->hw_caps & GF_VIDEO_HW_OPENGL_OFFSCREEN)) { st->visual->type_3d = 0; st->visual->camera.is_3D = 0; } else { st->visual->type_3d = 2; st->visual->camera.is_3D = 1; } #endif camera_invalidate(&st->visual->camera); }
void compositor_init_imagetexture(GF_Compositor *compositor, GF_Node *node) { GF_TextureHandler *txh; GF_SAFEALLOC(txh, GF_TextureHandler); gf_sc_texture_setup(txh, compositor, node); txh->update_texture_fcnt = imagetexture_update; gf_node_set_private(node, txh); gf_node_set_callback_function(node, imagetexture_destroy); txh->flags = 0; if (gf_node_get_tag(txh->owner)!=TAG_MPEG4_CacheTexture) { if (((M_ImageTexture*)node)->repeatS) txh->flags |= GF_SR_TEXTURE_REPEAT_S; if (((M_ImageTexture*)node)->repeatT) txh->flags |= GF_SR_TEXTURE_REPEAT_T; } else { const char *url; u32 i, count; M_CacheTexture*ct = (M_CacheTexture*)node; if (!ct->image.buffer) return; if (ct->repeatS) txh->flags |= GF_SR_TEXTURE_REPEAT_S; if (ct->repeatT) txh->flags |= GF_SR_TEXTURE_REPEAT_T; /*locate existing cache*/ url = gf_scene_get_service_url( gf_node_get_graph(node) ); count = gf_cfg_get_section_count(compositor->user->config); for (i=0; i<count; i++) { const char *opt; const char *name = gf_cfg_get_section_name(compositor->user->config, i); if (strncmp(name, "@cache=", 7)) continue; opt = gf_cfg_get_key(compositor->user->config, name, "serviceURL"); if (!opt || stricmp(opt, url)) continue; opt = gf_cfg_get_key(compositor->user->config, name, "cacheName"); if (opt && ct->cacheURL.buffer && !stricmp(opt, ct->cacheURL.buffer)) { opt = gf_cfg_get_key(compositor->user->config, name, "cacheFile"); if (opt) gf_delete_file((char*)opt); gf_cfg_del_section(compositor->user->config, name); break; } } } }
void compositor_init_background2d(GF_Compositor *compositor, GF_Node *node) { Background2DStack *ptr; GF_SAFEALLOC(ptr, Background2DStack); ptr->status_stack = gf_list_new(); ptr->reg_stacks = gf_list_new(); /*setup drawable object for background*/ ptr->drawable = drawable_stack_new(compositor, node); ptr->drawable->flags = DRAWABLE_USE_TRAVERSE_DRAW; ((M_Background2D *)node)->on_set_bind = b2D_set_bind; gf_sc_texture_setup(&ptr->txh, compositor, node); ptr->txh.update_texture_fcnt = UpdateBackgroundTexture; ptr->txh.flags = GF_SR_TEXTURE_REPEAT_S | GF_SR_TEXTURE_REPEAT_T; ptr->flags = CTX_IS_BACKGROUND; gf_node_set_private(node, ptr); gf_node_set_callback_function(node, TraverseBackground2D); }
void compositor_init_movietexture(GF_Compositor *compositor, GF_Node *node) { MovieTextureStack *st; GF_SAFEALLOC(st, MovieTextureStack); gf_sc_texture_setup(&st->txh, compositor, node); st->txh.update_texture_fcnt = movietexture_update; st->time_handle.UpdateTimeNode = movietexture_update_time; st->time_handle.udta = node; st->fetch_first_frame = 1; st->txh.flags = 0; if (((M_MovieTexture*)node)->repeatS) st->txh.flags |= GF_SR_TEXTURE_REPEAT_S; if (((M_MovieTexture*)node)->repeatT) st->txh.flags |= GF_SR_TEXTURE_REPEAT_T; #ifndef GPAC_DISABLE_X3D st->is_x3d = (gf_node_get_tag(node)==TAG_X3D_MovieTexture) ? 1 : 0; #endif gf_node_set_private(node, st); gf_node_set_callback_function(node, movietexture_destroy); gf_sc_register_time_node(compositor, &st->time_handle); }
void compositor_init_background(GF_Compositor *compositor, GF_Node *node) { BackgroundStack *ptr; GF_SAFEALLOC(ptr, BackgroundStack); ptr->compositor = compositor; ptr->reg_stacks = gf_list_new(); ((M_Background *)node)->on_set_bind = back_set_bind; gf_mx_init(ptr->current_mx); /*build texture cube*/ ptr->front_mesh = new_mesh(); mesh_set_vertex(ptr->front_mesh, -PLANE_HSIZE, -PLANE_HSIZE, -PLANE_HSIZE_LOW, 0, 0, FIX_ONE, 0, 0); mesh_set_vertex(ptr->front_mesh, PLANE_HSIZE, -PLANE_HSIZE, -PLANE_HSIZE_LOW, 0, 0, FIX_ONE, FIX_ONE, 0); mesh_set_vertex(ptr->front_mesh, PLANE_HSIZE, PLANE_HSIZE, -PLANE_HSIZE_LOW, 0, 0, FIX_ONE, FIX_ONE, FIX_ONE); mesh_set_vertex(ptr->front_mesh, -PLANE_HSIZE, PLANE_HSIZE, -PLANE_HSIZE_LOW, 0, 0, FIX_ONE, 0, FIX_ONE); mesh_set_triangle(ptr->front_mesh, 0, 1, 2); mesh_set_triangle(ptr->front_mesh, 0, 2, 3); mesh_update_bounds(ptr->front_mesh); ptr->back_mesh = new_mesh(); mesh_set_vertex(ptr->back_mesh, -PLANE_HSIZE, -PLANE_HSIZE, PLANE_HSIZE_LOW, 0, 0, -FIX_ONE, FIX_ONE, 0); mesh_set_vertex(ptr->back_mesh, PLANE_HSIZE, -PLANE_HSIZE, PLANE_HSIZE_LOW, 0, 0, -FIX_ONE, 0, 0); mesh_set_vertex(ptr->back_mesh, PLANE_HSIZE, PLANE_HSIZE, PLANE_HSIZE_LOW, 0, 0, -FIX_ONE, 0, FIX_ONE); mesh_set_vertex(ptr->back_mesh, -PLANE_HSIZE, PLANE_HSIZE, PLANE_HSIZE_LOW, 0, 0, -FIX_ONE, FIX_ONE, FIX_ONE); mesh_set_triangle(ptr->back_mesh, 0, 1, 2); mesh_set_triangle(ptr->back_mesh, 0, 2, 3); mesh_update_bounds(ptr->back_mesh); ptr->top_mesh = new_mesh(); mesh_set_vertex(ptr->top_mesh, -PLANE_HSIZE, PLANE_HSIZE_LOW, PLANE_HSIZE, 0, -FIX_ONE, 0, 0, 0); mesh_set_vertex(ptr->top_mesh, PLANE_HSIZE, PLANE_HSIZE_LOW, PLANE_HSIZE, 0, -FIX_ONE, 0, 0, FIX_ONE); mesh_set_vertex(ptr->top_mesh, PLANE_HSIZE, PLANE_HSIZE_LOW, -PLANE_HSIZE, 0, -FIX_ONE, 0, FIX_ONE, FIX_ONE); mesh_set_vertex(ptr->top_mesh, -PLANE_HSIZE, PLANE_HSIZE_LOW, -PLANE_HSIZE, 0, -FIX_ONE, 0, FIX_ONE, 0); mesh_set_triangle(ptr->top_mesh, 0, 1, 2); mesh_set_triangle(ptr->top_mesh, 0, 2, 3); mesh_update_bounds(ptr->top_mesh); ptr->bottom_mesh = new_mesh(); mesh_set_vertex(ptr->bottom_mesh, -PLANE_HSIZE, -PLANE_HSIZE_LOW, -PLANE_HSIZE, 0, FIX_ONE, 0, FIX_ONE, FIX_ONE); mesh_set_vertex(ptr->bottom_mesh, PLANE_HSIZE, -PLANE_HSIZE_LOW, -PLANE_HSIZE, 0, FIX_ONE, 0, FIX_ONE, 0); mesh_set_vertex(ptr->bottom_mesh, PLANE_HSIZE, -PLANE_HSIZE_LOW, PLANE_HSIZE, 0, FIX_ONE, 0, 0, 0); mesh_set_vertex(ptr->bottom_mesh, -PLANE_HSIZE, -PLANE_HSIZE_LOW, PLANE_HSIZE, 0, FIX_ONE, 0, 0, FIX_ONE); mesh_set_triangle(ptr->bottom_mesh, 0, 1, 2); mesh_set_triangle(ptr->bottom_mesh, 0, 2, 3); mesh_update_bounds(ptr->bottom_mesh); ptr->left_mesh = new_mesh(); mesh_set_vertex(ptr->left_mesh, -PLANE_HSIZE_LOW, -PLANE_HSIZE, -PLANE_HSIZE, FIX_ONE, 0, 0, FIX_ONE, 0); mesh_set_vertex(ptr->left_mesh, -PLANE_HSIZE_LOW, -PLANE_HSIZE, PLANE_HSIZE, FIX_ONE, 0, 0, 0, 0); mesh_set_vertex(ptr->left_mesh, -PLANE_HSIZE_LOW, PLANE_HSIZE, PLANE_HSIZE, FIX_ONE, 0, 0, 0, FIX_ONE); mesh_set_vertex(ptr->left_mesh, -PLANE_HSIZE_LOW, PLANE_HSIZE, -PLANE_HSIZE, FIX_ONE, 0, 0, FIX_ONE, FIX_ONE); mesh_set_triangle(ptr->left_mesh, 0, 1, 2); mesh_set_triangle(ptr->left_mesh, 0, 2, 3); mesh_update_bounds(ptr->left_mesh); ptr->right_mesh = new_mesh(); mesh_set_vertex(ptr->right_mesh, PLANE_HSIZE_LOW, -PLANE_HSIZE, PLANE_HSIZE, -FIX_ONE, 0, 0, FIX_ONE, 0); mesh_set_vertex(ptr->right_mesh, PLANE_HSIZE_LOW, -PLANE_HSIZE, -PLANE_HSIZE, -FIX_ONE, 0, 0, 0, 0); mesh_set_vertex(ptr->right_mesh, PLANE_HSIZE_LOW, PLANE_HSIZE, -PLANE_HSIZE, -FIX_ONE, 0, 0, 0, FIX_ONE); mesh_set_vertex(ptr->right_mesh, PLANE_HSIZE_LOW, PLANE_HSIZE, PLANE_HSIZE, -FIX_ONE, 0, 0, FIX_ONE, FIX_ONE); mesh_set_triangle(ptr->right_mesh, 0, 1, 2); mesh_set_triangle(ptr->right_mesh, 0, 2, 3); mesh_update_bounds(ptr->right_mesh); gf_sc_texture_setup(&ptr->txh_back, compositor, node); ptr->txh_back.update_texture_fcnt = UpdateBackgroundTexture; gf_sc_texture_setup(&ptr->txh_front, compositor, node); ptr->txh_front.update_texture_fcnt = UpdateBackgroundTexture; gf_sc_texture_setup(&ptr->txh_top, compositor, node); ptr->txh_top.update_texture_fcnt = UpdateBackgroundTexture; gf_sc_texture_setup(&ptr->txh_bottom, compositor, node); ptr->txh_bottom.update_texture_fcnt = UpdateBackgroundTexture; gf_sc_texture_setup(&ptr->txh_left, compositor, node); ptr->txh_left.update_texture_fcnt = UpdateBackgroundTexture; gf_sc_texture_setup(&ptr->txh_right, compositor, node); ptr->txh_right.update_texture_fcnt = UpdateBackgroundTexture; gf_node_set_private(node, ptr); gf_node_set_callback_function(node, TraverseBackground); }