Пример #1
0
/* fill 0 is no fill, so set fill->idx to one more than the shape's fill index */
static SWFFillStyle
addFillStyle(SWFShape shape, SWFFillStyle fill)
{
	int i;

	for ( i=0; i<*shape->nFills; ++i )
	{
		if ( SWFFillStyle_equals(fill, (*shape->fills)[i]) )
		{
			free(fill); // XXX - safe?
			return (*shape->fills)[i];
		}
	}

	if ( shape->isEnded )
	{
		SWFFill_setIdx(fill, 0);
		return fill;
	}

	if ( *shape->nFills%STYLE_INCREMENT == 0 )
	{
		*shape->fills =
			(SWFFillStyle*)realloc(*shape->fills,
							(*shape->nFills+STYLE_INCREMENT) * sizeof(SWFFillStyle));
	}

	SWFFill_setIdx(fill, *shape->nFills+1);

	(*shape->fills)[*shape->nFills] = fill;
	++(*shape->nFills);

	return fill;
}
Пример #2
0
/* fill 0 is no fill, so set idx to one more than the shape's fill index */
static int getFillIdx(SWFShape shape, SWFFillStyle fill)
{
    int i;

    for ( i=0; i<shape->nFills; ++i )
    {
        if ( SWFFillStyle_equals(fill, shape->fills[i]) )
            return (i+1);
    }
    return 0; // no fill
}
Пример #3
0
static int addFillStyle(SWFShape shape, SWFFillStyle fill)
{
    int i;

    for ( i=0; i<shape->nFills; ++i )
    {
        if ( SWFFillStyle_equals(fill, shape->fills[i]) )
            return i;
    }

    if ( shape->isEnded )
        return -1;

    if ( shape->nFills%STYLE_INCREMENT == 0 )
    {
        int size = (shape->nFills+STYLE_INCREMENT) * sizeof(SWFFillStyle);
        shape->fills = (SWFFillStyle*)realloc(shape->fills, size);
    }

    shape->fills[shape->nFills] = fill;
    ++shape->nFills;
    return shape->nFills;
}