gfxFontCache Class Reference
Font cache design:.
More...
#include <gfxFont.h>
List of all members.
Detailed Description
Font cache design:.
The mFonts hashtable contains most fonts, indexed by (name, style). It does not add a reference to the fonts it contains. When a font's refcount decreases to zero, instead of deleting it we add it to our expiration tracker. The expiration tracker tracks fonts with zero refcount. After a certain period of time, such fonts expire and are deleted.
We're using 3 generations with a ten-second generation interval, so zero-refcount fonts will be deleted 20-30 seconds after their refcount goes to zero, if timer events fire in a timely manner.
Member Enumeration Documentation
Constructor & Destructor Documentation
| gfxFontCache::gfxFontCache |
( |
|
) |
[inline] |
| gfxFontCache::~gfxFontCache |
( |
|
) |
[inline] |
Member Function Documentation
| void gfxFontCache::AddNew |
( |
gfxFont * |
aFont |
) |
|
| void gfxFontCache::DestroyFont |
( |
gfxFont * |
aFont |
) |
[protected] |
| static gfxFontCache* gfxFontCache::GetCache |
( |
|
) |
[inline, static] |
| static nsresult gfxFontCache::Init |
( |
|
) |
[static] |
| virtual void gfxFontCache::NotifyExpired |
( |
gfxFont * |
aObj |
) |
[virtual] |
This must be overridden to catch notifications.
It is called whenever we detect that an object has not been used for at least (K-1)*mTimerPeriod seconds. If timer events are not delayed, it will be called within roughly K*mTimerPeriod seconds after the last use. (Unless AgeOneGeneration or AgeAllGenerations have been called to accelerate the aging process.)
NOTE: These bounds ignore delays in timer firings due to actual work being performed by the browser. We use a slack timer so there is always at least mTimerPeriod milliseconds between firings, which gives us (K-1)*mTimerPeriod as a pretty solid lower bound. The upper bound is rather loose, however. If the maximum amount by which any given timer firing is delayed is D, then the upper bound before NotifyExpired is called is K*(mTimerPeriod + D).
The NotifyExpired call is expected to remove the object from the tracker, but it need not. The object (or other objects) could be "resurrected" by calling MarkUsed() on them, or they might just not be removed. Any objects left over that have not been resurrected or removed are placed in the new newest-generation, but this is considered "bad form" and should be avoided (we'll issue a warning). (This recycling counts as "a use" for the purposes of the expiry guarantee above...)
For robustness and simplicity, we allow objects to be notified more than once here in the same timer tick.
Implements nsExpirationTracker< gfxFont, 3 >.
| void gfxFontCache::NotifyReleased |
( |
gfxFont * |
aFont |
) |
|
| static void gfxFontCache::Shutdown |
( |
|
) |
[static] |
Member Data Documentation
The documentation for this class was generated from the following file: