[Swfed-svn] swfed-svn [141] swf_fill_style_bitmap が処理できそうな所まで実装 ( 未テスト )

Back to archive index

svnno****@sourc***** svnno****@sourc*****
2009年 6月 4日 (木) 02:09:24 JST


Revision: 141
          http://svn.sourceforge.jp/view?root=swfed&view=rev&rev=141
Author:   yoya
Date:     2009-06-04 02:09:24 +0900 (Thu, 04 Jun 2009)

Log Message:
-----------
swf_fill_style_bitmap が処理できそうな所まで実装 (未テスト)

Modified Paths:
--------------
    trunk/src/swf_fill_style.c
    trunk/src/swf_fill_style.h
    trunk/src/swf_fill_style_array.c
    trunk/src/swf_fill_style_array.h
    trunk/src/swf_fill_style_bitmap.c
    trunk/src/swf_fill_style_bitmap.h
    trunk/src/swf_fill_style_gradient.c
    trunk/src/swf_fill_style_gradient.h
    trunk/src/swf_fill_style_solid.c
    trunk/src/swf_fill_style_solid.h
    trunk/src/swf_matrix.c
    trunk/src/swf_morph_shape_with_style.c
    trunk/src/swf_morph_shape_with_style.h
    trunk/src/swf_shape_record.h
    trunk/src/swf_shape_with_style.c
    trunk/src/swf_shape_with_style.h
    trunk/src/swf_styles.c
    trunk/src/swf_styles.h
    trunk/src/swf_styles_count.h
    trunk/src/swf_tag_shape.c


-------------- next part --------------
Modified: trunk/src/swf_fill_style.c
===================================================================
--- trunk/src/swf_fill_style.c	2009-06-03 16:37:40 UTC (rev 140)
+++ trunk/src/swf_fill_style.c	2009-06-03 17:09:24 UTC (rev 141)
@@ -8,46 +8,68 @@
     shape_with_style->type = bitstream_getbyte(bs);
     switch (shape_with_style->type) {
       case 0x00: // solid fill
-//        swf_fill_style_solid_parse(bs, shape_with_style, tag);
+        swf_fill_style_solid_parse(bs, &(shape_with_style->solid), tag);
         break;
       case 0x10: // linear gradientfill
       case 0x11: // radial gradientfill
       case 0x12: // focal gradient fill
-//        swf_fill_style_gradient_parse(bs, shape_with_style, tag);
+        swf_fill_style_gradient_parse(bs, &(shape_with_style->gradient), tag);
         break;
       case 0x40: // tilled bitmap fill with smoothed edges
       case 0x41: // clipped bitmap fill with smoothed edges
       case 0x42: // tilled bitmap fill with hard edges
       case 0x43: // clipped bitmap fill with hard edges
-        //        swf_fill_style_bitmap_parse(bs, shape_with_style, tag);
+        swf_fill_style_bitmap_parse(bs, &(shape_with_style->bitmap), tag);
         break;
     }
     return 0;
 }
 
 int
