LCOV - code coverage report
Current view: top level - gfx/skia/skia/src/core - SkGlyphCache_Globals.h (source / functions) Hit Total Coverage
Test: output.info Lines: 8 8 100.0 %
Date: 2017-07-14 16:53:18 Functions: 2 2 100.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /*
       2             :  * Copyright 2010 Google Inc.
       3             :  *
       4             :  * Use of this source code is governed by a BSD-style license that can be
       5             :  * found in the LICENSE file.
       6             :  */
       7             : 
       8             : #ifndef SkGlyphCache_Globals_DEFINED
       9             : #define SkGlyphCache_Globals_DEFINED
      10             : 
      11             : #include "SkGlyphCache.h"
      12             : #include "SkMutex.h"
      13             : #include "SkSpinlock.h"
      14             : #include "SkTLS.h"
      15             : 
      16             : #ifndef SK_DEFAULT_FONT_CACHE_COUNT_LIMIT
      17             :     #define SK_DEFAULT_FONT_CACHE_COUNT_LIMIT   2048
      18             : #endif
      19             : 
      20             : #ifndef SK_DEFAULT_FONT_CACHE_LIMIT
      21             :     #define SK_DEFAULT_FONT_CACHE_LIMIT     (2 * 1024 * 1024)
      22             : #endif
      23             : 
      24             : ///////////////////////////////////////////////////////////////////////////////
      25             : 
      26             : class SkGlyphCache_Globals {
      27             : public:
      28           3 :     SkGlyphCache_Globals() {
      29           3 :         fHead = nullptr;
      30           3 :         fTotalMemoryUsed = 0;
      31           3 :         fCacheSizeLimit = SK_DEFAULT_FONT_CACHE_LIMIT;
      32           3 :         fCacheCount = 0;
      33           3 :         fCacheCountLimit = SK_DEFAULT_FONT_CACHE_COUNT_LIMIT;
      34           3 :     }
      35             : 
      36             :     ~SkGlyphCache_Globals() {
      37             :         SkGlyphCache* cache = fHead;
      38             :         while (cache) {
      39             :             SkGlyphCache* next = cache->fNext;
      40             :             delete cache;
      41             :             cache = next;
      42             :         }
      43             :     }
      44             : 
      45             :     mutable SkSpinlock     fLock;
      46             : 
      47          21 :     SkGlyphCache* internalGetHead() const { return fHead; }
      48             :     SkGlyphCache* internalGetTail() const;
      49             : 
      50             :     size_t getTotalMemoryUsed() const;
      51             :     int getCacheCountUsed() const;
      52             : 
      53             : #ifdef SK_DEBUG
      54             :     void validate() const;
      55             : #else
      56             :     void validate() const {}
      57             : #endif
      58             : 
      59             :     int getCacheCountLimit() const;
      60             :     int setCacheCountLimit(int limit);
      61             : 
      62             :     size_t  getCacheSizeLimit() const;
      63             :     size_t  setCacheSizeLimit(size_t limit);
      64             : 
      65             :     void purgeAll(); // does not change budget
      66             : 
      67             :     // call when a glyphcache is available for caching (i.e. not in use)
      68             :     void attachCacheToHead(SkGlyphCache*);
      69             : 
      70             :     // can only be called when the mutex is already held
      71             :     void internalDetachCache(SkGlyphCache*);
      72             :     void internalAttachCacheToHead(SkGlyphCache*);
      73             : 
      74             : private:
      75             :     SkGlyphCache* fHead;
      76             :     size_t  fTotalMemoryUsed;
      77             :     size_t  fCacheSizeLimit;
      78             :     int32_t fCacheCountLimit;
      79             :     int32_t fCacheCount;
      80             : 
      81             :     // Checkout budgets, modulated by the specified min-bytes-needed-to-purge,
      82             :     // and attempt to purge caches to match.
      83             :     // Returns number of bytes freed.
      84             :     size_t internalPurge(size_t minBytesNeeded = 0);
      85             : };
      86             : 
      87             : #endif

Generated by: LCOV version 1.13