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 | |
reed@google.com | 07f3ee1 | 2011-05-16 17:21:57 +0000 | [diff] [blame] | 16 | class SkPath; |
reed@google.com | ac10a2d | 2010-12-22 21:39:39 +0000 | [diff] [blame] | 17 | |
jvanverth | 733f5f5 | 2014-07-11 19:45:16 -0700 | [diff] [blame] | 18 | /* |
| 19 | * Wrapper class to turn a font cache descriptor into a key |
| 20 | * for GrFontScaler-related lookups |
| 21 | */ |
| 22 | class GrFontDescKey : public SkRefCnt { |
| 23 | public: |
joshualitt | 73d5de5 | 2015-07-17 06:19:19 -0700 | [diff] [blame^] | 24 | explicit GrFontDescKey(const SkDescriptor& desc) : fDesc(desc), fHash(desc.getChecksum()) {} |
mtklein | 2766c00 | 2015-06-26 11:45:03 -0700 | [diff] [blame] | 25 | |
joshualitt | 73d5de5 | 2015-07-17 06:19:19 -0700 | [diff] [blame^] | 26 | uint32_t getHash() const { return fHash; } |
| 27 | |
jvanverth | 733f5f5 | 2014-07-11 19:45:16 -0700 | [diff] [blame] | 28 | bool operator==(const GrFontDescKey& rh) const { |
joshualitt | 73d5de5 | 2015-07-17 06:19:19 -0700 | [diff] [blame^] | 29 | return fHash == rh.fHash && fDesc.getDesc()->equals(*rh.fDesc.getDesc()); |
jvanverth | 733f5f5 | 2014-07-11 19:45:16 -0700 | [diff] [blame] | 30 | } |
| 31 | |
| 32 | private: |
joshualitt | 73d5de5 | 2015-07-17 06:19:19 -0700 | [diff] [blame^] | 33 | SkAutoDescriptor fDesc; |
| 34 | uint32_t fHash; |
jvanverth | 733f5f5 | 2014-07-11 19:45:16 -0700 | [diff] [blame] | 35 | |
| 36 | typedef SkRefCnt INHERITED; |
| 37 | }; |
| 38 | |
| 39 | /* |
| 40 | * 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] | 41 | * |
jvanverth | 733f5f5 | 2014-07-11 19:45:16 -0700 | [diff] [blame] | 42 | * The client is responsible for instantiating this. The instance is created |
| 43 | * for a specific font+size+matrix. |
reed@google.com | ac10a2d | 2010-12-22 21:39:39 +0000 | [diff] [blame] | 44 | */ |
commit-bot@chromium.org | a4de8c2 | 2013-09-09 13:38:37 +0000 | [diff] [blame] | 45 | class GrFontScaler : public SkRefCnt { |
reed@google.com | ac10a2d | 2010-12-22 21:39:39 +0000 | [diff] [blame] | 46 | public: |
jvanverth | 733f5f5 | 2014-07-11 19:45:16 -0700 | [diff] [blame] | 47 | explicit GrFontScaler(SkGlyphCache* strike); |
| 48 | virtual ~GrFontScaler(); |
| 49 | |
| 50 | const GrFontDescKey* getKey(); |
jvanverth | 294c326 | 2014-10-10 11:36:12 -0700 | [diff] [blame] | 51 | GrMaskFormat getMaskFormat() const; |
| 52 | GrMaskFormat getPackedGlyphMaskFormat(GrGlyph::PackedID) const; |
jvanverth | 733f5f5 | 2014-07-11 19:45:16 -0700 | [diff] [blame] | 53 | bool getPackedGlyphBounds(GrGlyph::PackedID, SkIRect* bounds); |
| 54 | bool getPackedGlyphImage(GrGlyph::PackedID, int width, int height, |
| 55 | int rowBytes, void* image); |
| 56 | bool getPackedGlyphDFBounds(GrGlyph::PackedID, SkIRect* bounds); |
| 57 | bool getPackedGlyphDFImage(GrGlyph::PackedID, int width, int height, |
| 58 | void* image); |
| 59 | bool getGlyphPath(uint16_t glyphID, SkPath*); |
| 60 | |
reed@google.com | fa35e3d | 2012-06-26 20:16:17 +0000 | [diff] [blame] | 61 | private: |
jvanverth | 733f5f5 | 2014-07-11 19:45:16 -0700 | [diff] [blame] | 62 | SkGlyphCache* fStrike; |
| 63 | GrFontDescKey* fKey; |
| 64 | |
commit-bot@chromium.org | a4de8c2 | 2013-09-09 13:38:37 +0000 | [diff] [blame] | 65 | typedef SkRefCnt INHERITED; |
reed@google.com | ac10a2d | 2010-12-22 21:39:39 +0000 | [diff] [blame] | 66 | }; |
| 67 | |
| 68 | #endif |