gnash-commit
[Top][All Lists]
Advanced

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

[Gnash-commit] gnash ChangeLog server/edit_text_character.cpp ... [relea


From: Sandro Santilli
Subject: [Gnash-commit] gnash ChangeLog server/edit_text_character.cpp ... [release_0_8_1]
Date: Sat, 18 Aug 2007 08:06:23 +0000

CVSROOT:        /sources/gnash
Module name:    gnash
Branch:         release_0_8_1
Changes by:     Sandro Santilli <strk>  07/08/18 08:06:23

Modified files:
        .              : ChangeLog 
        server         : edit_text_character.cpp text.cpp text.h 
        server/parser  : movie_def_impl.cpp movie_def_impl.h 
                         movie_definition.h sprite_definition.h 
                         text_character_def.cpp 

Log message:
                * server/text.{cpp,h}: make text_style class store only the font
                  pointer, w/out the font_id, provide setFont and getFont
                  methods, the former always performing a lookup.
                * server/parser/text_character_def.cpp (read): use
                  text_style::setFont() to set the font this properly updates
                  the actual font pointer in the text_format, fixing bug #20812.
                * server/edit_text_character.cpp: use text_style::setFont() to
                  set font by pointer.
                * server/parser/: movie_definition.h, movie_def_impl.{h,cpp},
                  sprite_definition.h: const-correct get_font() method.
                * server/parser/movie_def_impl.{h,cpp}: const-corrected
                  in_import_table(), made private and re-activated assertion
                  checking temporarly removed during to GC layout changes.

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/gnash/ChangeLog?cvsroot=gnash&only_with_tag=release_0_8_1&r1=1.3971.2.29&r2=1.3971.2.30
http://cvs.savannah.gnu.org/viewcvs/gnash/server/edit_text_character.cpp?cvsroot=gnash&only_with_tag=release_0_8_1&r1=1.96&r2=1.96.2.1
http://cvs.savannah.gnu.org/viewcvs/gnash/server/text.cpp?cvsroot=gnash&only_with_tag=release_0_8_1&r1=1.35&r2=1.35.2.1
http://cvs.savannah.gnu.org/viewcvs/gnash/server/text.h?cvsroot=gnash&only_with_tag=release_0_8_1&r1=1.18&r2=1.18.2.1
http://cvs.savannah.gnu.org/viewcvs/gnash/server/parser/movie_def_impl.cpp?cvsroot=gnash&only_with_tag=release_0_8_1&r1=1.79&r2=1.79.2.1
http://cvs.savannah.gnu.org/viewcvs/gnash/server/parser/movie_def_impl.h?cvsroot=gnash&only_with_tag=release_0_8_1&r1=1.50&r2=1.50.2.1
http://cvs.savannah.gnu.org/viewcvs/gnash/server/parser/movie_definition.h?cvsroot=gnash&only_with_tag=release_0_8_1&r1=1.27&r2=1.27.2.1
http://cvs.savannah.gnu.org/viewcvs/gnash/server/parser/sprite_definition.h?cvsroot=gnash&only_with_tag=release_0_8_1&r1=1.26&r2=1.26.2.1
http://cvs.savannah.gnu.org/viewcvs/gnash/server/parser/text_character_def.cpp?cvsroot=gnash&only_with_tag=release_0_8_1&r1=1.4.2.1&r2=1.4.2.2

Patches:
Index: ChangeLog
===================================================================
RCS file: /sources/gnash/gnash/ChangeLog,v
retrieving revision 1.3971.2.29
retrieving revision 1.3971.2.30
diff -u -b -r1.3971.2.29 -r1.3971.2.30
--- ChangeLog   18 Aug 2007 07:19:29 -0000      1.3971.2.29
+++ ChangeLog   18 Aug 2007 08:06:21 -0000      1.3971.2.30
@@ -1,5 +1,21 @@
 2007-08-18 Sandro Santilli <address@hidden>
 
+       * server/text.{cpp,h}: make text_style class store only the font
+         pointer, w/out the font_id, provide setFont and getFont
+         methods, the former always performing a lookup.
+       * server/parser/text_character_def.cpp (read): use
+         text_style::setFont() to set the font this properly updates
+         the actual font pointer in the text_format, fixing bug #20812.
+       * server/edit_text_character.cpp: use text_style::setFont() to
+         set font by pointer.
+       * server/parser/: movie_definition.h, movie_def_impl.{h,cpp},
+         sprite_definition.h: const-correct get_font() method.
+       * server/parser/movie_def_impl.{h,cpp}: const-corrected
+         in_import_table(), made private and re-activated assertion
+         checking temporarly removed during to GC layout changes.
+
+2007-08-18 Sandro Santilli <address@hidden>
+
        * server/parser/text_character_def.cpp: use symbolic names for
          tag types, more verbose parsing.
 

Index: server/edit_text_character.cpp
===================================================================
RCS file: /sources/gnash/gnash/server/edit_text_character.cpp,v
retrieving revision 1.96
retrieving revision 1.96.2.1
diff -u -b -r1.96 -r1.96.2.1
--- server/edit_text_character.cpp      2 Aug 2007 21:23:42 -0000       1.96
+++ server/edit_text_character.cpp      18 Aug 2007 08:06:22 -0000      1.96.2.1
@@ -17,7 +17,7 @@
 // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 //
 
-/* $Id: edit_text_character.cpp,v 1.96 2007/08/02 21:23:42 strk Exp $ */
+/* $Id: edit_text_character.cpp,v 1.96.2.1 2007/08/18 08:06:22 strk Exp $ */
 
 #ifdef HAVE_CONFIG_H
 #include "config.h"
@@ -925,7 +925,7 @@
        float   scale = m_def->get_font_height() / 1024.0f;     // the EM 
square is 1024 x 1024
 
        text_glyph_record       rec;    // one to work on
-       rec.m_style.m_font = _font;
+       rec.m_style.setFont(_font);
        rec.m_style.m_color = getTextColor(); 
        rec.m_style.m_x_offset = PADDING_TWIPS + std::max(0, 
m_def->get_left_margin() + m_def->get_indent());
        rec.m_style.m_y_offset = PADDING_TWIPS + m_def->get_font_height()
@@ -998,7 +998,7 @@
 
                        // Start a new record on the next line.
                        rec.m_glyphs.resize(0);
-                       rec.m_style.m_font = _font;
+                       rec.m_style.setFont(_font); 
                        rec.m_style.m_color = getTextColor();
                        rec.m_style.m_x_offset = x;
                        rec.m_style.m_y_offset = y;
@@ -1172,7 +1172,7 @@
 
                        // Start a new record on the next line.
                        rec.m_glyphs.resize(0);
-                       rec.m_style.m_font = _font;
+                       rec.m_style.setFont(_font);
                        rec.m_style.m_color = getTextColor();
                        rec.m_style.m_x_offset = x;
                        rec.m_style.m_y_offset = y;

Index: server/text.cpp
===================================================================
RCS file: /sources/gnash/gnash/server/text.cpp,v
retrieving revision 1.35
retrieving revision 1.35.2.1
diff -u -b -r1.35 -r1.35.2.1
--- server/text.cpp     24 Jul 2007 19:57:10 -0000      1.35
+++ server/text.cpp     18 Aug 2007 08:06:22 -0000      1.35.2.1
@@ -17,7 +17,7 @@
 // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 //
 
-/* $Id: text.cpp,v 1.35 2007/07/24 19:57:10 strk Exp $ */
+/* $Id: text.cpp,v 1.35.2.1 2007/08/18 08:06:22 strk Exp $ */
 
 // Based on the public domain work of Thatcher Ulrich <address@hidden> 2003
 
@@ -45,20 +45,23 @@
 
 namespace gnash {
 
-       void text_style::resolve_font(movie_definition* root_def) const
+       bool text_style::setFont(int id, movie_definition& root_def) 
        {
-               if (m_font == NULL)
+               return resolve_font(id, root_def);
+       }
+
+       bool text_style::resolve_font(int id, const movie_definition& root_def)
                {
-                       assert(m_font_id >= 0);
+               assert(id >= 0);
 
-                       m_font = root_def->get_font(m_font_id);
+               m_font = root_def.get_font(id);
                        if (m_font == NULL)
                        {
                                IF_VERBOSE_MALFORMED_SWF(
        log_error(_("text style references unknown font (id = %d)"),
-               m_font_id);
+                               id);
                                );
-                       }
+                       return false;
                }
        }
 