-swf_fill_style_build(bitstream_t *bs, swf_fill_style_t *shape_with_style) {
+swf_fill_style_build(bitstream_t *bs, swf_fill_style_t *shape_with_style,
+    swf_tag_t *tag) {
+    bitstream_putbyte(bs, shape_with_style->type);
+    switch (shape_with_style->type) {
+      case 0x00: // solid fill
+        swf_fill_style_solid_build(bs, &(shape_with_style->solid), tag);
+        break;
+      case 0x10: // linear gradientfill
+      case 0x11: // radial gradientfill
+      case 0x12: // focal gradient fill
+        swf_fill_style_gradient_build(bs, &(shape_with_style->gradient), tag);
+        break;
+      case 0x40: // tilled bitmap fill with smoothed edges
+      case 0x41: // clipped bitmap fill with smoothed edges
+      case 0x42: // tilled bitmap fill with hard edges
+      case 0x43: // clipped bitmap fill with hard edges
+        swf_fill_style_bitmap_build(bs, &(shape_with_style->bitmap), tag);
+        break;
+    }
     return 0;
 }
 
 int
-swf_fill_style_print(swf_fill_style_t *shape_with_style, int indent_depth) {
+swf_fill_style_print(swf_fill_style_t *shape_with_style, int indent_depth,
+    swf_tag_t *tag) {
     print_indent(indent_depth);
     printf("type=0x%02x\n", shape_with_style->type);
         switch (shape_with_style->type) {
           case 0x00: // solid fill
-//        swf_fill_style_solid_print(bs, shape_with_style, indent_depth);
-              break;
+            swf_fill_style_solid_print(&(shape_with_style->solid),
+                                       indent_depth, tag);
+            break;
           case 0x10: // linear gradientfill
           case 0x11: // radial gradientfill
           case 0x12: // focal gradient fill
-//        swf_fill_style_gradient_print(hape_with_style, indent_depth);
+            swf_fill_style_gradient_print(&(shape_with_style->gradient),
+                                          indent_depth, tag);
             break;
           case 0x40: // tilled bitmap fill with smoothed edges
           case 0x41: // clipped bitmap fill with smoothed edges
           case 0x42: // tilled bitmap fill with hard edges
           case 0x43: // clipped bitmap fill with hard edges
-//        swf_fill_style_bitmap_print(shape_with_style, indent_depth);
+            swf_fill_style_bitmap_print(&(shape_with_style->bitmap),
+                                        indent_depth, tag);
             break;
         }
     return 0;

Modified: trunk/src/swf_fill_style.h
===================================================================
--- trunk/src/swf_fill_style.h	2009-06-03 16:37:40 UTC (rev 140)
+++ trunk/src/swf_fill_style.h	2009-06-03 17:09:24 UTC (rev 141)
@@ -21,7 +21,9 @@
 
 extern int swf_fill_style_parse(bitstream_t *bs, swf_fill_style_t *color,
                                 swf_tag_t *tag);
-extern int swf_fill_style_build(bitstream_t *bs, swf_fill_style_t *color);
-extern int swf_fill_style_print(swf_fill_style_t *color, int indent_depth);
+extern int swf_fill_style_build(bitstream_t *bs, swf_fill_style_t *color,
+                                swf_tag_t *tag);
+extern int swf_fill_style_print(swf_fill_style_t *color, int indent_depth,
+                                swf_tag_t *tag);
 
 #endif /* __SWF_FILL_STYLE_H__ */

Modified: trunk/src/swf_fill_style_array.c
===================================================================
--- trunk/src/swf_fill_style_array.c	2009-06-03 16:37:40 UTC (rev 140)
+++ trunk/src/swf_fill_style_array.c	2009-06-03 17:09:24 UTC (rev 141)
@@ -1,4 +1,5 @@
 #include <stdio.h>
+#include <stdlib.h> // calloc
 #include "bitstream.h"
 #include "swf_fill_style_array.h"
 
@@ -8,28 +9,45 @@
                            swf_tag_t *tag) {
     int i;
     shape_with_style->count = bitstream_getbyte(bs);
-    if (tag->tag != 2 || // DefineShape
+    if (tag->tag != 2 || // ! DefineShape
         shape_with_style->count == 255) {
         shape_with_style->count = bitstream_getbytesLE(bs, 2);
     }
+    shape_with_style->fill_style = calloc(shape_with_style->count, sizeof(swf_fill_style_t)); // XXX free !!! XXX
     for (i = 0 ; i < shape_with_style->count ; i++) {
-        swf_fill_style_parse(bs, &(shape_with_style->fill_style), tag);
+        swf_fill_style_parse(bs, &(shape_with_style->fill_style[i]), tag);
     }
     return 0;
 }
 
 int
-swf_fill_style_array_build(bitstream_t *bs, swf_fill_style_array_t *shape_with_style) {
-//    swf_fill_style_array_build(bs, &(shape_with_style->fill_styles));
-//    swf_line_style_array_build(bs, &(shape_with_style->line_styles));
-//    swf_fill_style_array_count_build(bs, &(shape_with_style->line_styles));
-    return 0;
+swf_fill_style_array_build(bitstream_t *bs, swf_fill_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_fill_style_built(bs, &(shape_with_style->fill_style[i]), tag);
+    }
 }
 
 int
-swf_fill_style_array_print(swf_fill_style_array_t *shape_with_style, int indent_depth) {
-//    swf_fill_style_array_print(&(shape_with_style->fill_styles), indent_depth);
-//    swf_line_style_array_print(&(shape_with_style->line_styles), indent_depth);
-//    swf_fill_style_array_count_print(&(shape_with_style->line_styles), indent_depth);
+swf_fill_style_array_print(swf_fill_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_fill_style_print(&(shape_with_style->fill_style[i]),
+                             indent_depth + 1, tag);
+    }
     return 0;
 }
+
+int
+swf_fill_style_array_delete(swf_fill_style_array_t *fill_style_array) {
+    free(fill_style_array->fill_style);
+}

Modified: trunk/src/swf_fill_style_array.h
===================================================================
--- trunk/src/swf_fill_style_array.h	2009-06-03 16:37:40 UTC (rev 140)
+++ trunk/src/swf_fill_style_array.h	2009-06-03 17:09:24 UTC (rev 141)
@@ -15,8 +15,15 @@
     swf_fill_style_t *fill_style;
 } swf_fill_style_array_t;
 
-extern int swf_fill_style_array_parse(bitstream_t *bs, swf_fill_style_array_t *color, swf_tag_t *tag);
-extern int swf_fill_style_array_build(bitstream_t *bs, swf_fill_style_array_t *color);
-extern int swf_fill_style_array_print(swf_fill_style_array_t *color, int indent_depth);
+extern int swf_fill_style_array_parse(bitstream_t *bs,
+                                      swf_fill_style_array_t *fill_style_array,
+                                      swf_tag_t *tag);
+extern int swf_fill_style_array_build(bitstream_t *bs,
+                                      swf_fill_style_array_t *fill_style_array,
+                                      swf_tag_t *tag);
+extern int swf_fill_style_array_print(swf_fill_style_array_t *fill_style_array,
+                                      int indent_depth,
+                                      swf_tag_t *tag);
+extern int swf_fill_style_array_delete(swf_fill_style_array_t *fill_style_array);
 
 #endif /* __SWF_FILL_STYLE_ARRAY_H__ */

Modified: trunk/src/swf_fill_style_bitmap.c
===================================================================
--- trunk/src/swf_fill_style_bitmap.c	2009-06-03 16:37:40 UTC (rev 140)
+++ trunk/src/swf_fill_style_bitmap.c	2009-06-03 17:09:24 UTC (rev 141)
@@ -3,21 +3,36 @@
 #include "swf_fill_style_bitmap.h"
 
 swf_fill_style_bitmap_parse(bitstream_t *bs,
-                            swf_fill_style_bitmap_t *fill_style_bitmap) {
-    ;
+                            swf_fill_style_bitmap_t *fill_style_bitmap,
+                            swf_tag_t *tag) {
+    fill_style_bitmap->bitmap_ref = bitstream_getbytesLE(bs, 2);
+    swf_matrix_parse(bs, &(fill_style_bitmap->bitmap_matrix));
+    if (tag->tag == 46 || tag->tag == 84) { // DefineMorphShape, DefineMorphShape2
+        swf_matrix_parse(bs, &(fill_style_bitmap->bitmap_matrix_morph));
+    }
     return 0;
 }
 
 int
 swf_fill_style_bitmap_build(bitstream_t *bs,
-                            swf_fill_style_bitmap_t *fill_style_bitmap) {
-    ;
+                            swf_fill_style_bitmap_t *fill_style_bitmap,
+                            swf_tag_t *tag) {
+    bitstream_putbytesLE(bs, fill_style_bitmap->bitmap_ref, 2);
+    swf_matrix_build(bs, &(fill_style_bitmap->bitmap_matrix));
+    if (tag->tag == 46 || tag->tag == 84) { // DefineMorphShape, DefineMorphShape2
+        swf_matrix_build(bs, &(fill_style_bitmap->bitmap_matrix_morph));
+    }
     return 0;
 }
 
 int
 swf_fill_style_bitmap_print(swf_fill_style_bitmap_t *fill_style_bitmap,
-                            int indent_depth) {
-    ;
+                            int indent_depth, swf_tag_t *tag) {
+    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
+        swf_matrix_print(&(fill_style_bitmap->bitmap_matrix_morph), indent_depth);
+    }
     return 0;
 }

Modified: trunk/src/swf_fill_style_bitmap.h
===================================================================
--- trunk/src/swf_fill_style_bitmap.h	2009-06-03 16:37:40 UTC (rev 140)
+++ trunk/src/swf_fill_style_bitmap.h	2009-06-03 17:09:24 UTC (rev 141)
@@ -7,6 +7,7 @@
 #ifndef __SWF_FILL_STYLE_BITMAP_H__
 #define __SWF_FILL_STYLE_BITMAP_H__
 
+#include "swf_tag.h"
 #include "swf_matrix.h"
 
 typedef struct swf_fill_style_bitmap_ {
@@ -16,8 +17,14 @@
     swf_matrix_t bitmap_matrix_morph; // DefineMorphShape, DefineMorphShape2
 } swf_fill_style_bitmap_t;
 
-extern int swf_fill_style_bitmap_parse(bitstream_t *bs, swf_fill_style_bitmap_t *color);
-extern int swf_fill_style_bitmap_build(bitstream_t *bs, swf_fill_style_bitmap_t *color);
-extern int swf_fill_style_bitmap_print(swf_fill_style_bitmap_t *color, int indent_depth);
+extern int swf_fill_style_bitmap_parse(bitstream_t *bs,
+                                       swf_fill_style_bitmap_t *bitmap,
+                                       swf_tag_t *tag);
+extern int swf_fill_style_bitmap_build(bitstream_t *bs,
+                                       swf_fill_style_bitmap_t *bitmap,
+                                       swf_tag_t *tag);
+extern int swf_fill_style_bitmap_print(swf_fill_style_bitmap_t *bitmap,
+                                       int indent_depth,
+                                       swf_tag_t *tag);
 
 #endif /* __SWF_FILL_STYLE_BITMAP_H__ */

Modified: trunk/src/swf_fill_style_gradient.c
===================================================================
--- trunk/src/swf_fill_style_gradient.c	2009-06-03 16:37:40 UTC (rev 140)
+++ trunk/src/swf_fill_style_gradient.c	2009-06-03 17:09:24 UTC (rev 141)
@@ -3,21 +3,40 @@
 #include "swf_fill_style_gradient.h"
 
 swf_fill_style_gradient_parse(bitstream_t *bs,
-                              swf_fill_style_gradient_t *fill_style_gradient) {
-    ;
+                              swf_fill_style_gradient_t *fill_style_gradient,
+                              swf_tag_t* tag) {
+    swf_matrix_parse(bs, &(fill_style_gradient->gradient_matrix));
+    // DefineMorphShape, DefineMorphShape2
+    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));
     return 0;
 }
 
 int
 swf_fill_style_gradient_build(bitstream_t *bs,
-                              swf_fill_style_gradient_t *fill_style_gradient) {
-    ;
+                              swf_fill_style_gradient_t *fill_style_gradient,
+                              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));
     return 0;
 }
 
 int
 swf_fill_style_gradient_print(swf_fill_style_gradient_t *fill_style_gradient,
-                              int indent_depth) {
-    ;
+                              int indent_depth, swf_tag_t* tag) {
+    swf_matrix_print(&(fill_style_gradient->gradient_matrix),
+                     indent_depth + 1);
+    // DefineMorphShape, DefineMorphShape2
+    if (tag->tag == 46 || tag->tag == 84) {
+        swf_matrix_print(&(fill_style_gradient->gradient_matrix_morph),
+                         indent_depth + 1);
+    }
+    swf_gradient_print(&(fill_style_gradient->gradient), indent_depth);
     return 0;
 }

