summaryrefslogtreecommitdiffstats
path: root/skia
diff options
context:
space:
mode:
authorsatish@chromium.org <satish@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-12-14 07:48:49 +0000
committersatish@chromium.org <satish@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-12-14 07:48:49 +0000
commit625332e06437018bf696dce93a4b2bd2c5e0b118 (patch)
tree56e128ddf94a81b6de1f29a9eabe59f0d79346c9 /skia
parentdc7cdcb970254f223262a66c812f240a8269ae87 (diff)
downloadchromium_src-625332e06437018bf696dce93a4b2bd2c5e0b118.zip
chromium_src-625332e06437018bf696dce93a4b2bd2c5e0b118.tar.gz
chromium_src-625332e06437018bf696dce93a4b2bd2c5e0b118.tar.bz2
Make members of Singleton<T> private and only visible to the singleton type. This enforces that the Singleton<T> pattern can only be used within classes which want singleton-ness.
As part of this CL I have also fixed up files which got missed in my previous CLs to use a GetInstance() method and use Singleton<T> from the source file. There are a small number of places where I have also switched to LazyInstance as that was more appropriate for types used in a single source file. BUG=65298 TEST=all existing tests should continue to pass. Review URL: http://codereview.chromium.org/5682008 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@69107 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'skia')
-rw-r--r--skia/ext/vector_platform_device_linux.cc11
1 files changed, 7 insertions, 4 deletions
diff --git a/skia/ext/vector_platform_device_linux.cc b/skia/ext/vector_platform_device_linux.cc
index 94292cdb..8f5be43 100644
--- a/skia/ext/vector_platform_device_linux.cc
+++ b/skia/ext/vector_platform_device_linux.cc
@@ -12,8 +12,8 @@
#include <map>
+#include "base/lazy_instance.h"
#include "base/logging.h"
-#include "base/singleton.h"
#include "skia/ext/bitmap_platform_device.h"
#include "third_party/skia/include/core/SkFontHost.h"
#include "third_party/skia/include/core/SkStream.h"
@@ -29,6 +29,8 @@ struct FontInfo {
};
typedef std::map<uint32_t, FontInfo> MapFontId2FontInfo;
+static base::LazyInstance<MapFontId2FontInfo> g_map_font_id_to_font_info(
+ base::LINKER_INITIALIZED);
// Wrapper for FT_Library that handles initialization and cleanup, and allows
// us to use a singleton.
@@ -55,6 +57,7 @@ class FtLibrary {
private:
FT_Library library_;
};
+static base::LazyInstance<FtLibrary> g_ft_library(base::LINKER_INITIALIZED);
// Verify cairo surface after creation/modification.
bool IsContextValid(cairo_t* context) {
@@ -604,12 +607,12 @@ bool VectorPlatformDevice::SelectFontById(uint32_t font_id) {
DCHECK(IsContextValid(context_));
DCHECK(SkFontHost::ValidFontID(font_id));
- FtLibrary* ft_library = Singleton<FtLibrary>::get();
+ FtLibrary* ft_library = g_ft_library.Pointer();
if (!ft_library->library())
return false;
// Checks if we have a cache hit.
- MapFontId2FontInfo* g_font_cache = Singleton<MapFontId2FontInfo>::get();
+ MapFontId2FontInfo* g_font_cache = g_map_font_id_to_font_info.Pointer();
DCHECK(g_font_cache);
MapFontId2FontInfo::iterator it = g_font_cache->find(font_id);
@@ -679,7 +682,7 @@ bool VectorPlatformDevice::SelectFontById(uint32_t font_id) {
// static
void VectorPlatformDevice::ClearFontCache() {
- MapFontId2FontInfo* g_font_cache = Singleton<MapFontId2FontInfo>::get();
+ MapFontId2FontInfo* g_font_cache = g_map_font_id_to_font_info.Pointer();
DCHECK(g_font_cache);
for (MapFontId2FontInfo::iterator it = g_font_cache->begin();