aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/core/SkGlyph.h
diff options
context:
space:
mode:
authorGravatar herb <herb@google.com>2015-02-25 06:47:06 -0800
committerGravatar Commit bot <commit-bot@chromium.org>2015-02-25 06:47:06 -0800
commitb69d0e0ac45e13f667bc11a937dcb547072bc93d (patch)
tree5812e63a4c4c502ee9bd4c5ea751c3766ddec836 /src/core/SkGlyph.h
parent5a23a14b1fbc7503bdeff83e4b45ae7c258c6e96 (diff)
BUG=skia:
(mtklein from here on) No public API changes. TBR=reed@google.com Committed: https://skia.googlesource.com/skia/+/f8d24e2c0c7b44b7ccf20e40890514db4cde7b15 Review URL: https://codereview.chromium.org/939123002
Diffstat (limited to 'src/core/SkGlyph.h')
-rw-r--r--src/core/SkGlyph.h63
1 files changed, 42 insertions, 21 deletions
diff --git a/src/core/SkGlyph.h b/src/core/SkGlyph.h
index 9abefa84c7..25aaed77a6 100644
--- a/src/core/SkGlyph.h
+++ b/src/core/SkGlyph.h
@@ -13,6 +13,7 @@
#include "SkMask.h"
class SkPath;
+class SkGlyphCache;
// needs to be != to any valid SkMask::Format
#define MASK_FORMAT_UNKNOWN (0xFF)
@@ -20,12 +21,23 @@ class SkPath;
#define kMaxGlyphWidth (1<<13)
-struct SkGlyph {
+class SkGlyph {
+ enum {
+ kSubBits = 2,
+ kSubMask = ((1 << kSubBits) - 1),
+ kSubShift = 24, // must be large enough for glyphs and unichars
+ kCodeMask = ((1 << kSubShift) - 1),
+ // relative offsets for X and Y subpixel bits
+ kSubShiftX = kSubBits,
+ kSubShiftY = 0
+ };
+
+ public:
+ static const SkFixed kSubpixelRound = SK_FixedHalf >> SkGlyph::kSubBits;
void* fImage;
SkPath* fPath;
SkFixed fAdvanceX, fAdvanceY;
- uint32_t fID;
uint16_t fWidth, fHeight;
int16_t fTop, fLeft;
@@ -33,12 +45,12 @@ struct SkGlyph {
int8_t fRsbDelta, fLsbDelta; // used by auto-kerning
int8_t fForceBW;
- void init(uint32_t id) {
- fID = id;
- fImage = NULL;
- fPath = NULL;
- fMaskFormat = MASK_FORMAT_UNKNOWN;
- fForceBW = 0;
+ void initWithGlyphID(uint32_t glyph_id) {
+ this->initCommon(MakeID(glyph_id));
+ }
+
+ void initGlyphIdFrom(const SkGlyph& glyph) {
+ this->initCommon(glyph.fID);
}
/**
@@ -94,18 +106,22 @@ struct SkGlyph {
*/
void zeroMetrics();
- enum {
- kSubBits = 2,
- kSubMask = ((1 << kSubBits) - 1),
- kSubShift = 24, // must be large enough for glyphs and unichars
- kCodeMask = ((1 << kSubShift) - 1),
- // relative offsets for X and Y subpixel bits
- kSubShiftX = kSubBits,
- kSubShiftY = 0
- };
+ void toMask(SkMask* mask) const;
+
+ private:
+ // TODO(herb) remove friend statement after SkGlyphCache cleanup.
+ friend class SkGlyphCache;
+
+ void initCommon(uint32_t id) {
+ fID = id;
+ fImage = NULL;
+ fPath = NULL;
+ fMaskFormat = MASK_FORMAT_UNKNOWN;
+ fForceBW = 0;
+ }
static unsigned ID2Code(uint32_t id) {
- return id & kCodeMask;
+ return (id & kCodeMask);
}
static unsigned ID2SubX(uint32_t id) {
@@ -134,11 +150,16 @@ struct SkGlyph {
x = FixedToSub(x);
y = FixedToSub(y);
return (x << (kSubShift + kSubShiftX)) |
- (y << (kSubShift + kSubShiftY)) |
- code;
+ (y << (kSubShift + kSubShiftY)) |
+ code;
}
- void toMask(SkMask* mask) const;
+ // FIXME - This is needed because the Android frame work directly
+ // accesses fID. Remove when fID accesses are cleaned up.
+#ifdef SK_BUILD_FOR_ANDROID_FRAMEWORK
+ public:
+#endif
+ uint32_t fID;
};
#endif