Index: src/core/SkGlyphCache.h |
diff --git a/src/core/SkGlyphCache.h b/src/core/SkGlyphCache.h |
index d18b61a0a9d544bd910ca01c469a87b5f69d3467..8b404dcc097f627c687a532986f0ff5ed3046325 100644 |
--- a/src/core/SkGlyphCache.h |
+++ b/src/core/SkGlyphCache.h |
@@ -244,8 +244,23 @@ |
friend class SkGlyphCache_Globals; |
}; |
-class SkAutoGlyphCacheBase { |
+class SkAutoGlyphCache { |
public: |
+ SkAutoGlyphCache(SkGlyphCache* cache) : fCache(cache) {} |
+ SkAutoGlyphCache(SkTypeface* typeface, const SkDescriptor* desc) { |
+ fCache = SkGlyphCache::DetachCache(typeface, desc); |
+ } |
+ SkAutoGlyphCache(const SkPaint& paint, |
+ const SkDeviceProperties* deviceProperties, |
+ const SkMatrix* matrix) { |
+ fCache = paint.detachCache(deviceProperties, matrix); |
+ } |
+ ~SkAutoGlyphCache() { |
+ if (fCache) { |
+ SkGlyphCache::AttachCache(fCache); |
+ } |
+ } |
+ |
SkGlyphCache* getCache() const { return fCache; } |
void release() { |
@@ -255,61 +270,11 @@ |
} |
} |
-protected: |
- // Hide the constructors so we can't create one of these directly. |
- // Create SkAutoGlyphCache or SkAutoGlyphCacheNoCache instead. |
- SkAutoGlyphCacheBase(SkGlyphCache* cache) : fCache(cache) {} |
- SkAutoGlyphCacheBase(SkTypeface* typeface, const SkDescriptor* desc) { |
- fCache = SkGlyphCache::DetachCache(typeface, desc); |
- } |
- SkAutoGlyphCacheBase(const SkPaint& paint, |
- const SkDeviceProperties* deviceProperties, |
- const SkMatrix* matrix) { |
- fCache = NULL; |
- } |
- SkAutoGlyphCacheBase() {} |
- |
+private: |
SkGlyphCache* fCache; |
-private: |
static bool DetachProc(const SkGlyphCache*, void*); |
}; |
- |
-class SkAutoGlyphCache : public SkAutoGlyphCacheBase { |
-public: |
- SkAutoGlyphCache(SkGlyphCache* cache) : SkAutoGlyphCacheBase(cache) {} |
- SkAutoGlyphCache(SkTypeface* typeface, const SkDescriptor* desc) : |
- SkAutoGlyphCacheBase(typeface, desc) {} |
- SkAutoGlyphCache(const SkPaint& paint, |
- const SkDeviceProperties* deviceProperties, |
- const SkMatrix* matrix) { |
- fCache = paint.detachCache(deviceProperties, matrix, false); |
- } |
- SkAutoGlyphCache() : SkAutoGlyphCacheBase() { |
- if (fCache) { |
- SkGlyphCache::AttachCache(fCache); |
- } |
- } |
-}; |
#define SkAutoGlyphCache(...) SK_REQUIRE_LOCAL_VAR(SkAutoGlyphCache) |
-class SkAutoGlyphCacheNoGamma : public SkAutoGlyphCacheBase { |
-public: |
- SkAutoGlyphCacheNoGamma(SkGlyphCache* cache) : SkAutoGlyphCacheBase(cache) {} |
- SkAutoGlyphCacheNoGamma(SkTypeface* typeface, const SkDescriptor* desc) : |
- SkAutoGlyphCacheBase(typeface, desc) {} |
- SkAutoGlyphCacheNoGamma(const SkPaint& paint, |
- const SkDeviceProperties* deviceProperties, |
- const SkMatrix* matrix) { |
- fCache = paint.detachCache(deviceProperties, matrix, true); |
- } |
- SkAutoGlyphCacheNoGamma() : SkAutoGlyphCacheBase() { |
- if (fCache) { |
- SkGlyphCache::AttachCache(fCache); |
- } |
- } |
-}; |
-#define SkAutoGlyphCacheNoGamma(...) SK_REQUIRE_LOCAL_VAR(SkAutoGlyphCacheNoGamma) |
- |
- |
#endif |