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

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

Issue 885903002: Make the glyph array entries inline. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Fix asserts for checking code in range Created 5 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 | « no previous file | src/core/SkGlyphCache.h » ('j') | src/core/SkGlyphCache.h » ('J')
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 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
97 enum { 97 enum {
98 kSubBits = 2, 98 kSubBits = 2,
99 kSubMask = ((1 << kSubBits) - 1), 99 kSubMask = ((1 << kSubBits) - 1),
100 kSubShift = 24, // must be large enough for glyphs and unichars 100 kSubShift = 24, // must be large enough for glyphs and unichars
101 kCodeMask = ((1 << kSubShift) - 1), 101 kCodeMask = ((1 << kSubShift) - 1),
102 // relative offsets for X and Y subpixel bits 102 // relative offsets for X and Y subpixel bits
103 kSubShiftX = kSubBits, 103 kSubShiftX = kSubBits,
104 kSubShiftY = 0 104 kSubShiftY = 0
105 }; 105 };
106 106
107 // The code is increased by one in MakeID. Adjust back. This allows the zero
108 // id to be the invalid id.
107 static unsigned ID2Code(uint32_t id) { 109 static unsigned ID2Code(uint32_t id) {
108 return id & kCodeMask; 110 return (id & kCodeMask) - 1;
109 } 111 }
110 112
111 static unsigned ID2SubX(uint32_t id) { 113 static unsigned ID2SubX(uint32_t id) {
112 return id >> (kSubShift + kSubShiftX); 114 return id >> (kSubShift + kSubShiftX);
113 } 115 }
114 116
115 static unsigned ID2SubY(uint32_t id) { 117 static unsigned ID2SubY(uint32_t id) {
116 return (id >> (kSubShift + kSubShiftY)) & kSubMask; 118 return (id >> (kSubShift + kSubShiftY)) & kSubMask;
117 } 119 }
118 120
119 static unsigned FixedToSub(SkFixed n) { 121 static unsigned FixedToSub(SkFixed n) {
120 return (n >> (16 - kSubBits)) & kSubMask; 122 return (n >> (16 - kSubBits)) & kSubMask;
121 } 123 }
122 124
123 static SkFixed SubToFixed(unsigned sub) { 125 static SkFixed SubToFixed(unsigned sub) {
124 SkASSERT(sub <= kSubMask); 126 SkASSERT(sub <= kSubMask);
125 return sub << (16 - kSubBits); 127 return sub << (16 - kSubBits);
126 } 128 }
127 129
130 // This and the MakeID below must not return an id of zero. Zero is used as
131 // the invalid id.
128 static uint32_t MakeID(unsigned code) { 132 static uint32_t MakeID(unsigned code) {
129 return code; 133 SkASSERT(code + 1 <= kCodeMask);
134 return code + 1;
130 } 135 }
131 136
137 // See comment for MakeID above.
132 static uint32_t MakeID(unsigned code, SkFixed x, SkFixed y) { 138 static uint32_t MakeID(unsigned code, SkFixed x, SkFixed y) {
133 SkASSERT(code <= kCodeMask); 139 SkASSERT(code + 1 <= kCodeMask);
134 x = FixedToSub(x); 140 x = FixedToSub(x);
135 y = FixedToSub(y); 141 y = FixedToSub(y);
136 return (x << (kSubShift + kSubShiftX)) | 142 return (x << (kSubShift + kSubShiftX)) |
137 (y << (kSubShift + kSubShiftY)) | 143 (y << (kSubShift + kSubShiftY)) |
138 code; 144 (code + 1);
139 } 145 }
140 146
141 void toMask(SkMask* mask) const; 147 void toMask(SkMask* mask) const;
142 }; 148 };
143 149
144 #endif 150 #endif
OLDNEW
« no previous file with comments | « no previous file | src/core/SkGlyphCache.h » ('j') | src/core/SkGlyphCache.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698