Example #1
0
void
destroySWFPlaceObject2Block(SWFPlaceObject2Block place)
{
	if ( place->actions != NULL )
		free(place->actions);

	if ( place->actionFlags != NULL )
/*	{	free(place->actionChars);	*/
		free(place->actionFlags);
/*	}	*/

	if( place->filterList != NULL )
		destroySWFFilterList(place->filterList);		

	if ( place->name != NULL )
		free(place->name);

	if ( place->out != NULL )
		destroySWFOutput(place->out);

	if ( place->matrix != NULL )
		destroySWFMatrix(place->matrix);

	if ( place->cXform != NULL )
		destroySWFCXform(place->cXform);

#if TRACK_ALLOCS
	ming_gc_remove_node(place->gcnode);
#endif

	free(place);
}
Example #2
0
void
SWFMatrix_rotate(SWFMatrix matrix, double degrees)
{
	SWFMatrix rot = newSWFRotateMatrix(degrees);
	SWFMatrix_leftMultiply(rot,matrix);
	destroySWFMatrix(rot);
}
Example #3
0
void 
SWFGradientMatrix_update(SWFMatrix matrix, SWFRect bounds)
{
	int w, h;
	float scaleX, scaleY;
	SWFMatrix tmp;
	if(bounds == NULL)
		return;

	w = SWFRect_getWidth(bounds);
	h = SWFRect_getHeight(bounds);
	scaleX = w / GRADIENT_SIZE;
	scaleY = h / GRADIENT_SIZE;

	/* update matrix translation first, to be realtive to the gradient's 
	 * coordinate system. */
	SWFMatrix_moveTo(matrix, SWFMatrix_getTranslateX(matrix) / scaleX, 
		SWFMatrix_getTranslateY(matrix) / scaleY);
	
	tmp = newSWFMatrix(scaleX, 0, 0, scaleY, bounds->minX + w/2,  bounds->minY + h/2);
	/* temporary matrix scales gradient to given bounds and centers it. */
	/* all transformations done by the user are "applied" on the tmp matrix */
	/* matrix = matrix * tmp -> "matrix is followed by tmp" */
	SWFMatrix_multiply(matrix, tmp);
	destroySWFMatrix(tmp);	
}
Example #4
0
/* THAGA */
void SWFShape_newStyles(SWFShape shape)
{
	ShapeRecord record;

	shape->isUsingNewStyles = TRUE;

	if (shape->isNewStylesLast == TRUE) {
		int i;

		record = shape->records[shape->nRecords-1];

		for ( i=0; i<*shape->nFills; ++i )
		{
			SWFMatrix matrix = SWFFillStyle_getMatrix((*shape->fills)[i]);

			if ( matrix != NULL )
				destroySWFMatrix(matrix);

			/* gradients and bitmaps are destroyed separately */

			free((*shape->fills)[i]);
		}

		if ( *shape->fills != NULL )
			free(*shape->fills);

		for ( i=0; i<*shape->nLines; ++i )
			free((*shape->lines)[i]);

		if ( *shape->lines != NULL )
			free(*shape->lines);
	}
	else {
		record = newShapeRecord(shape, SHAPERECORD_STATECHANGE);
	}

	record.record.stateChange->flags |= SWF_SHAPE_FILLSTYLE0FLAG;
	record.record.stateChange->flags |= SWF_SHAPE_FILLSTYLE1FLAG;
	record.record.stateChange->flags |= SWF_SHAPE_LINESTYLEFLAG;
	record.record.stateChange->flags |= SWF_SHAPE_NEWSTYLEFLAG;

	shape->lines = &record.record.stateChange->lines;
	shape->fills = &record.record.stateChange->fills;
	shape->nLines = &record.record.stateChange->nLines;
	shape->nFills = &record.record.stateChange->nFills;
	shape->isNewStylesLast = TRUE;

	*shape->lines = NULL;
	*shape->fills = NULL;
	*shape->nLines = 0;
	*shape->nFills = 0;
}
Example #5
0
void
destroySWFText(SWFText text)
{
	SWFTextRecord record = text->initialRecord, next;

	destroySWFOutput(text->out);

	if ( text->matrix != NULL )
		destroySWFMatrix(text->matrix);

	while ( record != NULL )
	{
		next = record->next;
		destroySWFTextRecord(record);
		record = next;
	}

#if TRACK_ALLOCS
	ming_gc_remove_node(text->gcnode);
#endif

	destroySWFCharacter((SWFCharacter) text);
}
Example #6
0
void
SWFShape_writeShapeRecord(SWFShape shape, ShapeRecord record)
{
	SWFOutput out = shape->out;

	switch(record.type)
	{
		case SHAPERECORD_STATECHANGE:
		{
			int flags = record.record.stateChange->flags;

			if(flags == 0)
				return;

			SWFOutput_writeBits(out, flags, 6);

			if(flags & SWF_SHAPE_MOVETOFLAG)
			{
				int x = record.record.stateChange->moveToX;
				int y = record.record.stateChange->moveToY;
				int nBits = max(SWFOutput_numSBits(x), SWFOutput_numSBits(y));

				SWF_assert(nBits<32);
				SWFOutput_writeBits(out, nBits, 5);
				SWFOutput_writeSBits(out, x, nBits);
				SWFOutput_writeSBits(out, y, nBits);
			}

			if(flags & SWF_SHAPE_FILLSTYLE0FLAG)
			{
				SWFOutput_writeBits(out, record.record.stateChange->leftFill,
														SWFOutput_numBits(shape->nFills2));
			}

			if(flags & SWF_SHAPE_FILLSTYLE1FLAG)
			{
				SWFOutput_writeBits(out, record.record.stateChange->rightFill,
														SWFOutput_numBits(shape->nFills2));
			}

			if(flags & SWF_SHAPE_LINESTYLEFLAG)
			{
				SWFOutput_writeBits(out, record.record.stateChange->line,
														SWFOutput_numBits(shape->nLines2));
			}

			/* newstyle's never used.	 But this is what it looks like: */

			if ( flags & SWF_SHAPE_NEWSTYLEFLAG )
			{
				int i;

				shape->lines = &record.record.stateChange->lines;
				shape->fills = &record.record.stateChange->fills;
				shape->nLines = &record.record.stateChange->nLines;
				shape->nFills = &record.record.stateChange->nFills;
				shape->nFills2 = *shape->nFills;
				shape->nLines2 = *shape->nLines;

				SWFOutput_writeFillStyles(shape->out, *shape->fills, *shape->nFills,
				BLOCK(shape)->type);

				SWFOutput_writeLineStyles(shape->out, *shape->lines, *shape->nLines,
					BLOCK(shape)->type);

				SWFOutput_writeBits(shape->out, SWFOutput_numBits(*shape->nFills), 4);
				SWFOutput_writeBits(shape->out, SWFOutput_numBits(*shape->nLines), 4);

				for ( i=0; i<*shape->nFills; ++i )
				{
					SWFMatrix matrix = SWFFillStyle_getMatrix((*shape->fills)[i]);

					if ( matrix != NULL )
						destroySWFMatrix(matrix);

					/* gradients and bitmaps are destroyed separately */

					free((*shape->fills)[i]);
				}

				if ( *shape->fills != NULL )
					free(*shape->fills);

				for ( i=0; i<*shape->nLines; ++i )
					free((*shape->lines)[i]);

				if ( *shape->lines != NULL )
					free(*shape->lines);
			}

			break;
		}

		case SHAPERECORD_LINETO:
		{
			int nBits;
			int dx = record.record.lineTo->dx;
			int dy = record.record.lineTo->dy;

			SWFOutput_writeBits(out, 3, 2); /* straight edge */

			if(dx==0 && dy!=0)
			{
				nBits = SWFOutput_numSBits(dy);
				SWF_assert(nBits<18);
				SWFOutput_writeBits(out, nBits-2, 4);
				SWFOutput_writeBits(out, 1, 2); /* vertical line */
				SWFOutput_writeSBits(out, dy, nBits);
			}
			else if(dy==0 && dx!=0)
			{
				nBits = SWFOutput_numSBits(dx);
				SWF_assert(nBits<18);
				SWFOutput_writeBits(out, nBits-2, 4);
				SWFOutput_writeBits(out, 0, 2); /* horizontal line */
				SWFOutput_writeSBits(out, dx, nBits);
			}
			else
			{
				nBits = max(SWFOutput_numSBits(dx), SWFOutput_numSBits(dy));
				nBits = max(nBits, 2);
				SWF_assert(nBits<18);
				SWFOutput_writeBits(out, nBits-2, 4);
				SWFOutput_writeBits(out, 1, 1); /* general line */
				SWFOutput_writeSBits(out, dx, nBits);
				SWFOutput_writeSBits(out, dy, nBits);
			}

			break;
		}

		case SHAPERECORD_CURVETO:
		{
			int controlx = record.record.curveTo->controlx;
			int controly = record.record.curveTo->controly;
			int anchorx = record.record.curveTo->anchorx;
			int anchory = record.record.curveTo->anchory;

			int nBits = max(max(SWFOutput_numSBits(controlx),
													SWFOutput_numSBits(controly)),
											max(SWFOutput_numSBits(anchorx),
													SWFOutput_numSBits(anchory)));

			if ( nBits < 2 )
				nBits = 2;

			SWF_assert(nBits < 18);

			SWFOutput_writeBits(out, 2, 2); /* curved edge */
			SWFOutput_writeBits(out, nBits-2, 4);
			SWFOutput_writeSBits(out, controlx, nBits);
			SWFOutput_writeSBits(out, controly, nBits);
			SWFOutput_writeSBits(out, anchorx, nBits);
			SWFOutput_writeSBits(out, anchory, nBits);

			break;
		}

		default:
			SWF_error("Unknown shapeRecordType");
	}
}
Example #7
0
void
destroySWFShape(SWFShape shape)
{
	int i, j;

	destroySWFOutput(shape->out);

	if (shape->isUsingNewStyles != TRUE) {
		for ( i=0; i<*shape->nFills; ++i )
		{
			SWFMatrix matrix = SWFFillStyle_getMatrix((*shape->fills)[i]);

			if ( matrix != NULL )
				destroySWFMatrix(matrix);

			/* gradients and bitmaps are destroyed separately */

			free((*shape->fills)[i]);
		}

		if ( *shape->fills != NULL )
			free(*shape->fills);

		for ( i=0; i<*shape->nLines; ++i )
			free((*shape->lines)[i]);

		if ( *shape->lines != NULL )
			free(*shape->lines);
	}

	if (shape->isEnded != TRUE) {
		for ( i=0; i<shape->nRecords; ++i )
		{
			ShapeRecord record = shape->records[i];

			if (record.type == SHAPERECORD_STATECHANGE &&
				 record.record.stateChange->flags & SWF_SHAPE_NEWSTYLEFLAG)
			{
				for ( j=0; i<record.record.stateChange->nFills; ++j )
				{
					SWFMatrix matrix = SWFFillStyle_getMatrix(record.record.stateChange->fills[j]);

					if ( matrix != NULL )
						destroySWFMatrix(matrix);

					/* gradients and bitmaps are destroyed separately */

					free(record.record.stateChange->fills[j]);
				}

				if ( record.record.stateChange->fills != NULL )
					free(record.record.stateChange->fills);

				for ( j=0; j<record.record.stateChange->nLines; ++j )
					free(record.record.stateChange->lines[j]);

				if ( record.record.stateChange->lines != NULL )
					free(record.record.stateChange->lines);
			}

			free(record.record.stateChange); /* all in union are pointers */
		}

		free(shape->records);
	}

#if TRACK_ALLOCS
	ming_gc_remove_node(shape->gcnode);
#endif

	destroySWFCharacter((SWFCharacter) shape);
}