svnno****@sourc*****
svnno****@sourc*****
2009年 6月 5日 (金) 02:04:14 JST
Revision: 142 http://svn.sourceforge.jp/view?root=swfed&view=rev&rev=142 Author: yoya Date: 2009-06-05 02:04:14 +0900 (Fri, 05 Jun 2009) Log Message: ----------- - swf_gradient_record.c の追加 - 他、関数の中身をいろいろ実装 TODO: swf_styles_count, swf_shape_record のその仲間たち。 Modified Paths: -------------- trunk/src/config.m4 trunk/src/swf_fill_style_bitmap.c trunk/src/swf_fill_style_gradient.c trunk/src/swf_fill_style_solid.c trunk/src/swf_gradient.c trunk/src/swf_gradient.h trunk/src/swf_gradient_record.h trunk/src/swf_line_style.c trunk/src/swf_line_style.h trunk/src/swf_line_style_array.c trunk/src/swf_line_style_array.h trunk/src/swf_shape_with_style.c trunk/src/swf_styles.c trunk/src/swf_tag_shape.c Added Paths: ----------- trunk/src/swf_gradient_record.c -------------- next part -------------- Modified: trunk/src/config.m4 =================================================================== --- trunk/src/config.m4 2009-06-03 17:09:24 UTC (rev 141) +++ trunk/src/config.m4 2009-06-04 17:04:14 UTC (rev 142) @@ -61,6 +61,6 @@ dnl dnl PHP_SUBST(SWFED_SHARED_LIBADD) - PHP_NEW_EXTENSION(swfed, swfed.c swf_object.c swf_header.c swf_rect.c swf_tag.c swf_tag_jpeg.c swf_tag_edit.c swf_tag_action.c swf_tag_lossless.c swf_tag_sound.c swf_tag_sprite.c swf_tag_shape.c swf_rgb.c swf_rgba.c swf_argb.c swf_xrgb.c swf_action.c swf_jpeg.c bitstream.c jpeg_segment.c swf_png.c swf_gif.c swf_shape_with_style.c swf_styles.c swf_fill_style_array.c swf_fill_style.c swf_morph_shape_with_style.c swf_fill_style_solid.c swf_fill_style_gradient.c swf_fill_style_bitmap.c swf_line_style_array.c swf_line_style.c swf_styles_count.c swf_shape_record.c swf_gradient.c swf_matrix.c swf_debug.c, $ext_shared) + PHP_NEW_EXTENSION(swfed, swfed.c swf_object.c swf_header.c swf_rect.c swf_tag.c swf_tag_jpeg.c swf_tag_edit.c swf_tag_action.c swf_tag_lossless.c swf_tag_sound.c swf_tag_sprite.c swf_tag_shape.c swf_rgb.c swf_rgba.c swf_argb.c swf_xrgb.c swf_action.c swf_jpeg.c bitstream.c jpeg_segment.c swf_png.c swf_gif.c swf_shape_with_style.c swf_styles.c swf_fill_style_array.c swf_fill_style.c swf_morph_shape_with_style.c swf_fill_style_solid.c swf_fill_style_gradient.c swf_fill_style_bitmap.c swf_line_style_array.c swf_line_style.c swf_styles_count.c swf_shape_record.c swf_gradient.c swf_matrix.c swf_gradient_record.c swf_debug.c, $ext_shared) fi Modified: trunk/src/swf_fill_style_bitmap.c =================================================================== --- trunk/src/swf_fill_style_bitmap.c 2009-06-03 17:09:24 UTC (rev 141) +++ trunk/src/swf_fill_style_bitmap.c 2009-06-04 17:04:14 UTC (rev 142) @@ -29,6 +29,8 @@ swf_fill_style_bitmap_print(swf_fill_style_bitmap_t *fill_style_bitmap, int indent_depth, swf_tag_t *tag) { print_indent(indent_depth); + printf("fill_style_bitmap\n"); + print_indent(indent_depth); printf("bitmap_ref=%u\n", fill_style_bitmap->bitmap_ref); swf_matrix_print(&(fill_style_bitmap->bitmap_matrix), indent_depth); if (tag->tag == 46 || tag->tag == 84) { // DefineMorphShape, DefineMorphShape2 Modified: trunk/src/swf_fill_style_gradient.c =================================================================== --- trunk/src/swf_fill_style_gradient.c 2009-06-03 17:09:24 UTC (rev 141) +++ trunk/src/swf_fill_style_gradient.c 2009-06-04 17:04:14 UTC (rev 142) @@ -10,26 +10,28 @@ if (tag->tag == 46 || tag->tag == 84) { swf_matrix_parse(bs, &(fill_style_gradient->gradient_matrix_morph)); } - swf_gradient_parse(bs, &(fill_style_gradient->gradient)); + swf_gradient_parse(bs, &(fill_style_gradient->gradient), tag); return 0; } int swf_fill_style_gradient_build(bitstream_t *bs, swf_fill_style_gradient_t *fill_style_gradient, - swf_tag_t* tag) { + swf_tag_t *tag) { swf_matrix_build(bs, &(fill_style_gradient->gradient_matrix)); // DefineMorphShape, DefineMorphShape2 if (tag->tag == 46 || tag->tag == 84) { swf_matrix_build(bs, &(fill_style_gradient->gradient_matrix_morph)); } - swf_gradient_build(bs, &(fill_style_gradient->gradient)); + swf_gradient_build(bs, &(fill_style_gradient->gradient), tag); return 0; } int swf_fill_style_gradient_print(swf_fill_style_gradient_t *fill_style_gradient, int indent_depth, swf_tag_t* tag) { + print_indent(indent_depth); + printf("fill_style_gradient\n"); swf_matrix_print(&(fill_style_gradient->gradient_matrix), indent_depth + 1); // DefineMorphShape, DefineMorphShape2 @@ -37,6 +39,6 @@ swf_matrix_print(&(fill_style_gradient->gradient_matrix_morph), indent_depth + 1); } - swf_gradient_print(&(fill_style_gradient->gradient), indent_depth); + swf_gradient_print(&(fill_style_gradient->gradient), indent_depth, tag); return 0; } Modified: trunk/src/swf_fill_style_solid.c =================================================================== --- trunk/src/swf_fill_style_solid.c 2009-06-03 17:09:24 UTC (rev 141) +++ trunk/src/swf_fill_style_solid.c 2009-06-04 17:04:14 UTC (rev 142) @@ -35,6 +35,8 @@ swf_fill_style_solid_print(swf_fill_style_solid_t *fill_style_solid, int indent_depth, swf_tag_t *tag ) { + print_indent(indent_depth); + printf("fill_style_solid\n"); if (tag->tag == 46 || tag->tag == 84) { // DefineMorphShape, DefineMorphShape2 swf_rgba_print(&(fill_style_solid->rgba), indent_depth + 1); swf_rgba_print(&(fill_style_solid->rgba_morph), indent_depth + 1); Modified: trunk/src/swf_gradient.c =================================================================== --- trunk/src/swf_gradient.c 2009-06-03 17:09:24 UTC (rev 141) +++ trunk/src/swf_gradient.c 2009-06-04 17:04:14 UTC (rev 142) @@ -3,17 +3,33 @@ #include "swf_gradient.h" int -swf_gradient_parse(bitstream_t *bs, swf_gradient_t *gradient) { +swf_gradient_parse(bitstream_t *bs, swf_gradient_t *gradient, + swf_tag_t *tag) { + int i; + if (tag->tag == 83) { // DefineShape4 + gradient->spread_mode = bitstream_getbits(bs, 2); + gradient->interpolation_mode = bitstream_getbits(bs, 2); + gradient->count = bitstream_getbits(bs, 4); + } else { + gradient->pad = bitstream_getbits(bs, 4); + gradient->count = bitstream_getbits(bs, 4); + } + for (i = 0 ; i < gradient->count ; i++) { + swf_grandient_record_parse(bs, &(gradient->gradient_record[i])); + gradient->focal_point = bitstream_getbytesLE(bs, 2); + } return 0; } int -swf_gradient_build(bitstream_t *bs, swf_gradient_t *gradient) { +swf_gradient_build(bitstream_t *bs, swf_gradient_t *gradient, + swf_tag_t *tag) { return 0; } int -swf_gradient_print(swf_gradient_t *gradient, int indent_depth) { +swf_gradient_print(swf_gradient_t *gradient, int indent_depth, + swf_tag_t *tag) { print_indent(indent_depth); return 0; } Modified: trunk/src/swf_gradient.h =================================================================== --- trunk/src/swf_gradient.h 2009-06-03 17:09:24 UTC (rev 141) +++ trunk/src/swf_gradient.h 2009-06-04 17:04:14 UTC (rev 142) @@ -7,6 +7,7 @@ #ifndef __SWF_GRADIENT_H__ #define __SWF_GRADIENT_H__ +#include "swf_tag.h" #include "swf_gradient_record.h" typedef union swf_gradient_ { @@ -19,8 +20,11 @@ } swf_gradient_t; -extern int swf_gradient_parse(bitstream_t *bs, swf_gradient_t *color); -extern int swf_gradient_build(bitstream_t *bs, swf_gradient_t *color); -extern int swf_gradient_print(swf_gradient_t *color, int indent_depth); +extern int swf_gradient_parse(bitstream_t *bs, swf_gradient_t *gradient, + swf_tag_t *tag); +extern int swf_gradient_build(bitstream_t *bs, swf_gradient_t *gradient, + swf_tag_t *tag); +extern int swf_gradient_print(swf_gradient_t *gradient, int indent_depth, + swf_tag_t *tag); #endif /* __SWF_GRADIENT_H__ */ Added: trunk/src/swf_gradient_record.c =================================================================== --- trunk/src/swf_gradient_record.c (rev 0) +++ trunk/src/swf_gradient_record.c 2009-06-04 17:04:14 UTC (rev 142) @@ -0,0 +1,37 @@ +#include <stdio.h> +#include "bitstream.h" +#include "swf_gradient_record.h" + +int +swf_gradient_record_parse(bitstream_t + *bs, swf_gradient_record_t *gradient_record, + swf_tag_t *tag) { + if (tag->tag == 46 || tag->tag == 84) { // DefineMorph || DefineMorphShape2 + gradient_record->position = bitstream_getbyte(bs); + swf_rgba_parse(bs, &(gradient_record->rgba)); + gradient_record->position_morph = bitstream_getbyte(bs); + swf_rgba_parse(bs, &(gradient_record->rgba_morph)); + } else if (tag->tag == 32 || tag->tag == 83) { + // DefineShape3 || DefineShape4 + gradient_record->position = bitstream_getbyte(bs); + swf_rgba_parse(bs, &(gradient_record->rgba)); + } else { + gradient_record->position = bitstream_getbyte(bs); + swf_rgb_parse(bs, &(gradient_record->rgb)); + } + return 0; +} + +int +swf_gradient_record_build(bitstream_t *bs, + swf_gradient_record_t *gradient_record, + swf_tag_t *tag) { + return 0; +} + +int +swf_gradient_record_print(swf_gradient_record_t *gradient_record, + int indent_depth, swf_tag_t *tag) { + print_indent(indent_depth); + return 0; +} Modified: trunk/src/swf_gradient_record.h =================================================================== --- trunk/src/swf_gradient_record.h 2009-06-03 17:09:24 UTC (rev 141) +++ trunk/src/swf_gradient_record.h 2009-06-04 17:04:14 UTC (rev 142) @@ -7,6 +7,7 @@ #ifndef __SWF_GRADIENT_RECORD_H__ #define __SWF_GRADIENT_RECORD_H__ +#include "swf_tag.h" #include "swf_rgba.h" #include "swf_rgb.h" @@ -18,8 +19,13 @@ swf_rgb_t rgb; // other } swf_gradient_record_t; -extern int swf_gradient_record_parse(bitstream_t *bs, swf_gradient_record_t *color); -extern int swf_gradient_record_build(bitstream_t *bs, swf_gradient_record_t *color); -extern int swf_gradient_record_print(swf_gradient_record_t *color, int indent_depth); +extern int swf_gradient_record_parse(bitstream_t *bs, + swf_gradient_record_t *gradient_record, + swf_tag_t *tag); +extern int swf_gradient_record_build(bitstream_t *bs, + swf_gradient_record_t *gradient_record, + swf_tag_t *tag); +extern int swf_gradient_record_print(swf_gradient_record_t *gradient_record, + int indent_depth, swf_tag_t *tag); #endif /* __SWF_GRADIENT_RECORD_H__ */ Modified: trunk/src/swf_line_style.c =================================================================== --- trunk/src/swf_line_style.c 2009-06-03 17:09:24 UTC (rev 141) +++ trunk/src/swf_line_style.c 2009-06-04 17:04:14 UTC (rev 142) @@ -2,19 +2,58 @@ #include "bitstream.h" #include "swf_line_style.h" -swf_line_style_parse(bitstream_t *bs, swf_line_style_t *line_style) { - ; +swf_line_style_parse(bitstream_t *bs, swf_line_style_t *line_style, + swf_tag_t *tag) { + if (tag->tag == 46) { // DefineMorphShape + line_style->width = bitstream_getbytesLE(bs, 2); + line_style->width_morph = bitstream_getbytesLE(bs, 2); + swf_rgba_parse(bs, &(line_style->rgba)); + swf_rgba_parse(bs, &(line_style->rgba_morph)); + } else if (tag->tag == 83 || tag->tag == 84) { + // DefineShape4 || DefineMorphShape2 + if (tag->tag == 84) { // DefineMorphShape2 + line_style->width_morph = bitstream_getbytesLE(bs, 2); + } + line_style->start_cap_style = bitstream_getbits(bs, 2); + line_style->join_style = bitstream_getbits(bs, 2); + line_style->has_fill = bitstream_getbits(bs, 1); + line_style->no_hscale = bitstream_getbits(bs, 1); + line_style->no_vscale = bitstream_getbits(bs, 1); + line_style->pixel_hinting = bitstream_getbits(bs, 1); + line_style->reserved = bitstream_getbits(bs, 5); + line_style->no_close = bitstream_getbits(bs, 1); + line_style->end_cap_style = bitstream_getbits(bs, 2); + if (line_style->join_style == 2) { + line_style->miter_limit_factor = bitstream_getbytesLE(bs, 2); + } + if (line_style->has_fill) { + swf_fill_style_parse(bs, &(line_style->fill_style), tag); + } else { + swf_rgba_parse(bs, &(line_style->rgba)); + if (tag->tag == 84) { // DefineMorphShape2 + swf_rgba_parse(bs, &(line_style->rgba_morph)); + } + } + } else if (tag->tag == 32) { // DefineShape3 + line_style->width = bitstream_getbytesLE(bs, 2); + swf_rgba_parse(bs, &(line_style->rgba)); + } else { + line_style->width = bitstream_getbytesLE(bs, 2); + swf_rgb_parse(bs, &(line_style->rgb)); + } return 0; } int -swf_line_style_build(bitstream_t *bs, swf_line_style_t *line_style) { +swf_line_style_build(bitstream_t *bs, swf_line_style_t *line_style, + swf_tag_t *tag) { ; return 0; } int -swf_line_style_print(swf_line_style_t *line_style, int indent_depth) { +swf_line_style_print(swf_line_style_t *line_style, int indent_depth, + swf_tag_t *tag) { ; return 0; } Modified: trunk/src/swf_line_style.h =================================================================== --- trunk/src/swf_line_style.h 2009-06-03 17:09:24 UTC (rev 141) +++ trunk/src/swf_line_style.h 2009-06-04 17:04:14 UTC (rev 142) @@ -7,6 +7,7 @@ #ifndef __SWF_LINE_STYLE_H__ #define __SWF_LINE_STYLE_H__ +#include "swf_tag.h" #include "swf_rgba.h" #include "swf_fill_style.h" #include "swf_rgb.h" @@ -32,8 +33,11 @@ } swf_line_style_t; -extern int swf_line_style_parse(bitstream_t *bs, swf_line_style_t *color); -extern int swf_line_style_build(bitstream_t *bs, swf_line_style_t *color); -extern int swf_line_style_print(swf_line_style_t *color, int indent_depth); +extern int swf_line_style_parse(bitstream_t *bs, + swf_line_style_t *line_style, swf_tag_t *tag); +extern int swf_line_style_build(bitstream_t *bs, + swf_line_style_t *line_style, swf_tag_t *tag); +extern int swf_line_style_print(swf_line_style_t *line_style, + int indent_depth, swf_tag_t *tag); #endif /* __SWF_LINE_STYLE_H__ */ Modified: trunk/src/swf_line_style_array.c =================================================================== --- trunk/src/swf_line_style_array.c 2009-06-03 17:09:24 UTC (rev 141) +++ trunk/src/swf_line_style_array.c 2009-06-04 17:04:14 UTC (rev 142) @@ -1,23 +1,53 @@ #include <stdio.h> +#include <stdlib.h> // calloc #include "bitstream.h" #include "swf_line_style_array.h" +int swf_line_style_array_parse(bitstream_t *bs, - swf_line_style_array_t *line_style_array) { - ; + swf_line_style_array_t *shape_with_style, + swf_tag_t *tag) { + int i; + shape_with_style->count = bitstream_getbyte(bs); + if (tag->tag != 2 || // ! DefineShape + shape_with_style->count == 255) { + shape_with_style->count = bitstream_getbytesLE(bs, 2); + } + shape_with_style->line_style = calloc(shape_with_style->count, sizeof(swf_line_style_t)); // XXX free !!! XXX + for (i = 0 ; i < shape_with_style->count ; i++) { + swf_line_style_parse(bs, &(shape_with_style->line_style[i]), tag); + } return 0; } int -swf_line_style_array_build(bitstream_t *bs, - swf_line_style_array_t *line_style_array) { - ; - return 0; +swf_line_style_array_build(bitstream_t *bs, swf_line_style_array_t *shape_with_style, swf_tag_t *tag) { + int i; + if (tag->tag != 2 || // ! DefineShape + 255 <= shape_with_style->count) { + bitstream_putbyte(bs, 255); + bitstream_putbytesLE(bs, shape_with_style->count, 2); + } else { + bitstream_putbyte(bs, shape_with_style->count); + } + for (i = 0 ; i < shape_with_style->count ; i++) { + swf_line_style_built(bs, &(shape_with_style->line_style[i]), tag); + } } int -swf_line_style_array_print(swf_line_style_array_t *line_style_array, - int indent_depth) { - ; +swf_line_style_array_print(swf_line_style_array_t *shape_with_style, int indent_depth, swf_tag_t *tag) { + int i; + print_indent(indent_depth); + printf("count=%u\n", shape_with_style->count); + for (i = 0 ; i < shape_with_style->count ; i++) { + swf_line_style_print(&(shape_with_style->line_style[i]), + indent_depth + 1, tag); + } return 0; } + +int +swf_line_style_array_delete(swf_line_style_array_t *line_style_array) { + free(line_style_array->line_style); +} Modified: trunk/src/swf_line_style_array.h =================================================================== --- trunk/src/swf_line_style_array.h 2009-06-03 17:09:24 UTC (rev 141) +++ trunk/src/swf_line_style_array.h 2009-06-04 17:04:14 UTC (rev 142) @@ -14,8 +14,14 @@ swf_line_style_t *line_style; } swf_line_style_array_t; -extern int swf_line_style_array_parse(bitstream_t *bs, swf_line_style_array_t *color); -extern int swf_line_style_array_build(bitstream_t *bs, swf_line_style_array_t *color); -extern int swf_line_style_array_print(swf_line_style_array_t *color, int indent_depth); +extern int swf_line_style_array_parse(bitstream_t *bs, + swf_line_style_array_t *line_style_array, + swf_tag_t *tag); +extern int swf_line_style_array_build(bitstream_t *bs, + swf_line_style_array_t *line_style_array, + swf_tag_t *tag); +extern int swf_line_style_array_print(swf_line_style_array_t *line_style_array, + int indent_depth, swf_tag_t *tag); +extern int swf_line_style_array_delete(swf_line_style_array_t *line_style_array); #endif /* __SWF_LINE_STYLE_ARRAY_H__ */ Modified: trunk/src/swf_shape_with_style.c =================================================================== --- trunk/src/swf_shape_with_style.c 2009-06-03 17:09:24 UTC (rev 141) +++ trunk/src/swf_shape_with_style.c 2009-06-04 17:04:14 UTC (rev 142) @@ -21,6 +21,6 @@ int swf_shape_with_style_print(swf_shape_with_style_t *shape_with_style, int indent_depth, swf_tag_t *tag) { swf_styles_print(&(shape_with_style->styles), indent_depth, tag); -// swf_shape_record_print(&(shape_with_style->shape_records), indent_depth); + swf_shape_record_print(&(shape_with_style->shape_records), indent_depth); return 0; } Modified: trunk/src/swf_styles.c =================================================================== --- trunk/src/swf_styles.c 2009-06-03 17:09:24 UTC (rev 141) +++ trunk/src/swf_styles.c 2009-06-04 17:04:14 UTC (rev 142) @@ -6,7 +6,7 @@ swf_styles_parse(bitstream_t *bs, swf_styles_t *shape_with_style, swf_tag_t *tag) { swf_fill_style_array_parse(bs, &(shape_with_style->fill_styles), tag); - swf_line_style_array_parse(bs, &(shape_with_style->line_styles)); + swf_line_style_array_parse(bs, &(shape_with_style->line_styles), tag); swf_styles_count_parse(bs, &(shape_with_style->styles_count)); return 0; } @@ -15,7 +15,7 @@ swf_styles_build(bitstream_t *bs, swf_styles_t *shape_with_style, swf_tag_t *tag) { swf_fill_style_array_build(bs, &(shape_with_style->fill_styles), tag); - swf_line_style_array_build(bs, &(shape_with_style->line_styles)); + swf_line_style_array_build(bs, &(shape_with_style->line_styles), tag); swf_styles_count_build(bs, &(shape_with_style->styles_count)); return 0; } @@ -25,7 +25,8 @@ swf_tag_t *tag) { swf_fill_style_array_print(&(shape_with_style->fill_styles), indent_depth, tag); - swf_line_style_array_print(&(shape_with_style->line_styles), indent_depth); + swf_line_style_array_print(&(shape_with_style->line_styles), indent_depth, + tag); swf_styles_count_print(&(shape_with_style->styles_count), indent_depth); return 0; } @@ -33,4 +34,5 @@ int swf_styles_delete(swf_styles_t *styles) { swf_fill_styles_array_delete(&(styles->fill_styles)); + swf_line_styles_array_delete(&(styles->line_styles)); } Modified: trunk/src/swf_tag_shape.c =================================================================== --- trunk/src/swf_tag_shape.c 2009-06-03 17:09:24 UTC (rev 141) +++ trunk/src/swf_tag_shape.c 2009-06-04 17:04:14 UTC (rev 142) @@ -152,6 +152,7 @@ swf_tag_shape_destroy_detail(swf_tag_t *tag) { swf_tag_shape_detail_t *swf_tag_shape = (swf_tag_shape_detail_t *) tag->detail; if (swf_tag_shape) { + swf_morph_shape_with_style_delete(&(swf_tag_shape->morph_shape_with_style)); free(swf_tag_shape); } return ;