Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(727)

Unified Diff: skia/ext/vector_platform_device_linux.cc

Issue 5682008: Make members of Singleton<T> private and only visible to the singleton type. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 10 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: skia/ext/vector_platform_device_linux.cc
diff --git a/skia/ext/vector_platform_device_linux.cc b/skia/ext/vector_platform_device_linux.cc
index 3d4559615ac4a2eed474d53c60a17978e535acdd..4bf5fd1908505a29a54d46c67dd8e8594f0dce6b 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) {
@@ -592,12 +595,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);
@@ -667,7 +670,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();

Powered by Google App Engine
This is Rietveld 408576698