Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(7)

Unified Diff: include/gpu/GrFontScaler.h

Issue 385263002: Refactor SkGrFontScaler and SkGrFontKey into non-virtual versions. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Rebase to ToT Created 6 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « gyp/gpu.gypi ('k') | include/gpu/GrKey.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: include/gpu/GrFontScaler.h
diff --git a/include/gpu/GrFontScaler.h b/include/gpu/GrFontScaler.h
index 0132d513042b543bbadffa4041a1b4562cbb3796..d90708de8f1f74703f9f55fd38d909f344cb870a 100644
--- a/include/gpu/GrFontScaler.h
+++ b/include/gpu/GrFontScaler.h
@@ -9,35 +9,76 @@
#define GrFontScaler_DEFINED
#include "GrGlyph.h"
-#include "GrKey.h"
+#include "GrTypes.h"
+
+#include "SkDescriptor.h"
class SkPath;
-/**
- * This is a virtual base class which Gr's interface to the host platform's
- * font scaler.
+/*
+ * Wrapper class to turn a font cache descriptor into a key
+ * for GrFontScaler-related lookups
+ */
+class GrFontDescKey : public SkRefCnt {
+public:
+ SK_DECLARE_INST_COUNT(SkGrDescKey)
+
+ 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));
+ }
+ bool operator==(const GrFontDescKey& rh) const {
+ return fHash == rh.fHash && this->eq(rh);
+ }
+
+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;
+
+ typedef SkRefCnt INHERITED;
+};
+
+/*
+ * This is Gr's interface to the host platform's font scaler.
*
- * The client is responsible for subclassing, and instantiating this. The
- * instance is created for a specific font+size+matrix.
+ * The client is responsible for instantiating this. The instance is created
+ * for a specific font+size+matrix.
*/
class GrFontScaler : public SkRefCnt {
public:
SK_DECLARE_INST_COUNT(GrFontScaler)
- virtual const GrKey* getKey() = 0;
- virtual GrMaskFormat getMaskFormat() = 0;
- virtual bool getPackedGlyphBounds(GrGlyph::PackedID, SkIRect* bounds) = 0;
- virtual bool getPackedGlyphImage(GrGlyph::PackedID, int width, int height,
- int rowBytes, void* image) = 0;
- // get bounds for distance field associated with packed ID
- virtual bool getPackedGlyphDFBounds(GrGlyph::PackedID, SkIRect* bounds) = 0;
- // copies distance field bytes into pre-allocated dfImage
- // (should be width*height bytes in size)
- virtual bool getPackedGlyphDFImage(GrGlyph::PackedID, int width, int height,
- void* dfImage) = 0;
- virtual bool getGlyphPath(uint16_t glyphID, SkPath*) = 0;
-
+ explicit GrFontScaler(SkGlyphCache* strike);
+ virtual ~GrFontScaler();
+
+ const GrFontDescKey* getKey();
+ GrMaskFormat getMaskFormat();
+ bool getPackedGlyphBounds(GrGlyph::PackedID, SkIRect* bounds);
+ bool getPackedGlyphImage(GrGlyph::PackedID, int width, int height,
+ int rowBytes, void* image);
+ bool getPackedGlyphDFBounds(GrGlyph::PackedID, SkIRect* bounds);
+ bool getPackedGlyphDFImage(GrGlyph::PackedID, int width, int height,
+ void* image);
+ bool getGlyphPath(uint16_t glyphID, SkPath*);
+
private:
+ SkGlyphCache* fStrike;
+ GrFontDescKey* fKey;
+
typedef SkRefCnt INHERITED;
};
« no previous file with comments | « gyp/gpu.gypi ('k') | include/gpu/GrKey.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698