[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Gnash-commit] gnash ChangeLog server/font.cpp server/font.h
From: |
Sandro Santilli |
Subject: |
[Gnash-commit] gnash ChangeLog server/font.cpp server/font.h |
Date: |
Wed, 02 Aug 2006 01:40:33 +0000 |
CVSROOT: /sources/gnash
Module name: gnash
Changes by: Sandro Santilli <strk> 06/08/02 01:40:33
Modified files:
. : ChangeLog
server : font.cpp font.h
Log message:
* server/font.cpp, server/font.h: tu_hash => std::map, minor
optimizations, more verbose parsing.
CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/gnash/ChangeLog?cvsroot=gnash&r1=1.573&r2=1.574
http://cvs.savannah.gnu.org/viewcvs/gnash/server/font.cpp?cvsroot=gnash&r1=1.16&r2=1.17
http://cvs.savannah.gnu.org/viewcvs/gnash/server/font.h?cvsroot=gnash&r1=1.10&r2=1.11
Patches:
Index: ChangeLog
===================================================================
RCS file: /sources/gnash/gnash/ChangeLog,v
retrieving revision 1.573
retrieving revision 1.574
diff -u -b -r1.573 -r1.574
--- ChangeLog 2 Aug 2006 01:22:59 -0000 1.573
+++ ChangeLog 2 Aug 2006 01:40:32 -0000 1.574
@@ -1,3 +1,11 @@
+2006-08-02 Sandro Santilli <address@hidden>
+
+ * server/font.cpp, server/font.h: tu_hash => std::map, minor
+ optimizations, more verbose parsing.
+ * gui/Makefile.am: use a GNASH_LIBS variable, to make future
+ additions cleaner. Fixes missed link of libamf.la in 'gnash'
+ executable,
+
2006-08-01 Rob Savoye <address@hidden>
* libamf/amf.cpp, amf.h: Changes for cleaner 64 bit support.
@@ -6,12 +14,6 @@
* macros/kde.m4: Remove 64 libraries as weel as 32 bit ones for
sed.
-2006-08-02 Sandro Santilli <address@hidden>
-
- * gui/Makefile.am: use a GNASH_LIBS variable, to make future
- additions cleaner. Fixes missed link of libamf.la in 'gnash'
- executable,
-
2006-08-01 Rob Savoye <address@hidden>
* configure.ac: Change testing to disabled by default.
Index: server/font.cpp
===================================================================
RCS file: /sources/gnash/gnash/server/font.cpp,v
retrieving revision 1.16
retrieving revision 1.17
diff -u -b -r1.16 -r1.17
--- server/font.cpp 1 Aug 2006 23:15:15 -0000 1.16
+++ server/font.cpp 2 Aug 2006 01:40:33 -0000 1.17
@@ -16,6 +16,8 @@
#include "shape_character_def.h"
#include "swf.h"
+#include <utility> // for std::make_pair
+
namespace gnash {
font::font()
:
@@ -189,18 +191,22 @@
if (wide_offsets)
{
// 32-bit offsets.
- for (int i = 0; i < glyph_count; i++)
+ for (unsigned int i = 0; i < glyph_count; i++)
{
- offsets.push_back(in->read_u32());
+ uint32_t off = in->read_u32();
+ log_parse("Glyph %d at offset %lu", i, off);
+ offsets.push_back(off);
}
font_code_offset = in->read_u32();
}
else
{
// 16-bit offsets.
- for (int i = 0; i < glyph_count; i++)
+ for (unsigned int i = 0; i < glyph_count; i++)
{
- offsets.push_back(in->read_u16());
+ uint16_t off = in->read_u16();
+ log_parse("Glyph %d at offset %u", i, off);
+ offsets.push_back(off);
}
font_code_offset = in->read_u16();
}
@@ -274,7 +280,7 @@
// Kerning pairs.
int kerning_count = in->read_u16();
- {for (int i = 0; i < kerning_count; i++)
+ for (int i = 0; i < kerning_count; i++)
{
uint16_t char0, char1;
if (m_wide_codes)
@@ -295,11 +301,12 @@
// Remember this adjustment; we can look it up
quickly
// later using the character pair as the key.
- if (m_kerning_pairs.find(k) ==
m_kerning_pairs.end())
- m_kerning_pairs.add(k, adjustment);
- else
+ if ( ! m_kerning_pairs.insert(std::make_pair(k, adjustment)).second )
+ {
log_parse("ERROR: Repeated kerning pair
found - ignoring\n");
- }}
+ }
+
+ }
}
}
@@ -336,28 +343,41 @@
if (m_wide_codes)
{
// Code table is made of uint16_t's.
- for (unsigned int i = 0; i < m_glyphs.size(); i++)
+ for (int i=0, n=m_glyphs.size(); i<n; ++i)
{
- m_code_table.add(in->read_u16(), i);
+ uint16_t code = in->read_u16();
+ //m_code_table.add(code, i);
+ m_code_table.insert(std::make_pair(code, i));
}
}
else
{
// Code table is made of bytes.
- for (unsigned int i = 0; i < m_glyphs.size(); i++)
+ for (int i=0, n=m_glyphs.size(); i<n; ++i)
{
- m_code_table.add(in->read_u8(), i);
+ uint8_t code = in->read_u8();
+ //m_code_table.add(code, i);
+ m_code_table.insert(std::make_pair(code, i));
}
}
}
int font::get_glyph_index(uint16_t code) const
{
- int glyph_index;
- if (m_code_table.get(code, &glyph_index))
+ code_table::const_iterator it = m_code_table.find(code);
+ if ( it != m_code_table.end() )
{
+ int glyph_index = it->second;
+#if 0
+ log_msg("get_glyph_index(%u) returning %d",
+ code, glyph_index);
+#endif
return glyph_index;
}
+
+#if 0
+ log_msg("get_glyph_index(%u) returning -1", code);
+#endif
return -1;
}
@@ -395,16 +415,17 @@
}
- float font::get_kerning_adjustment(int last_code, int code) const
// Return the adjustment in advance between the given two
// characters. Normally this will be 0; i.e. the
+ float font::get_kerning_adjustment(int last_code, int code) const
{
- float adjustment;
kerning_pair k;
k.m_char0 = last_code;
k.m_char1 = code;
- if (m_kerning_pairs.get(k, &adjustment))
+ kernings_table::const_iterator it = m_kerning_pairs.find(k);
+ if ( it != m_kerning_pairs.end() )
{
+ float adjustment = it->second;
return adjustment;
}
return 0;
Index: server/font.h
===================================================================
RCS file: /sources/gnash/gnash/server/font.h,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -b -r1.10 -r1.11
--- server/font.h 1 Aug 2006 11:01:52 -0000 1.10
+++ server/font.h 2 Aug 2006 01:40:33 -0000 1.11
@@ -14,6 +14,9 @@
#include "gnash.h"
#include "types.h"
#include "impl.h"
+
+#include <map>
+
class tu_file;
namespace gnash {
@@ -60,6 +63,38 @@
};
+ // @@ replace this with a flat hash, or else a sorted array
+ // (binary search)
+ struct kerning_pair
+ {
+ uint16_t m_char0, m_char1;
+
+ bool operator==(const kerning_pair& k) const
+ {
+ return m_char0 == k.m_char0 && m_char1 == k.m_char1;
+ }
+
+
+ };
+
+ // for use in standard algorithms
+ inline bool operator < (const kerning_pair& p1, const kerning_pair& p2)
+ {
+ if ( p1.m_char0 < p2.m_char0 )
+ {
+ return true;
+ }
+ else if ( p1.m_char0 == p2.m_char0 )
+ {
+ if ( p1.m_char1 < p2.m_char1 ) return true;
+ else return false;
+ }
+ else
+ {
+ return false;
+ }
+ }
+
/// \brief
/// A 'font' definition as read from SWF::DefineFont or
/// SWF::DefineFont2 tags.
@@ -134,6 +169,13 @@
int get_glyph_index(uint16_t code) const;
float get_advance(int glyph_index) const;
+
+ /// \brief
+ /// Return the adjustment in advance between the given two
+ /// characters.
+ //
+ /// Normally this will be 0
+ ///
float get_kerning_adjustment(int last_code, int this_code)
const;
float get_leading() const { return m_leading; }
float get_descent() const { return m_descent; }
@@ -168,13 +210,15 @@
// m_code_table[character_code] = glyph_index
//
// @@ TODO: avoid little allocs; replace this with a flat hash,
or else a sorted array (binary search)
- template<class T>
- struct simple_code_hash
- // Dummy hash functor.
- {
- size_t operator()(const T& data) const { return data; }
- };
- hash<uint16_t, int, simple_code_hash<uint16_t> > m_code_table;
+// template<class T>
+// struct simple_code_hash
+// // Dummy hash functor.
+// {
+// size_t operator()(const T& data) const { return data; }
+// };
+// hash<uint16_t, int, simple_code_hash<uint16_t> > m_code_table;
+ typedef std::map<uint16_t, int> code_table;
+ code_table m_code_table;
// Layout stuff.
float m_ascent;
@@ -184,19 +228,13 @@
// @@ we don't seem to use this thing at all, so don't bother
keeping it.
// std::vector<rect> m_bounds_table; // @@ this thing should
be optional.
- // @@ replace this with a flat hash, or else a sorted array
(binary search)
- struct kerning_pair
- {
- uint16_t m_char0, m_char1;
- bool operator==(const kerning_pair& k) const
- {
- return m_char0 == k.m_char0 && m_char1 ==
k.m_char1;
- }
- };
- hash<kerning_pair, float> m_kerning_pairs;
+ //hash<kerning_pair, float> m_kerning_pairs;
+ typedef std::map<kerning_pair, float> kernings_table;
+ kernings_table m_kerning_pairs;
};
+
} // end namespace gnash
- [Gnash-commit] gnash ChangeLog server/font.cpp server/font.h,
Sandro Santilli <=