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

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: Add parens as suggested by build 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') | 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 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) {
reed1 2015/02/02 11:49:36 can we add? SkASSERT(0 == (code & kCodeMask));
herb_g 2015/02/02 13:39:03 This assert doesn't make sense to me. Do you mean
herb_g 2015/02/02 15:34:11 Done. I think your intent was to check the pre-co
129 return code; 133 return code + 1;
130 } 134 }
131 135
136 // See comment for MakeID above.
132 static uint32_t MakeID(unsigned code, SkFixed x, SkFixed y) { 137 static uint32_t MakeID(unsigned code, SkFixed x, SkFixed y) {
133 SkASSERT(code <= kCodeMask); 138 SkASSERT(code <= kCodeMask);
134 x = FixedToSub(x); 139 x = FixedToSub(x);
135 y = FixedToSub(y); 140 y = FixedToSub(y);
136 return (x << (kSubShift + kSubShiftX)) | 141 return (x << (kSubShift + kSubShiftX)) |
137 (y << (kSubShift + kSubShiftY)) | 142 (y << (kSubShift + kSubShiftY)) |
138 code; 143 (code + 1);
139 } 144 }
140 145
141 void toMask(SkMask* mask) const; 146 void toMask(SkMask* mask) const;
142 }; 147 };
143 148
144 #endif 149 #endif
OLDNEW
« no previous file with comments | « no previous file | src/core/SkGlyphCache.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698