|
From: <br...@us...> - 2010-05-27 14:49:57
|
Revision: 4145
http://openvrml.svn.sourceforge.net/openvrml/?rev=4145&view=rev
Author: braden
Date: 2010-05-27 14:49:47 +0000 (Thu, 27 May 2010)
Log Message:
-----------
Call FcInit/FcFini to clean up resources used by Fontconfig.
Modified Paths:
--------------
trunk/ChangeLog
trunk/src/node/vrml97/text.cpp
Modified: trunk/ChangeLog
===================================================================
--- trunk/ChangeLog 2010-05-21 09:08:10 UTC (rev 4144)
+++ trunk/ChangeLog 2010-05-27 14:49:47 UTC (rev 4145)
@@ -1,3 +1,18 @@
+2010-05-27 Braden McDaniel <br...@en...>
+
+ Call FcInit/FcFini to clean up resources used by Fontconfig.
+
+ * src/node/vrml97/text.cpp
+ (text_node::text_geometry::text_geometry(const
+ boost::ptr_vector<line_geometry> &, const std::string &, const
+ std::string &, bool, float, float, float)): Initialize x_min_,
+ x_max_, y_min_, and y_max_ to 0.
+ (openvrml_node_vrml97::text_metatype::text_metatype(openvrml::browser&)):
+ Call FcInit if this is the first time we're using the Fontconfig
+ library.
+ (openvrml_node_vrml97::text_metatype::~text_metatype()): Call
+ FcFini if this is the last use of the Fontconfig library.
+
2010-05-21 Braden McDaniel <br...@en...>
We're expanding the pixels that libpng reads to full RGBA
Modified: trunk/src/node/vrml97/text.cpp
===================================================================
--- trunk/src/node/vrml97/text.cpp 2010-05-21 09:08:10 UTC (rev 4144)
+++ trunk/src/node/vrml97/text.cpp 2010-05-27 14:49:47 UTC (rev 4145)
@@ -1649,7 +1649,11 @@
const float size,
const float spacing,
const float max_extent)
- OPENVRML_THROW1(std::bad_alloc)
+ OPENVRML_THROW1(std::bad_alloc):
+ x_min_(0),
+ x_max_(0),
+ y_min_(0),
+ y_max_(0)
{
std::size_t polygons = 0;
for (boost::ptr_vector<line_geometry>::const_iterator line =
@@ -2748,6 +2752,15 @@
* @see http://freetype.org/freetype2/docs/reference/ft2-base_interface.html#FT_Library
*/
+namespace {
+ //
+ // We need to call FcFini once (and only once) when we're finished with
+ // the library (i.e., shutdown).
+ //
+ OPENVRML_LOCAL size_t fc_use_count = 0;
+ OPENVRML_LOCAL boost::mutex fc_use_count_mutex;
+}
+
/**
* @brief Construct.
*
@@ -2758,9 +2771,22 @@
node_metatype(text_metatype::id, browser)
{
# ifdef OPENVRML_ENABLE_RENDER_TEXT_NODE
- FT_Error error = 0;
- error = FT_Init_FreeType(&this->freeTypeLibrary);
- if (error) {
+ {
+ using boost::mutex;
+ using boost::unique_lock;
+
+ unique_lock<mutex> lock(fc_use_count_mutex);
+ if (fc_use_count++ == 0) {
+ FcBool fc_succeeded = FcInit();
+ if (!fc_succeeded) {
+ browser.err("error initializing fontconfig library");
+ }
+ }
+ }
+
+ FT_Error ft_error = 0;
+ ft_error = FT_Init_FreeType(&this->freeTypeLibrary);
+ if (ft_error) {
browser.err("error initializing FreeType library");
}
# endif // OPENVRML_ENABLE_RENDER_TEXT_NODE
@@ -2772,11 +2798,16 @@
openvrml_node_vrml97::text_metatype::~text_metatype() OPENVRML_NOTHROW
{
# ifdef OPENVRML_ENABLE_RENDER_TEXT_NODE
- FT_Error error = 0;
- error = FT_Done_FreeType(this->freeTypeLibrary);
- if (error) {
+ FT_Error ft_error = FT_Done_FreeType(this->freeTypeLibrary);
+ if (ft_error) {
this->browser().err("error shutting down FreeType library");
}
+
+ using boost::mutex;
+ using boost::unique_lock;
+
+ unique_lock<mutex> lock(fc_use_count_mutex);
+ if (--fc_use_count == 0) { FcFini(); }
# endif // OPENVRML_ENABLE_RENDER_TEXT_NODE
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|