Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1)

Side by Side Diff: src/core/SkGlyph.h

Issue 1654883003: add helper to create fancy underlines (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: correct comment to multiply by two Created 4 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « include/core/SkPaint.h ('k') | src/core/SkGlyphCache.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright 2006 The Android Open Source Project 2 * Copyright 2006 The Android Open Source Project
3 * 3 *
4 * Use of this source code is governed by a BSD-style license that can be 4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file. 5 * found in the LICENSE file.
6 */ 6 */
7 7
8 #ifndef SkGlyph_DEFINED 8 #ifndef SkGlyph_DEFINED
9 #define SkGlyph_DEFINED 9 #define SkGlyph_DEFINED
10 10
(...skipping 16 matching lines...) Expand all
27 enum { 27 enum {
28 kSubBits = 2, 28 kSubBits = 2,
29 kSubMask = ((1 << kSubBits) - 1), 29 kSubMask = ((1 << kSubBits) - 1),
30 kSubShift = 24, // must be large enough for glyphs and unichars 30 kSubShift = 24, // must be large enough for glyphs and unichars
31 kCodeMask = ((1 << kSubShift) - 1), 31 kCodeMask = ((1 << kSubShift) - 1),
32 // relative offsets for X and Y subpixel bits 32 // relative offsets for X and Y subpixel bits
33 kSubShiftX = kSubBits, 33 kSubShiftX = kSubBits,
34 kSubShiftY = 0 34 kSubShiftY = 0
35 }; 35 };
36 36
37 public: 37 // Support horizontal and vertical skipping strike-through / underlines.
38 // The caller walks the linked list looking for a match. For a horizontal un derline,
39 // the fBounds contains the top and bottom of the underline. The fInterval p air contains the
40 // beginning and end of of the intersection of the bounds and the glyph's pa th.
41 // If interval[0] >= interval[1], no intesection was found.
42 struct Intercept {
43 Intercept* fNext;
44 SkScalar fBounds[2]; // for horz underlines, the boundaries in Y
45 SkScalar fInterval[2]; // the outside intersections of the axis and t he glyph
46 };
47
48 struct PathData {
49 Intercept* fIntercept;
50 SkPath* fPath;
51 };
52
53 public:
38 static const SkFixed kSubpixelRound = SK_FixedHalf >> SkGlyph::kSubBits; 54 static const SkFixed kSubpixelRound = SK_FixedHalf >> SkGlyph::kSubBits;
39 // A value that can never be generated by MakeID. 55 // A value that can never be generated by MakeID.
40 static const uint32_t kImpossibleID = ~0; 56 static const uint32_t kImpossibleID = ~0;
41 void* fImage; 57 void* fImage;
42 SkPath* fPath; 58 PathData* fPathData;
43 SkFixed fAdvanceX, fAdvanceY; 59 SkFixed fAdvanceX, fAdvanceY;
44 60
45 uint16_t fWidth, fHeight; 61 uint16_t fWidth, fHeight;
46 int16_t fTop, fLeft; 62 int16_t fTop, fLeft;
47 63
48 uint8_t fMaskFormat; 64 uint8_t fMaskFormat;
49 int8_t fRsbDelta, fLsbDelta; // used by auto-kerning 65 int8_t fRsbDelta, fLsbDelta; // used by auto-kerning
50 int8_t fForceBW; 66 int8_t fForceBW;
51 67
52 void initWithGlyphID(uint32_t glyph_id) { 68 void initWithGlyphID(uint32_t glyph_id) {
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
126 } 142 }
127 }; 143 };
128 144
129 private: 145 private:
130 // TODO(herb) remove friend statement after SkGlyphCache cleanup. 146 // TODO(herb) remove friend statement after SkGlyphCache cleanup.
131 friend class SkGlyphCache; 147 friend class SkGlyphCache;
132 148
133 void initCommon(uint32_t id) { 149 void initCommon(uint32_t id) {
134 fID = id; 150 fID = id;
135 fImage = nullptr; 151 fImage = nullptr;
136 fPath = nullptr; 152 fPathData = nullptr;
137 fMaskFormat = MASK_FORMAT_UNKNOWN; 153 fMaskFormat = MASK_FORMAT_UNKNOWN;
138 fForceBW = 0; 154 fForceBW = 0;
139 } 155 }
140 156
141 static unsigned ID2Code(uint32_t id) { 157 static unsigned ID2Code(uint32_t id) {
142 return id & kCodeMask; 158 return id & kCodeMask;
143 } 159 }
144 160
145 static unsigned ID2SubX(uint32_t id) { 161 static unsigned ID2SubX(uint32_t id) {
146 return id >> (kSubShift + kSubShiftX); 162 return id >> (kSubShift + kSubShiftX);
(...skipping 22 matching lines...) Expand all
169 SkASSERT(code <= kCodeMask); 185 SkASSERT(code <= kCodeMask);
170 x = FixedToSub(x); 186 x = FixedToSub(x);
171 y = FixedToSub(y); 187 y = FixedToSub(y);
172 uint32_t ID = (x << (kSubShift + kSubShiftX)) | 188 uint32_t ID = (x << (kSubShift + kSubShiftX)) |
173 (y << (kSubShift + kSubShiftY)) | 189 (y << (kSubShift + kSubShiftY)) |
174 code; 190 code;
175 SkASSERT(ID != kImpossibleID); 191 SkASSERT(ID != kImpossibleID);
176 return ID; 192 return ID;
177 } 193 }
178 194
179 // FIXME - This is needed because the Android frame work directly 195 // FIXME - This is needed because the Android frame work directly
180 // accesses fID. Remove when fID accesses are cleaned up. 196 // accesses fID. Remove when fID accesses are cleaned up.
181 #ifdef SK_BUILD_FOR_ANDROID_FRAMEWORK 197 #ifdef SK_BUILD_FOR_ANDROID_FRAMEWORK
182 public: 198 public:
183 #endif 199 #endif
184 uint32_t fID; 200 uint32_t fID;
185 }; 201 };
186 SK_END_REQUIRE_DENSE 202 SK_END_REQUIRE_DENSE
187 203
188 #endif 204 #endif
OLDNEW
« no previous file with comments | « include/core/SkPaint.h ('k') | src/core/SkGlyphCache.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698