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

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

Issue 1880873002: Revert "Revert of Pass effects directly to fontcache (patchset #8 id:140001 of https://codereview.c… (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: 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
« no previous file with comments | « include/core/SkTypeface.h ('k') | src/core/SkGlyphCache.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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, 290 : INHERITED(paint.detachCache(surfaceProps,
289 SkPaint::kFakeGammaAndBoostContrast_Scaler ContextFlags, 291 SkPaint::kFakeGammaAndBoostContrast_Scaler ContextFlags,
290 matrix)) 292 matrix))
291 {} 293 {}
292 SkAutoGlyphCache(const SkPaint& paint, 294 SkAutoGlyphCache(const SkPaint& paint,
(...skipping 11 matching lines...) Expand all
304 SkAutoGlyphCacheNoGamma(const SkPaint& paint, 306 SkAutoGlyphCacheNoGamma(const SkPaint& paint,
305 const SkSurfaceProps* surfaceProps, 307 const SkSurfaceProps* surfaceProps,
306 const SkMatrix* matrix) 308 const SkMatrix* matrix)
307 : SkAutoGlyphCache(paint, surfaceProps, SkPaint::kNone_ScalerContextFlag s, matrix) 309 : SkAutoGlyphCache(paint, surfaceProps, SkPaint::kNone_ScalerContextFlag s, matrix)
308 {} 310 {}
309 }; 311 };
310 #define SkAutoGlyphCache(...) SK_REQUIRE_LOCAL_VAR(SkAutoGlyphCache) 312 #define SkAutoGlyphCache(...) SK_REQUIRE_LOCAL_VAR(SkAutoGlyphCache)
311 #define SkAutoGlyphCacheNoGamma(...) SK_REQUIRE_LOCAL_VAR(SkAutoGlyphCacheNoGamm a) 313 #define SkAutoGlyphCacheNoGamma(...) SK_REQUIRE_LOCAL_VAR(SkAutoGlyphCacheNoGamm a)
312 314
313 #endif 315 #endif
OLDNEW
« no previous file with comments | « include/core/SkTypeface.h ('k') | src/core/SkGlyphCache.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698