@@ -112,7 +115,7 @@
 
                        //rec.m_style.resolve_font(root_def);
 
-                       const font*     fnt = rec.m_style.m_font;
+                       const font*     fnt = rec.m_style.getFont();
                        if (fnt == NULL)
                        {
 #ifdef GNASH_DEBUG_TEXT_RENDERING
@@ -130,6 +133,7 @@
 
 #ifdef GNASH_DEBUG_TEXT_RENDERING
                        log_debug("text_screen_height for record %u == %g", i, 
text_screen_height);
+                       log_debug("font for record %u == %p", i, (const 
void*)rec.m_style.getFont());
 #endif
 
                        int     nominal_glyph_height = 
fnt->get_texture_glyph_nominal_size();

Index: server/text.h
===================================================================
RCS file: /sources/gnash/gnash/server/text.h,v
retrieving revision 1.18
retrieving revision 1.18.2.1
diff -u -b -r1.18 -r1.18.2.1
--- server/text.h       24 Jul 2007 19:43:30 -0000      1.18
+++ server/text.h       18 Aug 2007 08:06:22 -0000      1.18.2.1
@@ -40,8 +40,6 @@
        class text_style
        {
        public:
-               int     m_font_id;
-               mutable const font*     m_font;
                rgba    m_color;
                float   m_x_offset;
                float   m_y_offset;
@@ -51,17 +49,67 @@
 
                text_style()
                        :
-                       m_font_id(-1),
-                       m_font(NULL),
                        m_x_offset(0),
                        m_y_offset(0),
                        m_text_height(1.0f),
                        m_has_x_offset(false),
-                       m_has_y_offset(false)
+                       m_has_y_offset(false),
+                       m_font(NULL)
                {
                }
 
-               void    resolve_font(movie_definition* root_def) const;
+               /// Set font by id and movie_definition
+               //
+               /// This method will perform a lookup from the movie_definition
+               /// and appropriately set the m_font member.
+               ///
+               /// @param id
+               ///     The font id.
+               ///
+               /// @param root_def
+               ///     The movie_definition used for looking up font by id
+               ///
+               /// @return true on success, false on error (unknown font id)
+               ///
+               bool setFont(int id, movie_definition& def);
+
+               /// Set font by font pointer.
+               //
+               /// @param fnt
+               ///     The font pointer.
+               ///     Must not be NULL or an assertion will fail.
+               ///
+               bool setFont(const font* fnt)
+               {
+                       assert(fnt);
+                       m_font = fnt;
+               }
+
+               /// Return the associated font (possibly NULL).
+               //
+               /// @return 
+               ///     The font associated with this style. 
+               ///     NOTE: it may be NULL if a font set by 
id/movie_definition
+               ///           could not be resolved.
+               ///
+               const font* getFont() const
+               {
+                       return m_font;
+               }
+
+       private:
+
+               const font* m_font;
+
+               /// Set m_font based on m_font_id.
+               //
+               /// @param root_def
+               ///     The movie_definition used for looking up font by id
+               ///
+               /// @return true on success, false on error
+               ///     (unknown font id, would print an swferror about it)
+               ///
+               bool    resolve_font(int id, const movie_definition& root_def);
        };
 
 

Index: server/parser/movie_def_impl.cpp
===================================================================
RCS file: /sources/gnash/gnash/server/parser/movie_def_impl.cpp,v
retrieving revision 1.79
retrieving revision 1.79.2.1
diff -u -b -r1.79 -r1.79.2.1
--- server/parser/movie_def_impl.cpp    10 Jul 2007 16:21:40 -0000      1.79
+++ server/parser/movie_def_impl.cpp    18 Aug 2007 08:06:22 -0000      1.79.2.1
@@ -249,7 +249,7 @@
        //assert(m_jpeg_in.get() == NULL);
 }
 
