Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 Loading... | |
| 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 the glyph | |
| 46 }; | |
| 47 | |
| 48 Intercept* fIntercept; | |
|
f(malita)
2016/02/08 14:20:27
Caching this is nice, but may be overkill at this
caryclark
2016/02/09 19:10:57
If the same glyphs are underlined widely by the ca
| |
| 49 public: | |
| 38 static const SkFixed kSubpixelRound = SK_FixedHalf >> SkGlyph::kSubBits; | 50 static const SkFixed kSubpixelRound = SK_FixedHalf >> SkGlyph::kSubBits; |
| 39 // A value that can never be generated by MakeID. | 51 // A value that can never be generated by MakeID. |
| 40 static const uint32_t kImpossibleID = ~0; | 52 static const uint32_t kImpossibleID = ~0; |
| 41 void* fImage; | 53 void* fImage; |
| 42 SkPath* fPath; | 54 SkPath* fPath; |
| 43 SkFixed fAdvanceX, fAdvanceY; | 55 SkFixed fAdvanceX, fAdvanceY; |
| 44 | 56 |
| 45 uint16_t fWidth, fHeight; | 57 uint16_t fWidth, fHeight; |
| 46 int16_t fTop, fLeft; | 58 int16_t fTop, fLeft; |
| 47 | 59 |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 126 } | 138 } |
| 127 }; | 139 }; |
| 128 | 140 |
| 129 private: | 141 private: |
| 130 // TODO(herb) remove friend statement after SkGlyphCache cleanup. | 142 // TODO(herb) remove friend statement after SkGlyphCache cleanup. |
| 131 friend class SkGlyphCache; | 143 friend class SkGlyphCache; |
| 132 | 144 |
| 133 void initCommon(uint32_t id) { | 145 void initCommon(uint32_t id) { |
| 134 fID = id; | 146 fID = id; |
| 135 fImage = nullptr; | 147 fImage = nullptr; |
| 148 fIntercept = nullptr; | |
| 136 fPath = nullptr; | 149 fPath = nullptr; |
| 137 fMaskFormat = MASK_FORMAT_UNKNOWN; | 150 fMaskFormat = MASK_FORMAT_UNKNOWN; |
| 138 fForceBW = 0; | 151 fForceBW = 0; |
| 139 } | 152 } |
| 140 | 153 |
| 141 static unsigned ID2Code(uint32_t id) { | 154 static unsigned ID2Code(uint32_t id) { |
| 142 return id & kCodeMask; | 155 return id & kCodeMask; |
| 143 } | 156 } |
| 144 | 157 |
| 145 static unsigned ID2SubX(uint32_t id) { | 158 static unsigned ID2SubX(uint32_t id) { |
| (...skipping 23 matching lines...) Expand all Loading... | |
| 169 SkASSERT(code <= kCodeMask); | 182 SkASSERT(code <= kCodeMask); |
| 170 x = FixedToSub(x); | 183 x = FixedToSub(x); |
| 171 y = FixedToSub(y); | 184 y = FixedToSub(y); |
| 172 uint32_t ID = (x << (kSubShift + kSubShiftX)) | | 185 uint32_t ID = (x << (kSubShift + kSubShiftX)) | |
| 173 (y << (kSubShift + kSubShiftY)) | | 186 (y << (kSubShift + kSubShiftY)) | |
| 174 code; | 187 code; |
| 175 SkASSERT(ID != kImpossibleID); | 188 SkASSERT(ID != kImpossibleID); |
| 176 return ID; | 189 return ID; |
| 177 } | 190 } |
| 178 | 191 |
| 179 // FIXME - This is needed because the Android frame work directly | 192 // FIXME - This is needed because the Android frame work directly |
| 180 // accesses fID. Remove when fID accesses are cleaned up. | 193 // accesses fID. Remove when fID accesses are cleaned up. |
| 181 #ifdef SK_BUILD_FOR_ANDROID_FRAMEWORK | 194 #ifdef SK_BUILD_FOR_ANDROID_FRAMEWORK |
| 182 public: | 195 public: |
| 183 #endif | 196 #endif |
| 184 uint32_t fID; | 197 uint32_t fID; |
| 185 }; | 198 }; |
| 186 SK_END_REQUIRE_DENSE | 199 SK_END_REQUIRE_DENSE |
| 187 | 200 |
| 188 #endif | 201 #endif |
| OLD | NEW |