summaryrefslogtreecommitdiffstats
path: root/chromium/third_party/skia/src/core/SkGlyphCache.h
diff options
context:
space:
mode:
Diffstat (limited to 'chromium/third_party/skia/src/core/SkGlyphCache.h')
-rw-r--r--chromium/third_party/skia/src/core/SkGlyphCache.h75
1 files changed, 58 insertions, 17 deletions
diff --git a/chromium/third_party/skia/src/core/SkGlyphCache.h b/chromium/third_party/skia/src/core/SkGlyphCache.h
index 7b2ebb844e2..4daf6b06b6c 100644
--- a/chromium/third_party/skia/src/core/SkGlyphCache.h
+++ b/chromium/third_party/skia/src/core/SkGlyphCache.h
@@ -28,7 +28,7 @@ class SkGlyphCache_Globals;
This class represents a strike: a specific combination of typeface, size,
matrix, etc., and holds the glyphs for that strike. Calling any of the
getUnichar.../getGlyphID... methods will return the requested glyph,
- either instantly if it is already cahced, or by first generating it and then
+ either instantly if it is already cached, or by first generating it and then
adding it to the strike.
The strikes are held in a global list, available to all threads. To interact
@@ -92,6 +92,10 @@ public:
this will trigger that.
*/
const SkPath* findPath(const SkGlyph&);
+ /** Return the distance field associated with the glyph. If it has not been generated
+ this will trigger that.
+ */
+ const void* findDistanceField(const SkGlyph&);
/** Return the vertical metrics for this strike.
*/
@@ -240,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