Modified: trunk/src/swf_fill_style_gradient.h
===================================================================
--- trunk/src/swf_fill_style_gradient.h	2009-06-03 16:37:40 UTC (rev 140)
+++ trunk/src/swf_fill_style_gradient.h	2009-06-03 17:09:24 UTC (rev 141)
@@ -7,6 +7,7 @@
 #ifndef __SWF_FILL_STYLE_GRADIENT_H__
 #define __SWF_FILL_STYLE_GRADIENT_H__
 
+#include "swf_tag.h"
 #include "swf_matrix.h"
 #include "swf_gradient.h"
 
@@ -17,8 +18,13 @@
     swf_gradient_t gradient;
 } swf_fill_style_gradient_t;
 
-extern int swf_fill_style_gradient_parse(bitstream_t *bs, swf_fill_style_gradient_t *color);
-extern int swf_fill_style_gradient_build(bitstream_t *bs, swf_fill_style_gradient_t *color);
-extern int swf_fill_style_gradient_print(swf_fill_style_gradient_t *color, int indent_depth);
+extern int swf_fill_style_gradient_parse(bitstream_t *bs,
+                                         swf_fill_style_gradient_t *gradient,
+                                         swf_tag_t *tag);
+extern int swf_fill_style_gradient_build(bitstream_t *bs,
+                                         swf_fill_style_gradient_t *gradient,
+                                         swf_tag_t *tag);
+extern int swf_fill_style_gradient_print(swf_fill_style_gradient_t *gradient,
+                                         int indent_depth, swf_tag_t *tag);
 
 #endif /* __SWF_FILL_STYLE_GRADIENT_H__ */

