Index: src/core/SkGlyphCache.h |
diff --git a/src/core/SkGlyphCache.h b/src/core/SkGlyphCache.h |
index 8b404dcc097f627c687a532986f0ff5ed3046325..4daf6b06b6c07c04bcdada8fdcac516475b33a63 100644 |
--- a/src/core/SkGlyphCache.h |
+++ b/src/core/SkGlyphCache.h |
@@ -244,37 +244,74 @@ private: |
friend class SkGlyphCache_Globals; |
}; |
-class SkAutoGlyphCache { |
+class SkAutoGlyphCacheBase { |
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() { |
+ SkGlyphCache* getCache() const { return fCache; } |
+ |
+ void release() { |
if (fCache) { |
SkGlyphCache::AttachCache(fCache); |
+ fCache = NULL; |
} |
} |
- SkGlyphCache* getCache() const { return fCache; } |
- |
- void release() { |
+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() { |
+ fCache = NULL; |
+ } |
+ ~SkAutoGlyphCacheBase() { |
if (fCache) { |
SkGlyphCache::AttachCache(fCache); |
- fCache = NULL; |
} |
} |
-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); |
+ } |
+ |
+private: |
+ SkAutoGlyphCache() : SkAutoGlyphCacheBase() {} |
+}; |
#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); |
+ } |
+ |
+private: |
+ SkAutoGlyphCacheNoGamma() : SkAutoGlyphCacheBase() {} |
+}; |
+#define SkAutoGlyphCacheNoGamma(...) SK_REQUIRE_LOCAL_VAR(SkAutoGlyphCacheNoGamma) |
+ |
#endif |