| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2010 Google Inc. | 2 * Copyright 2010 Google Inc. |
| 3 * | 3 * |
| 4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
| 5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
| 6 */ | 6 */ |
| 7 | 7 |
| 8 #ifndef GrFontScaler_DEFINED | 8 #ifndef GrFontScaler_DEFINED |
| 9 #define GrFontScaler_DEFINED | 9 #define GrFontScaler_DEFINED |
| 10 | 10 |
| 11 #include "GrGlyph.h" | 11 #include "GrGlyph.h" |
| 12 #include "GrTypes.h" | 12 #include "GrTypes.h" |
| 13 | 13 |
| 14 #include "SkDescriptor.h" | 14 #include "SkDescriptor.h" |
| 15 | 15 |
| 16 class SkPath; | 16 class SkPath; |
| 17 | 17 |
| 18 /* | 18 /* |
| 19 * Wrapper class to turn a font cache descriptor into a key | 19 * Wrapper class to turn a font cache descriptor into a key |
| 20 * for GrFontScaler-related lookups | 20 * for GrFontScaler-related lookups |
| 21 */ | 21 */ |
| 22 class GrFontDescKey : public SkRefCnt { | 22 class GrFontDescKey : public SkRefCnt { |
| 23 public: | 23 public: |
| 24 explicit GrFontDescKey(const SkDescriptor& desc) : fDesc(desc), fHash(desc.g
etChecksum()) {} |
| 24 | 25 |
| 25 | 26 uint32_t getHash() const { return fHash; } |
| 26 typedef uint32_t Hash; | 27 |
| 27 | |
| 28 explicit GrFontDescKey(const SkDescriptor& desc); | |
| 29 virtual ~GrFontDescKey(); | |
| 30 | |
| 31 Hash getHash() const { return fHash; } | |
| 32 | |
| 33 bool operator<(const GrFontDescKey& rh) const { | |
| 34 return fHash < rh.fHash || (fHash == rh.fHash && this->lt(rh)); | |
| 35 } | |
| 36 bool operator==(const GrFontDescKey& rh) const { | 28 bool operator==(const GrFontDescKey& rh) const { |
| 37 return fHash == rh.fHash && this->eq(rh); | 29 return fHash == rh.fHash && fDesc.getDesc()->equals(*rh.fDesc.getDesc())
; |
| 38 } | 30 } |
| 39 | 31 |
| 40 private: | 32 private: |
| 41 // helper functions for comparisons | 33 SkAutoDescriptor fDesc; |
| 42 bool lt(const GrFontDescKey& rh) const; | 34 uint32_t fHash; |
| 43 bool eq(const GrFontDescKey& rh) const; | |
| 44 | |
| 45 SkDescriptor* fDesc; | |
| 46 enum { | |
| 47 kMaxStorageInts = 16 | |
| 48 }; | |
| 49 uint32_t fStorage[kMaxStorageInts]; | |
| 50 const Hash fHash; | |
| 51 | 35 |
| 52 typedef SkRefCnt INHERITED; | 36 typedef SkRefCnt INHERITED; |
| 53 }; | 37 }; |
| 54 | 38 |
| 55 /* | 39 /* |
| 56 * This is Gr's interface to the host platform's font scaler. | 40 * This is Gr's interface to the host platform's font scaler. |
| 57 * | 41 * |
| 58 * The client is responsible for instantiating this. The instance is created | 42 * The client is responsible for instantiating this. The instance is created |
| 59 * for a specific font+size+matrix. | 43 * for a specific font+size+matrix. |
| 60 */ | 44 */ |
| 61 class GrFontScaler : public SkRefCnt { | 45 class GrFontScaler : public SkRefCnt { |
| 62 public: | 46 public: |
| 63 | |
| 64 | |
| 65 explicit GrFontScaler(SkGlyphCache* strike); | 47 explicit GrFontScaler(SkGlyphCache* strike); |
| 66 virtual ~GrFontScaler(); | 48 virtual ~GrFontScaler(); |
| 67 | 49 |
| 68 const GrFontDescKey* getKey(); | 50 const GrFontDescKey* getKey(); |
| 69 GrMaskFormat getMaskFormat() const; | 51 GrMaskFormat getMaskFormat() const; |
| 70 GrMaskFormat getPackedGlyphMaskFormat(GrGlyph::PackedID) const; | 52 GrMaskFormat getPackedGlyphMaskFormat(GrGlyph::PackedID) const; |
| 71 bool getPackedGlyphBounds(GrGlyph::PackedID, SkIRect* bounds); | 53 bool getPackedGlyphBounds(GrGlyph::PackedID, SkIRect* bounds); |
| 72 bool getPackedGlyphImage(GrGlyph::PackedID, int width, int height, | 54 bool getPackedGlyphImage(GrGlyph::PackedID, int width, int height, |
| 73 int rowBytes, void* image); | 55 int rowBytes, void* image); |
| 74 bool getPackedGlyphDFBounds(GrGlyph::PackedID, SkIRect* bounds); | 56 bool getPackedGlyphDFBounds(GrGlyph::PackedID, SkIRect* bounds); |
| 75 bool getPackedGlyphDFImage(GrGlyph::PackedID, int width, int height, | 57 bool getPackedGlyphDFImage(GrGlyph::PackedID, int width, int height, |
| 76 void* image); | 58 void* image); |
| 77 bool getGlyphPath(uint16_t glyphID, SkPath*); | 59 bool getGlyphPath(uint16_t glyphID, SkPath*); |
| 78 | 60 |
| 79 private: | 61 private: |
| 80 SkGlyphCache* fStrike; | 62 SkGlyphCache* fStrike; |
| 81 GrFontDescKey* fKey; | 63 GrFontDescKey* fKey; |
| 82 | 64 |
| 83 typedef SkRefCnt INHERITED; | 65 typedef SkRefCnt INHERITED; |
| 84 }; | 66 }; |
| 85 | 67 |
| 86 #endif | 68 #endif |
| OLD | NEW |