Modified: trunk/src/swf_fill_style_solid.c
===================================================================
--- trunk/src/swf_fill_style_solid.c	2009-06-03 16:37:40 UTC (rev 140)
+++ trunk/src/swf_fill_style_solid.c	2009-06-03 17:09:24 UTC (rev 141)
@@ -3,21 +3,45 @@
 #include "swf_fill_style_solid.h"
 
 swf_fill_style_solid_parse(bitstream_t *bs,
-                           swf_fill_style_solid_t *fill_style_solid) {
-    ;
+                           swf_fill_style_solid_t *fill_style_solid,
+                           swf_tag_t *tag) {
+    if (tag->tag == 46 || tag->tag == 84) { // DefineMorphShape, DefineMorphShape2
+        swf_rgba_parse(bs, &(fill_style_solid->rgba));
+        swf_rgba_parse(bs, &(fill_style_solid->rgba_morph));
+    } else if (tag->tag == 32) { // DefineShape3
+        swf_rgba_parse(bs, &(fill_style_solid->rgba));
+    } else {
+        swf_rgb_parse(bs, &(fill_style_solid->rgb));
+    }
     return 0;
 }
 
 int
 swf_fill_style_solid_build(bitstream_t *bs,
-                           swf_fill_style_solid_t *fill_style_solid) {
-    ;
+                           swf_fill_style_solid_t *fill_style_solid,
+                           swf_tag_t *tag) {
+    if (tag->tag == 46 || tag->tag == 84) { // DefineMorphShape, DefineMorphShape2
+        swf_rgba_build(bs, &(fill_style_solid->rgba));
+        swf_rgba_build(bs, &(fill_style_solid->rgba_morph));
+    } else if (tag->tag == 32) { // DefineShape3
+        swf_rgba_build(bs, &(fill_style_solid->rgba));
+    } else {
+        swf_rgb_build(bs, &(fill_style_solid->rgb));
+    }
     return 0;
 }
 
 int
 swf_fill_style_solid_print(swf_fill_style_solid_t *fill_style_solid,
-                           int indent_depth) {
-    ;
+                           int indent_depth, swf_tag_t *tag
+) {
+    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);
+    } else if (tag->tag == 32) { // DefineShape3
+        swf_rgba_print(&(fill_style_solid->rgba), indent_depth + 1);
+    } else {
+        swf_rgb_print(&(fill_style_solid->rgb), indent_depth + 1);
+    }
     return 0;
 }

