aboutsummaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
authorGravatar jvanverth <jvanverth@google.com>2014-07-11 19:45:16 -0700
committerGravatar Commit bot <commit-bot@chromium.org>2014-07-11 19:45:16 -0700
commit733f5f5dbca10fc6385ec3c77b3e9ff78227dac7 (patch)
treed9ffdb538bf85fa2d56e977d5081e32e7f4f3ee7 /src
parent93de7a27e05004e1ff3171b43d89d36890f9f868 (diff)
Refactor SkGrFontScaler and SkGrFontKey into non-virtual versions.
This is a pre-cleanup for another change, but has the side benefit of making the code simpler in general. No perf increase, despite removing virtual functions. R=bsalomon@google.com, egdaniel@google.com Author: jvanverth@google.com Review URL: https://codereview.chromium.org/385263002
Diffstat (limited to 'src')
-rw-r--r--src/gpu/GrFontScaler.cpp (renamed from src/gpu/SkGrFontScaler.cpp)52
-rw-r--r--src/gpu/GrTextContext.cpp4
-rw-r--r--src/gpu/GrTextStrike.cpp2
-rw-r--r--src/gpu/GrTextStrike.h6
-rw-r--r--src/gpu/GrTextStrike_impl.h4
5 files changed, 25 insertions, 43 deletions
diff --git a/src/gpu/SkGrFontScaler.cpp b/src/gpu/GrFontScaler.cpp
index 44856906e3..164768f3b0 100644
--- a/src/gpu/SkGrFontScaler.cpp
+++ b/src/gpu/GrFontScaler.cpp
@@ -8,32 +8,14 @@
#include "GrTemplates.h"
-#include "SkGr.h"
+#include "GrFontScaler.h"
#include "SkDescriptor.h"
#include "SkDistanceFieldGen.h"
#include "SkGlyphCache.h"
-class SkGrDescKey : public GrKey {
-public:
- explicit SkGrDescKey(const SkDescriptor& desc);
- virtual ~SkGrDescKey();
-
-protected:
- // overrides
- virtual bool lt(const GrKey& rh) const;
- virtual bool eq(const GrKey& rh) const;
-
-private:
- SkDescriptor* fDesc;
- enum {
- kMaxStorageInts = 16
- };
- uint32_t fStorage[kMaxStorageInts];
-};
-
///////////////////////////////////////////////////////////////////////////////
-SkGrDescKey::SkGrDescKey(const SkDescriptor& desc) : GrKey(desc.getChecksum()) {
+GrFontDescKey::GrFontDescKey(const SkDescriptor& desc) : fHash(desc.getChecksum()) {
size_t size = desc.getLength();
if (size <= sizeof(fStorage)) {
fDesc = GrTCast<SkDescriptor*>(fStorage);
@@ -43,14 +25,14 @@ SkGrDescKey::SkGrDescKey(const SkDescriptor& desc) : GrKey(desc.getChecksum()) {
memcpy(fDesc, &desc, size);
}
-SkGrDescKey::~SkGrDescKey() {
+GrFontDescKey::~GrFontDescKey() {
if (fDesc != GrTCast<SkDescriptor*>(fStorage)) {
SkDescriptor::Free(fDesc);
}
}
-bool SkGrDescKey::lt(const GrKey& rh) const {
- const SkDescriptor* srcDesc = ((const SkGrDescKey*)&rh)->fDesc;
+bool GrFontDescKey::lt(const GrFontDescKey& rh) const {
+ const SkDescriptor* srcDesc = (&rh)->fDesc;
size_t lenLH = fDesc->getLength();
size_t lenRH = srcDesc->getLength();
int cmp = memcmp(fDesc, srcDesc, SkTMin<size_t>(lenLH, lenRH));
@@ -61,23 +43,23 @@ bool SkGrDescKey::lt(const GrKey& rh) const {
}
}
-bool SkGrDescKey::eq(const GrKey& rh) const {
- const SkDescriptor* srcDesc = ((const SkGrDescKey*)&rh)->fDesc;
+bool GrFontDescKey::eq(const GrFontDescKey& rh) const {
+ const SkDescriptor* srcDesc = (&rh)->fDesc;
return fDesc->equals(*srcDesc);
}
///////////////////////////////////////////////////////////////////////////////
-SkGrFontScaler::SkGrFontScaler(SkGlyphCache* strike) {
+GrFontScaler::GrFontScaler(SkGlyphCache* strike) {
fStrike = strike;
fKey = NULL;
}
-SkGrFontScaler::~SkGrFontScaler() {
+GrFontScaler::~GrFontScaler() {
SkSafeUnref(fKey);
}
-GrMaskFormat SkGrFontScaler::getMaskFormat() {
+GrMaskFormat GrFontScaler::getMaskFormat() {
SkMask::Format format = fStrike->getMaskFormat();
switch (format) {
case SkMask::kBW_Format:
@@ -96,14 +78,14 @@ GrMaskFormat SkGrFontScaler::getMaskFormat() {
}
}
-const GrKey* SkGrFontScaler::getKey() {
+const GrFontDescKey* GrFontScaler::getKey() {
if (NULL == fKey) {
- fKey = SkNEW_ARGS(SkGrDescKey, (fStrike->getDescriptor()));
+ fKey = SkNEW_ARGS(GrFontDescKey, (fStrike->getDescriptor()));
}
return fKey;
}
-bool SkGrFontScaler::getPackedGlyphBounds(GrGlyph::PackedID packed, SkIRect* bounds) {
+bool GrFontScaler::getPackedGlyphBounds(GrGlyph::PackedID packed, SkIRect* bounds) {
const SkGlyph& glyph = fStrike->getGlyphIDMetrics(GrGlyph::UnpackID(packed),
GrGlyph::UnpackFixedX(packed),
GrGlyph::UnpackFixedY(packed));
@@ -112,7 +94,7 @@ bool SkGrFontScaler::getPackedGlyphBounds(GrGlyph::PackedID packed, SkIRect* bou
return true;
}
-bool SkGrFontScaler::getPackedGlyphDFBounds(GrGlyph::PackedID packed, SkIRect* bounds) {
+bool GrFontScaler::getPackedGlyphDFBounds(GrGlyph::PackedID packed, SkIRect* bounds) {
const SkGlyph& glyph = fStrike->getGlyphIDMetrics(GrGlyph::UnpackID(packed),
GrGlyph::UnpackFixedX(packed),
GrGlyph::UnpackFixedY(packed));
@@ -148,7 +130,7 @@ void expand_bits(INT_TYPE* dst,
}
}
-bool SkGrFontScaler::getPackedGlyphImage(GrGlyph::PackedID packed,
+bool GrFontScaler::getPackedGlyphImage(GrGlyph::PackedID packed,
int width, int height,
int dstRB, void* dst) {
const SkGlyph& glyph = fStrike->getGlyphIDMetrics(GrGlyph::UnpackID(packed),
@@ -200,7 +182,7 @@ bool SkGrFontScaler::getPackedGlyphImage(GrGlyph::PackedID packed,
return true;
}
-bool SkGrFontScaler::getPackedGlyphDFImage(GrGlyph::PackedID packed,
+bool GrFontScaler::getPackedGlyphDFImage(GrGlyph::PackedID packed,
int width, int height,
void* dst) {
const SkGlyph& glyph = fStrike->getGlyphIDMetrics(GrGlyph::UnpackID(packed),
@@ -219,7 +201,7 @@ bool SkGrFontScaler::getPackedGlyphDFImage(GrGlyph::PackedID packed,
}
// we should just return const SkPath* (NULL means false)
-bool SkGrFontScaler::getGlyphPath(uint16_t glyphID, SkPath* path) {
+bool GrFontScaler::getGlyphPath(uint16_t glyphID, SkPath* path) {
const SkGlyph& glyph = fStrike->getGlyphIDMetrics(glyphID);
const SkPath* skPath = fStrike->findPath(glyph);
diff --git a/src/gpu/GrTextContext.cpp b/src/gpu/GrTextContext.cpp
index bc116714da..d281173dca 100644
--- a/src/gpu/GrTextContext.cpp
+++ b/src/gpu/GrTextContext.cpp
@@ -10,7 +10,7 @@
#include "SkAutoKern.h"
#include "SkGlyphCache.h"
-#include "SkGr.h"
+#include "GrFontScaler.h"
GrTextContext::GrTextContext(GrContext* context, const SkDeviceProperties& properties) :
fContext(context), fDeviceProperties(properties), fDrawTarget(NULL) {
@@ -69,7 +69,7 @@ GrFontScaler* GrTextContext::GetGrFontScaler(SkGlyphCache* cache) {
scaler = (GrFontScaler*)auxData;
}
if (NULL == scaler) {
- scaler = SkNEW_ARGS(SkGrFontScaler, (cache));
+ scaler = SkNEW_ARGS(GrFontScaler, (cache));
cache->setAuxProc(GlyphCacheAuxProc, scaler);
}
diff --git a/src/gpu/GrTextStrike.cpp b/src/gpu/GrTextStrike.cpp
index a9405ca852..b290d6c2a3 100644
--- a/src/gpu/GrTextStrike.cpp
+++ b/src/gpu/GrTextStrike.cpp
@@ -220,7 +220,7 @@ void GrFontCache::dump() const {
atlas and a position within that texture.
*/
-GrTextStrike::GrTextStrike(GrFontCache* cache, const GrKey* key,
+GrTextStrike::GrTextStrike(GrFontCache* cache, const GrFontDescKey* key,
GrMaskFormat format,
GrAtlas* atlas) : fPool(64) {
fFontScalerKey = key;
diff --git a/src/gpu/GrTextStrike.h b/src/gpu/GrTextStrike.h
index 903cbfd434..f7dec955a4 100644
--- a/src/gpu/GrTextStrike.h
+++ b/src/gpu/GrTextStrike.h
@@ -28,10 +28,10 @@ class GrFontPurgeListener;
*/
class GrTextStrike {
public:
- GrTextStrike(GrFontCache*, const GrKey* fontScalerKey, GrMaskFormat, GrAtlas*);
+ GrTextStrike(GrFontCache*, const GrFontDescKey* fontScalerKey, GrMaskFormat, GrAtlas*);
~GrTextStrike();
- const GrKey* getFontScalerKey() const { return fFontScalerKey; }
+ const GrFontDescKey* getFontScalerKey() const { return fFontScalerKey; }
GrFontCache* getFontCache() const { return fFontCache; }
GrMaskFormat getMaskFormat() const { return fMaskFormat; }
@@ -55,7 +55,7 @@ public:
private:
class Key;
GrTHashTable<GrGlyph, Key, 7> fCache;
- const GrKey* fFontScalerKey;
+ const GrFontDescKey* fFontScalerKey;
GrTAllocPool<GrGlyph> fPool;
GrFontCache* fFontCache;
diff --git a/src/gpu/GrTextStrike_impl.h b/src/gpu/GrTextStrike_impl.h
index dcfc04aaae..1dd623d24c 100644
--- a/src/gpu/GrTextStrike_impl.h
+++ b/src/gpu/GrTextStrike_impl.h
@@ -13,7 +13,7 @@
class GrFontCache::Key {
public:
- explicit Key(const GrKey* fontScalarKey) {
+ explicit Key(const GrFontDescKey* fontScalarKey) {
fFontScalerKey = fontScalarKey;
}
@@ -27,7 +27,7 @@ public:
}
private:
- const GrKey* fFontScalerKey;
+ const GrFontDescKey* fFontScalerKey;
};
void GrFontCache::detachStrikeFromList(GrTextStrike* strike) {