+ character_t* idtable = rfx_calloc(sizeof(character_t)*65536); // id to character mapping
+ SWFPLACEOBJECT** depthtable = rfx_calloc(sizeof(SWFPLACEOBJECT*)*65536); // depth to placeobject mapping
+
+ tag = swf->firstTag;
+ numplacements = 0;
+ while(tag) {
+ if(tag->id == ST_PLACEOBJECT ||
+ tag->id == ST_PLACEOBJECT2) {
+ numplacements++;
+ }
+ tag = tag->next;
+ }
+ placements = rfx_calloc(sizeof(SWFPLACEOBJECT)*numplacements);
+ numplacements = 0;
+
+ /* set background color */
+ color = swf_GetSWFBackgroundColor(swf);
+ swf_Render_SetBackgroundColor(buf, color);
+
+ /* parse definitions */
+ tag = swf->firstTag;
+ while(tag) {
+ if(swf_isDefiningTag(tag)) {
+ int id = swf_GetDefineID(tag);
+ idtable[id].tag = tag;
+ idtable[id].bbox = rfx_alloc(sizeof(SRECT));
+ *idtable[id].bbox = swf_GetDefineBBox(tag);
+
+ if(swf_isShapeTag(tag)) {
+ SHAPE2* shape = rfx_calloc(sizeof(SHAPE2));
+ swf_ParseDefineShape(tag, shape);
+ idtable[id].type = shape_type;
+ idtable[id].obj.shape = shape;
+ } else if(swf_isImageTag(tag)) {
+ int width,height;
+ RGBA*data = swf_ExtractImage(tag, &width, &height);
+ idtable[id].type = image_type;
+ swf_Render_AddImage(buf, id, data, width, height);
+ free(data);
+ } else if(tag->id == ST_DEFINEFONT ||
+ tag->id == ST_DEFINEFONT2) {
+ int t;
+ SWFFONT*swffont;
+ font_t*font = rfx_calloc(sizeof(font_t));
+ idtable[id].obj.font = font;
+ swf_FontExtract(swf,id,&swffont);
+ font->numchars = swffont->numchars;
+ font->glyphs = rfx_calloc(sizeof(SHAPE2*)*font->numchars);
+ for(t=0;t<font->numchars;t++) {
+ if(!swffont->glyph[t].shape->fillstyle.n) {
+ /* the actual fill color will be overwritten while rendering */
+ swf_ShapeAddSolidFillStyle(swffont->glyph[t].shape, &color_white);
+ }
+ font->glyphs[t] = swf_ShapeToShape2(swffont->glyph[t].shape);
+ }
+ swf_FontFree(swffont);
+ idtable[id].type = font_type;
+
+ } else if(tag->id == ST_DEFINEFONTINFO ||
+ tag->id == ST_DEFINEFONTINFO2) {
+ idtable[id].type = font_type;
+ } else if(tag->id == ST_DEFINETEXT ||
+ tag->id == ST_DEFINETEXT2) {
+ idtable[id].type = text_type;
+ }
+ } else if(tag->id == ST_PLACEOBJECT ||
+ tag->id == ST_PLACEOBJECT2) {
+ SWFPLACEOBJECT p;
+ swf_GetPlaceObject(tag, &p);
+ /* TODO: add move and deletion */
+ placements[numplacements++] = p;
+ swf_PlaceObjectFree(&p); //dirty! but it only removes items we don't need
+ }
+ tag = tag->next;
+ }