Modified: trunk/src/swf_fill_style_solid.h
===================================================================
--- trunk/src/swf_fill_style_solid.h	2009-06-03 16:37:40 UTC (rev 140)
+++ trunk/src/swf_fill_style_solid.h	2009-06-03 17:09:24 UTC (rev 141)
@@ -9,6 +9,7 @@
 
 #include "swf_rgba.h"
 #include "swf_rgb.h"
+#include "swf_tag.h"
 
 typedef union swf_fill_style_solid_ {
     unsigned char type;
@@ -17,8 +18,8 @@
     swf_rgb_t  rgb;        // other tag
 } swf_fill_style_solid_t;
 
-extern int swf_fill_style_solid_parse(bitstream_t *bs, swf_fill_style_solid_t *color);
-extern int swf_fill_style_solid_build(bitstream_t *bs, swf_fill_style_solid_t *color);
-extern int swf_fill_style_solid_print(swf_fill_style_solid_t *color, int indent_depth);
+extern int swf_fill_style_solid_parse(bitstream_t *bs, swf_fill_style_solid_t *color, swf_tag_t *tag);
+extern int swf_fill_style_solid_build(bitstream_t *bs, swf_fill_style_solid_t *color, swf_tag_t *tag);
+extern int swf_fill_style_solid_print(swf_fill_style_solid_t *color, int indent_depth, swf_tag_t *tag);
 
 #endif /* __SWF_FILL_STYLE_SOLID_H__ */

Modified: trunk/src/swf_matrix.c
===================================================================
--- trunk/src/swf_matrix.c	2009-06-03 16:37:40 UTC (rev 140)
+++ trunk/src/swf_matrix.c	2009-06-03 17:09:24 UTC (rev 141)
@@ -1,19 +1,85 @@
 #include <stdio.h>
+#include <math.h>
 #include "bitstream.h"
 #include "swf_matrix.h"
 
 int
 swf_matrix_parse(bitstream_t *bs, swf_matrix_t *matrix) {
+    int translate_bits;
+    bitstream_align(bs);
+    matrix->has_scale = bitstream_getbit(bs);
+    if (matrix->has_scale) {
+        int scale_bits = bitstream_getbits(bs, 5);
+        matrix->scale_x = bitstream_getbits(bs, scale_bits);
+        matrix->scale_y = bitstream_getbits(bs, scale_bits);
+    }
+    matrix->has_rotate = bitstream_getbit(bs);
+    if (matrix->has_rotate) {
+        int rotate_bits = bitstream_getbits(bs, 5);
+        matrix->rotate_skew0 = bitstream_getbits(bs, rotate_bits);
+        matrix->rotate_skew1 = bitstream_getbits(bs, rotate_bits);
+    }
+    translate_bits = bitstream_getbits(bs, 5);
+    matrix->translate_x = bitstream_getbits(bs, translate_bits);
+    matrix->translate_y = bitstream_getbits(bs, translate_bits);
     return 0;
 }
 
 int
 swf_matrix_build(bitstream_t *bs, swf_matrix_t *matrix) {
+    int translate_bits;
+    float log2_x, log2_y;
+    bitstream_align(bs);
+    bitstream_putbit(bs, matrix->has_scale);
+    if (matrix->has_scale) {
+        int scale_bits;
+        log2_x = log2f((float) matrix->scale_x);
+        log2_y = log2f((float) matrix->scale_y);
+        scale_bits = (log2_x > log2_y)? log2_x: log2_y;
+        scale_bits += 1; // XXX
+        bitstream_putbits(bs, scale_bits, 5);
+        bitstream_putbits(bs, matrix->scale_x, scale_bits);
+        bitstream_putbits(bs, matrix->scale_y, scale_bits);
+    }
+    bitstream_putbit(bs, matrix->has_rotate);
+    if (matrix->has_rotate) {
+        int rotate_bits;
+        float log2_skew0 = log2f((float) matrix->rotate_skew0);
+        float log2_skew1 = log2f((float) matrix->rotate_skew1);
+        rotate_bits = (log2_skew0 > log2_skew1)? log2_skew0: log2_skew1;
+        rotate_bits += 1; // XXX
+        bitstream_putbits(bs, rotate_bits, 5);
+        bitstream_putbits(bs, matrix->rotate_skew0, rotate_bits);
+        bitstream_putbits(bs, matrix->rotate_skew1, rotate_bits);
+    }
+    log2_x = log2f((float) matrix->translate_x);
+    log2_y = log2f((float) matrix->translate_y);
+    translate_bits = (log2_x > log2_y)? log2_x: log2_y;
+    translate_bits += 1; // XXX
+    bitstream_putbits(bs, translate_bits, 5);
+    bitstream_putbits(bs, matrix->translate_x, translate_bits);
+    bitstream_putbits(bs, matrix->translate_y, translate_bits);
     return 0;
 }
 
 int
 swf_matrix_print(swf_matrix_t *matrix, int indent_depth) {
     print_indent(indent_depth);
+    printf("has_scale=%d\n", matrix->has_scale);
+    if (matrix->has_scale) {
+        print_indent(indent_depth);
+        printf("scale_(x,y)=(%d,%d)\n",
+               matrix->scale_x, matrix->scale_y);
+    }
+    print_indent(indent_depth);
+    printf("has_rotate=%d\n", matrix->has_scale);
+    if (matrix->has_rotate) {
+        print_indent(indent_depth);
+        printf("rotate_(x,y)=(%d,%d)\n",
+               matrix->rotate_skew0, matrix->rotate_skew1);
+    }
+    print_indent(indent_depth);
+    printf("translate_(x,y)=(%d,%d) \n",
+           matrix->translate_x,  matrix->translate_y);
     return 0;
 }