-bool movie_def_impl::in_import_table(int character_id)
+bool movie_def_impl::in_import_table(int character_id) const
 {
     for (size_t i = 0, n = m_imports.size(); i < n; i++)
         {
@@ -356,7 +356,7 @@
     m_fonts.insert(make_pair(font_id, boost::intrusive_ptr<font>(f)));
 }
 
-font* movie_def_impl::get_font(int font_id)
+font* movie_def_impl::get_font(int font_id) const
 {
 #ifndef NDEBUG
     // make sure font_id is resolved
@@ -367,12 +367,10 @@
         }
 #endif // not NDEBUG
 
-    FontMap::iterator it = m_fonts.find(font_id);
+    FontMap::const_iterator it = m_fonts.find(font_id);
     if ( it == m_fonts.end() ) return NULL;
     boost::intrusive_ptr<font> f = it->second;
-#ifndef GNASH_USE_GC
     assert(f->get_ref_count() > 1);
-#endif // ndef GNASH_USE_GC
     return f.get();
 }
 

Index: server/parser/movie_def_impl.h
===================================================================
RCS file: /sources/gnash/gnash/server/parser/movie_def_impl.h,v
retrieving revision 1.50
retrieving revision 1.50.2.1
diff -u -b -r1.50 -r1.50.2.1
--- server/parser/movie_def_impl.h      1 Jul 2007 17:34:59 -0000       1.50
+++ server/parser/movie_def_impl.h      18 Aug 2007 08:06:23 -0000      1.50.2.1
@@ -321,6 +321,10 @@
        /// A flag set to true when load cancelation is requested
        bool _loadingCanceled;
 
