/*
 *			GPAC - MPEG-4 Systems C Development Kit
 *
 *			Copyright (c) Cyril Concolato 2004
 *					All rights reserved
 *
 *  This file is part of GPAC / SVG Scene Graph sub-project
 *
 *  GPAC is free software; you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation; either version 2, or (at your option)
 *  any later version.
 *
 *  GPAC is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.	
 *
 *  You should have received a copy of the GNU General Public License
 *  along with GNU Make; see the file COPYING.  If not, write to
 *  the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
 *
 */

#include <gpac/m4_svg_nodes.h>

#ifndef M4_DISABLE_SVG

#include <gpac/intern/m4_scenegraph_dev.h>

void SVG_DeletePath(SVG_PathData *d) 
{
	u32 i;
	for (i = 0; i < ChainGetCount(d->path_commands); i++) {
		u8 *command = ChainGetEntry(d->path_commands, i);
		free(command);
	}
	DeleteChain(d->path_commands);
	for (i = 0; i < ChainGetCount(d->path_points); i++) {
		SVG_Point *pt = ChainGetEntry(d->path_points, i);
		free(pt);
	}
	DeleteChain(d->path_points);
}

void SVG_DeleteTransformList(Chain *tr)
{
	u32 i;
	for (i = 0; i < ChainGetCount(tr); i++) {
		SVG_Matrix *m=ChainGetEntry(tr, i);
		free(m);
	}
	DeleteChain(tr);
}

void SVG_DeleteBeginOrEnd(Chain *list)
{
	u32 i;
	for (i = 0; i < ChainGetCount(list); i++) {
		SMIL_BeginOrEndValue *v=ChainGetEntry(list, i);
		free(v);
	}
	DeleteChain(list);
}

void SVG_DeletePoints(Chain *list)
{
	u32 i;
	for (i = 0; i < ChainGetCount(list); i++) {
		SVG_Point *p=ChainGetEntry(list, i);
		free(p);
	}
	DeleteChain(list);
}

void SVG_DeleteCoordinates(Chain *list)
{
	u32 i;
	for (i = 0; i < ChainGetCount(list); i++) {
		SVG_Coordinate *c=ChainGetEntry(list, i);
		free(c);
	}
	DeleteChain(list);
}

void SVG_DeletePaint(SVG_Paint *paint) 
{
	if (!paint) return;
	free(paint->color);
}

void SVG_DeleteOneAnimValue(u8 anim_datatype, void *anim_value)
{
	switch (anim_datatype) {
	case SVG_Paint_datatype:
		SVG_DeletePaint((SVG_Paint *)anim_value);
		break;
	case SVG_StrokeWidthValue_datatype:
	case SVG_Length_datatype:
	case SVG_Coordinate_datatype:
		break;
	case SVG_VisibilityValue_datatype:
		break;
	case SVG_DisplayValue_datatype:
		break;
	} 
}

void SMIL_DeleteAnimateValues(SMIL_AnimateValues *anim_values)
{
	u32 i, count;
	count = ChainGetCount(anim_values->values);
	for (i = 0; i < count; i++) {
		void *value = ChainGetEntry(anim_values->values, i);
		SVG_DeleteOneAnimValue(anim_values->datatype, value);
		free(value);
	}
	DeleteChain(anim_values->values);
	anim_values->values = NULL;
}

void SMIL_DeleteAnimateValue(SMIL_AnimateValue *anim_value)
{
	SVG_DeleteOneAnimValue(anim_value->datatype, anim_value->value);
	free(anim_value->value);
	anim_value->value = NULL;
}

#endif /*M4_DISABLE_SVG*/
