gnash-commit
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Gnash-commit] [SCM] Gnash branch, master, updated. release_0_8_9_final-


From: Bastiaan Jacques
Subject: [Gnash-commit] [SCM] Gnash branch, master, updated. release_0_8_9_final-1696-g4bbe965
Date: Thu, 01 Aug 2013 09:04:28 +0000

This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "Gnash".

The branch, master has been updated
       via  4bbe965a83139329be138bd00c4dc72f8a77e6be (commit)
      from  1fe4c1d27afd9fa97741df52c543382d94bc9be2 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
http://git.savannah.gnu.org/cgit//commit/?id=4bbe965a83139329be138bd00c4dc72f8a77e6be


commit 4bbe965a83139329be138bd00c4dc72f8a77e6be
Author: Bastiaan Jacques <address@hidden>
Date:   Thu Aug 1 11:04:13 2013 +0200

    Refactor.

diff --git a/libcore/swf/ShapeRecord.cpp b/libcore/swf/ShapeRecord.cpp
index dac29fd..4afe2d4 100644
--- a/libcore/swf/ShapeRecord.cpp
+++ b/libcore/swf/ShapeRecord.cpp
@@ -265,6 +265,28 @@ ShapeRecord::setLerp(const ShapeRecord& aa, const 
ShapeRecord& bb,
     }
 }
 
+unsigned
+ShapeRecord::readStyleChange(SWFStream& in, size_t num_style_bits, size_t 
numStyles)
+{
+    if (!num_style_bits) {
+       return 0;
+    }
+
+    in.ensureBits(num_style_bits);
+    unsigned style = in.read_uint(num_style_bits);
+
+    if ( style > numStyles ) {
+        IF_VERBOSE_MALFORMED_SWF(
+            log_swferror(_("Invalid fill style %1% in "
+                           "style change record - %2% defined. "
+                           "Set to 0."), style, numStyles);
+        );
+        style = 0;
+    }
+
+    return style;
+}
+
 void
 ShapeRecord::read(SWFStream& in, SWF::TagType tag, movie_definition& m,
         const RunResources& r)
