blob: e42c7a1da007f866592b9970d0769bbe57759f86 [file] [log] [blame]
reed@google.comac10a2d2010-12-22 21:39:39 +00001/*
epoger@google.comec3ed6a2011-07-28 14:26:00 +00002 * 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.comac10a2d2010-12-22 21:39:39 +00006 */
7
reed@google.comac10a2d2010-12-22 21:39:39 +00008#ifndef GrFontScaler_DEFINED
9#define GrFontScaler_DEFINED
10
11#include "GrGlyph.h"
jvanverth733f5f52014-07-11 19:45:16 -070012#include "GrTypes.h"
13
14#include "SkDescriptor.h"
reed@google.comac10a2d2010-12-22 21:39:39 +000015
joshualitt6c2c2b02015-07-24 10:37:00 -070016class SkGlyph;
reed@google.com07f3ee12011-05-16 17:21:57 +000017class SkPath;
reed@google.comac10a2d2010-12-22 21:39:39 +000018
jvanverth733f5f52014-07-11 19:45:16 -070019/*
20 * Wrapper class to turn a font cache descriptor into a key
21 * for GrFontScaler-related lookups
22 */
23class GrFontDescKey : public SkRefCnt {
24public:
joshualitt73d5de52015-07-17 06:19:19 -070025 explicit GrFontDescKey(const SkDescriptor& desc) : fDesc(desc), fHash(desc.getChecksum()) {}
mtklein2766c002015-06-26 11:45:03 -070026
joshualitt73d5de52015-07-17 06:19:19 -070027 uint32_t getHash() const { return fHash; }
28
jvanverth733f5f52014-07-11 19:45:16 -070029 bool operator==(const GrFontDescKey& rh) const {
joshualitt73d5de52015-07-17 06:19:19 -070030 return fHash == rh.fHash && fDesc.getDesc()->equals(*rh.fDesc.getDesc());
jvanverth733f5f52014-07-11 19:45:16 -070031 }
32
33private:
joshualitt73d5de52015-07-17 06:19:19 -070034 SkAutoDescriptor fDesc;
35 uint32_t fHash;
jvanverth733f5f52014-07-11 19:45:16 -070036
37 typedef SkRefCnt INHERITED;
38};
39
40/*
41 * This is Gr's interface to the host platform's font scaler.
reed@google.comac10a2d2010-12-22 21:39:39 +000042 *
jvanverth733f5f52014-07-11 19:45:16 -070043 * The client is responsible for instantiating this. The instance is created
44 * for a specific font+size+matrix.
reed@google.comac10a2d2010-12-22 21:39:39 +000045 */
commit-bot@chromium.orga4de8c22013-09-09 13:38:37 +000046class GrFontScaler : public SkRefCnt {
reed@google.comac10a2d2010-12-22 21:39:39 +000047public:
jvanverth733f5f52014-07-11 19:45:16 -070048 explicit GrFontScaler(SkGlyphCache* strike);
49 virtual ~GrFontScaler();
50
51 const GrFontDescKey* getKey();
jvanverth294c3262014-10-10 11:36:12 -070052 GrMaskFormat getMaskFormat() const;
joshualitt6c2c2b02015-07-24 10:37:00 -070053 GrMaskFormat getPackedGlyphMaskFormat(const SkGlyph&) const;
54 bool getPackedGlyphBounds(const SkGlyph&, SkIRect* bounds);
joshualitt4f19ca32015-07-30 07:59:20 -070055 bool getPackedGlyphImage(const SkGlyph&, int width, int height, int rowBytes,
56 GrMaskFormat expectedMaskFormat, void* image);
joshualitt6c2c2b02015-07-24 10:37:00 -070057 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);
jvanverth733f5f52014-07-11 19:45:16 -070061
reed@google.comfa35e3d2012-06-26 20:16:17 +000062private:
jvanverth733f5f52014-07-11 19:45:16 -070063 SkGlyphCache* fStrike;
64 GrFontDescKey* fKey;
65
commit-bot@chromium.orga4de8c22013-09-09 13:38:37 +000066 typedef SkRefCnt INHERITED;
reed@google.comac10a2d2010-12-22 21:39:39 +000067};
68
69#endif