blob: 644c8b719e3cccec7e770c254b0dacf47aee1bf5 [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
reed@google.com07f3ee12011-05-16 17:21:57 +000016class SkPath;
reed@google.comac10a2d2010-12-22 21:39:39 +000017
jvanverth733f5f52014-07-11 19:45:16 -070018/*
19 * Wrapper class to turn a font cache descriptor into a key
20 * for GrFontScaler-related lookups
21 */
22class GrFontDescKey : public SkRefCnt {
23public:
joshualitt73d5de52015-07-17 06:19:19 -070024 explicit GrFontDescKey(const SkDescriptor& desc) : fDesc(desc), fHash(desc.getChecksum()) {}
mtklein2766c002015-06-26 11:45:03 -070025
joshualitt73d5de52015-07-17 06:19:19 -070026 uint32_t getHash() const { return fHash; }
27
jvanverth733f5f52014-07-11 19:45:16 -070028 bool operator==(const GrFontDescKey& rh) const {
joshualitt73d5de52015-07-17 06:19:19 -070029 return fHash == rh.fHash && fDesc.getDesc()->equals(*rh.fDesc.getDesc());
jvanverth733f5f52014-07-11 19:45:16 -070030 }
31
32private:
joshualitt73d5de52015-07-17 06:19:19 -070033 SkAutoDescriptor fDesc;
34 uint32_t fHash;
jvanverth733f5f52014-07-11 19:45:16 -070035
36 typedef SkRefCnt INHERITED;
37};
38
39/*
40 * This is Gr's interface to the host platform's font scaler.
reed@google.comac10a2d2010-12-22 21:39:39 +000041 *
jvanverth733f5f52014-07-11 19:45:16 -070042 * The client is responsible for instantiating this. The instance is created
43 * for a specific font+size+matrix.
reed@google.comac10a2d2010-12-22 21:39:39 +000044 */
commit-bot@chromium.orga4de8c22013-09-09 13:38:37 +000045class GrFontScaler : public SkRefCnt {
reed@google.comac10a2d2010-12-22 21:39:39 +000046public:
jvanverth733f5f52014-07-11 19:45:16 -070047 explicit GrFontScaler(SkGlyphCache* strike);
48 virtual ~GrFontScaler();
49
50 const GrFontDescKey* getKey();
jvanverth294c3262014-10-10 11:36:12 -070051 GrMaskFormat getMaskFormat() const;
52 GrMaskFormat getPackedGlyphMaskFormat(GrGlyph::PackedID) const;
jvanverth733f5f52014-07-11 19:45:16 -070053 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.comfa35e3d2012-06-26 20:16:17 +000061private:
jvanverth733f5f52014-07-11 19:45:16 -070062 SkGlyphCache* fStrike;
63 GrFontDescKey* fKey;
64
commit-bot@chromium.orga4de8c22013-09-09 13:38:37 +000065 typedef SkRefCnt INHERITED;
reed@google.comac10a2d2010-12-22 21:39:39 +000066};
67
68#endif