Modified: trunk/src/swf_morph_shape_with_style.c
===================================================================
--- trunk/src/swf_morph_shape_with_style.c	2009-06-03 16:37:40 UTC (rev 140)
+++ trunk/src/swf_morph_shape_with_style.c	2009-06-03 17:09:24 UTC (rev 141)
@@ -6,26 +6,35 @@
                                  swf_morph_shape_with_style_t *morph_shape_with_style,
                                  swf_tag_t *tag) {
     swf_styles_parse(bs, &(morph_shape_with_style->styles), tag);
-//    swf_shape_record_parse(bs, &(morph_shape_with_style->shape_records));
-    //
-    //
+    swf_shape_record_parse(bs, &(morph_shape_with_style->shape_records));
+    swf_styles_count_parse(bs, &(morph_shape_with_style->styles_count));
+    swf_shape_record_parse(bs, &(morph_shape_with_style->shape_records_morph));
     return 0;
 }
 
 int
-swf_morph_shape_with_style_build(bitstream_t *bs, swf_morph_shape_with_style_t *morph_shape_with_style) {
-//   swf_styles_build(bs, &(morph_shape_with_style->styles));
-//   swf_shape_record_build(bs, &(morph_shape_with_style->shape_records));
-    //
-    //
+swf_morph_shape_with_style_build(bitstream_t *bs,
+                                 swf_morph_shape_with_style_t *morph_shape_with_style,
+                                 swf_tag_t *tag) {
+    swf_styles_build(bs, &(morph_shape_with_style->styles), tag);
+    swf_shape_record_build(bs, &(morph_shape_with_style->shape_records));
+    swf_styles_count_build(bs, &(morph_shape_with_style->styles_count));
+    swf_shape_record_build(bs, &(morph_shape_with_style->shape_records_morph));
     return 0;
 }
 
 int
-swf_morph_shape_with_style_print(swf_morph_shape_with_style_t *morph_shape_with_style, int indent_depth) {
-    swf_styles_print(&(morph_shape_with_style->styles), indent_depth);
-//   swf_shape_record_print(&(morph_shape_with_style->shape_records), indent_depth);
-    //
-    //
+swf_morph_shape_with_style_print(swf_morph_shape_with_style_t *morph_shape_with_style,
+                                 int indent_depth,
+                                 swf_tag_t *tag) {
+    swf_styles_print(&(morph_shape_with_style->styles), indent_depth, tag);
+    swf_shape_record_print(&(morph_shape_with_style->shape_records), indent_depth);
+    swf_styles_count_print(&(morph_shape_with_style->styles_count), indent_depth);
+    swf_shape_record_print(&(morph_shape_with_style->shape_records_morph), indent_depth);
     return 0;
 }
+
+int
+swf_morph_shape_with_style_delete(swf_morph_shape_with_style_t *morph_shape_with_style) {
+    swf_styles_delete(&(morph_shape_with_style->styles));
+}

Modified: trunk/src/swf_morph_shape_with_style.h
===================================================================
--- trunk/src/swf_morph_shape_with_style.h	2009-06-03 16:37:40 UTC (rev 140)
+++ trunk/src/swf_morph_shape_with_style.h	2009-06-03 17:09:24 UTC (rev 141)
@@ -13,18 +13,21 @@
 
 typedef struct swf_morph_shape_with_style_ {
     swf_styles_t       styles;
-    swf_shape_record_t *shape_records;
+    swf_shape_record_t shape_records;
     // char align;
     swf_styles_count_t styles_count;
-    swf_shape_record_t *shape_records_morph;
+    swf_shape_record_t shape_records_morph;
 } swf_morph_shape_with_style_t;
 
 extern int swf_morph_shape_with_style_parse(bitstream_t *bs,
                                             swf_morph_shape_with_style_t *morph_shape_with_style,
                                             swf_tag_t *tag);
 extern int swf_morph_shape_with_style_build(bitstream_t *bs,
-                                            swf_morph_shape_with_style_t *morph_shape_with_style);
+                                            swf_morph_shape_with_style_t *morph_shape_with_style,
+                                            swf_tag_t *tag);
 extern int swf_morph_shape_with_style_print(swf_morph_shape_with_style_t *morph_shape_with_style,
-                                            int indent_depth);
+                                            int indent_depth,
+                                            swf_tag_t *tag);
+extern int swf_morph_shape_with_style_delete(swf_morph_shape_with_style_t *morph_shape_with_style);
 
 #endif /* __SWF_MORPH_SHAPE_WITH_STYLE_H__ */