@@ -351,7 +373,6 @@ ShapeRecord::read(SWFStream& in, SWF::TagType tag, 
movie_definition& m,
     // At the moment we just store each edge with
     // the full necessary info to render it, which
     // is simple but not optimally efficient.
-    int fill_base = 0;
     int line_base = 0;
     int   x = 0, y = 0;
     Path  current_path;
@@ -409,33 +430,10 @@ ShapeRecord::read(SWFStream& in, SWF::TagType tag, 
movie_definition& m,
                     current_path.ap.x = x;
                     current_path.ap.y = y;
                 }
-                in.ensureBits(num_fill_bits);
-                unsigned style = in.read_uint(num_fill_bits);
-                if (style > 0) {
-                    style += fill_base;
-                }
-    
-                if (tag == SWF::DEFINEFONT || tag == SWF::DEFINEFONT2) {
-                    if ( style > 1 ) {         // 0:hide 1:renderer
-                        IF_VERBOSE_MALFORMED_SWF(
-                             log_swferror(_("Invalid fill style %d in "
-                                     "fillStyle0Change record for font tag "
-                                     "(0 or 1 valid). Set to 0."), style);
-                        );
-                        style = 0;
-                    }
-                } else {
-                    // 1-based index
-                    if ( style > subshape.fillStyles().size() ) {
-                        IF_VERBOSE_MALFORMED_SWF(
-                             log_swferror(_("Invalid fill style %d in "
-                                     "fillStyle0Change record - %d defined. "
-                                     "Set to 0."), style, 
subshape.fillStyles().size());
-                        );
-                        style = 0;
-                    }
-                }
-    
+
+                unsigned style = readStyleChange(in, num_fill_bits,
+                    (tag == SWF::DEFINEFONT || tag == SWF::DEFINEFONT2) ? 1 : 
subshape.fillStyles().size());
+
                 current_path.setLeftFill(style);
 #if SHAPE_LOG
                 IF_VERBOSE_PARSE(
@@ -452,32 +450,9 @@ ShapeRecord::read(SWFStream& in, SWF::TagType tag, 
movie_definition& m,
                     current_path.ap.x = x;
                     current_path.ap.y = y;
                 }
-                in.ensureBits(num_fill_bits);
-                unsigned style = in.read_uint(num_fill_bits);
-                if (style > 0) {
-                    style += fill_base;
-                }
-    
-                if (tag == SWF::DEFINEFONT || tag == SWF::DEFINEFONT2) {
-                    if ( style > 1 ) {          // 0:hide 1:renderer
-                        IF_VERBOSE_MALFORMED_SWF(
-                             log_swferror(_("Invalid fill style %d in "
-                                     "fillStyle1Change record for font tag "
-                                     "(0 or 1 valid). Set to 0."), style);
-                        );
-                        style = 0;
-                    }
-                } else {
-                    // 1-based index
-                    if ( style > subshape.fillStyles().size() ) {
-                        IF_VERBOSE_MALFORMED_SWF(
-                            log_swferror(_("Invalid fill style %d in "
-                                    "fillStyle1Change record - %d defined. "
-                                    "Set to 0."), style, 
subshape.fillStyles().size());
-                        );
-                        style = 0;
-                    }
-                }
+                unsigned style = readStyleChange(in, num_fill_bits,
+                    (tag == SWF::DEFINEFONT || tag == SWF::DEFINEFONT2) ? 1 : 
subshape.fillStyles().size());
+
                 current_path.setRightFill(style);
 #if SHAPE_LOG
                 IF_VERBOSE_PARSE (
@@ -494,31 +469,9 @@ ShapeRecord::read(SWFStream& in, SWF::TagType tag, 
movie_definition& m,
                     current_path.ap.x = x;
                     current_path.ap.y = y;
                 }
-                in.ensureBits(num_line_bits);
-                unsigned style = in.read_uint(num_line_bits);
-                if (style > 0) {
-                    style += line_base;
-                }
-                if (tag == SWF::DEFINEFONT || tag == SWF::DEFINEFONT2) {
-                    if ( style > 1 ) {         // 0:hide 1:renderer
-                        IF_VERBOSE_MALFORMED_SWF(
-                            log_swferror(_("Invalid line style %d in "
-                                    "lineStyleChange record for font tag "
-                                    "(0 or 1 valid). Set to 0."), style);
-                        );
-                        style = 0;
-                    }
-                } else {
-                    // 1-based index
-                    if (style > subshape.lineStyles().size()) {
-                        IF_VERBOSE_MALFORMED_SWF(
-                            log_swferror(_("Invalid fill style %d in "
-                                    "lineStyleChange record - %d defined. "
-                                    "Set to 0."), style, 
subshape.lineStyles().size());
-                        );
-                        style = 0;
-                    }
-                }
+                unsigned style = readStyleChange(in, num_line_bits,
+                    (tag == SWF::DEFINEFONT || tag == SWF::DEFINEFONT2) ? 1 : 
subshape.lineStyles().size());
+
                 current_path.setLineStyle(style);
 #if SHAPE_LOG
                 IF_VERBOSE_PARSE(
diff --git a/libcore/swf/ShapeRecord.h b/libcore/swf/ShapeRecord.h
index 2d9be20..2f73612 100644
--- a/libcore/swf/ShapeRecord.h
+++ b/libcore/swf/ShapeRecord.h
@@ -194,6 +194,8 @@ public:
 
 private:
 
+    unsigned readStyleChange(SWFStream& in, size_t num_fill_bits, size_t 
numStyles);
+
     /// Shape record flags for use in parsing.
     enum ShapeRecordFlags {
         SHAPE_END = 0x00,

-----------------------------------------------------------------------

Summary of changes:
 libcore/swf/ShapeRecord.cpp |  111 ++++++++++++------------------------------
 libcore/swf/ShapeRecord.h   |    2 +
 2 files changed, 34 insertions(+), 79 deletions(-)


hooks/post-receive
-- 
Gnash



reply via email to

[Prev in Thread] Current Thread [Next in Thread]