| 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 SkGlyph; | 16 class SkGlyph; |
| 17 class SkPath; | 17 class SkPath; |
| 18 | 18 |
| 19 /* | 19 /* |
| 20 * Wrapper class to turn a font cache descriptor into a key | |
| 21 * for GrFontScaler-related lookups | |
| 22 */ | |
| 23 class GrFontDescKey : public SkRefCnt { | |
| 24 public: | |
| 25 explicit GrFontDescKey(const SkDescriptor& desc) : fDesc(desc), fHash(desc.g
etChecksum()) {} | |
| 26 | |
| 27 uint32_t getHash() const { return fHash; } | |
| 28 | |
| 29 bool operator==(const GrFontDescKey& rh) const { | |
| 30 return fHash == rh.fHash && *fDesc.getDesc() == *rh.fDesc.getDesc(); | |
| 31 } | |
| 32 | |
| 33 private: | |
| 34 SkAutoDescriptor fDesc; | |
| 35 uint32_t fHash; | |
| 36 | |
| 37 typedef SkRefCnt INHERITED; | |
| 38 }; | |
| 39 | |
| 40 /* | |
| 41 * This is Gr's interface to the host platform's font scaler. | 20 * This is Gr's interface to the host platform's font scaler. |
| 42 * | 21 * |
| 43 * The client is responsible for instantiating this. The instance is created | 22 * The client is responsible for instantiating this. The instance is created |
| 44 * for a specific font+size+matrix. | 23 * for a specific font+size+matrix. |
| 45 */ | 24 */ |
| 46 class GrFontScaler final : public SkNoncopyable { | 25 class GrFontScaler final : public SkNoncopyable { |
| 47 public: | 26 public: |
| 48 explicit GrFontScaler(SkGlyphCache* strike); | 27 explicit GrFontScaler(SkGlyphCache* strike); |
| 49 ~GrFontScaler(); | |
| 50 | 28 |
| 51 const GrFontDescKey* getKey(); | 29 const SkDescriptor& getKey(); |
| 52 GrMaskFormat getMaskFormat() const; | |
| 53 GrMaskFormat getPackedGlyphMaskFormat(const SkGlyph&) const; | 30 GrMaskFormat getPackedGlyphMaskFormat(const SkGlyph&) const; |
| 54 bool getPackedGlyphBounds(const SkGlyph&, SkIRect* bounds); | 31 bool getPackedGlyphBounds(const SkGlyph&, SkIRect* bounds); |
| 55 bool getPackedGlyphImage(const SkGlyph&, int width, int height, int rowBytes
, | 32 bool getPackedGlyphImage(const SkGlyph&, int width, int height, int rowBytes
, |
| 56 GrMaskFormat expectedMaskFormat, void* image); | 33 GrMaskFormat expectedMaskFormat, void* image); |
| 57 bool getPackedGlyphDFBounds(const SkGlyph&, SkIRect* bounds); | 34 bool getPackedGlyphDFBounds(const SkGlyph&, SkIRect* bounds); |
| 58 bool getPackedGlyphDFImage(const SkGlyph&, int width, int height, void* imag
e); | 35 bool getPackedGlyphDFImage(const SkGlyph&, int width, int height, void* imag
e); |
| 59 const SkPath* getGlyphPath(const SkGlyph&); | 36 const SkPath* getGlyphPath(const SkGlyph&); |
| 60 const SkGlyph& grToSkGlyph(GrGlyph::PackedID); | 37 const SkGlyph& grToSkGlyph(GrGlyph::PackedID); |
| 61 | 38 |
| 62 private: | 39 private: |
| 63 // The SkGlyphCache actually owns this GrFontScaler. The GrFontScaler is del
eted when the | 40 // The SkGlyphCache actually owns this GrFontScaler. The GrFontScaler is del
eted when the |
| 64 // SkGlyphCache is deleted. | 41 // SkGlyphCache is deleted. |
| 65 SkGlyphCache* fStrike; | 42 SkGlyphCache* fStrike; |
| 66 GrFontDescKey* fKey; | |
| 67 | 43 |
| 68 typedef SkNoncopyable INHERITED; | 44 typedef SkNoncopyable INHERITED; |
| 69 }; | 45 }; |
| 70 | 46 |
| 71 #endif | 47 #endif |
| OLD | NEW |