aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorGravatar joshualitt <joshualitt@chromium.org>2015-07-17 06:19:19 -0700
committerGravatar Commit bot <commit-bot@chromium.org>2015-07-17 06:19:19 -0700
commit73d5de5763b4813c87e523adf2002ab48d3f4278 (patch)
treed775c805c1579fc13c355a28b727630476c51201
parent91110195a2eee170c11885da9d16f94b00a39f87 (diff)
Cleanup of GrFontDescKey
-rw-r--r--src/core/SkDescriptor.h5
-rw-r--r--src/gpu/GrFontScaler.cpp35
-rw-r--r--src/gpu/GrFontScaler.h30
3 files changed, 11 insertions, 59 deletions
diff --git a/src/core/SkDescriptor.h b/src/core/SkDescriptor.h
index 0693ccfe60..e559215cb1 100644
--- a/src/core/SkDescriptor.h
+++ b/src/core/SkDescriptor.h
@@ -136,6 +136,11 @@ class SkAutoDescriptor : SkNoncopyable {
public:
SkAutoDescriptor() : fDesc(NULL) {}
SkAutoDescriptor(size_t size) : fDesc(NULL) { this->reset(size); }
+ SkAutoDescriptor(const SkDescriptor& desc) : fDesc(NULL) {
+ size_t size = desc.getLength();
+ this->reset(size);
+ memcpy(fDesc, &desc, size);
+ }
~SkAutoDescriptor() { this->free(); }
diff --git a/src/gpu/GrFontScaler.cpp b/src/gpu/GrFontScaler.cpp
index ed1970e262..364944eef9 100644
--- a/src/gpu/GrFontScaler.cpp
+++ b/src/gpu/GrFontScaler.cpp
@@ -15,41 +15,6 @@
///////////////////////////////////////////////////////////////////////////////
-GrFontDescKey::GrFontDescKey(const SkDescriptor& desc) : fHash(desc.getChecksum()) {
- size_t size = desc.getLength();
- if (size <= sizeof(fStorage)) {
- fDesc = GrTCast<SkDescriptor*>(fStorage);
- } else {
- fDesc = SkDescriptor::Alloc(size);
- }
- memcpy(fDesc, &desc, size);
-}
-
-GrFontDescKey::~GrFontDescKey() {
- if (fDesc != GrTCast<SkDescriptor*>(fStorage)) {
- SkDescriptor::Free(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));
- if (0 == cmp) {
- return lenLH < lenRH;
- } else {
- return cmp < 0;
- }
-}
-
-bool GrFontDescKey::eq(const GrFontDescKey& rh) const {
- const SkDescriptor* srcDesc = (&rh)->fDesc;
- return fDesc->equals(*srcDesc);
-}
-
-///////////////////////////////////////////////////////////////////////////////
-
GrFontScaler::GrFontScaler(SkGlyphCache* strike) {
fStrike = strike;
fKey = NULL;
diff --git a/src/gpu/GrFontScaler.h b/src/gpu/GrFontScaler.h
index 5e769905d0..644c8b719e 100644
--- a/src/gpu/GrFontScaler.h
+++ b/src/gpu/GrFontScaler.h
@@ -21,33 +21,17 @@ class SkPath;
*/
class GrFontDescKey : public SkRefCnt {
public:
+ explicit GrFontDescKey(const SkDescriptor& desc) : fDesc(desc), fHash(desc.getChecksum()) {}
-
- typedef uint32_t Hash;
-
- explicit GrFontDescKey(const SkDescriptor& desc);
- virtual ~GrFontDescKey();
-
- Hash getHash() const { return fHash; }
-
- bool operator<(const GrFontDescKey& rh) const {
- return fHash < rh.fHash || (fHash == rh.fHash && this->lt(rh));
- }
+ uint32_t getHash() const { return fHash; }
+
bool operator==(const GrFontDescKey& rh) const {
- return fHash == rh.fHash && this->eq(rh);
+ return fHash == rh.fHash && fDesc.getDesc()->equals(*rh.fDesc.getDesc());
}
private:
- // helper functions for comparisons
- bool lt(const GrFontDescKey& rh) const;
- bool eq(const GrFontDescKey& rh) const;
-
- SkDescriptor* fDesc;
- enum {
- kMaxStorageInts = 16
- };
- uint32_t fStorage[kMaxStorageInts];
- const Hash fHash;
+ SkAutoDescriptor fDesc;
+ uint32_t fHash;
typedef SkRefCnt INHERITED;
};
@@ -60,8 +44,6 @@ private:
*/
class GrFontScaler : public SkRefCnt {
public:
-
-
explicit GrFontScaler(SkGlyphCache* strike);
virtual ~GrFontScaler();