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

Unified Diff: src/core/SkGlyphCache.h

Issue 258883002: Gamma correction for distance field text. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Fix SkAutoGlyphCache destructor Created 6 years, 6 months 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
« no previous file with comments | « include/core/SkPaint.h ('k') | src/core/SkMaskGamma.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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
« no previous file with comments | « include/core/SkPaint.h ('k') | src/core/SkMaskGamma.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698