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

Side by Side 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 unified diff | Download patch
« no previous file with comments | « include/core/SkPaint.h ('k') | src/core/SkMaskGamma.h » ('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 /* 2 /*
3 * Copyright 2006 The Android Open Source Project 3 * Copyright 2006 The Android Open Source Project
4 * 4 *
5 * Use of this source code is governed by a BSD-style license that can be 5 * Use of this source code is governed by a BSD-style license that can be
6 * found in the LICENSE file. 6 * found in the LICENSE file.
7 */ 7 */
8 8
9 9
10 #ifndef SkGlyphCache_DEFINED 10 #ifndef SkGlyphCache_DEFINED
(...skipping 226 matching lines...) Expand 10 before | Expand all | Expand 10 after
237 void* fData; 237 void* fData;
238 }; 238 };
239 AuxProcRec* fAuxProcList; 239 AuxProcRec* fAuxProcList;
240 void invokeAndRemoveAuxProcs(); 240 void invokeAndRemoveAuxProcs();
241 241
242 inline static SkGlyphCache* FindTail(SkGlyphCache* head); 242 inline static SkGlyphCache* FindTail(SkGlyphCache* head);
243 243
244 friend class SkGlyphCache_Globals; 244 friend class SkGlyphCache_Globals;
245 }; 245 };
246 246
247 class SkAutoGlyphCache { 247 class SkAutoGlyphCacheBase {
248 public: 248 public:
249 SkAutoGlyphCache(SkGlyphCache* cache) : fCache(cache) {}
250 SkAutoGlyphCache(SkTypeface* typeface, const SkDescriptor* desc) {
251 fCache = SkGlyphCache::DetachCache(typeface, desc);
252 }
253 SkAutoGlyphCache(const SkPaint& paint,
254 const SkDeviceProperties* deviceProperties,
255 const SkMatrix* matrix) {
256 fCache = paint.detachCache(deviceProperties, matrix);
257 }
258 ~SkAutoGlyphCache() {
259 if (fCache) {
260 SkGlyphCache::AttachCache(fCache);
261 }
262 }
263
264 SkGlyphCache* getCache() const { return fCache; } 249 SkGlyphCache* getCache() const { return fCache; }
265 250
266 void release() { 251 void release() {
267 if (fCache) { 252 if (fCache) {
268 SkGlyphCache::AttachCache(fCache); 253 SkGlyphCache::AttachCache(fCache);
269 fCache = NULL; 254 fCache = NULL;
270 } 255 }
271 } 256 }
272 257
273 private: 258 protected:
259 // Hide the constructors so we can't create one of these directly.
260 // Create SkAutoGlyphCache or SkAutoGlyphCacheNoCache instead.
261 SkAutoGlyphCacheBase(SkGlyphCache* cache) : fCache(cache) {}
262 SkAutoGlyphCacheBase(SkTypeface* typeface, const SkDescriptor* desc) {
263 fCache = SkGlyphCache::DetachCache(typeface, desc);
264 }
265 SkAutoGlyphCacheBase(const SkPaint& paint,
266 const SkDeviceProperties* deviceProperties,
267 const SkMatrix* matrix) {
268 fCache = NULL;
269 }
270 SkAutoGlyphCacheBase() {
271 fCache = NULL;
272 }
273 ~SkAutoGlyphCacheBase() {
274 if (fCache) {
275 SkGlyphCache::AttachCache(fCache);
276 }
277 }
278
274 SkGlyphCache* fCache; 279 SkGlyphCache* fCache;
275 280
281 private:
276 static bool DetachProc(const SkGlyphCache*, void*); 282 static bool DetachProc(const SkGlyphCache*, void*);
277 }; 283 };
284
285 class SkAutoGlyphCache : public SkAutoGlyphCacheBase {
286 public:
287 SkAutoGlyphCache(SkGlyphCache* cache) : SkAutoGlyphCacheBase(cache) {}
288 SkAutoGlyphCache(SkTypeface* typeface, const SkDescriptor* desc) :
289 SkAutoGlyphCacheBase(typeface, desc) {}
290 SkAutoGlyphCache(const SkPaint& paint,
291 const SkDeviceProperties* deviceProperties,
292 const SkMatrix* matrix) {
293 fCache = paint.detachCache(deviceProperties, matrix, false);
294 }
295
296 private:
297 SkAutoGlyphCache() : SkAutoGlyphCacheBase() {}
298 };
278 #define SkAutoGlyphCache(...) SK_REQUIRE_LOCAL_VAR(SkAutoGlyphCache) 299 #define SkAutoGlyphCache(...) SK_REQUIRE_LOCAL_VAR(SkAutoGlyphCache)
279 300
301 class SkAutoGlyphCacheNoGamma : public SkAutoGlyphCacheBase {
302 public:
303 SkAutoGlyphCacheNoGamma(SkGlyphCache* cache) : SkAutoGlyphCacheBase(cache) { }
304 SkAutoGlyphCacheNoGamma(SkTypeface* typeface, const SkDescriptor* desc) :
305 SkAutoGlyphCacheBase(typeface, desc) {}
306 SkAutoGlyphCacheNoGamma(const SkPaint& paint,
307 const SkDeviceProperties* deviceProperties,
308 const SkMatrix* matrix) {
309 fCache = paint.detachCache(deviceProperties, matrix, true);
310 }
311
312 private:
313 SkAutoGlyphCacheNoGamma() : SkAutoGlyphCacheBase() {}
314 };
315 #define SkAutoGlyphCacheNoGamma(...) SK_REQUIRE_LOCAL_VAR(SkAutoGlyphCacheNoGamm a)
316
280 #endif 317 #endif
OLDNEW
« 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