Modified: trunk/src/swf_shape_record.h
===================================================================
--- trunk/src/swf_shape_record.h	2009-06-03 16:37:40 UTC (rev 140)
+++ trunk/src/swf_shape_record.h	2009-06-03 17:09:24 UTC (rev 141)
@@ -18,8 +18,11 @@
     union swf_shape_record_ *next;
 } swf_shape_record_t;
 
-extern int swf_shape_record_parse(bitstream_t *bs, swf_shape_record_t *color);
-extern int swf_shape_record_build(bitstream_t *bs, swf_shape_record_t *color);
-extern int swf_shape_record_print(swf_shape_record_t *color, int indent_depth);
+extern int swf_shape_record_parse(bitstream_t *bs,
+                                  swf_shape_record_t *shape_record);
+extern int swf_shape_record_build(bitstream_t *bs,
+                                  swf_shape_record_t *shape_record);
+extern int swf_shape_record_print(swf_shape_record_t *shape_record,
+                                  int indent_depth);
 
 #endif /* __SWF_SHAPE_RECORD_H__ */

Modified: trunk/src/swf_shape_with_style.c
===================================================================
--- trunk/src/swf_shape_with_style.c	2009-06-03 16:37:40 UTC (rev 140)
+++ trunk/src/swf_shape_with_style.c	2009-06-03 17:09:24 UTC (rev 141)
@@ -7,20 +7,20 @@
                            swf_shape_with_style_t *shape_with_style,
                            swf_tag_t *tag) {
     swf_styles_parse(bs, &(shape_with_style->styles), tag);
-//    swf_shape_record_parse(bs, &(shape_with_style->shape_records));
+    swf_shape_record_parse(bs, &(shape_with_style->shape_records));
     return 0;
 }
 
 int
-swf_shape_with_style_build(bitstream_t *bs, swf_shape_with_style_t *shape_with_style) {
-//   swf_styles_build(bs, &(shape_with_style->styles));
-//   swf_shape_record_build(bs, &(shape_with_style->shape_records));
+swf_shape_with_style_build(bitstream_t *bs, swf_shape_with_style_t *shape_with_style, swf_tag_t *tag) {
+    swf_styles_build(bs, &(shape_with_style->styles), tag);
+    swf_shape_record_build(bs, &(shape_with_style->shape_records));
     return 0;
 }
 
 int
-swf_shape_with_style_print(swf_shape_with_style_t *shape_with_style, int indent_depth) {
-    swf_styles_print(&(shape_with_style->styles), indent_depth);
+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);
     return 0;
 }

Modified: trunk/src/swf_shape_with_style.h
===================================================================
--- trunk/src/swf_shape_with_style.h	2009-06-03 16:37:40 UTC (rev 140)
+++ trunk/src/swf_shape_with_style.h	2009-06-03 17:09:24 UTC (rev 141)
@@ -7,6 +7,7 @@
 #ifndef __SWF_SHAPE_WITH_STYLE_H__
 #define __SWF_SHAPE_WITH_STYLE_H__
 
+#include "swf_tag.h"
 #include "swf_styles.h"
 #include "swf_shape_record.h"
 
@@ -18,7 +19,11 @@
 extern int swf_shape_with_style_parse(bitstream_t *bs,
                                       swf_shape_with_style_t *color,
                                       swf_tag_t *tag);
-extern int swf_shape_with_style_build(bitstream_t *bs, swf_shape_with_style_t *color);
-extern int swf_shape_with_style_print(swf_shape_with_style_t *color, int indent_depth);
+extern int swf_shape_with_style_build(bitstream_t *bs,
+                                      swf_shape_with_style_t *color,
+                                      swf_tag_t *tag);
+extern int swf_shape_with_style_print(swf_shape_with_style_t *color,
+                                      int indent_depth,
+                                      swf_tag_t *tag);
 
 #endif /* __SWF_SHAPE_WITH_STYLE_H__ */

Modified: trunk/src/swf_styles.c
===================================================================
--- trunk/src/swf_styles.c	2009-06-03 16:37:40 UTC (rev 140)
+++ trunk/src/swf_styles.c	2009-06-03 17:09:24 UTC (rev 141)
@@ -6,23 +6,31 @@
 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_styles_count_parse(bs, &(shape_with_style->line_styles));