+       /// Debug helper; returns true if the given
+       /// character_id is listed in the import table.
+       bool in_import_table(int character_id) const;
+
 public:
 
        movie_def_impl(create_bitmaps_flag cbf, create_font_shapes_flag cfs);
@@ -425,10 +429,6 @@
            m_imports.push_back(import_info(source_url, id, symbol));
        }
 
-       /// Debug helper; returns true if the given
-       /// character_id is listed in the import table.
-       bool in_import_table(int character_id);
-
        /// \brief
        /// Calls back the visitor for each movie that we
        /// import symbols from.
@@ -453,7 +453,7 @@
 
        void    add_font(int font_id, font* f);
 
-       font*   get_font(int font_id);
+       font*   get_font(int font_id) const;
 
        // See dox in movie_definition.h
        bitmap_character_def*   get_bitmap_character_def(int character_id);

Index: server/parser/movie_definition.h
===================================================================
RCS file: /sources/gnash/gnash/server/parser/movie_definition.h,v
retrieving revision 1.27
retrieving revision 1.27.2.1
diff -u -b -r1.27 -r1.27.2.1
--- server/parser/movie_definition.h    1 Jul 2007 10:54:34 -0000       1.27
+++ server/parser/movie_definition.h    18 Aug 2007 08:06:23 -0000      1.27.2.1
@@ -326,7 +326,7 @@
        ///
        /// @see add_font
        ///
-       virtual font* get_font(int /*id*/)
+       virtual font* get_font(int /*id*/) const
        {
                return NULL;
        }

Index: server/parser/sprite_definition.h
===================================================================
RCS file: /sources/gnash/gnash/server/parser/sprite_definition.h,v
retrieving revision 1.26
retrieving revision 1.26.2.1
diff -u -b -r1.26 -r1.26.2.1
--- server/parser/sprite_definition.h   5 Jul 2007 19:29:10 -0000       1.26
+++ server/parser/sprite_definition.h   18 Aug 2007 08:06:23 -0000      1.26.2.1
@@ -189,7 +189,7 @@
        }
 
        /// Delegate call to associated root movie
-       virtual font* get_font(int id)
+       virtual font* get_font(int id) const
        {
                return m_movie_def->get_font(id);
        }

Index: server/parser/text_character_def.cpp
===================================================================
RCS file: /sources/gnash/gnash/server/parser/text_character_def.cpp,v
retrieving revision 1.4.2.1
retrieving revision 1.4.2.2
diff -u -b -r1.4.2.1 -r1.4.2.2
--- server/parser/text_character_def.cpp        18 Aug 2007 06:20:01 -0000      
1.4.2.1
+++ server/parser/text_character_def.cpp        18 Aug 2007 08:06:23 -0000      
1.4.2.2
@@ -66,10 +66,13 @@
                        if (has_font)
                        {
                                uint16_t        font_id = in->read_u16();
-                               style.m_font_id = font_id;
-                               style.resolve_font(m);
+                               if ( ! style.setFont(font_id, *m) )
+                               {
+                                       // setFont would have already printed 
an swferror on failure
+                               }
+
                                IF_VERBOSE_PARSE(
-                               log_parse(_("  has_font: font id = %d"), 
font_id);
+                               log_parse(_("  has_font: font id = %d (%p)"), 
font_id, (void*)style.getFont());
                                );
                        }
                        if (has_color)
@@ -137,7 +140,7 @@
 
                        m_text_glyph_records.resize(m_text_glyph_records.size() 
+ 1);
                        text_glyph_record& grecord = 
m_text_glyph_records.back();
-                       grecord.m_style = style;
+                       grecord.m_style = style; // copy current style
                        grecord.read(in, glyph_count, glyph_bits, advance_bits);
 
                        IF_VERBOSE_PARSE(




reply via email to

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