reed@google.com | ac10a2d | 2010-12-22 21:39:39 +0000 | [diff] [blame] | 1 | /* |
epoger@google.com | ec3ed6a | 2011-07-28 14:26:00 +0000 | [diff] [blame] | 2 | * Copyright 2010 Google Inc. |
| 3 | * |
| 4 | * Use of this source code is governed by a BSD-style license that can be |
| 5 | * found in the LICENSE file. |
reed@google.com | ac10a2d | 2010-12-22 21:39:39 +0000 | [diff] [blame] | 6 | */ |
| 7 | |
reed@google.com | ac10a2d | 2010-12-22 21:39:39 +0000 | [diff] [blame] | 8 | #ifndef GrFontScaler_DEFINED |
| 9 | #define GrFontScaler_DEFINED |
| 10 | |
| 11 | #include "GrGlyph.h" |
jvanverth | 733f5f5 | 2014-07-11 19:45:16 -0700 | [diff] [blame] | 12 | #include "GrTypes.h" |
| 13 | |
| 14 | #include "SkDescriptor.h" |
reed@google.com | ac10a2d | 2010-12-22 21:39:39 +0000 | [diff] [blame] | 15 | |
joshualitt | 6c2c2b0 | 2015-07-24 10:37:00 -0700 | [diff] [blame] | 16 | class SkGlyph; |
reed@google.com | 07f3ee1 | 2011-05-16 17:21:57 +0000 | [diff] [blame] | 17 | class SkPath; |
reed@google.com | ac10a2d | 2010-12-22 21:39:39 +0000 | [diff] [blame] | 18 | |
jvanverth | 733f5f5 | 2014-07-11 19:45:16 -0700 | [diff] [blame] | 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: |
joshualitt | 73d5de5 | 2015-07-17 06:19:19 -0700 | [diff] [blame] | 25 | explicit GrFontDescKey(const SkDescriptor& desc) : fDesc(desc), fHash(desc.getChecksum()) {} |
mtklein | 2766c00 | 2015-06-26 11:45:03 -0700 | [diff] [blame] | 26 | |
joshualitt | 73d5de5 | 2015-07-17 06:19:19 -0700 | [diff] [blame] | 27 | uint32_t getHash() const { return fHash; } |
| 28 | |
jvanverth | 733f5f5 | 2014-07-11 19:45:16 -0700 | [diff] [blame] | 29 | bool operator==(const GrFontDescKey& rh) const { |
joshualitt | 73d5de5 | 2015-07-17 06:19:19 -0700 | [diff] [blame] | 30 | return fHash == rh.fHash && fDesc.getDesc()->equals(*rh.fDesc.getDesc()); |
jvanverth | 733f5f5 | 2014-07-11 19:45:16 -0700 | [diff] [blame] | 31 | } |
| 32 | |
| 33 | private: |
joshualitt | 73d5de5 | 2015-07-17 06:19:19 -0700 | [diff] [blame] | 34 | SkAutoDescriptor fDesc; |
| 35 | uint32_t fHash; |
jvanverth | 733f5f5 | 2014-07-11 19:45:16 -0700 | [diff] [blame] | 36 | |
| 37 | typedef SkRefCnt INHERITED; |
| 38 | }; |
| 39 | |
| 40 | /* |
| 41 | * This is Gr's interface to the host platform's font scaler. |
reed@google.com | ac10a2d | 2010-12-22 21:39:39 +0000 | [diff] [blame] | 42 | * |
jvanverth | 733f5f5 | 2014-07-11 19:45:16 -0700 | [diff] [blame] | 43 | * The client is responsible for instantiating this. The instance is created |
| 44 | * for a specific font+size+matrix. |
reed@google.com | ac10a2d | 2010-12-22 21:39:39 +0000 | [diff] [blame] | 45 | */ |
commit-bot@chromium.org | a4de8c2 | 2013-09-09 13:38:37 +0000 | [diff] [blame] | 46 | class GrFontScaler : public SkRefCnt { |
reed@google.com | ac10a2d | 2010-12-22 21:39:39 +0000 | [diff] [blame] | 47 | public: |
jvanverth | 733f5f5 | 2014-07-11 19:45:16 -0700 | [diff] [blame] | 48 | explicit GrFontScaler(SkGlyphCache* strike); |
| 49 | virtual ~GrFontScaler(); |
| 50 | |
| 51 | const GrFontDescKey* getKey(); |
jvanverth | 294c326 | 2014-10-10 11:36:12 -0700 | [diff] [blame] | 52 | GrMaskFormat getMaskFormat() const; |
joshualitt | 6c2c2b0 | 2015-07-24 10:37:00 -0700 | [diff] [blame] | 53 | GrMaskFormat getPackedGlyphMaskFormat(const SkGlyph&) const; |
| 54 | bool getPackedGlyphBounds(const SkGlyph&, SkIRect* bounds); |
joshualitt | 4f19ca3 | 2015-07-30 07:59:20 -0700 | [diff] [blame] | 55 | bool getPackedGlyphImage(const SkGlyph&, int width, int height, int rowBytes, |
| 56 | GrMaskFormat expectedMaskFormat, void* image); |
joshualitt | 6c2c2b0 | 2015-07-24 10:37:00 -0700 | [diff] [blame] | 57 | bool getPackedGlyphDFBounds(const SkGlyph&, SkIRect* bounds); |
| 58 | bool getPackedGlyphDFImage(const SkGlyph&, int width, int height, void* image); |
| 59 | const SkPath* getGlyphPath(const SkGlyph&); |
| 60 | const SkGlyph& grToSkGlyph(GrGlyph::PackedID); |
jvanverth | 733f5f5 | 2014-07-11 19:45:16 -0700 | [diff] [blame] | 61 | |
reed@google.com | fa35e3d | 2012-06-26 20:16:17 +0000 | [diff] [blame] | 62 | private: |
jvanverth | 733f5f5 | 2014-07-11 19:45:16 -0700 | [diff] [blame] | 63 | SkGlyphCache* fStrike; |
| 64 | GrFontDescKey* fKey; |
| 65 | |
commit-bot@chromium.org | a4de8c2 | 2013-09-09 13:38:37 +0000 | [diff] [blame] | 66 | typedef SkRefCnt INHERITED; |
reed@google.com | ac10a2d | 2010-12-22 21:39:39 +0000 | [diff] [blame] | 67 | }; |
| 68 | |
| 69 | #endif |