+    swf_line_style_array_parse(bs, &(shape_with_style->line_styles));
+    swf_styles_count_parse(bs, &(shape_with_style->styles_count));
     return 0;
 }
 
 int
-swf_styles_build(bitstream_t *bs, swf_styles_t *shape_with_style) {
-    swf_fill_style_array_build(bs, &(shape_with_style->fill_styles));
-//    swf_line_style_array_build(bs, &(shape_with_style->line_styles));
-//    swf_styles_count_build(bs, &(shape_with_style->line_styles));
+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_styles_count_build(bs, &(shape_with_style->styles_count));
     return 0;
 }
 
 int
-swf_styles_print(swf_styles_t *shape_with_style, int indent_depth) {
-    swf_fill_style_array_print(&(shape_with_style->fill_styles), indent_depth);
-//    swf_line_style_array_print(&(shape_with_style->line_styles), indent_depth);
-//    swf_styles_count_print(&(shape_with_style->line_styles), indent_depth);
+swf_styles_print(swf_styles_t *shape_with_style, int indent_depth,
+                 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_styles_count_print(&(shape_with_style->styles_count), indent_depth);
     return 0;
 }
+
+int
+swf_styles_delete(swf_styles_t *styles) {
+    swf_fill_styles_array_delete(&(styles->fill_styles));
+}

Modified: trunk/src/swf_styles.h
===================================================================
--- trunk/src/swf_styles.h	2009-06-03 16:37:40 UTC (rev 140)
+++ trunk/src/swf_styles.h	2009-06-03 17:09:24 UTC (rev 141)
@@ -18,9 +18,12 @@
     swf_styles_count_t styles_count;
 } swf_styles_t;
 
-extern int swf_styles_parse(bitstream_t *bs, swf_styles_t *color,
+extern int swf_styles_parse(bitstream_t *bs, swf_styles_t *styles,
                             swf_tag_t *tag);
-extern int swf_styles_build(bitstream_t *bs, swf_styles_t *color);
-extern int swf_styles_print(swf_styles_t *color, int indent_depth);
+extern int swf_styles_build(bitstream_t *bs, swf_styles_t *styles,
+                            swf_tag_t *tag);
+extern int swf_styles_print(swf_styles_t *styles, int indent_depth,
+                            swf_tag_t *tag);
+extern int swf_styles_delete(swf_styles_t *styles);
 
 #endif /* __SWF_STYLES_H__ */

Modified: trunk/src/swf_styles_count.h
===================================================================
--- trunk/src/swf_styles_count.h	2009-06-03 16:37:40 UTC (rev 140)
+++ trunk/src/swf_styles_count.h	2009-06-03 17:09:24 UTC (rev 141)
@@ -12,8 +12,11 @@
     unsigned char line_bits_count:4;
 } swf_styles_count_t;
 
-extern int swf_styles_count_parse(bitstream_t *bs, swf_styles_count_t *color);
-extern int swf_styles_count_build(bitstream_t *bs, swf_styles_count_t *color);
-extern int swf_styles_count_print(swf_styles_count_t *color, int indent_depth);
+extern int swf_styles_count_parse(bitstream_t *bs,
+                                  swf_styles_count_t *styles_count);
+extern int swf_styles_count_build(bitstream_t *bs,
+                                  swf_styles_count_t *styles_count);
+extern int swf_styles_count_print(swf_styles_count_t *styles_count,
+                                  int indent_depth);
 
 #endif /* __SWF_STYLES_COUNT_H__ */

Modified: trunk/src/swf_tag_shape.c
===================================================================
--- trunk/src/swf_tag_shape.c	2009-06-03 16:37:40 UTC (rev 140)
+++ trunk/src/swf_tag_shape.c	2009-06-03 17:09:24 UTC (rev 141)
@@ -68,7 +68,7 @@
     }
     if (swf_tag_shape->is_morph) {
         swf_tag_shape->offset_morph = bitstream_getbytesLE(bs, 4);
-        ; // swf_morph_shape_with_style_parse(bs, &swf_tag_shape->morph_shape_with_style);
+        swf_morph_shape_with_style_parse(bs, &swf_tag_shape->morph_shape_with_style, tag);
     } else {
         swf_shape_with_style_parse(bs, &swf_tag_shape->shape_with_style, tag);
     }
@@ -139,9 +139,11 @@
     if (swf_tag_shape->is_morph) {
         print_indent(indent_depth);
         printf("offset_morph=%lu\n", swf_tag_shape->offset_morph);
-        ; // swf_morph_shape_with_style_print(&swf_tag_shape->morph_shape_with_style, indent_depth);
+        swf_morph_shape_with_style_print(&swf_tag_shape->morph_shape_with_style,
+                                         indent_depth, tag);
     } else {
-        swf_shape_with_style_print(&swf_tag_shape->shape_with_style, indent_depth);
+        swf_shape_with_style_print(&swf_tag_shape->shape_with_style,
+                                   indent_depth, tag);
     }
     return ;
 }



Swfed-svn メーリングリストの案内
Back to archive index