make face_manager copyable

This commit is contained in:
Mickey Rose 2016-01-26 21:13:03 +01:00
parent a7ecabcde3
commit 844021a892
2 changed files with 11 additions and 9 deletions

View file

@ -100,10 +100,8 @@ private:
static font_memory_cache_type global_memory_fonts_;
};
class MAPNIK_DECL face_manager : private util::noncopyable
class MAPNIK_DECL face_manager
{
using face_ptr_cache_type = std::map<std::string, face_ptr>;
public:
face_manager(font_library & library,
freetype_engine::font_file_mapping_type const& font_file_mapping,
@ -112,9 +110,13 @@ public:
face_set_ptr get_face_set(std::string const& name);
face_set_ptr get_face_set(font_set const& fset);
face_set_ptr get_face_set(std::string const& name, boost::optional<font_set> fset);
inline stroker_ptr get_stroker() { return stroker_; }
stroker_ptr get_stroker() const { return stroker_; }
private:
face_ptr_cache_type face_ptr_cache_;
using face_cache = std::map<std::string, face_ptr>;
using face_cache_ptr = std::shared_ptr<face_cache>;
face_cache_ptr face_cache_;
font_library & library_;
freetype_engine::font_file_mapping_type const& font_file_mapping_;
freetype_engine::font_memory_cache_type const& font_memory_cache_;

View file

@ -361,7 +361,7 @@ face_ptr freetype_engine::create_face(std::string const& family_name,
face_manager::face_manager(font_library & library,
freetype_engine::font_file_mapping_type const& font_file_mapping,
freetype_engine::font_memory_cache_type const& font_cache)
: face_ptr_cache_(),
: face_cache_(new face_cache()),
library_(library),
font_file_mapping_(font_file_mapping),
font_memory_cache_(font_cache)
@ -376,8 +376,8 @@ face_manager::face_manager(font_library & library,
face_ptr face_manager::get_face(std::string const& name)
{
auto itr = face_ptr_cache_.find(name);
if (itr != face_ptr_cache_.end())
auto itr = face_cache_->find(name);
if (itr != face_cache_->end())
{
return itr->second;
}
@ -391,7 +391,7 @@ face_ptr face_manager::get_face(std::string const& name)
freetype_engine::get_cache());
if (face)
{
face_ptr_cache_.emplace(name,face);
face_cache_->emplace(name, face);
}
return face;
}