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_start-


From: Benjamin Wolsey
Subject: [Gnash-commit] [SCM] Gnash branch, master, updated. release_0_8_9_start-88-gc97e181
Date: Fri, 18 Feb 2011 19:18:43 +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  c97e1810798e201548b1fdfdebc66f4c13ef6ca2 (commit)
       via  6f266fd3546842164de7b52bd392a733e877bdaa (commit)
       via  109914e9793237adc7638b78e974fa273b8be097 (commit)
      from  aab6f25286f4718526cc5d7ee2a33b9e0d012145 (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=c97e1810798e201548b1fdfdebc66f4c13ef6ca2


commit c97e1810798e201548b1fdfdebc66f4c13ef6ca2
Author: Benjamin Wolsey <address@hidden>
Date:   Fri Feb 18 20:12:09 2011 +0100

    Add comments

diff --git a/libcore/Font.cpp b/libcore/Font.cpp
index 98cc87e..1be16a5 100644
--- a/libcore/Font.cpp
+++ b/libcore/Font.cpp
@@ -193,7 +193,12 @@ Font::codeTableLookup(int glyph, bool embedded) const
     
     CodeTable::const_iterator it = std::find_if(ctable.begin(), ctable.end(),
             CodeLookup(glyph));
+
     if (it == ctable.end()) {
+        // NB: this occurs with a long and complex SWF (bug #32537)
+        // that defines the same font twice and ends up with a glyph
+        // table shorter than the number of glyphs. We don't know
+        // whether it's a SWF or a Gnash bug.
         log_error("Failed to find glyph %s in %s font %s",
                 glyph, embedded ? "embedded" : "device", _name);
         return 0;

http://git.savannah.gnu.org/cgit//commit/?id=6f266fd3546842164de7b52bd392a733e877bdaa


commit 6f266fd3546842164de7b52bd392a733e877bdaa
Author: Benjamin Wolsey <address@hidden>
Date:   Fri Feb 18 20:02:58 2011 +0100

    Clean up, drop debug logging.

diff --git a/libcore/Font.cpp b/libcore/Font.cpp
index 574af78..98cc87e 100644
--- a/libcore/Font.cpp
+++ b/libcore/Font.cpp
@@ -196,7 +196,6 @@ Font::codeTableLookup(int glyph, bool embedded) const
     if (it == ctable.end()) {
         log_error("Failed to find glyph %s in %s font %s",
                 glyph, embedded ? "embedded" : "device", _name);
-        log_error("Font table size: %s", _embeddedCodeTable->size());
         return 0;
     }
     return it->first;
diff --git a/libcore/swf/DefineFontTag.cpp b/libcore/swf/DefineFontTag.cpp
index 6a914e9..968d727 100644
--- a/libcore/swf/DefineFontTag.cpp
+++ b/libcore/swf/DefineFontTag.cpp
@@ -57,8 +57,6 @@ void
 DefineFontTag::readCodeTable(SWFStream& in, Font::CodeTable& table,
         bool wideCodes, size_t glyphCount)
 {
-    log_error("Read code table");
-
     IF_VERBOSE_PARSE(
         log_parse(_("reading code table at offset %1%, "
                 "%2% glyphs"), in.tell(), glyphCount);
@@ -133,32 +131,25 @@ DefineFontTag::readDefineFont(SWFStream& in, 
movie_definition& m,
     offsets.push_back(in.read_u16());
 
     IF_VERBOSE_PARSE (
-    log_parse("offset[0] = %d", offsets[0]);
+        log_parse("offset[0] = %d", offsets[0]);
     );
 
-    int        count = offsets[0] >> 1;
-    if ( count > 0 )
-    {
+    const size_t count = offsets[0] >> 1;
+    if (count > 0) {
         in.ensureBytes(count*2);
-        for (int i = 1; i < count; i++)
-        {
+        for (size_t i = 1; i < count; ++i) {
             offsets.push_back(in.read_u16());
 
             IF_VERBOSE_PARSE (
-            log_parse("offset[%d] = %d", i, offsets[i]);
+                log_parse("offset[%d] = %d", i, offsets[i]);
             );
         }
     }
-    else
-    {
-        log_error("Negative embedded glyph table size: %d", count);
-    }
 
     _glyphTable.resize(count);
 
     // Read the glyph shapes.
-    for (int i = 0; i < count; i++)
-    {
+    for (size_t i = 0; i < count; ++i) {
         // Seek to the start of the shape data.
         unsigned long new_pos = table_base + offsets[i];
 
@@ -252,7 +243,6 @@ DefineFontTag::readDefineFont2Or3(SWFStream& in, 
movie_definition& m,
     }
 
     _glyphTable.resize(glyph_count);
-    log_error("Glyph count: %s", glyph_count);
 
     // Read the glyph shapes.
     for (size_t i = 0; i < glyph_count; ++i) {
@@ -283,6 +273,7 @@ DefineFontTag::readDefineFont2Or3(SWFStream& in, 
movie_definition& m,
 
     readCodeTable(in, *table, wideCodes, _glyphTable.size());
     _codeTable.reset(table.release());
+    log_debug("Code table size: %s", _codeTable->size());
 
     // Read layout info for the glyphs.
     if (has_layout) {
@@ -336,7 +327,6 @@ DefineFontTag::readDefineFont2Or3(SWFStream& in, 
movie_definition& m,
                     log_swferror(_("Repeated kerning pair found - ignoring"));
                 );
             }
-
         }
     }
 }

http://git.savannah.gnu.org/cgit//commit/?id=109914e9793237adc7638b78e974fa273b8be097


commit 109914e9793237adc7638b78e974fa273b8be097
Author: Benjamin Wolsey <address@hidden>
Date:   Fri Feb 18 19:30:32 2011 +0100

    Const correctness for readability.
    Pass Font by intrueive_ptr to movie definitions.
    Temporary debugging.

diff --git a/libcore/Font.cpp b/libcore/Font.cpp
index fd55ac8..574af78 100644
--- a/libcore/Font.cpp
+++ b/libcore/Font.cpp
@@ -21,16 +21,17 @@
 
 // Based on the public domain work of Thatcher Ulrich <address@hidden> 2003
 
-#include "smart_ptr.h" 
 #include "Font.h"
+
+#include <utility> 
+#include <memory>
+
+#include "smart_ptr.h" 
 #include "log.h"
 #include "ShapeRecord.h"
 #include "DefineFontTag.h"
 #include "FreetypeGlyphsProvider.h"
 
-#include <utility> // for std::make_pair
-#include <memory>
-
 namespace gnash {
 
 namespace {
@@ -44,12 +45,12 @@ class CodeLookup
 public:
     CodeLookup(const int glyph) : _glyph(glyph) {}
 
-    bool operator()(const std::pair<const boost::uint16_t, int>& p) {
+    bool operator()(const std::pair<const boost::uint16_t, int>& p) const {
         return p.second == _glyph;
     }
 
 private:
-    int _glyph;
+    const int _glyph;
 };
 
 }
@@ -83,7 +84,9 @@ Font::Font(std::auto_ptr<SWF::DefineFontTag> ft)
     _italic(_fontTag->italic()),
     _bold(_fontTag->bold())
 {
-    if (_fontTag->hasCodeTable()) _embeddedCodeTable = 
_fontTag->getCodeTable();
+    if (_fontTag->hasCodeTable()) {
+        _embeddedCodeTable = _fontTag->getCodeTable();
+    }
 }
 
 Font::Font(const std::string& name, bool bold, bool italic)
@@ -160,8 +163,7 @@ Font::setFlags(boost::uint8_t flags)
 void
 Font::setCodeTable(std::auto_ptr<CodeTable> table)
 {
-    if (_embeddedCodeTable)
-    {
+    if (_embeddedCodeTable) {
         IF_VERBOSE_MALFORMED_SWF(
             log_swferror(_("Attempt to add an embedded glyph CodeTable to "
                     "a font that already has one. This should mean there "
@@ -191,7 +193,12 @@ Font::codeTableLookup(int glyph, bool embedded) const
     
     CodeTable::const_iterator it = std::find_if(ctable.begin(), ctable.end(),
             CodeLookup(glyph));
-    assert (it != ctable.end());
+    if (it == ctable.end()) {
+        log_error("Failed to find glyph %s in %s font %s",
+                glyph, embedded ? "embedded" : "device", _name);
+        log_error("Font table size: %s", _embeddedCodeTable->size());
+        return 0;
+    }
     return it->first;
 }
 
diff --git a/libcore/parser/SWFMovieDefinition.cpp 
b/libcore/parser/SWFMovieDefinition.cpp
index 52e65e7..376b772 100644
--- a/libcore/parser/SWFMovieDefinition.cpp
+++ b/libcore/parser/SWFMovieDefinition.cpp
@@ -190,10 +190,10 @@ SWFMovieDefinition::getDefinitionTag(boost::uint16_t id) 
const
 }
 
 void
-SWFMovieDefinition::add_font(int font_id, Font* f)
+SWFMovieDefinition::add_font(int font_id, boost::intrusive_ptr<Font> f)
 {
     assert(f);
-    m_fonts.insert(std::make_pair(font_id, boost::intrusive_ptr<Font>(f)));
+    m_fonts.insert(std::make_pair(font_id, f));
 }
 
 Font*
diff --git a/libcore/parser/SWFMovieDefinition.h 
b/libcore/parser/SWFMovieDefinition.h
index 6e6e40f..8c47c1d 100644
--- a/libcore/parser/SWFMovieDefinition.h
+++ b/libcore/parser/SWFMovieDefinition.h
@@ -252,7 +252,7 @@ public:
     bool get_labeled_frame(const std::string& label, size_t& frame_number)
         const;
 
-    void add_font(int font_id, Font* f);
+    void add_font(int font_id, boost::intrusive_ptr<Font> f);
 
     Font* get_font(int font_id) const;
 
diff --git a/libcore/parser/movie_definition.h 
b/libcore/parser/movie_definition.h
index 50d720e..c829c6e 100644
--- a/libcore/parser/movie_definition.h
+++ b/libcore/parser/movie_definition.h
@@ -251,7 +251,7 @@ public:
        /// This method is here to be called by DEFINEFONT tags loaders.
        /// The default implementation does nothing.
        ///
-       virtual void add_font(int /*id*/, Font* /*ch*/)
+       virtual void add_font(int /*id*/, boost::intrusive_ptr<Font> /*ch*/)
        {
        }
 
diff --git a/libcore/parser/sprite_definition.h 
b/libcore/parser/sprite_definition.h
index eaf40d4..8be5d3a 100644
--- a/libcore/parser/sprite_definition.h
+++ b/libcore/parser/sprite_definition.h
@@ -140,7 +140,7 @@ public:
        }
 
        /// Overridden just for complaining  about malformed SWF
-       virtual void add_font(int /*id*/, Font* /*ch*/)
+       virtual void add_font(int /*id*/, boost::intrusive_ptr<Font> /*ch*/)
        {
                IF_VERBOSE_MALFORMED_SWF (
                log_swferror(_("add_font tag appears in sprite tags"));
diff --git a/libcore/swf/DefineFontTag.cpp b/libcore/swf/DefineFontTag.cpp
index dd097b8..6a914e9 100644
--- a/libcore/swf/DefineFontTag.cpp
+++ b/libcore/swf/DefineFontTag.cpp
@@ -48,19 +48,20 @@ DefineFontTag::loader(SWFStream& in, TagType tag, 
movie_definition& m,
     const boost::uint16_t fontID = in.read_u16();
 
     std::auto_ptr<DefineFontTag> ft(new DefineFontTag(in, m, tag, r));
-
-    Font* f = new Font(ft);
+    boost::intrusive_ptr<Font> f(new Font(ft));
 
     m.add_font(fontID, f);
-
 }
 
 void
 DefineFontTag::readCodeTable(SWFStream& in, Font::CodeTable& table,
         bool wideCodes, size_t glyphCount)
 {
+    log_error("Read code table");
+
     IF_VERBOSE_PARSE(
-        log_parse(_("reading code table at offset %lu"), in.tell());
+        log_parse(_("reading code table at offset %1%, "
+                "%2% glyphs"), in.tell(), glyphCount);
     );
 
     // Good. We can only do this once.
@@ -70,7 +71,7 @@ DefineFontTag::readCodeTable(SWFStream& in, Font::CodeTable& 
table,
         in.ensureBytes(2 * glyphCount);
         // Code table is made of boost::uint16_t's.
         for (size_t i=0; i < glyphCount; ++i) {
-            boost::uint16_t code = in.read_u16();
+            const boost::uint16_t code = in.read_u16();
             table.insert(std::make_pair(code, i));
         }
     }
@@ -78,7 +79,7 @@ DefineFontTag::readCodeTable(SWFStream& in, Font::CodeTable& 
table,
         // Code table is made of bytes.
         in.ensureBytes(1 * glyphCount);
         for (size_t i = 0; i < glyphCount; ++i) {
-            boost::uint8_t code = in.read_u8();
+            const boost::uint8_t code = in.read_u8();
             table.insert(std::make_pair(code, i));
         }
     }
@@ -177,23 +178,23 @@ void
 DefineFontTag::readDefineFont2Or3(SWFStream& in, movie_definition& m,
         const RunResources& r)
 {
-    IF_VERBOSE_PARSE (
-    log_parse(_("reading DefineFont2 or DefineFont3"));
+    IF_VERBOSE_PARSE(
+        log_parse(_("reading DefineFont2 or DefineFont3"));
     );
 
     in.ensureBytes(2); // 1 for the flags, 1 unknown
-    int flags = in.read_u8();
-    bool has_layout = flags & (1 << 7);
+    const int flags = in.read_u8();
+    const bool has_layout = flags & (1 << 7);
     _shiftJISChars = flags & (1 << 6);
     _unicodeChars = flags & (1 << 5);
     _ansiChars = flags & (1 << 4);
-    bool wide_offsets = flags & (1 << 3);
-    bool wideCodes = flags & (1 << 2);
+    const bool wide_offsets = flags & (1 << 3);
+    const bool wideCodes = flags & (1 << 2);
     _italic = flags & (1 << 1);
     _bold = flags & (1 << 0);
 
     // Next is language code, always 0 for SWF5 or previous
-    int languageCode = in.read_u8();
+    const int languageCode = in.read_u8();
     if (languageCode) {
         LOG_ONCE(log_unimpl("LanguageCode (%d) in DefineFont tag",
                     languageCode));
@@ -202,7 +203,7 @@ DefineFontTag::readDefineFont2Or3(SWFStream& in, 
movie_definition& m,
     in.read_string_with_length(_name);
 
     in.ensureBytes(2); 
-    boost::uint16_t glyph_count = in.read_u16();
+    const boost::uint16_t glyph_count = in.read_u16();
 
     IF_VERBOSE_PARSE (
         log_parse(" has_layout = %d", has_layout);
@@ -217,7 +218,7 @@ DefineFontTag::readDefineFont2Or3(SWFStream& in, 
movie_definition& m,
         log_parse(" glyphs count = %d", glyph_count);
     );
     
-    unsigned long table_base = in.tell();
+    const unsigned long table_base = in.tell();
 
     // Read the glyph offsets.  Offsets
     // are measured from the start of the
@@ -228,14 +229,11 @@ DefineFontTag::readDefineFont2Or3(SWFStream& in, 
movie_definition& m,
     if (wide_offsets) {
         // 32-bit offsets.
         in.ensureBytes(4*glyph_count + 4); 
-        for (size_t i = 0; i < glyph_count; ++i)
-        {
+        for (size_t i = 0; i < glyph_count; ++i) {
             const boost::uint32_t off = in.read_u32(); 
-
             IF_VERBOSE_PARSE (
                 log_parse(_("Glyph %d at offset %u"), i, off);
             );
-
             offsets.push_back(off);
         }
         font_code_offset = in.read_u32();
@@ -244,19 +242,17 @@ DefineFontTag::readDefineFont2Or3(SWFStream& in, 
movie_definition& m,
         // 16-bit offsets.
         in.ensureBytes(2*glyph_count + 2); 
         for (size_t i = 0; i < glyph_count; ++i) {
-
             const boost::uint16_t off = in.read_u16(); 
-
-            IF_VERBOSE_PARSE (
+            IF_VERBOSE_PARSE(
                 log_parse(_("Glyph %d at offset %u"), i, off);
             );
-
             offsets.push_back(off);
         }
         font_code_offset = in.read_u16();
     }
 
     _glyphTable.resize(glyph_count);
+    log_error("Glyph count: %s", glyph_count);
 
     // Read the glyph shapes.
     for (size_t i = 0; i < glyph_count; ++i) {
@@ -274,9 +270,8 @@ DefineFontTag::readDefineFont2Or3(SWFStream& in, 
movie_definition& m,
         _glyphTable[i].glyph.reset(new ShapeRecord(in, SWF::DEFINEFONT2, m, 
r));
     }
 
-    unsigned long current_position = in.tell();
-    if (font_code_offset + table_base != current_position)
-    {
+    const unsigned long current_position = in.tell();
+    if (font_code_offset + table_base != current_position) {
         // Bad offset!  Don't try to read any more.
         IF_VERBOSE_MALFORMED_SWF(
             log_swferror(_("Bad offset in DefineFont2"));
@@ -297,7 +292,7 @@ DefineFontTag::readDefineFont2Or3(SWFStream& in, 
movie_definition& m,
         _leading = in.read_s16();
         
         // Advance table; i.e. how wide each DisplayObject is.
-        size_t nGlyphs = _glyphTable.size();
+        const size_t nGlyphs = _glyphTable.size();
         in.ensureBytes(nGlyphs*2);
 
         for (size_t i = 0; i < nGlyphs; i++) {
@@ -307,7 +302,6 @@ DefineFontTag::readDefineFont2Or3(SWFStream& in, 
movie_definition& m,
             _glyphTable[i].advance = static_cast<float>(in.read_u16());
         }
 
-        // TODO: shouldn't we log_unimpl here ??
         for (size_t i = 0; i < nGlyphs; i++) {
             LOG_ONCE(log_unimpl("Bounds table in DefineFont2Tag"));
             readRect(in);

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

Summary of changes:
 libcore/Font.cpp                      |   31 ++++++++++-----
 libcore/parser/SWFMovieDefinition.cpp |    4 +-
 libcore/parser/SWFMovieDefinition.h   |    2 +-
 libcore/parser/movie_definition.h     |    2 +-
 libcore/parser/sprite_definition.h    |    2 +-
 libcore/swf/DefineFontTag.cpp         |   68 ++++++++++++--------------------
 6 files changed, 52 insertions(+), 57 deletions(-)


hooks/post-receive
-- 
Gnash



reply via email to

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