aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/gpu/GrTextStrike.h
diff options
context:
space:
mode:
authorGravatar jvanverth <jvanverth@google.com>2014-07-22 13:25:26 -0700
committerGravatar Commit bot <commit-bot@chromium.org>2014-07-22 13:25:26 -0700
commitdd6d22751a1ec858daaf78c3929c22737483e3db (patch)
treec336f0a593044a91810d6cf49db16f8d82562267 /src/gpu/GrTextStrike.h
parent1c63bf6e90f160c9a0d7484dedfaf87c0aa341e9 (diff)
Replace use of GrTHashTable in GrFontCache with SkTDynamicHash.
Searching the font cache for existing text strikes was showing up as a hotspot on Android. This change reduces that cost. R=bsalomon@google.com, robertphillips@google.com, mtklein@google.com Author: jvanverth@google.com Review URL: https://codereview.chromium.org/390103002
Diffstat (limited to 'src/gpu/GrTextStrike.h')
-rw-r--r--src/gpu/GrTextStrike.h27
1 files changed, 13 insertions, 14 deletions
diff --git a/src/gpu/GrTextStrike.h b/src/gpu/GrTextStrike.h
index f7dec955a4..89b054291d 100644
--- a/src/gpu/GrTextStrike.h
+++ b/src/gpu/GrTextStrike.h
@@ -13,7 +13,7 @@
#include "GrAllocPool.h"
#include "GrFontScaler.h"
-#include "GrTHashTable.h"
+#include "SkTDynamicHash.h"
#include "GrGlyph.h"
#include "GrDrawTarget.h"
#include "GrAtlas.h"
@@ -39,22 +39,25 @@ public:
bool addGlyphToAtlas(GrGlyph*, GrFontScaler*);
// testing
- int countGlyphs() const { return fCache.getArray().count(); }
- const GrGlyph* glyphAt(int index) const {
- return fCache.getArray()[index];
- }
+ int countGlyphs() const { return fCache.count(); }
// remove any references to this plot
void removePlot(const GrPlot* plot);
+ static const GrFontDescKey& GetKey(const GrTextStrike& ts) {
+ return *(ts.fFontScalerKey);
+ }
+ static uint32_t Hash(const GrFontDescKey& key) {
+ return key.getHash();
+ }
+
public:
// for easy removal from list
GrTextStrike* fPrev;
GrTextStrike* fNext;
private:
- class Key;
- GrTHashTable<GrGlyph, Key, 7> fCache;
+ SkTDynamicHash<GrGlyph, GrGlyph::PackedID> fCache;
const GrFontDescKey* fFontScalerKey;
GrTAllocPool<GrGlyph> fPool;
@@ -83,10 +86,7 @@ public:
bool freeUnusedPlot(GrTextStrike* preserveStrike);
// testing
- int countStrikes() const { return fCache.getArray().count(); }
- const GrTextStrike* strikeAt(int index) const {
- return fCache.getArray()[index];
- }
+ int countStrikes() const { return fCache.count(); }
GrTextStrike* getHeadStrike() const { return fHead; }
void updateTextures() {
@@ -117,8 +117,7 @@ public:
private:
friend class GrFontPurgeListener;
- class Key;
- GrTHashTable<GrTextStrike, Key, 8> fCache;
+ SkTDynamicHash<GrTextStrike, GrFontDescKey> fCache;
// for LRU
GrTextStrike* fHead;
GrTextStrike* fTail;
@@ -126,7 +125,7 @@ private:
GrGpu* fGpu;
GrAtlas* fAtlases[kAtlasCount];
- GrTextStrike* generateStrike(GrFontScaler*, const Key&);
+ GrTextStrike* generateStrike(GrFontScaler*);
inline void detachStrikeFromList(GrTextStrike*);
void purgeStrike(GrTextStrike* strike);
};