CVSROOT: /sources/gnash Module name: gnash Changes by: Sandro Santilli <strk> 07/08/18 08:05:00
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&r1=1.4022&r2=1.4023 http://cvs.savannah.gnu.org/viewcvs/gnash/server/edit_text_character.cpp?cvsroot=gnash&r1=1.99&r2=1.100 http://cvs.savannah.gnu.org/viewcvs/gnash/server/text.cpp?cvsroot=gnash&r1=1.35&r2=1.36 http://cvs.savannah.gnu.org/viewcvs/gnash/server/text.h?cvsroot=gnash&r1=1.18&r2=1.19 http://cvs.savannah.gnu.org/viewcvs/gnash/server/parser/movie_def_impl.cpp?cvsroot=gnash&r1=1.79&r2=1.80 http://cvs.savannah.gnu.org/viewcvs/gnash/server/parser/movie_def_impl.h?cvsroot=gnash&r1=1.51&r2=1.52 http://cvs.savannah.gnu.org/viewcvs/gnash/server/parser/movie_definition.h?cvsroot=gnash&r1=1.28&r2=1.29 http://cvs.savannah.gnu.org/viewcvs/gnash/server/parser/sprite_definition.h?cvsroot=gnash&r1=1.27&r2=1.28 http://cvs.savannah.gnu.org/viewcvs/gnash/server/parser/text_character_def.cpp?cvsroot=gnash&r1=1.5&r2=1.6 Patches: Index: ChangeLog =================================================================== RCS file: /sources/gnash/gnash/ChangeLog,v retrieving revision 1.4022 retrieving revision 1.4023 diff -u -b -r1.4022 -r1.4023 --- ChangeLog 18 Aug 2007 07:19:26 -0000 1.4022 +++ ChangeLog 18 Aug 2007 08:04:59 -0000 1.4023 @@ -1,5 +1,21 @@ 2007-08-18 Sandro Santilli <[EMAIL PROTECTED]> + * 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 <[EMAIL PROTECTED]> + * 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.99 retrieving revision 1.100 diff -u -b -r1.99 -r1.100 --- server/edit_text_character.cpp 16 Aug 2007 10:31:51 -0000 1.99 +++ server/edit_text_character.cpp 18 Aug 2007 08:04:59 -0000 1.100 @@ -17,7 +17,7 @@ // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA // -/* $Id: edit_text_character.cpp,v 1.99 2007/08/16 10:31:51 strk Exp $ */ +/* $Id: edit_text_character.cpp,v 1.100 2007/08/18 08:04:59 strk Exp $ */ #ifdef HAVE_CONFIG_H #include "config.h" @@ -1019,7 +1019,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() @@ -1092,7 +1092,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; @@ -1274,7 +1274,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.36 diff -u -b -r1.35 -r1.36 --- server/text.cpp 24 Jul 2007 19:57:10 -0000 1.35 +++ server/text.cpp 18 Aug 2007 08:04:59 -0000 1.36 @@ -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.36 2007/08/18 08:04:59 strk Exp $ */ // Based on the public domain work of Thatcher Ulrich <[EMAIL PROTECTED]> 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.19 diff -u -b -r1.18 -r1.19 --- server/text.h 24 Jul 2007 19:43:30 -0000 1.18 +++ server/text.h 18 Aug 2007 08:05:00 -0000 1.19 @@ -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.80 diff -u -b -r1.79 -r1.80 --- 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:05:00 -0000 1.80 @@ -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.51 retrieving revision 1.52 diff -u -b -r1.51 -r1.52 --- server/parser/movie_def_impl.h 9 Aug 2007 12:18:07 -0000 1.51 +++ server/parser/movie_def_impl.h 18 Aug 2007 08:05:00 -0000 1.52 @@ -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.28 retrieving revision 1.29 diff -u -b -r1.28 -r1.29 --- server/parser/movie_definition.h 9 Aug 2007 12:18:07 -0000 1.28 +++ server/parser/movie_definition.h 18 Aug 2007 08:05:00 -0000 1.29 @@ -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.27 retrieving revision 1.28 diff -u -b -r1.27 -r1.28 --- server/parser/sprite_definition.h 9 Aug 2007 12:18:07 -0000 1.27 +++ server/parser/sprite_definition.h 18 Aug 2007 08:05:00 -0000 1.28 @@ -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.5 retrieving revision 1.6 diff -u -b -r1.5 -r1.6 --- server/parser/text_character_def.cpp 18 Aug 2007 06:20:07 -0000 1.5 +++ server/parser/text_character_def.cpp 18 Aug 2007 08:05:00 -0000 1.6 @@ -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( _______________________________________________ Gnash-commit mailing list Gnash-commit@gnu.org http://lists.gnu.org/mailman/listinfo/gnash-commit