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

Side by Side Diff: src/core/SkGlyphCache.h

Issue 1863013003: Pass effects directly to fontcache (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: removed DUMMY effects Created 4 years, 8 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 unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright 2006 The Android Open Source Project 2 * Copyright 2006 The Android Open Source Project
3 * 3 *
4 * Use of this source code is governed by a BSD-style license that can be found in the LICENSE file. 4 * Use of this source code is governed by a BSD-style license that can be found in the LICENSE file.
5 */ 5 */
6 6
7 #ifndef SkGlyphCache_DEFINED 7 #ifndef SkGlyphCache_DEFINED
8 #define SkGlyphCache_DEFINED 8 #define SkGlyphCache_DEFINED
9 9
10 #include "SkBitmap.h" 10 #include "SkBitmap.h"
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after
122 122
123 //! Add a proc/data pair to the glyphcache. proc should be non-null 123 //! Add a proc/data pair to the glyphcache. proc should be non-null
124 void setAuxProc(void (*auxProc)(void*), void* auxData); 124 void setAuxProc(void (*auxProc)(void*), void* auxData);
125 125
126 SkScalerContext* getScalerContext() const { return fScalerContext; } 126 SkScalerContext* getScalerContext() const { return fScalerContext; }
127 127
128 /** Find a matching cache entry, and call proc() with it. If none is found c reate a new one. 128 /** Find a matching cache entry, and call proc() with it. If none is found c reate a new one.
129 If the proc() returns true, detach the cache and return it, otherwise le ave it and return 129 If the proc() returns true, detach the cache and return it, otherwise le ave it and return
130 nullptr. 130 nullptr.
131 */ 131 */
132 static SkGlyphCache* VisitCache(SkTypeface*, const SkDescriptor* desc, 132 static SkGlyphCache* VisitCache(SkTypeface*, const SkScalerContextEffects&, const SkDescriptor*,
133 bool (*proc)(const SkGlyphCache*, void*), 133 bool (*proc)(const SkGlyphCache*, void*),
134 void* context); 134 void* context);
135 135
136 /** Given a strike that was returned by either VisitCache() or DetachCache() add it back into 136 /** Given a strike that was returned by either VisitCache() or DetachCache() add it back into
137 the global cache list (after which the caller should not reference it an ymore. 137 the global cache list (after which the caller should not reference it an ymore.
138 */ 138 */
139 static void AttachCache(SkGlyphCache*); 139 static void AttachCache(SkGlyphCache*);
140 using AttachCacheFunctor = SkFunctionWrapper<void, SkGlyphCache, AttachCache >; 140 using AttachCacheFunctor = SkFunctionWrapper<void, SkGlyphCache, AttachCache >;
141 141
142 /** Detach a strike from the global cache matching the specified descriptor. Once detached, 142 /** Detach a strike from the global cache matching the specified descriptor. Once detached,
143 it can be queried/modified by the current thread, and when finished, be reattached to the 143 it can be queried/modified by the current thread, and when finished, be reattached to the
144 global cache with AttachCache(). While detached, if another request is m ade with the same 144 global cache with AttachCache(). While detached, if another request is m ade with the same
145 descriptor, a different strike will be generated. This is fine. It does mean we can have 145 descriptor, a different strike will be generated. This is fine. It does mean we can have
146 more than 1 strike for the same descriptor, but that will eventually get purged, and the 146 more than 1 strike for the same descriptor, but that will eventually get purged, and the
147 win is that different thread will never block each other while a strike is being used. 147 win is that different thread will never block each other while a strike is being used.
148 */ 148 */
149 static SkGlyphCache* DetachCache(SkTypeface* typeface, const SkDescriptor* d esc) { 149 static SkGlyphCache* DetachCache(SkTypeface* typeface, const SkScalerContext Effects& effects,
150 return VisitCache(typeface, desc, DetachProc, nullptr); 150 const SkDescriptor* desc) {
151 return VisitCache(typeface, effects, desc, DetachProc, nullptr);
151 } 152 }
152 153
153 static void Dump(); 154 static void Dump();
154 155
155 /** Dump memory usage statistics of all the attaches caches in the process u sing the 156 /** Dump memory usage statistics of all the attaches caches in the process u sing the
156 SkTraceMemoryDump interface. 157 SkTraceMemoryDump interface.
157 */ 158 */
158 static void DumpMemoryStatistics(SkTraceMemoryDump* dump); 159 static void DumpMemoryStatistics(SkTraceMemoryDump* dump);
159 160
160 typedef void (*Visitor)(const SkGlyphCache&, void* context); 161 typedef void (*Visitor)(const SkGlyphCache&, void* context);
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after
271 272
272 AuxProcRec* fAuxProcList; 273 AuxProcRec* fAuxProcList;
273 }; 274 };
274 275
275 class SkAutoGlyphCache : public std::unique_ptr<SkGlyphCache, SkGlyphCache::Atta chCacheFunctor> { 276 class SkAutoGlyphCache : public std::unique_ptr<SkGlyphCache, SkGlyphCache::Atta chCacheFunctor> {
276 public: 277 public:
277 /** deprecated: use get() */ 278 /** deprecated: use get() */
278 SkGlyphCache* getCache() const { return this->get(); } 279 SkGlyphCache* getCache() const { return this->get(); }
279 280
280 SkAutoGlyphCache(SkGlyphCache* cache) : INHERITED(cache) {} 281 SkAutoGlyphCache(SkGlyphCache* cache) : INHERITED(cache) {}
281 SkAutoGlyphCache(SkTypeface* typeface, const SkDescriptor* desc) 282 SkAutoGlyphCache(SkTypeface* typeface, const SkScalerContextEffects& effects ,
282 : INHERITED(SkGlyphCache::DetachCache(typeface, desc)) 283 const SkDescriptor* desc)
284 : INHERITED(SkGlyphCache::DetachCache(typeface, effects, desc))
283 {} 285 {}
284 /** deprecated: always enables fake gamma */ 286 /** deprecated: always enables fake gamma */
285 SkAutoGlyphCache(const SkPaint& paint, 287 SkAutoGlyphCache(const SkPaint& paint,
286 const SkSurfaceProps* surfaceProps, 288 const SkSurfaceProps* surfaceProps,
287 const SkMatrix* matrix) 289 const SkMatrix* matrix)
288 : INHERITED(paint.detachCache(surfaceProps, SkPaint::FakeGamma::On, matr ix)) 290 : INHERITED(paint.detachCache(surfaceProps, SkPaint::FakeGamma::On, matr ix))
289 {} 291 {}
290 SkAutoGlyphCache(const SkPaint& paint, 292 SkAutoGlyphCache(const SkPaint& paint,
291 const SkSurfaceProps* surfaceProps, 293 const SkSurfaceProps* surfaceProps,
292 SkPaint::FakeGamma fakeGamma, 294 SkPaint::FakeGamma fakeGamma,
293 const SkMatrix* matrix) 295 const SkMatrix* matrix)
294 : INHERITED(paint.detachCache(surfaceProps, fakeGamma, matrix)) 296 : INHERITED(paint.detachCache(surfaceProps, fakeGamma, matrix))
295 {} 297 {}
296 private: 298 private:
297 using INHERITED = std::unique_ptr<SkGlyphCache, SkGlyphCache::AttachCacheFun ctor>; 299 using INHERITED = std::unique_ptr<SkGlyphCache, SkGlyphCache::AttachCacheFun ctor>;
298 }; 300 };
299 301
300 class SkAutoGlyphCacheNoGamma : public SkAutoGlyphCache { 302 class SkAutoGlyphCacheNoGamma : public SkAutoGlyphCache {
301 public: 303 public:
302 SkAutoGlyphCacheNoGamma(const SkPaint& paint, 304 SkAutoGlyphCacheNoGamma(const SkPaint& paint,
303 const SkSurfaceProps* surfaceProps, 305 const SkSurfaceProps* surfaceProps,
304 const SkMatrix* matrix) 306 const SkMatrix* matrix)
305 : SkAutoGlyphCache(paint, surfaceProps, SkPaint::FakeGamma::Off, matrix) 307 : SkAutoGlyphCache(paint, surfaceProps, SkPaint::FakeGamma::Off, matrix)
306 {} 308 {}
307 }; 309 };
308 #define SkAutoGlyphCache(...) SK_REQUIRE_LOCAL_VAR(SkAutoGlyphCache) 310 #define SkAutoGlyphCache(...) SK_REQUIRE_LOCAL_VAR(SkAutoGlyphCache)
309 #define SkAutoGlyphCacheNoGamma(...) SK_REQUIRE_LOCAL_VAR(SkAutoGlyphCacheNoGamm a) 311 #define SkAutoGlyphCacheNoGamma(...) SK_REQUIRE_LOCAL_VAR(SkAutoGlyphCacheNoGamm a)
310 312
311 #endif 313 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698